	opera = (navigator.userAgent.indexOf('Opera') >= 0) ? true : false;
        IE = (document.all && !opera) ? true : false;
        NS6 = (document.getElementById && !IE && !opera) ? true : false;
	show = 0;

//        IE = (document.all) ? 1: 0;
//        NS6 = (document.getElementById) ? 1 : 0;
	//document.onload = inst();


//--------------------------
function check_submit(){
	var args=check_submit.arguments;
        var error = false;
        for (i=1; i<(args.length); i+=1) {
		if (!document.forms[args[0]].elements[ args[i] ].value){
	       	        alert("Íå âñå ïîëÿ çàïîëíåíû");
			return false;
		}
	}

        if (document.forms[args[0]].elements['email'].value && !checkmail(document.forms[args[0]].elements['email'].value)) {
                alert("Âû ââåëè íåâåðíûé E-mail");
                return false;
        }

	return true;
}

//--------------------------
function checkmail(email) 
{ 
  if (email=="") return(false) 
  if (email.indexOf(".")==-1) return(false) 
  if (email.indexOf(".")==email.length-1) return(false) 
  dog=email.indexOf("@"); 
  if (dog==-1) return(false) 
  if ((dog<1)||(dog>email.length-5)) return(false) 
  if ((email.charAt(dog-1)=='.')||(email.charAt(dog+1)=='.')) return(false)
  return(true) 
} 



var caution = false

function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "")
	if (!caution || (name + "=" + escape(value)).length <= 4000)
		document.cookie = curCookie
	else
		if (confirm("Cookie exceeds 4KB and will be cut!"))
			document.cookie = curCookie
}

function getCookie(name) {
	var prefix = name + "="
	var cookieStartIndex = document.cookie.indexOf(prefix)
	if (cookieStartIndex == -1)
		return null
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
	if (cookieEndIndex == -1)
		cookieEndIndex = document.cookie.length
	return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}

function inst() {
      outline = new Array(
		new Array("line1",0)
	);

	var storedValue = getCookie("outline");

	if (storedValue) {
		for (var i = 0; i < outline.length; ++i) {
			lay = outline[i][0];
			if (storedValue.charAt(i) == '0'){
				if(IE) document.all(lay).style.display = "none"
				else document.getElementById(lay).style.display = "none"
				outline[i][1] = 0;
			}
			else {
				if(IE) document.all(lay).style.display = "block"
				else document.getElementById(lay).style.display = "block";
				outline[i][1] = 1;
			}
		}
	    }
}

function lrOnOff(lay) {
	text = ''
	for (i=0; i<=outline.length-1; i++){
	if(outline[i][0] == lay){ outline[i][1] = Math.abs(outline[i][1]-1);
	param = (outline[i][1]==1)? 'block':'none' ;
}
	text += outline[i][1];
	setCookie("outline", text);
}
	if(IE) document.all(lay).style.display = param
	else document.getElementById(lay).style.display = param
}

function WriteMenu() {

//document.write("<tr><td><div class=\"menu\"><A href=\'#\'>ÒÅÍÄÅÐÛ</A></div><hr></td><TD align=\"right\"><IMG class=\"typebutton\" src=\"img/button-menu.gif\"></TD></tr>\n");
//document.write("<tr><td><div class=\"menu\"><A href=\'expose.php\'>ÂÛÑÒÀÂÊÈ</A></div><hr></td><TD align=\"right\"><IMG class=\"typebutton\" src=\"img/button-menu.gif\"></TD></tr>\n");
document.write("<tr><td><div class=\"menu\" onclick=\"lrOnOff(\'line1\')\"><A href=\'#\'>ÊÎÌÌÅÐ×ÅÑÊÎÅ ÏÐÅÄËÎÆÅÍÈÅ</A></div><hr></td><TD align=\"right\"><IMG class=\"typebutton\" src=\"img/button-menu.gif\"></TD></tr>\n");
document.write("<tr><td><div id=\"line1\" class=\"menu\">\n");

document.write("<IMG src=\"img/trt.gif\" class=\"type2\"><A href=\'commercial.php?invl=1\'>ÈÍÂÅÑÒÈÖÈÈ</A><IMG class=\"typebutton1\" src=\"img/button-menu.gif\"><hr>");
document.write("<IMG src=\"img/trt.gif\" class=\"type3\"><A href=\'commercial.php?invl=1&st=1\'>ÑÏÐÎÑ</A><IMG class=\"typebutton1\" src=\"img/button-menu.gif\"><hr>");
document.write("<IMG src=\"img/trt.gif\" class=\"type3\"><A href=\'commercial.php?invl=1&st=2\'>ÏÐÅÄËÎÆÅÍÈß</A><IMG class=\"typebutton1\" src=\"img/button-menu.gif\"><hr>");
document.write("<IMG src=\"img/trt.gif\" class=\"type2\"><A href=\'commercial.php?trdl=1\'>ÒÎÐÃÎÂËß</A><IMG class=\"typebutton1\" src=\"img/button-menu.gif\"><hr>");
document.write("<IMG src=\"img/trt.gif\" class=\"type3\"><A href=\'commercial.php?trdl=1&st=1\'>ÑÏÐÎÑ</A><IMG class=\"typebutton1\" src=\"img/button-menu.gif\"><hr>");
document.write("<IMG src=\"img/trt.gif\" class=\"type3\"><A href=\'commercial.php?trdl=1&st=2\'>ÏÐÅÄËÎÆÅÍÈß</A><IMG class=\"typebutton1\" src=\"img/button-menu.gif\"><hr>");
document.write("<IMG src=\"img/trt.gif\" class=\"type2\"><A href=\'commercial.php?srvl=1\'>ÓÑËÓÃÈ</A><IMG class=\"typebutton1\" src=\"img/button-menu.gif\"><hr>");
document.write("<IMG src=\"img/trt.gif\" class=\"type3\"><A href=\'commercial.php?srvl=1&st=1\'>ÑÏÐÎÑ</A><IMG class=\"typebutton1\" src=\"img/button-menu.gif\"><hr>");
document.write("<IMG src=\"img/trt.gif\" class=\"type3\"><A href=\'commercial.php?srvl=1&st=2\'>ÏÐÅÄËÎÆÅÍÈß</A><IMG class=\"typebutton1\" src=\"img/button-menu.gif\"><hr>");
document.write("</div></td></tr>\n");

}


function inst_map() {

		document.all.map.width=document.all.f.width-30;
		document.all.map.height=document.all.map.width*0.6;

/*        	if(IE){
                clnx= document.body.clientWidth;
                clny= document.body.clientHeight;
                }

	        if(NS6 && !IE)  {
                clnx= window.innerWidth;
                clny= window.innerHeight;
                }

		var mapObj=document.map;
		clnx=Math.round(clnx/2.2);
		clny=Math.round(clnx/1.7);

		document.all.map.width=clnx+100;
		mapObj.TSetProperty("_root", 8, clnx);
		document.all.map.height=clny+50;
		mapObj.TSetProperty("_root", 9, clny);
*/
}


function openTnvedWin(form_name, id_land){
                var url="inc/tnved.php?form_name="+form_name;
		id_land = (id_land)? id_land:'';
		url=url+"&id_land="+id_land;
		
		vWinCal = window.open(url, "Tnwed", "width=300,height=500,status=no,resizable=1, scrollbars=1,top=200,left=400");
		vWinCal.opener = self;
		vWinCal.focus();
		ggWinCal = vWinCal;


}

function openCategoryWin(form_name){
                var url="inc/category.php?form_name="+form_name;
		
		vWinCal = window.open(url, "Category", "width=300,height=500,status=no,resizable=1, scrollbars=1,top=200,left=400");
		vWinCal.opener = self;
		vWinCal.focus();
		ggWinCal = vWinCal;


}



function CheckCommercial(tems_val, lay){
//	alert(tems_val);
	if (tems_val=='comm' || tems_val=='trd_1'|| tems_val=='trd_2')show = 1;
	else show = 0;

	param = (show==1)? 'block':'none' ;

	if(IE) document.all(lay).style.display = param;
	else document.getElementById(lay).style.display = param;

}



