var xmlHttp
var running = false

function changeLang(newLang, errBusy)
{
	if(running == true)
	{
		//document.getElementById("info").innerHTML=errBusy;
		exit;
	}
	running = true;
	//document.getElementById("info").innerHTML="";
	//alert("2")

	//Get http object
	xmlHttp=GetXmlHttpObject();
	//alert("4")
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		running = false;
		return;
	}
	//alert("5")
	//Create the request line
	var url="changeLang.php";
	url=url+"?lang="+encodeURIComponent(newLang);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
}

function stateChanged()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		running = false;
		document.location.reload(true);
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}