
function mouseMove(e){
	var xCoordinate = ((document.all) ? window.event.x + document.body.scrollLeft : e.pageX)-5;
	var yCoordinate = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY;
	var yNavigation = 130;
	
	if(document.getElementById("skipNavigation"))
		yNavigation += (document.all) ? 0  : 190;
	if(yCoordinate >= yNavigation && yCoordinate < (yNavigation+27)) {
		detectNavigation(xCoordinate, "hover");
	}
	else {
		detectNavigation(-1, "out");
	}
}

function mouseOut(e){
	detectNavigation(-1, "out");
}

function mouseClickFlash(xCoordinate){
	var countryNavigationDiv = document.getElementById("countryNavigation");
	
	if(typeof countryNavigationDiv != undefined) {
		cursorPointX = parseInt(countryNavigationDiv.offsetLeft + xCoordinate);
		detectNavigation(cursorPointX, "click");
	}
}

function detectNavigation(xCoordinate, action){
	var countryNavigationDiv = document.getElementById("countryNavigation");
	var skiNavigationUl = document.getElementById("skiNavigation");
	
	if(typeof countryNavigationDiv != undefined) {
		cursorPointX = parseInt(xCoordinate);
		skiNavigationUlLis = skiNavigationUl.getElementsByTagName("li");
		for(var i=0; i<skiNavigationUlLis.length; i++)  {
			liOffsetLeft  = parseInt(skiNavigationUlLis[i].offsetLeft);
			liWidth 			= parseInt(skiNavigationUlLis[i].offsetWidth);
			
			if(action == "hover") {
				makeHover(liOffsetLeft, liWidth, cursorPointX, skiNavigationUlLis[i]);
			}
			else {
				if(action == "out") {
					if(skiNavigationUlLis[i].className.search(/ ?active/) != -1)
						skiNavigationUlLis[i].className = "active";
					else
						skiNavigationUlLis[i].className = "";
				}
				else {
					if(action == "click") {
						clickAnker(liOffsetLeft, liWidth, cursorPointX, skiNavigationUlLis[i]);
					}
				}
			}
		}
	}
}

function makeHover(liOffsetLeft, liWidth, cursorPointX, skiNavigationLi) {
	var ie5      = (navigator.appVersion.indexOf("MSIE 5")>-1) ? true : false;
  var ie6      = (navigator.appVersion.indexOf("MSIE 6")>-1) ? true : false;
  
	if(!ie5 && !ie6) {
		if((liOffsetLeft <= cursorPointX) && ((liOffsetLeft+liWidth) >= cursorPointX) && skiNavigationLi.className.search(/ ?hover/) == -1) {
			skiNavigationLi.className += " hover";
		}
		else {
			if((liOffsetLeft >= cursorPointX) || ((liOffsetLeft+liWidth) <= cursorPointX)) {
				if(skiNavigationLi.className.search(/ ?active/) != -1)
					skiNavigationLi.className = "active";
				else
					skiNavigationLi.className = "";
			}
		}
	}
}

function clickAnker(liOffsetLeft, liWidth, cursorPointX, skiNavigationLi) {
	if((liOffsetLeft <= cursorPointX) && ((liOffsetLeft+liWidth) >= cursorPointX)) {
		document.location.href = skiNavigationLi.getElementsByTagName("a")[0].href;
	}
}