	function FormEditShowHide(){
		if (document.getElementById('form_form').style.display=='none')
			document.getElementById('form_form').style.display = 'block';
		else	document.getElementById('form_form').style.display = 'none';
	}

	function ShowHideDiv(id){
		if (document.getElementById(id).style.display=='block')
			document.getElementById(id).style.display = 'none';
		else	document.getElementById(id).style.display = 'block';
	}

	var last_idn = 0;

	function WriteNode(idn){
		if (document.getElementById('form'+idn).style.display=='none'){
			if (last_idn){
				document.getElementById('b1'+last_idn).name	= '';
				document.getElementById('b2'+last_idn).name	= '';
				document.getElementById('form'+last_idn).style.display = 'none';
			}
			document.getElementById('b1'+idn).name	= 'b1';
			document.getElementById('b2'+idn).name	= 'b2';
			document.getElementById('b1'+idn).value	= document.getElementById('b1div'+idn).innerHTML;
			document.getElementById('b2'+idn).value	= document.getElementById('b2div'+idn).innerHTML;
			document.getElementById('com').value	= 'write';
			document.getElementById('idnn').value	= idn;
			document.getElementById('form'+idn).style.display = 'block';
			last_idn = idn;
		}else	document.getElementById('form'+idn).style.display = 'none';
	}

	function AddNode(idn){
		if (document.getElementById('addform').style.display=='none'){
			document.getElementById('addb1').name	= 'b1';
			document.getElementById('addb2').name	= 'b2';
			document.getElementById('com').value	= 'add';
			document.getElementById('idnn').value	= idn;
			document.getElementById('addform').style.display = 'block';
		}
	}

	function DelNode(idn){
		if (confirm('Точно удалить?')){
			document.getElementById('b1'+idn).name	= 'b1';
			document.getElementById('b1'+idn).value	= '123';
			document.getElementById('com').value	= 'del';
			document.getElementById('idnn').value	= idn;
			document.getElementById('form_form').submit();
		}
	}

	function SubmitProduct(){
		if (document.getElementById('b4').value)
			document.getElementById('productb2').value = '[no]'+document.getElementById('productb2').value;
		if (!document.getElementById('productb2').value)
			document.getElementById('productb2').value = '   ';
	}

	function OrderFormShow(idn){
		document.getElementById("order"+idn).style.display="block";
	}

	function ShowOrder(idn){
		document.getElementById("order"+idn).style.display="block";
	}

	function ShowMenuItem(i) {
		var divid = 'MenuItem'+i; 
		if (document.getElementById(divid).style.display=='none')
			document.getElementById(divid).style.display='block';
		else	document.getElementById(divid).style.display='none';
	}
	function SendMessageInOrder(author){
		document.getElementById('b2order').style.display = "none";
		document.getElementById('b2order').value	= author + document.getElementById('b2order').value + "</div>" + document.getElementById('coments').innerHTML ;
		document.getElementById('comorder').value	= 'write';
		document.getElementById('form_order_mes').submit();
	}

	function ChangeImgProd(src){
		document.getElementById('imgprod').src=src;
		document.getElementById('imgprod').style.display='block';
	}

	function SetOrderStatus(st){
		document.getElementById('setstatus').value = st;
		document.getElementById('formOrderStatus').submit();
	}

	function GotoTypePage(){
		document.getElementById('form_view_catalog').submit();
	}

	var rm = new Array(0,100, 0,100);
	var rtmt = new Array();
	var rimgnum = 4;
	var rimgnum2= 1;
	var rpausa  = 501;
	var rccicl  = 0;
	function CoolChangeImg() {
		rm[0]+=1;
		rm[1]-=1;
		if (navigator.appName=="Microsoft Internet Explorer"){
			rm[0]+=3;
			rm[1]-=3;
		}
		if (rccicl>0){
			document.getElementById("imgstep"+rimgnum).style.opacity	= rm[1]/100;
			document.getElementById("imgstep"+rimgnum).style.filter		= 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + (100-rm[0]) + ')';
			document.getElementById("imgstep"+rimgnum2).style.opacity	= rm[0]/100;
			document.getElementById("imgstep"+rimgnum2).style.filter	= 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + (100-rm[1]) + ')';
		}else{	document.getElementById("imgstep"+rimgnum2).style.opacity	= 1;
			document.getElementById("imgstep"+rimgnum2).style.filter	= 'progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
		}
		if (rpausa>4){
			clearTimeout(rtmt);
			rpausa = 4;
			if (navigator.appName=="Microsoft Internet Explorer")
			rpausa = 40;
		}
		rtmt = setTimeout("CoolChangeImg()",rpausa);
		if (rm[0]>98){
			rccicl++;
			rpausa  = 500;
			rimgnum++;
			if (rimgnum>4) rimgnum=1;
			rimgnum2++;
			if (rimgnum2>4)rimgnum2=1;
			rm = new Array(0,100, 0,100);
			rt = new Array();
//			document.getElementById("fff").innerHTML = rimgnum+";"+rimgnum2+";pausa="+rpausa;
			clearTimeout(rtmt);
			rtmt = setTimeout("CoolChangeImg()",rpausa);
		}
	}




	function PostQuestion (){
		var error = 0;
		if (!document.getElementById('postquest_b2').value){
			alert("Введите текст письма!");
			error=1;
		}
		if (!document.getElementById('postquest_b1').value){
			alert("Введите своё имя!");
			error=1;
		}
		if (!document.getElementById('postquest_b3').value){
			alert("Введите свои контакты!");
			error=1;
		}
		if (!error)
			document.getElementById('mbformqq').submit();
	}

	function ClickToLetter(){
		if (document.getElementById('postquest_b2').value=='Писать письмо на эл. почту здесь...')
			document.getElementById('postquest_b2').value = "";
	}




	function BuySubmit(idn){
		var v = document.getElementById('cnt'+idn).value;
		if ((v>0 || v==0) && v!=''){
			document.getElementById('cntt'+idn).value=v;
			document.getElementById('BuyForm'+idn).submit();
		}else	alert("Перед кнопкой \"купить\" введите количество единиц товара, которое хотите купить!");
	}

	last_val=0;

	function SelectPriceText(idno,idnp){
		document.getElementById('price'+idno+'p'+idnp).style.border = '1 solid black';
		last_val = document.getElementById('price'+idno+'p'+idnp).value;
	}

	function unSelectPriceText(idno,idnp){
		document.getElementById('price'+idno+'p'+idnp).style.border = '0';
		if (last_val!=document.getElementById('price'+idno+'p'+idnp).value){
			process ("template/catalog_ajax.php","orderdiv"+idno,"idno="+idno+"&idnp="+idnp+"&price="+document.getElementById('price'+idno+'p'+idnp).value );
		}
	}

	function SelectCountText(idno,idnp){
		document.getElementById('count'+idno+'p'+idnp).style.border = '1 solid black';
		last_val = document.getElementById('count'+idno+'p'+idnp).value;
	}

	function unSelectCountText(idno,idnp){
		document.getElementById('count'+idno+'p'+idnp).style.border = '0';
		if (last_val!=document.getElementById('count'+idno+'p'+idnp).value){
			process ("template/catalog_ajax.php","orderdiv"+idno,"idno="+idno+"&idnp="+idnp+"&count="+document.getElementById('count'+idno+'p'+idnp).value );
		}
	}

	function SelectInputText(name, idn){
		document.getElementById(name+idn).style.border = '1 solid black';
		last_val = document.getElementById(name+idn).value;
	}

	function unSelectInputText(name, idn){
		document.getElementById(name+idn).style.border = '0';
		if (last_val!=document.getElementById(name+idn).value){
			process ("template/catalog_ajax.php",'orderdiv'+idn,"idn="+idn+"&"+name+"="+document.getElementById(name+idn).value );
		}
	}

	function SetStatus(idn, st){
		process ("template/catalog_ajax.php",'orderdiv'+idn,"idn="+idn+"&setstatus="+st );
	}

	function ProductInfoSave (idn){
		process ("template/catalog_ajax.php",'product'+idn,"product="+idn+"&b1="+document.getElementById('product'+idn+'b1').value+"&b2="+document.getElementById('product'+idn+'b2').value );
	}

	function ProductInfoLoad (idn){
		if (document.getElementById('product'+idn).style.display=='block')
			document.getElementById('product'+idn).style.display = 'none';
		else{	document.getElementById('product'+idn).style.display = 'block';
			process ("template/catalog_ajax.php",'product'+idn,"product="+idn );
		}
	}

	function SetCountProduct(idn){
		if (document.getElementById('count'+idn).value!=''){
			process ("template/catalog_ajax.php",'',"product="+idn+"&count="+document.getElementById('count'+idn).value );
			alert("Добавлено!");
		}else	alert("Введите количество единиц товара, которое хотите купить!");
	}


	function SelectPricePText(idnp){
		document.getElementById('price'+idnp).style.border = '1 solid black';
		last_val = document.getElementById('price'+idnp).value;
	}

	function unSelectPricePText(idnp){      
		document.getElementById('price'+idnp).style.border = '0';
		if (last_val!=document.getElementById('price'+idnp).value){
			process ("template/catalog_ajax.php","pricerozn"+idnp,"idnp="+idnp+"&price="+document.getElementById('price'+idnp).value );
		}
	}

	function ShowPicProduct(idn){
		document.all("imgprod"+idn).style.visibility='visible';
		document.all("imgprod"+idn).src="template/catalog_img.php?s=m&n="+idn;

	}
	function HidePicProduct(idn){
		document.all("imgprod"+idn).style.visibility='hidden';
	}

	function DelOrder(idno){      
		if (confirm("Точно удалить?"))
			process ("template/catalog_ajax.php",'orderdiv'+idno,"delorder="+idno );
	}
	
	last_page = '';
	function OrderShowDiv(id){
		var d = 0;

		// меняем окно
		if (last_page && last_page!=id && !d){
			document.getElementById(last_page).style.visibility = 'hidden';
			document.getElementById(id).style.visibility = 'visible';
			last_page = id;
			d = 1;
		}

		// закрываем окно
		if (last_page && last_page==id && !d){
			document.getElementById(id).style.visibility = 'hidden';
			last_page = 0;
			d = 1;
		}

		// открываем окно
		if (!last_page && !d){
			document.getElementById(id).style.visibility = 'visible';
			last_page = id;
			d = 1;
		}
	}

	function OrderHideDiv(){
		document.getElementById(last_page).style.visibility = 'hidden';
		last_page = 0;
	}

	var last_comentdiv = 0;
	function ShowProductComent(idn){
		if (last_comentdiv)
		document.all(last_comentdiv).style.visibility	='hidden';
        	document.all("prodcoment"+idn).style.visibility	='visible';
		document.all("prodcoment"+idn).style.opacity	= 75/100;
		last_comentdiv = "prodcoment"+idn;
	}
	function HideProductComent(idn){
		document.all("prodcoment"+idn).style.visibility='hidden';
		last_comentdiv = 0;
	}


	var last_let = 0;
	var last_idnlet = 0;
	function SelLetter(idno, id){
		last_idnlet = id;
		id = idno+"o"+id;
		if (last_let)		
			document.getElementById('letter'+last_let).style.display = "none";
			document.getElementById('letter'+id).style.display = "block";
		last_let = id;

	}

	function SendLetterAbOrder (idno){
		var id = last_idnlet + "o" + idno;
		var nak = 0;
		var fak = 0;
		var pre = 0;
		if (document.getElementById('nakladn'+idno).checked)	nak = 1;
		if (document.getElementById('faktura'+idno).checked)    fak = 1;
		if (document.getElementById('preinvoice'+idno).checked)	pre = 1;
		process ("template/catalog_ajax.php",'orderdiv'+idno,"sendletter="+idno+"&b1="+document.getElementById('b1'+id).value+"&b2="+document.getElementById('b2'+id).value +"&fakt="+fak+"&nakl="+nak+"&pre="+pre);  
	}

	function ShowReportMonth (dt){
		process ("template/catalog_ajax.php",'reportmonth',"reportmonth=1&dt="+dt);  
	}

	function ShowReportDay (dt){
		process ("template/catalog_ajax.php",'reportday',"reportday=1&dt="+dt);  
	}

	function AddPrintAdres (idno){
		process ("template/catalog_ajax.php",'',"idno="+idno+"&printadres=1");  
	}

	function AddPrintAdresGP (idno){
		process ("template/catalog_ajax.php",'',"idno="+idno+"&printadresgp=1");  
	}

	function CleanPrintAdres (){
		process ("template/catalog_ajax.php",'',"clean=1&printadres=1");  
	}


	function FindOrder(){

		var product = '';
		var orderid = '';
		var city    = '';
		var status  = '';
		var fam     = '';
		var dost    = '';
		if (document.getElementById('searchproduct').value)
			product = document.getElementById('searchproduct').value;
		if (document.getElementById('searchorderid').value)
			orderid = document.getElementById('searchorderid').value;
		if (document.getElementById('searchcity').value)
			city = document.getElementById('searchcity').value;
		if (document.getElementById('searchstatus').value)
			status = document.getElementById('searchstatus').value;
		if (document.getElementById('searchfam').value)
			fam = document.getElementById('searchfam').value;
		if (document.getElementById('searchdost').value)
			dost = document.getElementById('searchdost').value;
		process ("template/catalog_ajax.php",'foundorders',"findorder=1&prod="+product+"&orderid="+orderid+"&city="+city+"&status="+status+"&fam="+fam+"&dost="+dost);  
	}
                                
	function SearchTextInCatalog(){
		var text = document.getElementById('searchtext').value;
		process ("template/catalog_search_ajax.php","div_catalog","text="+text);  
	}

	function oformzakaz(sum){
		if (sum<150)
			alert ("Минимальная сумма заказа составляет 150грн!");
		else	document.getElementById('formzakaz').submit();

	}