var menuUp=0;
var oldelement;

function ddmenuLeave(ev)
{
	var e = ev
	var srcEle;
	var srcEvt;
	if(window.event)
		{
		srcEle = e.srcElement;
		srcEvt = e;
		} 
	else{
		srcEle = e.target;
		srcEvt = e;
		}
	var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
	if(reltg.nodeType!=1) reltg=reltg.parentNode;
	str1 = new String(reltg.className);
	str2=str1.match(/menu/gi);
	if (str2=="menu") return;
	ddmenuHideAll();
	oldelement=null;
}

function ddmenuHideAll()
{
	menuUp=0;
	for(i=1;i<=ddmenuNum;i++)
		document.getElementById('submenu_'+i).style.visibility = "hidden";
}


function ddmenuShowLayer(elem, xLeft, xTop,xHeight)
{
	if (oldelement!=elem){ playsound(soundfile1);}
		ddmenuHideAll();
	document.getElementById(elem).style.left = xLeft+1;
	document.getElementById(elem).style.top = xTop+xHeight//+20;
	document.getElementById(elem).style.visibility = "visible";
	menuUp=1;
	oldelement=elem;
}

function getElementHeight(Elem)
{
	var elemheight=Elem.offsetHeight;
	return elemheight;
}

function getElementLeft(Elem) 
{
	xPos = Elem.offsetLeft;
	tempEl = Elem.offsetParent;
	while (tempEl != null) 
		{
  		xPos += tempEl.offsetLeft;
		tempEl = tempEl.offsetParent;
  		}
  		//alert(xPos);
	return xPos;
}

function getElementTop(Elem) 
{
	xPos = Elem.offsetTop;
	tempEl = Elem.offsetParent;
	while (tempEl != null) 
		{
  		xPos += tempEl.offsetTop;
		tempEl = tempEl.offsetParent;
  		}
  		//alert(xPos);
	return xPos;
	}

function SelectMenu(item)
{
	var i;
	
	for(i=1;i<5;i++)
		{
		if(i!=item)
			document.getElementById("menu_"+i).style.backgroundImage = "url(/images/MBG_Gray.jpg)";
		else
			document.getElementById("menu_"+i).style.backgroundImage = "url(/images/MBG_Blue.jpg)";
		}
}

function GoMenu(item)
{
	window.location=item;
}

function showBalloon(xLeft, xTop)
{
	var ele;
	if(navigator.appName == "Microsoft Internet Explorer")
		{
		ele="Balloon1";
		}
	else{
		ele="Balloon";
		}
		
	balloonWait=1;
	
	window.scroll(0,0);
	document.getElementById(ele).style.left = (xLeft-540+((620/10)*(10-balloonWait)))+'px';
	document.getElementById(ele).style.top = (xTop-270+((400/10)*(10-balloonWait)))+'px';
	document.getElementById(ele).style.width = (620/10)*balloonWait+'px';
	document.getElementById(ele).style.height = (400/10)*balloonWait+'px';
	document.getElementById(ele).style.visibility = "visible";
	setTimeout("balloonNext('"+ele+"', "+xLeft+", "+xTop+")",1);
}

function balloonNext(elem, xLeft, xTop)
{
	balloonWait+=1;
	document.getElementById(elem).style.left = (xLeft-540+((620/10)*(10-balloonWait)));
	document.getElementById(elem).style.top = (xTop-270+((400/10)*(10-balloonWait)));
	document.getElementById(elem).style.width = (620/10)*balloonWait;
	document.getElementById(elem).style.height = (400/10)*balloonWait;
	if(balloonWait!=10) {setTimeout("balloonNext('"+elem+"', "+xLeft+", "+xTop+")",1); }
}

function hideBalloon(elem)
{
	document.getElementById(elem).style.visibility = "hidden";
}
