// add event onclick to button checkdomain

//window.onload = addEventHandlers;

function addEventHandlers()
{
	var ctl = document.getElementById("cmdCheckSub");
  if (ctl != null) ctl.onclick = checkSubdomain;
	ctl = document.getElementById("checksub");
  if (ctl != null) ctl.onfocus = onFocusCheckSub;
}

function onFocusCheckSub()
{
	var ctl = document.getElementById("checksub");
  if (ctl != null) ctl.value = '';
}

function checkSubdomain()
{
	var ctl = document.getElementById("checksub");
	if (ctl != null) sendRequest('index.php?a=check&sub' + ctl.value, checkSubdomainState, false, false);
}

function checkSubdomainState() 
{ 
	if (httpRequest != null) 
	{
		if (httpRequest.readyState == 4 || httpRequest.readyState == "complete")
    { 
			document.getElementById("txtCheckSubResult").innerHTML = httpRequest.responseText; 
    }
	} 
}

function validateSignupForm()
{
  var ctl = document.getElementById("email");
  if (ctl != null) 
  	if (ctl.value == '') {
			alert('Vul een e-mail adres in a.u.b.');
			return false;
		} else {
			if (!emailCheck(ctl.value)) return false;
		}
	
	ctl = document.getElementById("pass");
  if (ctl != null) 
  	if (ctl.value == '') {
			alert('Vul een wachtwoord in a.u.b.');
			return false;
		}
		else 
		{
			var ctl2 = document.getElementById("pass2");
			if (ctl2 != null) 
			{
				if (ctl.value != ctl2.value) 
				{
					alert('Beide wachtwoorden dienen aan elkaar gelijk te zijn!');
					return false;
				}
			}
			else return false;			
		}
  
  return true;
}	
	
/*
xmlHttp.onreadystatechange=function()
  {
  if(xmlHttp.readyState==4)
    {
    document.myForm.time.value=xmlHttp.responseText;
    }
  }
*/

function doesUrlExist() 
{
  httpRequest.open("HEAD", "/faq/index.html",true);
   httpRequest.onreadystatechange=function() {
    if (httpRequest.readyState == 4) {
     if (httpRequest.status == 200) alert("URL Exists!")
      else if (httpRequest.status==404) alert("URL doesn't exist!")
       else alert("Status is "+xmlhttp.status)
    }
   }
	 httpRequest.send(null)
} // end function
