var IsIE = (/msie/).test( navigator.userAgent.toLowerCase() ) ;
if(!IsIE){
	IsGecko = true;
}

function mainNavOver(self){
	self.className = 'mainnva4hover';
}

function mainNavOut(self){
	self.className = 'mainnva4';
}



/* Get Exact Scroll Size */
function getScrollTop(){
	var sT = 0;
	
	sT = document.body.scrollTop; 
	if(!IsIE && !sT){
		sT = document.documentElement.scrollTop;
	}
	
	return sT;
}

function getScrollLeft(){
	var sL = 0;

	sL = document.body.scrollLeft;
	if(!IsIE && !sL){
		sL = document.documentElement.scrollLeft;
	}
	
	return sL;
}

/*
Mouses Actions
*/
function getMouseX(e){
	
	var tempX = 0;
	if (IsIE) {
		if(event){
			tempX = event.clientX + getScrollLeft();
		}
	}else{
		tempX = e.pageX;
	}
	
	if (tempX < 0){ tempX = 0; }
	
	return tempX;
}

function getMouseY(e){
	var tempY = 0;

	if (IsIE) {
		
		if(event){
			tempY = event.clientY + getScrollTop();
		}
	} else {
		tempY = e.pageY;
    }  
	if (tempY < 0){ tempY = 0; }
	
	return tempY;
}

/*
Get Div Position
*/
function getAreaLeft(o){
	var l=o.offsetLeft;      
    while(o=o.offsetParent){    
      l+=o.offsetLeft;     
    }
	return l;
}
function getAreaTop(o){
	var t=o.offsetTop;      
    while(o=o.offsetParent){    
      t+=o.offsetTop;     
    }
	return t;
}

/*
x: mouse X
y: mouse Y
l: left of the area
t: top of the area
r: right of the area
b: bottom of the area
*/
function isInArea(x, y, l, t, r, b){
	isIn = false;

	if(x >= l && x <= r){
		if(y >= t && y <= b){
			isIn = true;
		}
	}
	return isIn;
}

var i = 0;

function browserMouseMoving(e){
	var x = getMouseX(e);
	var y = getMouseY(e);
	
	the_mainnav1=(document.all)?document.all('mainnav1'):document.getElementById('mainnav1');
	the_maincat2=(document.all)?document.all('maincat2'):document.getElementById('maincat2');

	isIn1 = false;
	if(the_mainnav1 && the_maincat2){
		mX1 = getAreaLeft(the_mainnav1);
		mY1 = getAreaTop(the_mainnav1);

		mX2 = getAreaLeft(the_maincat2) + the_maincat2.offsetWidth;
		mY2 = getAreaTop(the_maincat2) + the_maincat2.offsetHeight;

		isIn1 = isInArea(x, y, mX1, mY1, mX2, mY2);
	}
	
	the_catNav=(document.all)?document.all('catNav'):document.getElementById('catNav');

	isIn2 = false;
	//if(catNav){
	if(the_catNav){
		mX1 = getAreaLeft(the_catNav);
		mY1 = getAreaTop(the_catNav);
		mX2 = mX1 + the_catNav.offsetWidth;
		mY2 = mY1 + the_catNav.offsetHeight;
		isIn2 = isInArea(x, y, mX1, mY1, mX2, mY2);
	}

	if(!isIn1 && !isIn2){
		the_catNavStyle = (document.all)?document.all('catNav').style:document.getElementById('catNav').style;
		the_catNav2Style = (document.all)?document.all('catNav2').style:document.getElementById('catNav2').style;
		the_searchbarStyle = (document.all)?document.all('searchbar').style:document.getElementById('searchbar').style;
		
		the_searchbar2Style = (document.all)?document.all('searchbar2').style:document.getElementById('searchbar2').style;

		the_catNavStyle.display = 'none';
		the_catNav2Style.display = 'none';
		the_searchbarStyle.display = '';
		the_searchbar2Style.display = '';

		if (!IsIE) {
			document.removeEventListener("mousemove", browserMouseMoving, false);
		}else{
			document.detachEvent('onmousemove', browserMouseMoving);
		}
	}
}


function mainCatOver(){
	the_catNavStyle = (document.all)?document.all('catNav').style:document.getElementById('catNav').style;
	the_catNav2Style = (document.all)?document.all('catNav2').style:document.getElementById('catNav2').style;

	the_searchbarStyle = (document.all)?document.all('searchbar').style:document.getElementById('searchbar').style;
	the_searchbar2Style = (document.all)?document.all('searchbar2').style:document.getElementById('searchbar2').style;

	the_catNavStyle.display = '';
	the_catNav2Style.display = '';
	the_searchbarStyle.display = 'none';
	the_searchbar2Style.display = 'none';

	if (!IsIE) {
		document.addEventListener("mousemove", browserMouseMoving, false);
	}else{
		document.attachEvent('onmousemove', browserMouseMoving);
	}
}