// JavaScript Document

var xmlHttp

function setCountry(str)
{
	if (str.length==0)
	{
		document.getElementById("flagImg").innerHTML="<?php echo '<img src='../flags/$ImgCode.png' />'; ?>"
		return
	}
	xmlHttp=getHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url="setcountry.php"
	url=url+"?q="+str
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function setField(str)
{
	document.getElementById("country").value=str
}

function stateChanged()
{
	if (xmlHttp.readyState==1 || xmlHttp.readyState==2 || xmlHttp.readyState==3)
	{
		document.getElementById("flagImg").innerHTML="<img src='../al_loading.gif' width='20' height='20' />"
	}
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("flagImg").innerHTML=xmlHttp.responseText
		history.go(0)
	}
}
function getHttpObject()
{
	var xmlHttp=null;
	try
	{
		//Standard compliant browsers
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		//IE
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
