function add_state()
{
	document.getElementById("txtHint_1").style.display="none";
	
	document.getElementById("txtHint_2").style.display="block";

}

function add_state1()
{
	
	document.getElementById("txtHint").style.display="none";
	document.getElementById("txtHint_0").style.display="block";
	document.registration_content.addnew.value="add";


}


function pay_by_bank()
{
	if (AllTrim(document.bank_payment.Cheque_no.value)!="")
	{
		if(isNaN(document.bank_payment.Cheque_no.value)){
		alert('please enter cheque number in number only');
		document.bank_payment.Cheque_no.value="";
		document.bank_payment.Cheque_no.focus();
		}
		else{
		document.bank_payment.page.value=9;
		document.bank_payment.payment.value="yes";
		document.bank_payment.submit();
		}
	}
	else {
		alert("Please fill cheque no");
		document.bank_payment.Cheque_no.value="";
		document.bank_payment.Cheque_no.focus();
		}
}


function company_info()
{
	document.login_enter.page.value=12;
	
	document.login_enter.action='index.php';
	document.login_enter.submit();
}

function company_realatelink()
{
	document.login_enter.page.value=1;
	document.login_enter.action='index.php';
	document.login_enter.submit();
}

function company_history()
{
	document.login_enter.page.value=12;
	document.login_enter.action='index.php?history=1';
	document.login_enter.submit();
}

function company_Editprof()
{
	document.login_enter.page.value=12;
	document.login_enter.action='index.php?Editprof=1';
	document.login_enter.submit();
}


function Country_List()
{
	document.login_enter.page.value=2;
	document.login_enter.searchtype.value=2;
	document.login_enter.action='index.php';
	document.login_enter.submit();
}


function Country_List1()
{
	document.login_enter.page.value=2;
	document.login_enter.searchtype.value=1;
	document.login_enter.action='index.php';
	document.login_enter.submit();
}


function postdata()
{
	registration_content.action="./registration_action.php";
	registration_content.submit();
	return true;
}

function selet_cnt(ind,msg)
{
	
	if (ind==0)
	{
		alert(msg);
		
		return false;
	}
	return true;
}

function submitme()
{

   if ( (isString(AllTrim(document.registration_content.txtusername.value),"Please enter UserName.",document.registration_content.txtusername.focus())
		
		&&isString(AllTrim(document.registration_content.txtpassword.value),"Please enter Password.",document.registration_content.txtpassword.focus())
		&&isString(AllTrim(document.registration_content.txtconfirmpass.value),"Please Confirm Password.",document.registration_content.txtconfirmpass.focus())
		&&isString(AllTrim(document.registration_content.txtfname.value),"Please enter first name.",document.registration_content.txtfname.focus())
		&&isString(AllTrim(document.registration_content.txtlname.value),"Please enter last name.",document.registration_content.txtlname.focus())
		&&isString(AllTrim(document.registration_content.txtresidence_address.value),"Please enter personal Address.",document.registration_content.txtresidence_address.focus())&&(selet_cnt(document.registration_content.residence_country.value,"Please select country"))
		
		))
   		{
			
			 if (AllTrim(document.registration_content.addnew.value)=="add")
			{
				
				if ((isString(AllTrim(document.registration_content.residence_state1.value),"Please enter state.",document.registration_content.residence_state1.focus()))&&(isString(AllTrim(document.registration_content.residence_city1.value),"Please enter city.",document.registration_content.residence_city1.focus()))&&(isEmail(AllTrim(document.registration_content.email.value),"Invalid Email format.",document.registration_content.email.focus())))
				{
					if(document.registration_content.usertype.value==1){
						
				if ((isString(AllTrim(document.registration_content.service1.value),"Please enter service1.",document.registration_content.service1.focus()))
				&&(isString(AllTrim(document.registration_content.code.value),"Please enter security code.",document.registration_content.code.focus())))
						
registration_content.submit();
					}
					else{
						if ((isString(AllTrim(document.registration_content.service2.value),"Please enter service1.",document.registration_content.service2.focus()))
				&&(isString(AllTrim(document.registration_content.code.value),"Please enter security code.",document.registration_content.code.focus())))
						
registration_content.submit();
						
					}
					
			
			 }
			}
			 else
			 {
				
				 if ((isString(AllTrim(document.registration_content.residence_state.value),"Please select state.",document.registration_content.residence_state.focus()))&&(isString(AllTrim(document.registration_content.residence_city.value),"Please select city.",document.registration_content.residence_city.focus()))&&(isEmail(AllTrim(document.registration_content.email.value),"Invalid Email format.",document.registration_content.email.focus())))
				 
				 {
					if(document.registration_content.usertype.value==1){
						
				if ((isString(AllTrim(document.registration_content.service1.value),"Please enter service1.",document.registration_content.service1.focus()))
				&&(isString(AllTrim(document.registration_content.code.value),"Please enter security code.",document.registration_content.code.focus())))
						
registration_content.submit();
					}
					else{
						if ((isString(AllTrim(document.registration_content.service2.value),"Please enter service1.",document.registration_content.service2.focus()))
				&&(isString(AllTrim(document.registration_content.code.value),"Please enter security code.",document.registration_content.code.focus())))
						
registration_content.submit();
						
					}
				 
				
			 }
				
			
		}
		}
   return false;
}



//function submitme()
//{
//     alert("in fun");
// // if(AllTrim(document.registration_content.txtusername.value=="")){
////	alert("Please enter UserName.");
////	document.registration_content.txtusername.focus();
////	return false;
////	}
//	if(AllTrim(document.registration_content.txtpassword.value)==""){
//	alert("Please enter Password.");
//	document.registration_content.txtpassword.focus();
//	return false;
//	}
//	 if(AllTrim(document.registration_content.txtconfirmpass.value)==""){
//	alert("Please Confirm Password.");
//	document.registration_content.txtconfirmpass.focus();
//		return false;
//	}
//	if(AllTrim(document.registration_content.txtfname.value)==""){
//		alert("Please enter first name.");
//		document.registration_content.txtfname.focus();
//			return false;
//	}
//	if(AllTrim(document.registration_content.txtlname.value)==""){
//
//	alert("Please enter last name.");
//	document.registration_content.txtlname.focus();
//		return false;
//	}
//	if(AllTrim(document.registration_content.txtresidence_address.value)==""){
//	alert("Please enter personal Address.");
//	document.registration_content.txtresidence_address.focus();
//		return false;
//	}
//	if(document.registration_content.residence_country.value==""){
//		alert("Please select country");
//		document.registration_content.residence_country.focus();
//		return false;
//	}
//	if((AllTrim(document.registration_content.residence_state.value)=="")||(AllTrim(document.registration_content.residence_state1.value)==""){
//		alert("Please select state.");
//		
//			return false;
//	}
//
//	if((AllTrim(document.registration_content.residence_city.value==""))||(AllTrim(document.registration_content.residence_city1.value==""))){
//	alert("Please select city.");
//	//document.registration_content.residence_city.focus();
//		return false;
//	}
//	else
//	{
//		return true;
//	}
// return false;	
//}
//		






function show_block()
{
	if (document.registration_content.usertype.value==2)
	{
		
		document.getElementById("residence_country1").style.display="block";
		document.getElementById("residence_country2").style.display="none";

		document.getElementById("needed").style.display="block";
		document.getElementById("provide").style.display="none";

	}
	else
	{
		document.getElementById("residence_country1").style.display="none";
		document.getElementById("residence_country2").style.display="block";
		document.getElementById("needed").style.display="none";
		document.getElementById("provide").style.display="block";

	}
}

var xmlhttp;

function showUser(str,str2)
{
xmlhttp=GetXmlHttpObject();
//alert(document.registration_content.ajaxcall.value);
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
  if(document.registration_content.ajaxcall.value==0)
{
	var url="getuser.php";
	document.registration_content.addnew.value="noadd";
	
}else
{
	var url="getstate.php";
}

url=url+"?q="+str;
url=url+"&q2="+str2;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
{
if(document.registration_content.ajaxcall.value==0)
{
	document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
	//document.getElementById("stateid").value=document.getElementById("residence_state").value;
	
}
else
{
	document.getElementById("txtHint_1").innerHTML=xmlhttp.responseText;
	//document.getElementById("stateid1").value=document.getElementById("office_state").value;
}

}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}


function tt()
{
	alert("");	
}

function confirm_pass()
{
	if (document.registration_content.txtpassword.value!=document.registration_content.txtconfirmpass.value)
	{
		document.registration_content.txtconfirmpass.value="";
		document.registration_content.txtconfirmpass.focus();
		alert("Confirm Password is not same");
		
	}
}

function AllTrim(sStr)
{ 
	while (sStr.substring(0,1) == ' ')
	{
		sStr = sStr.substring(1, sStr.length);
	}
	while (sStr.substring(sStr.length-1, sStr.length) == ' ')
	{
		sStr = sStr.substring(0,sStr.length-1);
	}
	return sStr;
}


function isString(str,msg,inputvalue)
{	
	if (str=="")
	{
		alert(msg);
		
		return false;
	}
	return true;
}



function isDate(str,msg)
{
   tstr1 = str.substring(2,3);
   tstr2 = str.substring(5,6);
   tstr3 = str.length;
   if ((tstr1=='/') && (tstr2 == '/') && (tstr3=10) )
   {
	   return true;
   }
   alert(msg);
   return false;
}

function isImage(str,msg)
{
   var z =  str;
   var z1 = z.substring(z.indexOf('.'),z.length);
   if ((z1=='.jpg') || (z1=='.JPG') || (z1=='.gif') || (z1=='.GIF') || (z1==''))
   {
      return true;
   }
   alert(msg);
   return false;
}


function isEmail(str,msg,inputvalue)
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)

	if (str.indexOf(at)==-1)
	{
	   alert(msg)
	   return false;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
	   alert(msg)
	   return false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
	    alert(msg)
	    return false;
	}

	if (str.indexOf(at,(lat+1))!=-1)
	{
	   alert(msg)
	   return false;
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{
	   alert(msg)
	   return false;
	}

	if (str.indexOf(dot,(lat+2))==-1)
	{
	   alert(msg)
	   return false;
	}
		
	if (str.indexOf(" ")!=-1)
	{
	   alert(msg)
	   return false;
	}

	return true;
}

function edit_confirm_pass()
{
		
	if (editprof.txtpassword.value!=editprof.txtconfirmpass.value)
	{
		editprof.txtconfirmpass.value="";
		alert("Confirm Password is not same");
		document.editprof.txtconfirmpass.focus();
		
	}
}

function edit_submitme()
{
   if ( isString(AllTrim(document.editprof.txtusername.value),"Please enter UserName.",document.editprof.txtusername.focus())
		&&isString(AllTrim(document.editprof.txtpassword.value),"Please enter Password.",document.editprof.txtpassword.focus())
		&&isString(AllTrim(document.editprof.txtconfirmpass.value),"Please Confirm Password.",document.editprof.txtconfirmpass.focus())
		&&isString(AllTrim(document.editprof.txtfname.value),"Please first name.",document.editprof.txtfname.focus())
		&&isString(AllTrim(document.editprof.txtlname.value),"Please last name.",document.editprof.txtlname.focus())
		&&isString(AllTrim(document.editprof.txtresidence_address.value),"Please enter personal Address.",document.editprof.txtresidence_address.focus())
		&&isEmail(AllTrim(document.editprof.email.value),"Invalid Email format.",document.editprof.email.focus()) 
		&&isString(AllTrim(document.editprof.service.value),"please enter services.",document.editprof.service.focus()) 
		)
   		{
		document.editprof.edit.value=1;
		editprof.submit();
		}
		
   return false;
}

////////    pincode 




function showpin(str)
{
	flag="true";
if (str.length==0)
  {
  document.getElementById("txtHint").innerHTML="";

  }
  
  if (isNaN(str)==true)
  {
	  str=0;
  }
 
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
var url="gepincode.php";
url=url+"?pincode="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=pinchange;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function pinchange()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("pincode").innerHTML=xmlhttp.responseText;
  document.getElementById("valid_pin").value=xmlhttp.responseText;
  if (document.getElementById("valid_pin").value)
  {
	document.registration_content.txtresidence_pincode.value="";
	//document.registration_content.btnsubmit.disabled=true;
	}
	else{
			document.registration_content.btnsubmit.disabled=false;

		}
  }
}

function showpin1(str)
{
	flag="true";
if (str.length==0)
  {
  document.getElementById("txtHint").innerHTML="";

  }
  
  if (isNaN(str)==true)
  {
	  str=0;
  }
 
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
var url="gepincode.php";
url=url+"?pincode="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=pinchange1;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function pinchange1()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("pincode1").innerHTML=xmlhttp.responseText;
  document.getElementById("valid_pin1").value=xmlhttp.responseText;
  if (document.getElementById("valid_pin1").value)
  {
	document.registration_content.txtoffice_pincode.value="";
	//document.registration_content.btnsubmit.disabled=true;
	}
	else{
			document.registration_content.btnsubmit.disabled=false;

		}
  }
}

function showduplicateuser(str)
{
if (str.length==0)
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
var url="getduplicateuser.php";
url=url+"?getduplicateuser="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=userchange;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function userchange()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("validuser").innerHTML=xmlhttp.responseText;
  document.getElementById("valid_user").value=xmlhttp.responseText;
  if (document.getElementById("valid_user").value)
  {
		document.registration_content.txtusername.value="";

	document.registration_content.btnsubmit.disabled=true;
	document.registration_content.txtusername.focus();
	}
	else{
			document.registration_content.btnsubmit.disabled=false;

		}
  }
}

function showpin_onedit(str)
{
if (str.length==0)
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
var url="gepincode.php";
url=url+"?pincode="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=pinchange_onedit;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function pinchange_onedit()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("pincode").innerHTML=xmlhttp.responseText;
  document.getElementById("valid_pin").value=xmlhttp.responseText;
  if (document.getElementById("valid_pin").value)
  {
		document.editprof.txtresidence_pincode.value="";

	document.editprof.btnsubmit.disabled=true;
	}
	else{
			document.editprof.btnsubmit.disabled=false;

		}
  }
}

function showduplicatemail(str)
{

xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
var url="getduplicatemail.php";
url=url+"?getduplicatemail="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=mailchange;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function mailchange()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("validmail").innerHTML=xmlhttp.responseText;
  document.getElementById("valid_mail").value=xmlhttp.responseText;
  if (document.getElementById("valid_mail").value)
  {
		document.registration_content.email.value="";

	document.registration_content.btnsubmit.disabled=true;
	document.registration_content.email.focus();
	}
	else{
			document.registration_content.btnsubmit.disabled=false;

		}
  }
}

function showduplicatemail_edit(str)
{

xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
var url="getduplicatemail.php";
url=url+"?getduplicatemail="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=mailchange_edit;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function mailchange_edit()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("validmail").innerHTML=xmlhttp.responseText;
  document.getElementById("valid_mail").value=xmlhttp.responseText;
  if (document.getElementById("valid_mail").value)
  {
		document.editprof.email.value="";

	document.editprof.btnsubmit.disabled=true;
	document.editprof.email.focus();
	}
	else{
			document.editprof.btnsubmit.disabled=false;

		}
  }
}


function showduplicate_address(str)
{

fname=document.registration_content.txtfname.value;
lname=document.registration_content.txtlname.value;
address=document.registration_content.txtresidence_address.value;
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
var url="getduplicateaddress.php";
url=url+"?fname="+fname+"&lname="+lname+"&address="+address;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=addresschange;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function addresschange()
{
if (xmlhttp.readyState==4)
  {
	  if(xmlhttp.responseText!=""){
	  alert(xmlhttp.responseText);
	  }
	  if(xmlhttp.responseText=="Your name and address match with existing records.")
	  {
  document.getElementById("validaddress").innerHTML=xmlhttp.responseText;
  document.getElementById("valid_address").value=xmlhttp.responseText;
   if (document.getElementById("valid_address").value)
  {
		//document.registration_content.email.value="";

	document.registration_content.btnsubmit.disabled=true;
	//document.registration_content.email.focus();
	}
	else{
			document.registration_content.btnsubmit.disabled=false;

		}
	  }
	 else{
		  document.getElementById("validaddress").innerHTML="";
		  ocument.registration_content.btnsubmit.disabled=false;

	 }
  }
}

function showduplicate_editaddress(str)
{

fname=document.editprof.txtfname.value;
lname=document.editprof.txtlname.value;
address=document.editprof.txtresidence_address.value;
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
var url="getduplicateaddress.php";
url=url+"?fname="+fname+"&lname="+lname+"&address="+address;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=editaddresschange;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function editaddresschange()
{
if (xmlhttp.readyState==4)
  {
	   if(xmlhttp.responseText!=""){
	  alert(xmlhttp.responseText);
	  }
	  if(xmlhttp.responseText=="Your name and address match with existing records.")
	  {
  document.getElementById("validaddress").innerHTML=xmlhttp.responseText;
  document.getElementById("valid_address").value=xmlhttp.responseText;
   if (document.getElementById("valid_address").value)
  {
		//document.registration_content.email.value="";

	document.editprof.btnsubmit.disabled=true;
	//document.registration_content.email.focus();
	}
	else{
			document.editprof.btnsubmit.disabled=false;

		}
	  }
	else{
		document.getElementById("validaddress").innerHTML="";
		document.editprof.btnsubmit.disabled=false;
		
	}
  }
}