var xmlHttp




function getstates()
{

document.getElementById("states").innerHTML='<img src="images/loading.gif" border="0">';

strcountryid=document.myform.optcountryid.value;


xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 

var url="getstates.php";
url=url+"?txtcountryid="+strcountryid;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{
document.getElementById("states").innerHTML=xmlHttp.responseText;
getcities();
}
}


//Get cities
function getcities()
{

document.getElementById("cities").innerHTML='<img src="images/loading.gif" border="0">';

strstateid=document.myform.optstateid.value;


xmlHttp1=GetXmlHttpObject()
if (xmlHttp1==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 

var url="getcities.php";
url=url+"?txtstateid="+strstateid;
url=url+"&sid="+Math.random();
xmlHttp1.onreadystatechange=stateChanged1;
xmlHttp1.open("GET",url,true);
xmlHttp1.send(null);
} 

function stateChanged1() 
{ 
if (xmlHttp1.readyState==4)
{
document.getElementById("cities").innerHTML=xmlHttp1.responseText;
}
}



function doreg()
{


$strmess="";

if(document.myform.txtusername.value=="")
$strmess=$strmess+" Username is Blank\n";

if(document.myform.txtpassword.value=="")
$strmess=$strmess+" Password is Blank\n";

if(document.myform.txtrepassword.value=="")
$strmess=$strmess+" Confirm Password is Blank\n";

if(document.myform.txtfirstname.value=="")
$strmess=$strmess+" First Name is Blank\n";

if(document.myform.txtlastname.value=="")
$strmess=$strmess+" Last Name is Blank\n";

if(document.myform.optgender.value=="-")
$strmess=$strmess+" Select Gender\n";

if(document.myform.optbirthmon.value=="-")
$strmess=$strmess+" Select Birth Month\n";

if(document.myform.optbirthyear.value=="-")
$strmess=$strmess+" Select Birth Year\n";

if(document.myform.optbirthday.value=="-")
$strmess=$strmess+" Select Birth Day\n";

if(document.myform.txtaddress.value=="")
$strmess=$strmess+" Address is Blank\n";

if(document.myform.optcityid.value=="-")
$strmess=$strmess+" Select City\n";

if(document.myform.optstateid.value=="-")
$strmess=$strmess+" Select State\n";

if(document.myform.optcountryid.value=="-")
$strmess=$strmess+" Select Country\n";

if(document.myform.txtpincode.value=="")
$strmess=$strmess+" Pin code is Blank\n";

if(document.myform.txtphone.value=="")
$strmess=$strmess+" Phone is Blank\n";

if(document.myform.txtmobile.value=="")
$strmess=$strmess+" Mobile is Blank\n";

if(document.myform.txtemail.value=="")
$strmess=$strmess+" Mobile is Blank\n";

if(document.myform.optmaritalstatusid.value=="-")
$strmess=$strmess+" Select Marital Status\n";

if(document.myform.optqualificationid.value=="-")
$strmess=$strmess+" Select Qualification\n";

if(document.myform.optincomegroupid.value=="-")
$strmess=$strmess+" Select Income Group\n";


if(document.myform.txtpassword.value!=document.myform.txtrepassword.value)
$strmess=$strmess+" Password and confirm Password do not Match\n";

if($strmess!="")
alert($strmess);
else
{
dob=document.myform.optbirthyear.value+"-"+document.myform.optbirthmon.value+"-"+document.myform.optbirthday.value;
strusername=document.myform.txtusername.value;
strpassword=document.myform.txtpassword.value;
strfirstname=document.myform.txtfirstname.value;
strlastname=document.myform.txtlastname.value;
strgender=document.myform.optgender.value;
strdob=dob;

straddress=document.myform.txtaddress.value;
strcity=document.myform.optcityid.value;
strstate=document.myform.optstateid.value;
strcountry=document.myform.optcountryid.value;
strpincode=document.myform.txtpincode.value;
strphone=document.myform.txtphone.value;
strmobile=document.myform.txtmobile.value;

stremail=document.myform.txtemail.value;
strmarital=document.myform.optmaritalstatusid.value;
strqualification=document.myform.optqualificationid.value;
strincome=document.myform.optincomegroupid.value;


xmlHttp2=GetXmlHttpObject()
if (xmlHttp2==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 

var url="register.php";
url=url+"?txtusername=" + strusername + "&txtpassword=" + strpassword + "&txtfirstname=" + strfirstname + "&txtlastname=" + strlastname + "&txtgender=" + strgender + "&txtdob=" + strdob + "&txtaddress=" + straddress + "&txtcity=" + strcity + "&txtstate=" + strstate + "&txtcountry=" + strcountry + "&txtpincode=" + strpincode + "&txtphone=" + strphone + "&txtmobile=" + strmobile + "&txtemail=" + stremail + "&txtmarital=" + strmarital + "&txtqualification=" + strqualification + "&txtincome=" + strincome; 
url=url+"&sid="+Math.random();
xmlHttp2.onreadystatechange=stateChanged2;
xmlHttp2.open("GET",url,true);
xmlHttp2.send(null);
}
} 

function stateChanged2() 
{ 
if (xmlHttp2.readyState==4)
{
if(xmlHttp2.responseText=="Registration Successfull")
document.myform.submit();
else
alert(xmlHttp2.responseText);
}
}


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;
}