var isIE4=(navigator.appVersion.indexOf("MSIE")!=-1 && parseFloat(navigator.appVersion)>=4)?true:false;
var isNN6=(navigator.appName=="Netscape" && parseFloat(navigator.appVersion)>=5)?true:false;
var isOPERA=(navigator.appName=="Opera" && parseFloat(navigator.appVersion)>=7)?true:false;

var timeout;
var timeout2;
var timeout3;
var timeoutSub;
var DivSet="dropDown1";
var openDiv;
var openDivSub=null
var openX;
var openY;

function ShowItSub(div,divSub,xx,divMain) 
{
	if (openDivSub) hideSub(openDivSub);
	clearTimeout(timeout3);
	openX=getDivXSub(divMain,divSub)+xx;
	openY=getDivYSub(divMain,divSub)+5;
	openDiv=div;
	setDivX();
	openDivSub=div;
}


function ShowParent()
{
	clearTimeout(timeout);
	clearTimeout(timeout3);
}

function ShowIt (parametr,div,div2,pause)
{	
	if (parametr == true)
	{
		checkIt(div2);
		clearTimeout(timeout);
		hide();
		x=getDivX(div);
		y=getDivY(div);
		shiftY=getDivHeight(div);
		
		if (pause && openDiv!=div2)
		{
			openDiv=div2;
			openX=x;
			openY=y+shiftY;
			timeout2=setTimeout('setDivX()',1000);
		} 
		else 
		{
			openDiv=div2;
			openX=x;
			openY=y+shiftY;
			setDivX();
		}
		DivSet=div2;
	}
	if (parametr == false) 
		timeout=setTimeout('hide()',1000);		
}

function checkIt(divName)
{
	if (isIE4) 
		selfWidth = document.all[divName].offsetWidth;
	
	if (isNN6 || isOPERA) 
		selfWidth = document.getElementById(divName).offsetWidth;
	
	if (selfWidth > 340) 
	{
		if (isIE4 || isOPERA) 
			document.getElementById(divName).style.width=340;		
		if (isNN6) 
			document.getElementById(divName).style.width=340;		
	}
}

function getDivHeight(divName)
{
	if (isIE4) 
		return document.all[divName].offsetHeight;	
	if (isNN6 || isOPERA) 
		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 (isNN6 || isOPERA) return document.getElementById(szDivName).offsetLeft; 
	return 0;
}

// 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( isNN6 || isOPERA) return document.getElementById( szDivName ).offsetTop; 
	return 0;
}

// get X coordinate of element's upper-left corner
function getDivXSub(szDivName, divSub)
{
	if (isIE4)
	{
		var nPos = 0;
		objCurrent = document.all[divSub];
		while(objCurrent!=null)
		{
			nPos += objCurrent.offsetLeft;
			objCurrent = objCurrent.offsetParent;
		}
		return nPos;
	}
	if (isNN6 || isOPERA) 
	{
		w1 = document.getElementById(szDivName).offsetLeft;
		w2 = document.getElementById(divSub).offsetLeft;
		return w1+w2;
	}
	return 0;
}	

//get Y coordinate of element's upper-left corner
function getDivYSub(szDivName, divSub)
{
	if (isIE4)
	{
		var nPos = 0;
		objCurrent = document.all[divSub];
	
		// 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( isNN6 || isOPERA)  
	{
		w1 = document.getElementById(szDivName).offsetTop;
		w2 = document.getElementById(divSub).offsetTop;
		return w1+w2;
	}
}

function setDivX()
{
	document.getElementById(openDiv).style.left=openX;
	document.getElementById(openDiv).style.top=openY;
	document.getElementById(openDiv).style.visibility="visible"; 
	document.getElementById(openDiv).style.display="block"; 	
}

function hide()
{
	if (isIE4)
		document.all[DivSet].style.visibility="hidden";
	if (isNN6 || isOPERA)
		document.getElementById(DivSet).style.visibility="hidden"; 
}

function hideSub(divName)
{
	if (isIE4)
		document.getElementById(divName).style.visibility="hidden"; 
	if	(isNN6 || isOPERA)
		document.getElementById(divName).style.visibility="hidden";
}

function hideSubTimeout(divName)
{
	timeout3=setTimeout('hideSub("'+divName+'")',500);
}