function layer(layerName){
 //DOM1
  if(document.getElementById) return document.getElementById(layerName)
 //MSIE4
  if(document.all) return document.all[layerName]
 //Netscape 4
  if(document.layers) return document.layers[layerName]
 //неподдерживаемый браузер
  return null
}

function LayerWrite(lname,lvalue)
{
 layer(lname).innerHTML=lvalue;
// For NS:
//.document.open()
//.document.write(text)
//.document.close()

}

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 popUp(x,y,URL) {
closetime = 20;
id = 'popup';
popup = window.open(URL, id, 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+x+',height='+y+',left=50,top=50');
if (closetime) setTimeout("popup.close();", closetime*1000);
}

function ShowImage1(theurl) {

 if (theurl == '') { return; }

id = 'okno'+Math.round(1000*Math.random());

if (navigator.appName.indexOf("Internet Explorer") >= 0) 
{
 var myImage = new Image();
 myImage.src = theurl;

 w = 'width='+myImage.width;
 h = 'height='+myImage.height;
 wh1 = w+','+h;
 res = '=0';
 bt = '['+myImage.width+'x'+myImage.height+'] ';
}
 else
{
// myImage = new Image();
// myImage.src = theurl;
 w = '';
 h = '';
 wh1 = 'width=200,height=200';
 res = '';
 bt = '(?) ';
}
okno = window.open(theurl, id, wh1+'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable'+res+',left=50,top=50');
d = okno.document;
d.writeln('<html>\n<head>\n<title>',bt,'Sargona: ',theurl,'\n</title>');
d.writeln('<meta http-equiv="Content-Type" content="text/html;charset=windows-1251">\n</head>');
d.writeln('<body bgcolor="white" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
d.write  ('<a href="javascript:close()">');
//d.write  ('<img src="'+theurl+'" ',w,' ',h,' border="0" hspace="0" vspace="0" alt="Close the window">');
d.write  ('<img src="'+theurl+'"  border="0" hspace="0" vspace="0" alt="Close the window">');
d.writeln('</a>');
d.writeln('</body>');
d.writeln('</html>');
okno.focus();
}

function ShowImage2(theurl)
{
 if (theurl == '') { return; }

 var var_image = new Image();
 var_image.src = theurl;
 width = var_image.width + 20;
 heigth = var_image.height +30;
 str_style= "\" width="+width+",height="+heigth+"\"";
 window.open(var_image.src,"myImage",str_style);
}

function ShowImage(theurl)
{
 if (theurl == '') { return; }
 
 id = 'win'+Math.round(1000*Math.random());

 var myImage = new Image();
 myImage.src = theurl;
 window.open(myImage.src,id,'');
}

function submitonce(theform) {
	// if IE 4+ or NS 6+
	if (document.all || document.getElementById) {
		// hunt down "submit" and "reset"
		for (i=0;i<theform.length;i++) {
			var tempobj=theform.elements[i];
			if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset") {
				//disable it
				tempobj.disabled=true;
			}
		}
	}
}

