// JavaScript Document

var xmlhttp;
function loadXMLDoc(url)
{
var userid=document.form1.UserName.value;
url="Receiver.asp?username="+userid;

xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for Firefox, Opera, IE7, etc.
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=state_Change;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }
}

function state_Change()
{
if (xmlhttp.readyState==4)
  {// 4 = "loaded"
  if (xmlhttp.status==200)
    {// 200 = "OK"
    //document.getElementById('T1').innerHTML=xmlhttp.responseText;
    document.form1.state2.value =xmlhttp.responseText;
		//start of code 4 submit enable/disable
	if(document.form1.state2.value=="Available")
		{	
			document.form1.Submit.disabled=false;
		}
		else
		{
			document.form1.Submit.disabled=true;
		}
	
	//end of code 4 submit enable/disable
	

    }
  else
    {
    alert("Problem retrieving data:" + xmlhttp.statusText);
    }
  }
}

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 emailcheck(str) 
{

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ext=str.substr(str.indexOf(".")+1,str.length);
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
	
		return true;

}
 


function validation_form()
{
	
firstname=AllTrim(document.form1.First.value);
if(firstname=="")
 {   
  alert("Please enter First Name");
  document.form1.First.focus();
  return false;
 }
   
 lastname=AllTrim(document.form1.Last.value);
  if(lastname=="")
 {
 alert("Last name should not be empty");
 document.form1.Last.focus();
 return false;
 }
 username=AllTrim(document.form1.UserName.value);

 if(username=="")
 {
 alert("User name should not be empty");
 document.form1.UserName.focus();
 return false;
 }
  
 
 password=AllTrim(document.form1.Password.value);
 
 if(password=="")
 {
 alert("Password should not be empty");
 document.form1.Password.focus();
 return false;
 }
 confirmpassword=AllTrim(document.form1.ConfirmPassword.value);

 if(confirmpassword=="")
 {
 alert("Confirm Password should not be empty");
 document.form1.ConfirmPassword.focus();
 return false;
 }
 if(document.form1.Password.value!=document.form1.ConfirmPassword.value)
 {
   alert("Please Insert Correct Password");
   document.form1.ConfirmPassword.focus();
   return false;
 }
 email=AllTrim(document.form1.Email.value)
 if(document.form1.Email.value=="")
 {
 alert("Personal Email should not be empty");
 document.form1.Email.focus();
 return false;
 }
 
  
 else if(emailcheck(document.form1.Email.value)==false)
 {
  
  document.form1.Email.focus();
  return false;
 }
 
 
 /*confirmemail=AllTrim(document.form1.CompanyEmail.value)
 if(document.form1.CompanyEmail.value=="")
 {
 alert("Company Email id should not be empty");
 document.form1.CompanyEmail.focus();
 return false;
 }

   
 else if(emailcheck(document.form1.CompanyEmail.value)==false)
 {
  
  document.form1.CompanyEmail.focus();
  return false;
 }*/
 var str=document.form1.LowerLimit.value
 
 str1=str.toString();
		for (var i=0; i<str1.length;i++)
		{
		var c=str.charAt(i);
		if (((c < "0") || (c > "9"))) 
		{
			alert("Please enter Lower Limit in digit");
			document.form1.LowerLimit.value =""  
			document.form1.LowerLimit.focus ();
			return false;
		}
	}
 var str=document.form1.UpperLimit.value
 
 str1=str.toString();
		for (var i=0; i<str1.length;i++)
		{
		var c=str.charAt(i);
		if (((c < "0") || (c > "9"))) 
		{
			alert("Please enter Upper Limit in digit");
			document.form1.UpperLimit.value =""  
			document.form1.UpperLimit.focus ();
			return false;
		}
	}
   var str=document.form1.ListingFees.value
 
 str1=str.toString();
		for (var i=0; i<str1.length;i++)
		{
		var c=str.charAt(i);
		if (((c < "0") || (c > "9"))) 
		{
			alert("Please enter Listing Fees in digit");
			document.form1.ListingFees.value =""  
			document.form1.ListingFees.focus ();
			return false;
		}
	}
	

	accountnumber=AllTrim(document.form1.AccountNo.value);
	if(accountnumber=="")
 {   
  alert("Please enter Account Number");
  document.form1.AccountNo.focus();
  return false;
 }
 

if(document.form1.select_type_1.checked==false)
{
	alert("Please select your Account Type");
	return false;
	
}

 	rtgscode=AllTrim(document.form1.RTGSCode.value);
	if(rtgscode=="")
 {   
  alert("Please enter RTGSCode");
  document.form1.RTGSCode.focus();
  return false;
 }
 
  
 	bankname=AllTrim(document.form1.BankName.value);
	if(bankname=="")
 {   
  alert("Please enter Bank Name");
  document.form1.BankName.focus();
  return false;
 }
 
 	bankadd=AllTrim(document.form1.BankAddress.value);
	if(bankadd=="")
 {   
  alert("Please enter Bank BankAddress");
  document.form1.BankAddress.focus();
  return false;
 }
 
 bankcity=AllTrim(document.form1.BankCity.value);
	if(bankcity=="")
 {   
  alert("Please enter Bank Bank City");
  document.form1.BankCity.focus();
  return false;
 }
 
 bankstate=AllTrim(document.form1.BankState.value);
	if(bankstate=="")
 {   
  alert("Please enter Bank State ");
  document.form1.BankState.focus();
  return false;
 }
 
  bankcountry=AllTrim(document.form1.BankCountry.value);
	if(bankcountry=="")
 {   
  alert("Please enter BankCountry");
  document.form1.BankCountry.focus();
  return false;
 }
 
 bankpin=AllTrim(document.form1.BankPinCode.value);
	if(bankpin=="")
 {   
  alert("Please enter  Bank PinCode");
  document.form1.BankPinCode.focus();
  return false;
 }
 
  
 
return true;

}


function validation_LoginForm()
 {username1=AllTrim(document.form2.UserName.value);

 if(username1=="")
 {
 alert("Login Name should not be empty");
 document.form2.UserName.focus();
 return false;
 }
  
 
 password1=AllTrim(document.form2.Password.value);
 
 if(password1=="")
 {
 alert("Password should not be empty");
 document.form2.Password.focus();
 return false;
 }
 return true;
 }
