var xmlHttp
var Process=new String() 
var arr;
var content=new String();

var plx;
var plxer=new String();

function reg(retrievetype)
{ 
xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null){
		  alert ("Your browser does not support AJAX!");
		  return;
		}
		Process=retrievetype;
		arr=Process.split("~");
		if(arr[0]=="user") {
			var url="ar.php?retrievetype=" + retrievetype + "&n="+ parseInt(Math.random()*999999999);			
		}else if(arr[0]=="url") {
			var url="ar.php?retrievetype=" + retrievetype + "&n="+ parseInt(Math.random()*999999999);			
		}else if(arr[0]=="pos") {
			var url="ar.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){ 
	var arr_return;
	content=xmlHttp.responseText;
		if(arr[0]=="user") {
			if(content!="OK"){
				alert(content);
				document.frm.username.value="";
				document.frm.username.focus();
			}
		}else if(arr[0]=="url") {
			if(content!="OK"){
				alert(content);
				document.frm.url.value="";
				document.frm.url.focus();
			}
		}else if(arr[0]=="pos") {
			plxer = content;
			plx = plxer.split("~~~");
			if(plx[0]=="OK"){
				if (plx[1] == "TTT"){
					if(confirm("Continue your registration?")){
						document.frm.action="registration_proc.php";
						document.frm.submit();
					}
				} else {
					if(confirm(plx[1]+"Continue your registration?")){
						document.frm.action="registration_proc.php";
						document.frm.submit();
					}
				}
			}else{
				alert(content);
			}
		}
	}
}

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;
}

