function topMenu (id,over){
	document.getElementById("topmenu"+id).className = "topMenu" + over;
}

var isIE4=(navigator.appVersion.indexOf("MSIE")!=-1 && parseFloat(navigator.appVersion)>=4)?true:false;
var isNN4=(navigator.appName=="Netscape" && parseFloat(navigator.appVersion)<5)?true:false;
var isNN6=(navigator.appName=="Netscape" && parseFloat(navigator.appVersion)>=5)?true:false;
var isOPERA=(navigator.appName=="Opera" && parseFloat(navigator.appVersion)>=7)?true:false;

isIE4 = true;
isNN6 = false;

var timeout;
var DivSet="div0";

function ShowIt (parametr,div,div2) {
	if (parametr == true) {
		clearTimeout(timeout);hide();
		x=getDivX(div);
		y=getDivY(div);
		shiftY=getDivHeight(div);
		setDivX(div2,x,y+shiftY);
		DivSet=div2;
	}
	if (parametr == false) {
		timeout=setTimeout('hide()',500);
	}
}

function getDivHeight(divName){
	if( isIE4 ) {
		return document.all[divName].offsetHeight;
	} else if( isNN6 || isOPERA ) {
		return document.getElementById(divName).offsetHeight;
	} else {
		return document.getElementById(divName).offsetHeight;
	}
}


// get X coordinate of element's upper-left corner
function getDivX( szDivName )
{
	if( isIE4 )
	{
		var nPos = 0;
		objCurrent = document.all[ szDivName ];
		while( objCurrent != null )
		{
			nPos += objCurrent.offsetLeft;
			objCurrent = objCurrent.offsetParent;
		}
		return nPos;
	}
	if( isNN4 )
		return document.layers[ szDivName ].pageX; 
	if( isNN6 || isOPERA )
		return document.getElementById( szDivName ).offsetLeft;

	//return 0;
	return 100;
}		

// get Y coordinate of element's upper-left corner
function getDivY( szDivName )
{
	if( isIE4 )
	{
		var nPos = 0;
		objCurrent = document.all[ szDivName ];
	
		// prevent relative Y positioning problems in IE55 and IE6:
		if( objCurrent.style.position.toLowerCase() != "absolute" )
			objCurrent.style.position = "static";
	
		while( objCurrent != null )
		{
			nPos += objCurrent.offsetTop;
			objCurrent = objCurrent.offsetParent;
		}

		return nPos;
	}
	if( isNN4 )
		return document.layers[ szDivName ].pageY; 
	if( isNN6 || isOPERA)
		return document.getElementById( szDivName ).offsetTop;
	//return 0;
	return document.getElementById( szDivName ).offsetTop;

}

function setDivX(DivName,x,y){
 if(isIE4){
 document.all[DivName].style.left=x+178+"px";
 document.all[DivName].style.top=y-15+"px";
 document.all[DivName].style.visibility="visible";
 } else if(isNN4){
 document.layers[DivName].pageX=x+178;
 document.layers[DivName].pageY=y-15;
 document.layers[DivName].visibility="show";
 } else if(isNN6 || isOPERA){
 document.getElementById(DivName).style.left=x+178;
 document.getElementById(DivName).style.top=y-15;
 document.getElementById(DivName).style.visibility="visible";
 } else {
 document.getElementById(DivName).style.left=x+178;
 document.getElementById(DivName).style.top=y-15;
 document.getElementById(DivName).style.visibility="visible";
 }
}

function hide(){
 if(isIE4){
 document.all[DivSet].style.visibility="hidden";
 }
 if(isNN4){
 document.layers[DivSet].visibility="hidden";
 }
 if(isNN6 || isOPERA){
 document.getElementById(DivSet).style.visibility="hidden";
 } 
}

function mOver(src){
	if(!src.contains(event.fromElement)){src.style.cursor='hand'}
}
function mOut(src){
	if(!src.contains(event.toElement)){src.style.cursor='default'}
}
function goUrl(url){
	if(url){
		location.href=url;
	}
return false; 
}
var e				= new Image();
e.src				= "/pictures/e.gif";

function new_window(url,w,h) {
	if (w==0 || h==0) {
		window.open(url);
	} else {
		gwin = window.open(url,'gwin','width='+w+',height='+h+',status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes');
		gwin.focus();
	}
	return false;
}
function new_window22(url,w,h) {
	if (w==0 || h==0) {
		window.open(url);
	} else {
		gwin = window.open(url,'gwin','width='+w+',height='+h+',status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes');
		gwin.focus();
	}
}

function open_window(isrc,ititle) {
	mwin=window.open('','mwin','width=550,height=400,scrolling=no,resizable=yes');
	mwin.document.open();
	mwin.document.write('<html>\n<head>\n<title>'+((ititle=="") ? 'Sadovnik Shop' : ititle+'')+'</title>\n</head>\n<body style="overflow: hidden; margin: 0px; padding: 0px;">\n');
	mwin.document.write('<a href="javascript:void(0);" onclick="window.close(); return false;" title="Кликните, чтобы закрыть окно"><img src="'+isrc+'" border="0" onload="self.resizeTo(this.width+8,this.height+30);" alt="Кликните, чтобы закрыть окно" /></a></body></html>');	
}
function print_window(){ 
	if (window.print()) {
		id='self';
		if (!(eval(id) == null || eval(id+".closed"))) {
			eval('self.print()');
		}
	}
}
function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}
