
//ajax script
var div=new String();
function image(retrievetype)
{ 
xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null){
		  alert ("Your browser does not support AJAX!");
		  return;
		}
		Process=retrievetype;
		arr=Process.split("~");
		if(arr[0]=="n") {
			var url="scripts/image.php?retrievetype=" + retrievetype + "&n="+ parseInt(Math.random()*999999999);
		}else if(arr[0]=="countries") {
			var url="scripts/image.php?retrievetype=" + retrievetype + "&n="+ parseInt(Math.random()*999999999); 
			document.getElementById("countries").innerHTML="Please wait while getting list of countries<img src=\"images/progress_bar_blue.gif\" height=\"10\" width=\"140\">";						
		}else if(arr[0]=="datechecker") {
			var url="scripts/image.php?retrievetype=" + retrievetype + "&n="+ parseInt(Math.random()*999999999);
		}else if(arr[0]=="username"){
			var url="scripts/image.php?retrievetype=" + retrievetype + "&n="+ parseInt(Math.random()*999999999); 
			document.getElementById("check_username").innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Please wait checking your username<img src=\"images/progress_bar_blue.gif\" height=\"10\" width=\"140\">";						
		}else if(arr[0]=="check_code"){
			var url="scripts/image.php?retrievetype=" + retrievetype + "&n="+ parseInt(Math.random()*999999999); 
		}
		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
}		
function stateChanged() { 
	if (xmlHttp.readyState==4){ 
	content=xmlHttp.responseText;
	arr2=content.split("~");
		if(arr[0]=="n"){	
			//alert(content);
			//document.getElementById("new_code").innerHTML="<img src=\"scripts/image_load.php?i=" + arr2[1]+ "\" />";
			document.getElementById("new_code").innerHTML="<input type=\"text\" name=\"p\" value=\""+ arr2[1] +"\" disabled=\"disabled\" style=\"text-align:center\" />";
			document.signupform.s.value=arr2[2];
			document.signupform.b.value=arr2[3];
			document.signupform.d.value=arr2[4];			
		}else if(arr[0]=="countries") {
			document.getElementById("countries").innerHTML=content;
		}else if(arr[0]=="datechecker") {		
			if(arr[4]=="bday" || arr[4]=="bday2" || arr[4]=="bday3") {
				document.getElementById("datechecker").innerHTML=content;
			}else if(arr[4]=="approve") {
				document.getElementById("datechecker_approve").innerHTML=content;
			}else if(arr[4]=="visit") {
				document.getElementById("datechecker_visit").innerHTML=content;
			}
			
		}else if(arr[0]=="username") {
			if(content=="OKEI") {
				alert("Username is now validated");
				document.signupform.username.value="YES";				
				document.getElementById("check_username").innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name=\"cmdcheck\" type=\"button\" class=\"formbutton\" id=\"cmdcheck\" value=\"Validate UserName\" onclick=\"javascript:getAJAXRecords('username~'+document.signupform.user_id.value);\"/> User Name is now validated";
			}else if(content=="INVALID") {
				alert("Your username is already existing please try another username.\n Invalid length of username(minimum of 7 characters).");
				document.signupform.username.value="NO";
				document.getElementById("check_username").innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name=\"cmdcheck\" type=\"button\" class=\"formbutton\" id=\"cmdcheck\" value=\"Validate UserName\" onclick=\"javascript:getAJAXRecords('username~'+document.signupform.user_id.value);\"/> User Name is not yet validated";
				document.signupform.user_id.value="";
				document.signupform.user_id.focus();

			}else {
				alert(content);
			}
		}else if(arr[0]=="check_code"){
			if(content=="OK"){
				if(confirm("Proceed to your Registration?")){
					document.signupform.action="register_sendmail.php";
					document.signupform.submit();
				}
			}else{
				alert("Invalid Security Code");
			}
		}
	}
}
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;
}

//end of code

