function FillBillingInfo(status)
{
if (status)
	{
	document.frm.NameOnCard_FirstName.value=document.frm.FirstName.value;
	document.frm.NameOnCard_MiddleName.value=document.frm.MiddleName.value;
	document.frm.NameOnCard_LastName.value=document.frm.LastName.value;
	document.frm.Email.value=document.frm.EmailAddress.value;
	document.frm.BillingAddress1.value=document.frm.Address1.value;
	document.frm.BillingCity.value=document.frm.City.value;
	<!--- document.frm.BillingZip_Code.value=document.frm.Zip_Code.value;	 --->
	document.frm.BillingPhone.value=document.frm.Phone.value;
	document.frm.BillingCell.value=document.frm.Cell_no.value;
    document.frm.BillingState.selectedIndex=document.frm.State.selectedIndex;
	document.frm.BillingCountry.selectedIndex=document.frm.Country.selectedIndex    

	}	
else
	{
	document.frm.NameOnCard_FirstName.value="";
	document.frm.NameOnCard_MiddleName.value="";
	document.frm.NameOnCard_LastName.value="";
	document.frm.Email.value="";
	document.frm.BillingAddress1.value="";
	document.frm.BillingCity.value="";
	document.frm.BillingPhone.value="";
	document.frm.BillingCell.value="";
	<!--- document.frm.BillingZip_Code.value=""; --->
    document.frm.BillingState.selectedIndex=0;
	document.frm.BillingCountry.selectedIndex=0;
	}
}

function checkNumeric(FieldName, str)
{
	var numaric = FieldName.value;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<59))
		  {
		  }
		else	{
			alert(str + ' should only contains digits')
			if  (FieldName.value.length>1){ FieldName.select();}
			FieldName.select();
			 return false;
		  }
		}
 return true;
}




function checkNumericNLen(FieldName, str)
{

	if (FieldName.value.length < 13){

		return false
	}
	else{

	var numaric = FieldName.value;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<59))
		  {
		  }
		else	{
			alert(str + ' should only contains digits')
			if  (FieldName.value.length>1){ FieldName.select();}
			FieldName.focus();
			 return false;
		  }
		}//end for
		 return true;
 }//end else
 
}//end function checknumericNLEN


function checkNumericPhone(FieldName, str)
{

	var numaric = FieldName.value;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh == 40) || (hh == 41) || (hh == 45) || (hh == 32))
		  {
		  }
		else	{
			alert(str + ' should only contains digits, (, ), -')
			if  (FieldName.value.length>1){ FieldName.select();}
			FieldName.focus();
			 return false;
		  }
		}
 return true;
}

function Submit_Form2(FormName,stat)
{ 
	if (FormName.FirstName.value=='') 			{ alert('Please enter your first name') 	}
	else if (FormName.LastName.value=='')   	{ alert('Please enter your Last name')  	}
	else if (FormName.EmailAddress.value=='') 	{ alert('Please enter your email address')	}
	else if (FormName.Address1.value=='')   	{ alert('Please enter your address')		}
	else if (FormName.City.value=='')   		{ alert('Please enter your city')		}
	else if (FormName.State.value=='')   		{ alert('Please enter your state')		}
	else if (FormName.Zip_Code.value=='')   	{ alert('Please enter zip code')		}
	else if (FormName.Phone.value=='')   		{ alert('Please enter your phone no')		}
	else if (FormName.password.value=='')   	{ alert('Please enter your password')		}	
	else if (FormName.password.value.length<8)   	{ alert('Passwords must be at least 8 characters')		}	
	else if (FormName.confirmpassword.value=='')   	{ alert('Please confirm your password')		}		
	else if (FormName.confirmpassword.value != FormName.password.value)   	{ alert('Password does not matched')		}			
	else if (FormName.in_agree.checked == false)   	{ alert('You must click I Agree to the Terms of Service Agreement')		}		
	else if (FormName.SiteSubDomain.value=='')   		{ alert('Please enter your Personailzed URL')		}
	else
	{
	document.frm.submit();	
	}
}
function Submit_Form(FormName,stat)
{ 
//if (stat1) 
//{
if (ValidatorNull(FormName.SiteSubDomain,'Please fill in your Site SubDomain') == true 
//&& ValidateAlpha(FormName.NameOnCard_FirstName,'Please check your First Name on card') == true
//	if 
//	(ValidateAlpha(FormName.NameOnCard_FirstName,'Please check your First Name on card') == true)
//	&&
//	(ValidateAlpha(FormName.NameOnCard_LastName,'Please check your Last Name on card') == true)
//	&&
//	(ValidateEmailAddress(FormName.Email,'Please check your Email Address') == true)
//	&&
//	(ValidatorNull(FormName.BillingAddress1,'Please fill in your billing address line 1') == true)
//	&&
//	(ValidatorNull(FormName.BillingCity,'Please fill your City name') == true)
//	&&
//	(ValidatCMB(FormName.BillingState,'Please Select a state') == true)
//	&&
//	(checkZIP(FormName.BillingZip_Code,'Please fill in your zip code') == true)
//	&&
//	(ValidatCMB(FormName.BillingCountry,'Please Select a Country') == true)
//	&&
//	(checkNumericPhone(FormName.BillingPhone,'Please enter your Phone Number ') == true)
//	&&
//	(checkNumericPhone(FormName.BillingCell,'Please enter your Cell Number ') == true)
//	&&	
//	(checkCCLenClient(FormName.CardNumber,'Please enter your Credit Card Number') == true)
//	&&
////	(ccChkDate(FormName.CardExpirationMonth, 'Please Select a correct Expiration Month', 1))
////	&&
//	(ccChkDate(FormName.CardExpirationYear, 'Please Select a correct Expiration Year', 0))
	&&	ValidatAgree(FormName.in_agree, 'You Must agree to the Terms of Service')==true)

//	)//end if bracket
	{	
	if (FormName.password.value=='' )
		{
		alert('Please enter password')
		FormName.password.focus()
		return false
		}
		else if (FormName.password.value.length<8)
		{
		alert('Password should be at least 8 character')
		FormName.password.focus()
		return false
		}
			
	else if (FormName.confirmpassword.value=='')
		{
		alert('Please confirm password')
		FormName.confirmpassword.focus()
		return false
		}
	else if (FormName.password.value != FormName.confirmpassword.value)
		{
		alert('Please check your password; the confirmation entry does not match.');
		FormName.confirmpassword.focus()
		return false
		}
	else	
		{
		document.frm.submit();
		}
		
 	}
// }
// else
// {
// frm.submit();
// }
}





/*          old version

	if (ValidatorNull(FormName.NameOnCard_FirstName,'First Name on card can not left blank or spaces'))	 
	if (ValidateAlpha(FormName.NameOnCard_FirstName,'Name can not contain numbers or spaces'))	 
	if (ValidatorNull(FormName.NameOnCard_LastName,'Last Name on card can not left blank'))
	if (ValidateAlpha(FormName.NameOnCard_LastName,'Name can not contain numbers or spaces'))	 
	if (ValidatorNull(FormName.Email,'Please enter email address'))
	if (ValidateEmailAddress(FormName.Email,'Please enter a valid email address'))
	if (ValidatorNull(FormName.BillingAddress1,'Please enter billing address'))
	if (ValidatorNull(FormName.BillingCity,'Please enter billing city name'))
	if (ValidatorNull(FormName.BillingState,'Please select billing state name'))

	if (checkNumeric(FormName.BillingZip_Code, 'Zip code'))*/
	/*if (ValidatorNull(FormName.BillingZip_Code,'Please enter billing zip code'))*/
/*	if (ValidatorNull(FormName.BillingCountry,'Please enter billing country'))
	if (checkNumericPhone(FormName.BillingPhone, 'Phone Number'))
//	if (ValidatorNumber(FormName.BillingPhone,'Please enter a valid phone no'))
	//if (ValidatorNull(FormName.CardNumber,'Please enter card no'))			
	//if (ValidatorFieldSize(FormName.CardNumber,13,'Invalid card no'))
	if (checkNumericNLen(FormName.CardNumber,'Credit Card Number'))
	if (ValidatorNull(FormName.SiteSubDomain,'Please enter subdomain name or select from the options '))	
	if (ValidateDomainName(FormName.SiteSubDomain,'Domain name can contain only alpha or numbers'))	
//	if (ChangeSiteSubDomain(FormName.NameOnCard_FirstName,FormName.NameOnCard_FirstName,FormName.SiteSubDomain.value))
	if (SiteSubDomainAvailable(FormName.SiteSubDomainAvailable,'Domain not available'))
	if (ValidatAgree(FormName.in_agree,'Terms of Service Agreement '))
	{
document.frm.submit();
	}
	*/
	

	
/**********************************************************************************/
/******************** Form Validation for National Signup *************************/
/**********************************************************************************/

function Submit_Form3(FormName,stat)
{ 
//if (stat1) 
//{
if (ValidatorNull(FormName.SiteSubDomain,'Please fill in your Site SubDomain') == true 
&& ValidateAlpha(FormName.FirstName,'Please check your First Name') == true
&& (ValidateAlpha(FormName.LastName,'Please check your Last Name') == true)
&& (ValidateEmailAddress(FormName.EmailAddress,'Please check your Email Address') == true)
&& (ValidatorNull(FormName.Address1,'Please fill in your address ') == true)
&& (ValidatorNull(FormName.City,'Please fill your City name') == true)
&& (ValidatCMB(FormName.State,'Please full in state') == true)
//&& (checkZIP(FormName.Zip_Code,'Please fill in your zip code') == true)
//	&&
//	(ValidatCMB(FormName.BillingCountry,'Please Select a Country') == true)
&&	(checkNumericPhone(FormName.Phone,'Please enter your Phone Number ') == true)
//	&&
//	(checkNumericPhone(FormName.BillingCell,'Please enter your Cell Number ') == true)
//	&&	
//	(checkCCLenClient(FormName.CardNumber,'Please enter your Credit Card Number') == true)
//	&&
////	(ccChkDate(FormName.CardExpirationMonth, 'Please Select a correct Expiration Month', 1))
////	&&
//	(ccChkDate(FormName.CardExpirationYear, 'Please Select a correct Expiration Year', 0))
	&&	ValidatAgree(FormName.in_agree, 'You Must agree to the Terms of Service')==true)

//	)//end if bracket
	{	
	if (FormName.password.value=='' )
		{
		alert('Please enter password')
		FormName.password.focus()
		return false
		}
		else if (FormName.password.value.length<8)
		{
		alert('Password should be at least 8 character')
		FormName.password.focus()
		return false
		}
			
	else if (FormName.confirmpassword.value=='')
		{
		alert('Please confirm password')
		FormName.confirmpassword.focus()
		return false
		}
	else if (FormName.password.value != FormName.confirmpassword.value)
		{
		alert('Please check your password; the confirmation entry does not match.');
		FormName.confirmpassword.focus()
		return false
		}
	else	
		{
		document.frm.submit();
		}
		
 	}
// }
// else
// {
// frm.submit();
// }
}
/****************************************** end ***************************************/

	
	
	


/************************************************************************************/
/*************** This function will validate null values ***************************/
/************************************************************************************/


function ValidatorNull(FieldName,msg)
{
	if (FieldName.value == "")
	{
		alert(msg);
		FieldName.focus();
		return (false);
	}
	else
	{
		return (true);
	}
}

/************************************************************************************/
/*************** This function will validate Alpha Characters ***********************/
/************************************************************************************/

function ValidateAlpha(FieldName,msg)
{
	if ( FieldName.value.length > 0 ) {
		var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
		var checkStr = FieldName.value;
		var allValid = true;
			for (i = 0;  i < checkStr.length;  i++)
				{
					ch = checkStr.charAt(i);
					for (j = 0;  j < checkOK.length;  j++)
					if (ch == checkOK.charAt(j))
					break;
						if (j == checkOK.length)
							{
							allValid = false;
							break;
							}
				}
			if (!allValid)
				{
					alert(msg);
					if  (FieldName.value.length>1){ FieldName.select();}
					FieldName.focus();
					return (false);
				}
			else
				{
				return (true);
				}
	}
	else{
		alert(msg);
		if  (FieldName.value.length>1){FieldName.select();}
		FieldName.focus();
		return (false);
	}
}




/************************************************************************************/
/*************** This function will validate Email Address  *************************/
/************************************************************************************/




function ValidateEmailAddress(FieldName,msg)
	{
		var checkEmail = "@.";
		var checkStr = FieldName.value;
		var EmailValid = false;
		var EmailAt = false;
		var EmailPeriod = false;
			for (i = 0;  i < checkStr.length;  i++)
				{
					ch = checkStr.charAt(i);
					for (j = 0;  j < checkEmail.length;  j++)
						{
						if (ch == checkEmail.charAt(j) && ch == "@")	EmailAt = true;
						if (ch == checkEmail.charAt(j) && ch == ".")	EmailPeriod = true;
						if (EmailAt && EmailPeriod)			break;
						if (j == checkEmail.length)			break;
						}
		
						if (EmailAt && EmailPeriod)
						{
						EmailValid = true
						break;
						}
				}
			if (!EmailValid)
				{
				alert(msg);
				if  (FieldName.value.length>1){ FieldName.select();}
				FieldName.focus();
				return (false);
				}
			else
				{
				return (true);
				}
				

}


/************************************************************************************/
/*************** This function will validate number values  *************************/
/************************************************************************************/


function ValidatorNumber(FieldName,msg)
{
	if (isNaN(FieldName.value))
	{
		alert(msg);
		if  (FieldName.value.length>1){ FieldName.select();}
		FieldName.focus();
		return (false);
	}
	else
		{
		return (true);
		}
	
}


/************************************************************************************/
/*************** This function will validate field size   *************************/
/************************************************************************************/


function ValidatorFieldSize(FieldName,sz,msg)
{
//	if (FieldName.value.length!=sz)		--Changed by Nauman
	if (FieldName.value.length < sz)
	{
		alert(msg);
		if  (FieldName.value.length>1){ FieldName.select();}
		FieldName.focus();
		return (false);
	}
	else
	{
	return (true);
	}
}



/************************************************************************************/
/*************** This function will validate domain name   *************************/
/************************************************************************************/



function ValidateSiteSubDomain(fname,lname,userdefinedsubdomain)
{

	if (userdefinedsubdomain.value !='')
		{				
		if(ValidateDomainName(userdefinedsubdomain,'Domain name can not contain special characters'))
			{
			a="_incSearchSubDomain.cfm?FirstName="+fname+"&LastName="+lname+"&UserDefinedSubDomain="+userdefinedsubdomain.value
//			window.document.FrmDomain.location.href=a
			window.frames['FrmDomain'].location.href=a
			}
		else
			{
			return false;
			}
		}

}



function ValidateSiteSubDomain2(fname,lname,userdefinedsubdomain)
{


	if (userdefinedsubdomain.value !='')
		{				
		if(ValidateDomainName(userdefinedsubdomain,'Domain name can not contain special characters'))
			{
			
			a="_incSearchSubDomain2.cfm?FirstName="+fname+"&LastName="+lname+"&UserDefinedSubDomain="+userdefinedsubdomain.value
			window.frames['FrmDomain'].location.href=a
			}
		else
			{
			return false;
			}
		}

}




function SiteSubDomainAvailable(fieldname,msg)
{
if (fieldname.value=='Y')
	{
	return (true);

	}
else
	{
	return (false);

	}
	
}



function ValidateDomainName(FieldName,msg)
{

var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
	var checkStr = FieldName.value;
	var allValid = true;
		for (i = 0;  i < checkStr.length;  i++)
			{
				ch = checkStr.charAt(i);
				for (j = 0;  j < checkOK.length;  j++)
				if (ch == checkOK.charAt(j))
				break;
					if (j == checkOK.length)
						{
						allValid = false;
						break;
						}
			}
		if (!allValid)
			{
				alert(msg);
				FieldName.focus();
				return (false);
			}
		else
			{
			return (true);
			}
}





function ValidatAgree(FieldName,msg)
{

	if (FieldName.checked == false)
	{
		alert(msg);
		FieldName.focus();
		return (false);
	}
	else
	{
		return (true);
	}
}




function ValidatCMB(FieldName,msg)
{
	if (FieldName.value == "")
	{
		alert(msg);
		FieldName.focus();
		return (false);
	}
	else
	{
		return (true);
	}
}






/*
checks for number in a given string including length
Takes 2 strings as input first for checking and second errmsg and error
*/
function checkZIP(FieldName,msg)
{
 if(FieldName.value.length > 4 && FieldName.value.length < 7)
 	{
 	if ( (FieldName.value.length > 7))
	{
		alert(msg);
		if  (FieldName.value.length>1){ FieldName.select();}
		FieldName.focus();
		return false
	}
	else
	{
		var numaric = FieldName.value;
		for(var j=0; j<numaric.length; j++)
			{
			  var alphaa = numaric.charAt(j);
			  var hh = alphaa.charCodeAt(0);
			  if((hh > 47 && hh<59))
				  {
				  }
	 		 else
			 	{
					alert(msg + ' should only contains digits')
					if  (FieldName.value.length>1){ FieldName.select();}
					FieldName.focus();
					 return false;
				 }
		    }//end for
		 return true;
	 }//end else
	}//if Close
else
	{
		alert(msg);
		if  (FieldName.value.length>1){ FieldName.select();}
		FieldName.focus();
		return false; 
	}
 
}//end function checkZIP()



/*
checks for phone number in a given string  ( allowed 0-9, (, ) , -, <space> )
Takes 2 strings as input first for checking and second errmsg
*/

function checkNumericPhone(FieldName,msg)
{
if (FieldName.value.length > 0) {

	var numaric = FieldName.value;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh == 40) || (hh == 41) || (hh == 45) || (hh == 32))
		  {
		  }
		else	{
			alert(msg + ' should only contains digits, (, ), -')
			if (FieldName.value.length>1 ){FieldName.select();}
			FieldName.focus();
			 return false;
		  }
		}
 return true;
}

else{
	alert(msg);
	if (FieldName.value.length>1 ){FieldName.select();}
	FieldName.focus();
	return false;
}
}//end CheckNumericPhone()



function checkCCLenClient(FieldName, str)
{

	if (FieldName.value.length < 13){
		alert(' Please Check your Credit Card Number')
		if (FieldName.value.length>1 ){FieldName.select();}
		FieldName.focus();
		return false
	}
	else{

	var numaric = FieldName.value;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh == 120) )
		  {
		  }
		else	{
			alert(str + ' Please Check your Credit Card Number')
			if (FieldName.value.length>1 ){FieldName.select();}
			FieldName.focus();
			 return false;
		  }
		}//end for
		 return true;
 }//end else
 
}//end function checkCCLenClient()


function ccChkDate(fieldName, str, chk)
{

	var thisdate = new Date();
	
	if( chk == 1){
		//chk Month
		if ( fieldName.value >= (thisdate.getMonth()+1)){
			return true;
		}
		else{
			alert(str);
			if (fieldName.length.value>1 ){fieldName.select();}
			fieldName.focus();
			return false;
		}
	}
	else{
		//chk Year

		if ( fieldName.value >= thisdate.getYear()){
			return true;
		}
		else{
			alert(str);
			if (fieldName.length.value>1 ){fieldName.select();}
			fieldName.focus();
			return false;
		}
	}

}//end CheckNumericPhone()