function show_submenu(id)
{
	if (document.getElementById("lyr"+id).style.display=="none")
	{
		document.getElementById("lyr"+id).style.display="block";
		if (document.getElementById("spn"+id)!=null && document.getElementById("spn"+id)!=undefined)
		document.getElementById("spn"+id).innerHTML="&ndash;&nbsp;";
	}
	else
	{
		document.getElementById("lyr"+id).style.display="none";
		if (document.getElementById("spn"+id)!=null && document.getElementById("spn"+id)!=undefined)
		document.getElementById("spn"+id).innerHTML="+&nbsp;";
	}
}

function zeroBasket()
{
	if (inbasket.length==0)
	{
		alert("yaaa");
		return;	
	}
location.href="?action=basket";
}

function FindText()
{
	pForm = document.findform;
	if (pForm.searchword.value=="")
	{
		alert('مهرباني وكړى يو څه وليكى ');
		return false;
	}
pForm.submit();
}

function maxpic(path,winwid,winhei,name,type)
{
	third = "width="+winwid+" height="+winhei+" resizable";
	var newWindow = window.open("","",third);
	if (newWindow!=null)
	{
		newWindow.document.write("<title>"+name+"</title>");
		newWindow.document.write("<body leftmargin=0 topmargin=0 align=center oncontextmenu='return false'>");
		if (type==4)
		{
			newWindow.document.write("<EMBED SRC="+path+" quality=high width="+winwid+" height="+winhei+" TYPE=application/x-shockwave-flash></EMBED>");
		}
			else if (type==3)
			{
				newWindow.document.write("<EMBED SRC="+path+" width="+winwid+" height="+winhei+" AUTOSTART=true REPEAT=false></EMBED>");
			}
				else
				{
					newWindow.document.write("<IMG SRC="+path+" width="+winwid+" height="+winhei+" onClick='window.close();' onmouseover='this.style.cursor=\"hand\";' alt='Äëÿ çàêðûòèÿ - íàæìèòå'>");
				}
		newWindow.document.write("</body>");
		newWindow.document.close();
		newWindow.document.focus();
	}
}

function OnCheckField(NameForm,delo)
{	
	pForm =  document.forms[NameForm];

	if(pForm.name.value=="" || pForm.phone.value=="")
	{
		alert("");
		return false;
	}			

	if (delo==3)
	{
		onAction(delo);
	}
		else
		{
			if (delo==1)
			{
				pForm.subact.value='a';
			}
				else
				{
					pForm.subact.value='e';
				}
			 	pForm.go.disabled = true;
			 	pForm.submit();
		}
}

function onAction(delo)
{
pForm = document.basket;
var m_nCheckDel = OnDeletePos();
	if (delo==1 && m_nCheckDel==0)
	{
		alert('');
		return false;
	}

	if (delo==1)
	{
		m_bWarning = confirm(' ('+m_nCheckDel+' øò.) ');
		if (m_bWarning==false){return false;}
						pForm.subact.value='d';
	}

	if (delo==2){pForm.subact.value='c';}
	if (delo>=3){pForm.subact.value='o';}

	pForm.delet.disabled=true;
	pForm.check.disabled=true;
	pForm.order.disabled=true;
	pForm.submit();
}

function OnDeletePos()
{
var m_nElements    = document.basket.elements.length;
var m_nChecked     = 0;
	for (var n=0; n<m_nElements; n++)
	{
		if(document.basket.elements[n].name.substring(0,7)=='dellarr' && document.basket.elements[n].checked == true)
		{m_nChecked++;}
	}
return m_nChecked;
}

function sendInBasket(string,id,sid,pid,cp,of,type)
{
	if (inbasket.length!=0 && inbasket.indexOf(id)>=0)
	{
		alert('')
		return;
	}
	strSend='?action=basket&subact=a'+string+'&pid='+pid+'&sid='+sid+'&id='+id+'&CurrentPage='+cp+'&OutputFrom='+of+'&type='+type;
	location.href=strSend;
}

function OnCheckZero(NameForm,NameField,Field)
{	
	pForm   = document.forms[NameForm];
	if (pForm.elements[NameField].value.replace(/(^\s*)|(\s*$)/,"")=="")
	{
		alert(""+Field+"");
		return false;	
	}
pForm.submit();
}

function CopyGood(path,winwid)
{
	var newWindow = window.open(path,winwid,"width=418,height=550,status=no,toolbar=no,resizable=no,menubar=no,location=no,scrollbars=yes,top=0,left=0");
	if (newWindow!=null)
	{
		newWindow.document.close();
		newWindow.document.focus();
	}
}

var newWind="";
function EditText(name,butname,titul,wdth,hght)
{
 newWind = window.open("m_Editor/m_MiniEditor.php?titul="+titul+"&name="+name+"&butname="+butname,"winedthtml","width="+wdth+",height="+hght+",status=no,toolbar=no,menubar=no,location=no,scrollbars=auto,top=20,left=20")
}

function CloseEditWin()
{
	if (newWind.closed==false)	newWind.close();
}

function SoderField(string)
{
	var regexp = /<.*?>/g;
	var ContrlString = string.replace(regexp,"");
	regexp = /&nbsp;/g;
	ContrlString = ContrlString.replace(regexp,"");
	regexp = /(^\s*)|(\s*$)/g;
	ContrlString = ContrlString.replace(regexp,"");
	return ContrlString;
}

function SetImg(Name,Img)
{
	var actPnt=actMenu*1;
	var curPnt=Name.substring(3,Name.length)*1;
//	actPnt=parseInt(actMenu);
//	curPnt=parseInt(Name.substr(3,1));
	if (actPnt==curPnt && firstStart!=0)
	{
	 return false;	
	}
 document.images[Name].src=eval(Img+'.src');
}

function activeTopMenu()
{
	if (actMenu>0 && actMenu<6)
	{
		SetImg("PIC"+actMenu,"I"+actMenu+"_2");
	}
		firstStart=1;
}

function OpenMenu(opencolor)
{
 if (openMenu.length!=0)
 {
  for (i=0;i<openMenu.length;i++)
  {
   document.getElementById("sbm"+openMenu[i]).style.display="block";
   if (document.getElementById("spn"+openMenu[i])!=null && document.getElementById("spn"+openMenu[i])!=undefined)
   {
    document.getElementById("grp"+openMenu[i]).style.color=opencolor;
    document.getElementById("spn"+openMenu[i]).style.color=opencolor;
    document.getElementById("spn"+openMenu[i]).innerHTML="&ndash;&nbsp;";
   }
  }
 }
}

function ButUpDown(updown,top,right,bottom,left,id)
{
 if (updown==1)
 {
  document.getElementById(id).style.paddingTop=top;
  document.getElementById(id).style.paddingRight=right;
  document.getElementById(id).style.paddingBottom=bottom;
  document.getElementById(id).style.paddingLeft=left;
 }
  else
	 {
   document.getElementById(id).style.paddingTop=top;
   document.getElementById(id).style.paddingRight=right;
   document.getElementById(id).style.paddingBottom=bottom;
   document.getElementById(id).style.paddingLeft=left;
  }
}

var stepRight = 0;
var stepBottom = 0;
function viewFullGood(string,id,width,namewin)
{
 stepRight  = (stepRight==200)?stepRight:stepRight+10;
 stepBottom = (stepBottom==200)?stepBottom:stepBottom+10;
	var newWindow = window.open(string+"&id="+id,namewin+id,"width="+width+",height=600,status=no,toolbar=no,resizable=yes,menubar=no,location=no,scrollbars=yes,top="+stepBottom+",left="+stepRight);
	if (newWindow!=null)
	{
		newWindow.document.close();
		newWindow.document.focus();
	}
}

var LeftOtstup = new Array ('0');
var TopOtstup  = new Array ('0');
var ListLayers = "1";
function ShowLayers()
{
	if (ListLayers.length!=0)
	{
	  var bottomPad  = 0;
	  var winWidth   = parseInt(document.getElementById("lyr1").style.width);
	  var maxHeight  = document.body.clientHeight-bottomPad;
	  var leftOtstup = (document.body.clientWidth<winWidth)?0:((document.body.clientWidth/2)-(winWidth/2));
	  for (i=1;i<=ListLayers.length;i++)
	  {
			if (document.getElementById("lyr"+i))
			{
				 with (document.getElementById("lyr"+i))
				 {
					if (ListLayers.substr(i-1,1)!="0")
					{
						style.top  = parseInt(TopOtstup[i-1]);
						style.left = (leftOtstup + parseInt(LeftOtstup[i-1]));
						if (i!=1)
						{
							style.display = "block";
							curHeight = parseInt(TopOtstup[i-1]) + clientHeight;
							if (curHeight>maxHeight) maxHeight=curHeight;
						}
					}
					else
					{
						if (style.display == "block") style.display = "none";
					}
				 }
			}
	  }
		document.getElementById("content").style.height=maxHeight+bottomPad;
		document.getElementById("lyr1").style.visibility="visible";
	}
}
