<!--
var digits = "0123456789";
var phoneNumberDelimiters = "()- ";
var validWorldPhoneChars = phoneNumberDelimiters + "+";
var minDigitsInIPhoneNumber = 10;
var nchange_selection="";
var govern_selection="";
var apply_selection="";
function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

var emailFilter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

function checkForm()
{
   var ch_fname, ch_lname, ch_wedding_date, ch_city, ch_email, ch_phone1, ch_phone2, ch_phone3, ch_key; 
   
   with(window.document.qform)
   {
      ch_fname=first_name; 
	  ch_lname=last_name; 
	  ch_email= e_mail;
	  
	  ch_phone1=home_phone;
	  ch_phone2=home_phone2;
	  ch_phone3=home_phone3;	  
	  
	  ch_city=city;
	  ch_wedding_date=wedding_date;	  
	   ch_search_engine=search_engine;
	 // ch_specified_other=specified_other;
	  ch_search_term=search_term;
	  ch_NA=NA;
	  ch_key=keystring;
	  
	  
   }
   
		var at="@"
		var dot="."
		var str=ch_email.value
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)		
		var atpos=str.indexOf(at)
		var dotpos=str.indexOf(dot)
		var dname= str.substring(atpos+1, dotpos)
		
		// phone generate
if(trim(ch_phone1.value) != '' && trim(ch_phone2.value) != '' && trim(ch_phone3.value) != ''){
		var ch_contact = trim(ch_phone1.value) + "-" + trim(ch_phone2.value) + "-" + trim(ch_phone3.value);
		//alert("primary: " + ch_contact);
}
		
		
  if(trim(ch_fname.value) == '')
   {
      alert('Please enter your First Name');
      ch_fname.focus();
      return false;	  
   }
   
   if(trim(ch_lname.value) == '')
   {
      alert('Please enter your Last Name');
      ch_lname.focus();
      return false;	  
   }
    if(trim(ch_wedding_date.value) == '')
   {
      alert('Please enter Wedding Date');
      ch_wedding_date.focus();
      return false;	  
   } 
   
   if(!ValidatePDate(ch_wedding_date))
   {
      //alert('Please enter Valid Date Format in MM/DD/YYYY');
      ch_wedding_date.focus();
      return false;	  
   } 
   
   if(trim(ch_city.value) == '')
   {
      alert('Please enter your City');
      ch_city.focus();
      return false;	  
   }  

	
	if(trim(ch_phone1.value) == '')
   {
      alert('Please enter your Primary Phone Number');
      ch_phone1.focus();
      return false;	  
   }  
   
   if(ch_phone1.value.length != 3)
   {
      alert('Please enter 3 digits in the input box');
      ch_phone1.focus();
      return false;	  
   }  
   
   if(trim(ch_phone2.value) == '')
   {
      alert('Please enter complete Primary Phone Number');
      ch_phone2.focus();
      return false;	  
   }  
   
   if(ch_phone2.value.length != 3)
   {
      alert('Please enter 3 digits in the input box');
      ch_phone2.focus();
      return false;	  
   } 
   
   if(trim(ch_phone3.value) == '')
   {
      alert('Please enter complete Primary Phone Number');
      ch_phone3.focus();
      return false;	  
   }  
   
   if(ch_phone3.value.length != 4)
   {
      alert('Please enter 4 digits in the input box');
      ch_phone3.focus();
      return false;	  
   } 
   
	
   if (checkInternationalPhone(ch_contact)==false){
		alert("Please Enter a Valid Phone Number")
		ch_phone1.focus()
		return false
	}
	
	if(trim(ch_email.value) == '')
   {
      alert('Please enter Your Email Address');
      ch_email.focus();
      return false;	  
   }
   
	if (!(emailFilter.test(ch_email.value))) { 
       alert("Please enter a valid email address.");
	   ch_email.focus()
	   return false
	}
	
	if(trim(ch_search_engine.value) == '--')
   {
      alert('Please select Referred Search Engine');
      ch_search_engine.focus();
      return false;	  
   } 
   else 
  {
		if(trim(ch_search_engine.value) == 'Other')
		{
		
			if(document.qform.specified_other.value=="")
				{
					alert("Please Enter Other Search Engine");
					document.qform.specified_other.focus();
					return false;
				}
		}
  }
   if(!ch_NA.checked && trim(ch_search_term.value) == '')
   {
      alert('Please enter Search Term or Check Not Applicable');
      ch_search_term.focus();
      return false;	  
   }    

	
	if(trim(ch_key.value) == '')
   {
      alert('Please enter Captcha word for security');
      ch_key.focus();
      return false;	  
   }
   
   return true;
}

function trim(str)
{
   return str.replace(/^\s+|\s+$/g,'');
}

function valButton2(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) 
	{
		cardtype = btn[cnt].value;
		return btn[cnt].value;
	}
    else return null;
}


function isValidCreditCard(type, ccnum) {
   if (type == "Visa") {
      // Visa: length 16, prefix 4, dashes optional.
      var re = /^4\d{3}-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "MasterCard") {
      // Mastercard: length 16, prefix 51-55, dashes optional.
      var re = /^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "Disc") {
      // Discover: length 16, prefix 6011, dashes optional.
      var re = /^6011-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "AmEx") {
      // American Express: length 15, prefix 34 or 37.
      var re = /^3[4,7]\d{13}$/;
   } else if (type == "Diners") {
      // Diners: length 14, prefix 30, 36, or 38.
      var re = /^3[0,6,8]\d{12}$/;
   }
   if (!re.test(ccnum)) return false;
   // Remove all dashes for the checksum checks to eliminate negative numbers
   ccnum = ccnum.split("-").join("");
   // Checksum ("Mod 10")
   // Add even digits in even length strings or odd digits in odd length strings.
   var checksum = 0;
   for (var i=(2-(ccnum.length % 2)); i<=ccnum.length; i+=2) {
      checksum += parseInt(ccnum.charAt(i-1));
   }
   // Analyze odd digits in even length strings or even digits in odd length strings.
   for (var i=(ccnum.length % 2) + 1; i<ccnum.length; i+=2) {
      var digit = parseInt(ccnum.charAt(i-1)) * 2;
      if (digit < 10) { checksum += digit; } else { checksum += (digit-9); }
   }
   if ((checksum % 10) == 0) return true; else return false;
}


function IsNumeric(sText)

{
   var ValidChars = "0123456789./-";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   

}


function validateDate(fld) {
    var RegExPattern = /^((((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$/;
    var errorMessage = 'Please Enter the Date Format in MM/DD/YYYY';
    if ((fld.value.match(RegExPattern)) && (fld.value!='')) {
        //alert('Date is OK');
		return true;
    } else {
        //alert(errorMessage);
        //fld.focus();
		return false;
    } 
}
 
 /* 
 function IsValidDate(Day,Mn,Yr){
    var DateVal = Mn + "/" + Day + "/" + Yr;
    var dt = new Date(DateVal);

    if(dt.getDate()!=Day){
        alert('Invalid Date');
        return(false);
        }
    else if(dt.getMonth()!=Mn-1){
    //this is for the purpose JavaScript starts the month from 0

        alert('Invalid Date');
        return(false);
        }
    else if(dt.getFullYear()!=Yr){
        alert('Invalid Date');
        return(false);
        }
        
    return(true);
 } 
 
 */
 
 
 
 /**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}

function ValidatePDate(dt){
	//var dt=document.frmSample.txtDate
	if (isDate(dt.value)==false){
		//dt.focus()
		return false
	}
    return true
 }
//-->







