function httpResponse() {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			allcountries = http_request.responseText;
			var temp = getAbsolutePosition( document.getElementById("country_inp") );
			var temp2 = getAbsolutePosition( document.getElementById("main") );
			document.getElementById("country_layer").style.top = temp[1]-temp2[1]+24;
			document.getElementById("country_layer").style.left = temp[0]-temp2[0];
			document.getElementById("country_layer").style.visibility = "visible";
			document.getElementById("country_layer").innerHTML = allcountries;
		}
	}

}

function checkCountries()
{
	if( document.forms.regform.country.value.length > 0 )
	{
		sendHTTPRequest("./includes/checkCountry.php","lang="+session_lang+"&text="+document.forms.regform.country.value);
	}
}

function setCountry(val)
{
	watchingCountry = false;
	document.forms.regform.country.value = val;
	document.getElementById("country_layer").style.visibility = "hidden";
	document.getElementById("country_layer").style.top = "0px";
}

function setCountry2(val)
{
	watchingCountry = false;
	document.forms.regform.country.value = val;
	document.getElementById("country_layer").style.visibility = "hidden";
	document.getElementById("country_layer").style.top = "0px";
}

var watchingCountry = false;
var countryValue = "";

function watchCountry()
{
	if( !watchingCountry )
	return;
	
	if( document.forms.regform.country.value != countryValue )
	{
		countryValue = 	document.forms.regform.country.value;
		checkCountries();
	}
	window.setTimeout("watchCountry()",100);
}

function activateCountryWatch()
{
	watchingCountry = true;
	countryValue = document.forms.regform.country.value;
	window.setTimeout("watchCountry()",0);
}


function deActivateCountryWatchTime()
{
	if( !watchingCountry )
	return;
	
	setCountry(document.forms.regform.country.value);
}

function deActivateCountryWatch()
{
	if( !watchingCountry )
	return;
	
	window.setTimeout("deActivateCountryWatchTime()",200);
}