function chkMatchpwd()
{
	if (!(document.forms[0].Password.value == document.forms[0].Password1.value))
	{ 
		alert('Your passwords do not match please re-enter them again')
		return false;
	}
	else
	{
		return true
	}
}

function VFranchiseeCode()
{
	var str = document.forms[0].Login_Id.value;
	if (str == "")
   	{
   		alert("\nThe Login name field is empty.\n Please enter your Login name.");
   		document.forms[0].Login_Id.focus();
   		return false;
   	}
	else
	{
		return true;
	}
}

function VLoginId()
{
	var str = document.forms[0].Login_Id.value;
	if (str == "")
   	{
   		alert("\nThe Login name field is empty.\n Please enter your Login name.");
   		document.forms[0].Login_Id.focus();
   		return false;
   	}
  	if (str.length < 5)
  	{
  		alert("\nThe Login name should be minimum 5 characters.");
    		document.forms[0].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");
		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 field accepts Alphabets, Numbers & the Underscore character only.\nPlease re-enter your Login name.\n");
      			document.forms[0].Login_Id.focus();
      			return false;
      		}
  	 }
	return true;
}
function VPassConfirm() 
{
	var pwdstr = document.forms[0].Password.value;
	var pwdconfstr = document.forms[0].Password1.value;
	if(pwdstr != pwdconfstr)
	{
		alert("Your password entries are not matching.\nPlease re-enter.");
		document.forms[0].Password1.focus();
		return false;
	}
	return true;
} 
function ValidEmailId(retval,retobj)
{
	
	xstr = retval;
	xobj = retobj;

	if (xstr.indexOf("@") == -1 || xstr.indexOf(".") == -1)
	{
		alert(" Invalid Email Id, Please include a proper Email Address.");
		xobj.focus();
		return false;
	}
	return true;
}
function VFirstName() 
{
	var str = document.forms[0].Fname.value;
	if (str == "")
   	{
   		alert("The First Name field is empty.\nPlease enter your First Name.");
   		document.forms[0].Fname.focus();
   		return false;
   	}
  	return true; 
 }

function VLastName() 
{
	var str = document.forms[0].Lname.value;
	if (str == "")
   	{
  		alert("The Last Name field is empty.\nPlease enter your Last Name.");
		document.forms[0].Lname.focus();
		return false;
	}
	return true;
 }

function VCity() 
{
	var str = document.forms[0].City.value;
	if (str == "")
   	{
		alert("The City field is empty.\nPlease enter your City.");
		document.forms[0].City.focus();
		return false;
	}
 	return true;
}
 
function VZipCode() 
{
	var str = document.forms[0].Zip.value;
	if (str == "")
   	{
   		alert("The Zip Code is empty.\nPlease enter your Zip Code.");
   		document.forms[0].Zip.focus();
   		return false;
   	}
    return true;  
}
 
function VState() 
{
	var str = document.forms[0].State.value;
	if (str == "")
   	{
   		alert("The State is empty.\nPlease enter your State.");
   		document.forms[0].State.focus();
   		return false;
   	}
    return true;  
}
function VAddress() 
{
	var str = document.forms[0].Address.value;
	if (str == "")
   	{
   		alert("The Address is empty.\nPlease enter your Address.");
   		document.forms[0].Address.focus();
   		return false;
   	}
    return true;  
}

function VTelNo1() 
{
	var str = document.forms[0].TelNo1.value;
	if (str == "")
   	{
   		alert("The Telephone # is empty.\nPlease enter your Telephone # .");
   		document.forms[0].TelNo1.focus();
   		return false;
   	}
    return true;  
}

function VFranchiseeName() 
{
	var str = document.forms[0].FranchiseeName.value;
	if (str == "")
   	{
   		alert("The FranchiseeName is empty.\nPlease enter your FranchiseeName.");
   		document.forms[0].FranchiseeName.focus();
   		return false;
   	}
    return true;  
}
//password
function VPasswd() 
{
	var str = document.forms[0].Password.value;
	var str1= document.forms[0].Login_Id.value;
	if((str == "") || (str.length < 5)) 
   	{
   		alert("The password field contains less than 5 characters.\nPlease re-enter.");
		document.forms[0].Password.focus();
		return false;
	}
	return true;
}
 
   
// Submit button
function mysubmit()
{
	if(validate())
 	{
		return true;
   	}
	else
	{
		return false
	}
}

function validate()
{
	if((VFranchiseeName()) && (VAddress()) && ((VCity()) && (VState()) && (VZipCode()) && (ValidEmailId(document.forms[0].Email.value, document.forms[0].Email)) && (VTelNo1()) && (VFirstName()) &&(VLastName()) && (VLoginId()) && (VPasswd()) && (VPassConfirm()) ))
	{
   		return true;
	}
	else {
		return false;
	}
}
