// JavaScript Document

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function makeMenuExtent(menuName){
	var menu_extent=document.getElementById('menu_extent');
	var active_menu_extent=document.getElementById('active_menu_extent');
	var navContainer=document.getElementById('nav');
	var linkCollection=navContainer.getElementsByTagName('a');
	for(x=0;x<linkCollection.length;x++){
		if(linkCollection[x].rel.length){
			if(linkCollection[x].className.indexOf('_on')!=-1){
				var posX=findPosX(linkCollection[x]);
				var posY=findPosY(linkCollection[x]);
				active_menu_extent.style.left=0;
				active_menu_extent.style.top=posY+"px";
				active_menu_extent.style.width=posX+"px";
				active_menu_extent.style.display='';
			}
			
			linkCollection[x].onmouseover=function(){
				var posX=findPosX(this);
				var posY=findPosY(this);
				menu_extent.style.left=0;
				menu_extent.style.top=posY+"px";
				menu_extent.style.width=posX+"px";
				menu_extent.style.display='block';
				var submenus=this.parentNode.getElementsByTagName('ul');
				if(submenus.length){
					submenus[0].style.display='block';
					submenus[0].parentNode.onmouseover=function(){
						linkCollect=this.getElementsByTagName('a');
						classString=linkCollect[0].className.substring(0,5);
						linkCollect[0].className=classString+"_on";
						submenus[0].style.display='block';
						menu_extent.style.left=0;
						menu_extent.style.top=posY+"px";
						menu_extent.style.width=posX+"px";
						menu_extent.style.display='block';
					}
					submenus[0].parentNode.onmouseout=function(){
						linkCollect=this.getElementsByTagName('a');
						classString=linkCollect[0].className.substring(0,5);
						if(classString!=menuName){
							linkCollect[0].className=classString;
						}
						submenus[0].style.display='none';
						menu_extent.style.left=0;
						menu_extent.style.top=posY+"px";
						menu_extent.style.width=posX+"px";
						menu_extent.style.display='none';
					}
				}
			}
			linkCollection[x].onmouseout=function(){
				var posX=findPosX(this);
				var posY=findPosY(this);
				menu_extent.style.left=0;
				menu_extent.style.top=posY+"px";
				menu_extent.style.width=posX+"px";
				menu_extent.style.display='none';
				submenus=this.parentNode.getElementsByTagName('ul');
			}
		}
	}
}


function extend_background(){
	var footerObj=document.getElementById('footer');
	//var logoObj=document.getElementById('logo');
	var topPos=130;
	var bottomPos=findPosY(footerObj);
	var finalHeight=bottomPos-topPos;
	var background_extentObj=document.getElementById('background_extent');
	background_extentObj.style.top="130px";
	background_extentObj.style.height=finalHeight+"px";
	background_extentObj.style.width="100%";
	//alert(finalHeight);
}