function validateform1()
{
	document.getElementsByName('selected_state')[0].value = document.getElementById('stateofresidence').value;
	document.getElementsByName('selected_city')[0].value = document.getElementById('nearest_city').value;
	//alert(document.getElementsByName('selected_state')[0].value);
	document.frm_main.submit();
	//return false;
}
	

function validateform()
{
		var emailId = document.frm_registration.email.value;
		var apos=emailId.indexOf("@");
		var dotpos=emailId.lastIndexOf(".");
		var lastpos=emailId.length-1;		
			if (emailId.indexOf(' ')==-1 && 0 < emailId.indexOf('@') && 0 < emailId.indexOf('.') && emailId.indexOf('@')+1 < emailId.length && emailId.length >= 5)
		{
	    }
	    else
	    {
	      alert("Please provide a valid email address");
	      document.frm_registration.email.focus();
	      return false;
		}
			
			if(document.frm_registration.profileid.value == "")
			{
				alert("please enter Profile ID");
				document.frm_registration.profileid.focus();
				return false;
			}
			
			else if(document.frm_registration.email.value == "")
			{
				alert("Please enter Email");
				document.frm_registration.email.focus();
				return false;
			}
			
			
			
			else if(document.frm_registration.retypeemail.value == "")
			{
				alert("Please Re-type Email");
				document.frm_registration.retypeemail.focus();
				return false;
			}
			
			else if(document.frm_registration.retypeemail.value != document.frm_registration.email.value)
			{
				alert("Email Mismatch! Please Re-type correct Email");
				document.frm_registration.retypeemail.focus();
				document.frm_registration.retypeemail.select();
				return false;
			}			
			
			else if(document.frm_registration.password1.value == "")
			{
				alert("Please enter Password");
				document.frm_registration.password1.focus();
				return false;
			}
	
			else if(document.frm_registration.password2.value == "")
			{
				alert("Please Retype Password");
				document.frm_registration.password2.focus();
				return false;
			}
			
			else if(document.frm_registration.password2.value != document.frm_registration.password1.value)
			{
				alert("Password Mismatch! Please Retype Correct Password");
				document.frm_registration.password2.focus();
				document.frm_registration.password2.select();
				return false;
			}
			
			else if(document.frm_registration.gender[1].checked == false && document.frm_registration.gender[0].checked == false)
			{
				alert("Please select gender");
				return false;
			}
			
			else if(document.frm_registration.day.options[document.frm_registration.day.selectedIndex].value == "")
			{
				alert("Please select your date of birth");
				document.frm_registration.day.focus();
				return false;
			}
			
			
			else if(document.frm_registration.month.options[document.frm_registration.month.selectedIndex].value == "")
			{
				alert("Please select your date of birth");
				document.frm_registration.day.focus();
				return false;
			}
			
			else if(document.frm_registration.year.options[document.frm_registration.year.selectedIndex].value == "")
			{
				alert("Please select your date of birth");
				document.frm_registration.day.focus();
				return false;
			}
		
			else if(document.frm_registration.confirm_policy.checked == false)
			{
				alert("You need to be agree with our privacy policy and terms and conditions");
				document.frm_registration.confirm_policy.focus();
				return false;
			}

			document.getElementsByName('selected_state')[0].value = document.getElementById('stateofresidence').value;
			document.getElementsByName('selected_city')[0].value = document.getElementById('nearest_city').value;
			//alert(document.getElementsByName('selected_state')[0].value);
			document.frm_registration.submit();
			//return false;
		}
	
	
	
		
		
		var result;
var xmlhttp;
var theurl;
var abc;

abc = 0;
function loadXMLDoc(url)
{
theurl = url;
xmlhttp=null
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=state_Change
today =  new Date();
rnd = today.getTime( );  
url = url + "?rnd=" + rnd;
var i=0;
var Temp=document.frm_registration.country.options[document.frm_registration.country.selectedIndex].value;
url = url + "&CountryID=" + Temp;
xmlhttp.open("GET",url,true)
  xmlhttp.send(null)
  }
else
  {
  alert("Your browser does not support XMLHTTP.")
  }
}function state_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
  {
  // if "OK"
  if (xmlhttp.status==200)
    {
		if(abc==0)
		{
		result = xmlhttp.responseText
		document.getElementById('cityspan').innerHTML = result;
		loadXMLDoc("get_states2.php");
		abc=1;
		}
		else
		{
			result = xmlhttp.responseText
			document.getElementById('statespan').innerHTML = result;
			abc=0;
		}
    }
  else
    {
    alert("Problem retrieving XML data")
    }
  }
}

