var xmlhttp;
var check=0;
var values="";

function XmlHttpObject()
{
	var xmlhttp = null;
	try
	{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (a)
	{
		try
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (b)
		{
		}
	}
	if (!xmlhttp && (typeof XMLHttpRequest != 'undefined')){
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function GetInfo(){
	xmlhttp=XmlHttpObject();
	if (xmlhttp==null){	return;	} 
	xmlhttp.open("POST","info_handler.php?s="+Math.random(),true);
	xmlhttp.onreadystatechange=infoChanged; 
	xmlhttp.send(null);
}

function GetSignupName(suggestion){
	xmlhttp=XmlHttpObject();
	if (xmlhttp==null){	return;	} 
	xmlhttp.open("POST","signup_handler.php?s="+suggestion,true);
	xmlhttp.onreadystatechange=signupChanged; 
	xmlhttp.send(null);
}

function DoXmlHttpObject(page, str){ 
	xmlhttp=XmlHttpObject();
	if (xmlhttp==null){	return;	} 
	xmlhttp.open("POST","server/"+page+".php?str="+str+"&s="+Math.random(),true);
	xmlhttp.onreadystatechange=stateChanged; 
	xmlhttp.send(null);
} 

function infoChanged() 
{ 
	if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete")
	{
		temp=xmlhttp.responseText;
		temp=temp.split('|||');
		if (temp[1]!=null){
			if (temp[1]!=undefined){
				if (temp[1]!=0){
					document.getElementById('money_a').innerHTML="&euro; "+GetMoney(temp[1]);
					document.getElementById('money_b').innerHTML="&euro; "+GetMoney(temp[2]);
				}
			}
		}
		
		if (temp[0]==1)
		{
			document.getElementById('mail').style.display="block";
		}
		if (temp[3]==1)
		{
			document.getElementById('dog').style.display="block";
		}
		if (temp[4]==1)
		{
			document.getElementById('horses').style.display="block";
		}
		setTimeout("GetInfo()",12000);
	}
}

function signupChanged(){ 
	if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete"){
		if (xmlhttp.responseText=='0'){
			document.getElementById('availability').innerHTML='<font color="green">Accountnaam beschikbaar</font>';	
		}
		else{
			document.getElementById('availability').innerHTML='<font color="red"><b>Accountnaam NIET beschikbaar</b></font>';	
			setTimeout("EmptySignup()",1000);
		}
	}
}

function EmptySignup(){
	document.getElementById('namevalue').value='';
}