// JavaScript Document
var subNavTimerId = 0;

function swapImg(obj, action) {
	if (action == "over") {
		//if (obj.src.indexOf("on.gif") == -1)
			obj.src = obj.src.replace(".gif", "on.gif");
	} else {
		obj.src = obj.src.replace("on.gif", ".gif");
	}
}


function showSubNav(subnav) {
	clearTimeout(subNavTimerId);
	subNavTimerId = 0;
	
	if (subnav != 'current') {
		loadSubNav(subnav);
		document.getElementById('sub_nav').style.visibility = "visible";
	} else {
		if (document.getElementById('sub_nav').style.visibility == "hidden") {
			document.getElementById('sub_nav').style.visibility = "visible";
		}
	}
}

function hideSubNav() {
	obj = document.getElementById('sub_nav');
	obj.style.visibility = "hidden";
}

function subNavTimeout() {
	if (document.getElementById('sub_nav').style.visibility == "visible") {
		if (subNavTimerId == 0) {
			subNavTimerId = setTimeout( "hideSubNav()", 2000 );
		}
	}
}

function loadSubNav(subnav) {
	var xmlHttp;
	
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			document.getElementById('sub_nav').innerHTML = xmlHttp.responseText;
			document.getElementById('sub_nav').style.visibility = "visible";
		}
	}
	
	xmlHttp.open("GET","subnav.aspx?subnav="+subnav,true);
	xmlHttp.send(null);
}



function changeLang(url, lang) {
	if (url.indexOf("#")>-1) {
		url = url.substr(0, url.indexOf("#"));
	}
	
	if (url.indexOf("?")>-1) {
		window.location = url+"&lang="+lang;
	} else {
		window.location = url+"?lang="+lang;
	}
}