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("Ваша корзина пуста!");
		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();
}

