function chkMatchpwd()
{
	if (!(document.frmAWS.Password.value == document.frmAWS.Password1.value))
	{ 
		alert('Your passwords do not match please re-enter them again')
		return false;
	}
	else
	{
		return true
	}
}

function VFranchiseeCode()
{
	var str = document.frmAWS.Login_Id.value;
	if (str == "")
   	{
   		alert("\nThe Login name is empty.\n Please enter your Login name.");
   		document.frmAWS.Login_Id.focus();
   		return false;
   	}
	if ( str.length > 50)
	{
		alert("\nThe Login name can not be greater than 50 characters.");
   		document.frmAWS.Login_Id.focus();
   		return false;
	}
		return true;
}

function VLoginId()
{
	var str = document.frmAWS.Login_Id.value;
	if (str == "")
   	{
   		alert("\nThe Login name is empty.\n Please enter your Login.");
   		document.frmAWS.Login_Id.focus();
   		return false;
   	}
  	if (str.length < 5)
  	{
  		alert("\nThe Login name should be minimum 5 characters.");
    		document.frmAWS.Login_Id.focus();
     		return false;
  	}
	if (str.length > 50)
	{
		alert("\nThe Login name can not be greater than 50 characters.");
    	document.frmAWS.Login_Id.focus();
     	return false;
	}
	if((str.substring(0,1) < "a" || str.substring(0,1) > "z") && (str.substring(0,1) < "A" || str.substring(0,1) > "Z"))
	{
		alert("The Login name should begin with an alphabet. \n");
		document.frmAWS.Login_Id.focus();
		return false;
	}
	for (var i = 0; i < str.length; i++) 
	{
		var ch = str.substring(i, i + 1);
		if ( ((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) && (ch < "0" || "9" < ch) && (ch != '_') && (ch != '-') ) 
      		{
      			alert("The Login name accepts Alphabets, Numbers & the Underscore character only.\nPlease re-enter your Login name.\n");
      			document.frmAWS.Login_Id.focus();
      			return false;
      		}
  	 }
	return true;
}
function VPassConfirm() 
{
	var pwdstr = document.frmAWS.Password.value;
	var pwdconfstr = document.frmAWS.Password1.value;
	if(pwdstr != pwdconfstr)
	{
		alert("Your password entries are not matching.\nPlease re-enter.");
		document.frmAWS.Password.focus();
		return false;
	}
	return true;
} 
function ValidEmailId(retval,retobj)
{
	
	xstr = retval;
	xobj = retobj;
	//alert("vipul");

	if (xstr.indexOf("@") == -1 || xstr.indexOf(".") == -1)
	{
		alert(" Invalid Email Id, Please include a proper Email Address.");
		xobj.focus();
		return false;
	}
	return true;
}
function VCompanyName() 
{
	var str = document.frmAWS.companyName.value;
	if (str == "")
   	{
   		alert("The Company Name is empty.\nPlease enter your Company Name.");
   		document.frmAWS.companyName.focus();
   		return false;
   	}
	if ( str.length > 100 )
	{
		alert("The Company Name can not be greater than 100 characters.");
   		document.frmAWS.companyName.focus();
   		return false;
	}
  	return true; 
 }

function VFirstName() 
{
	var str = document.frmAWS.Fname.value;
	if (str == "")
   	{
   		alert("The First Name is empty.\nPlease enter your First Name.");
   		document.frmAWS.Fname.focus();
   		return false;
   	}
	if ( str.length > 50 )
	{
		alert("The First Name can not be greater than 50 characters.");
   		document.frmAWS.Fname.focus();
   		return false;
	}
  	return true; 
 }

function VLastName() 
{
	var str = document.frmAWS.Lname.value;
	if (str == "")
   	{
  		alert("The Last Name is empty.\nPlease enter your Last Name.");
		document.frmAWS.Lname.focus();
		return false;
	}
	if ( str.length > 50 )
	{
		alert("The Last Name can not be greater than 50 characters.");
   		document.frmAWS.Lname.focus();
   		return false;
	}

	return true;
 }

function VCity() 
{
	var str = document.frmAWS.City.value;
	if (str == "")
   	{
		alert("The City field is empty.\nPlease enter your City.");
		document.frmAWS.City.focus();
		return false;
	}
	if ( str.length > 50 )
	{
		alert("The City can not be greater than 50 characters.");
		document.frmAWS.City.focus();
		return false;
	}

 	return true;
}
 
function VZipCode() 
{
	var str = document.frmAWS.Zip.value;
	if (str == "")
   	{
   		alert("The Zip Code is empty.\nPlease enter your Zip Code.");
   		document.frmAWS.Zip.focus();
   		return false;
   	}
	if (str.length > 50)
	{
		alert("The Zip Code can not be greater than 50 characters.");
   		document.frmAWS.Zip.focus();
   		return false;
	}

    return true;  
}
 
function VState() 
{
	var str = document.frmAWS.State.value;
	if (str == "")
   	{
   		alert("The State is empty.\nPlease enter your State.");
   		document.frmAWS.State.focus();
   		return false;
   	}
	if (str.length > 50)
	{
		alert("The State can be greater than 50 characters.");
   		document.frmAWS.State.focus();
   		return false;
	}
    return true;  
}
function VAddress() 
{
	var str = document.frmAWS.Address.value;
	if (str == "")
   	{
   		alert("The Address is empty.\nPlease enter your Address.");
   		document.frmAWS.Address.focus();
   		return false;
   	}
	if ( str.length > 255 )
	{
		alert("The Address can not be greater than 255 characters.");
   		document.frmAWS.Address.focus();
   		return false;
	}
    return true;  
}

function VTelNo1() 
{
	var str = document.frmAWS.TelNo1.value;
	if (str == "")
   	{
   		alert("The Telephone # is empty.\nPlease enter your Telephone # .");
   		document.frmAWS.TelNo1.focus();
   		return false;
   	}
	if ( str.length > 50 )
	{
		alert("The Telephone # can not be greater than 50 characters.");
   		document.frmAWS.TelNo1.focus();
   		return false;

	}
    return true;  
}

function VWebSite() 
{
	/*
	var str = document.frmAWS.website.value;
	if (str == "")
   	{
   		alert("The Web Site Address is not entered.\nPlease enter your Web Site Address.");
		document.frmAWS.website.focus();
   		return false;
   	}
	if ( str.length > 50 )
	{
		alert("The Web Site Address can not be greater than 50 characters.");
   		document.frmAWS.website.focus();
   		return false;
	}
*/
    return true;  
	
}

/*function VFranchiseeName() 
{
	var str = document.frmAWS.FranchiseeName.value;
	if (str == "")
   	{
   		alert("The Company Name is empty.\nPlease enter your Company Name.");
   		document.frmAWS.FranchiseeName.focus();
   		return false;
   	}
    return true;  
}*/
//password
function VPPAINo() 
{
	var str = document.frmAWS.PPAINo.value;
	//var str1 = document.frmAWS.UPICNo.value;
	if (str == "")
   	{
   		alert("Please enter your PPAI #");
   		document.frmAWS.PPAINo.focus();
   		return false;
   	}
	return true;  
}

function VPasswd() 
{
	var str = document.frmAWS.Password1.value;
	var str1= document.frmAWS.Login_Id.value;
	if((str == "") || (str.length < 5)) 
   	{
   		alert("The Password contains less than 5 Characters.\nPlease re-enter.");
		document.frmAWS.Password1.focus();
		return false;
	}
	if (str.length > 50)
	{
		alert("The Password can nto be greater than 50 characters.");
		document.frmAWS.Password1.focus();
		return false;
	}	
	return true;
}
 
   
// Submit button
function mysubmit(str)
{
	
	if(validate())
 	{
		if( str == "edit" )
			document.frmAWS.action="editProfile.asp?val=y";
		else
			document.frmAWS.action="register.asp?val=y";
		document.frmAWS.submit();
		return true;
   	}
	else
	{
		return false;
	}
}

function validate()
{
	if((VCompanyName()) && (VAddress())&& (VCity()) && (VState()) && (VZipCode()) && (ValidEmailId(document.frmAWS.Email.value, document.frmAWS.Email)) && (VTelNo1()) && (VPPAINo())  && (VFirstName()) &&(VLastName()) && (VLoginId()) && (VPasswd()) && (VPassConfirm()) && (VWebSite()))
	{
   		return true;
	}
	else
	{
		return false;
	}
}

function emysubmit(section)
{
	
	if(evalidate())
 	{
		document.frmAWS.action="enquiry.asp?val=y&section="+section ;
		document.frmAWS.submit();
		return true;
   	}
	else
	{
		return false;
	}
}

function evalidate()
{
	if((VCompanyName()) && (VAddress()) && (VCity()) && (VState()) && (VZipCode()) && (ValidEmailId(document.frmAWS.Email.value, document.frmAWS.Email)) && (VTelNo1()) && (VFirstName()) &&(VLastName()))
	{
   		return true;
	}
	else
	{
		return false;
	}
}
