<!--



//for date format validation

//Basic check for format validity

//var validformat=/^\d{1,2}\/\d{1,2}\/\d{4}$/ 

/*

function validateDate(dtControl) 

{

   // var input = document.getElementById(dtControl)

   var input = dtControl;

    var validformat=/^\d{1,2}\/\d{1,2}\/\d{4}$/ //Basic check for format validity

    var returnval=false

    if (!validformat.test(input))

    //alert('Invalid Date Format. Use DD/MM/YYYY')

		return returnval

    else{ //Detailed check for valid date ranges

    var dayfield=input.split("/")[0]

    var monthfield=input.split("/")[1]

    var yearfield=input.split("/")[2]    

    var dayobj = new Date(yearfield, monthfield-1, dayfield)

    if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))

    //alert('Invalid Day, Month, or Year range detected. Please correct.')    

		return returnval

}*/



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_company, ch_contact, ch_phone1, ch_phone2, ch_phone3, ch_email, ch_pdate, ch_event_type, ch_from_time, ch_to_time, ch_guests, ch_located, ch_approve_250, ch_card, ch_card_address, ch_city, ch_ctype, ch_card_no, ch_expdate, ch_card_code, ch_iagree, ch_name, ch_title, ch_date, ch_key; 

   

   with(window.document.sform)

   {

      ch_company=company;

	  ch_contact=contact;

	  ch_phone1=phone1;

	  ch_phone2=phone2;

	  ch_phone3=phone3;

	  ch_email=email;

	  ch_pdate=pdate;

	  ch_event_type=event_type;

	  ch_from_time=from_time; 

	  ch_to_time=to_time;

	  ch_guests=guests;

	  ch_located=located;

	  ch_approve_250=approve_250;

	 /* ch_card=card;

	  ch_card_address=card_address;
	
	  ch_city=city;

	  ch_ctype=card_type;
	
	  ch_card_no=card_no;

	  ch_expdate=expdate;

	  ch_card_code=card_code; 
		
	  ch_iagree=iagree; 
	*/
	  ch_name=pname; 

	  ch_title=title; 

	  ch_sdate=submit_date;

	  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_phone = trim(ch_phone1.value) + "-" + trim(ch_phone2.value) + "-" + trim(ch_phone3.value);

		//alert("primary: " + ch_contact);

}

		

  if(trim(ch_company.value) == '')

   {

      alert('Please enter your Company Name');

      ch_company.focus();

      return false;	  

   }

   

   else if(trim(ch_contact.value) == '')

   {

      alert('Please enter your Contact Number');

      ch_contact.focus();

      return false;	  

   }

   /*

   else if (checkInternationalPhone(ch_contact)==false){

		alert("Please Enter a Valid Phone Number")

		ch_contact.focus()

		return false

	}

	*/

	else if(trim(ch_phone1.value) == '')

   {

      alert('Please enter your Phone Number');

      ch_phone1.focus();

      return false;	  

   }  

   

   else if(ch_phone1.value.length != 3)

   {

      alert('Please enter 3 digits in the input box');

      ch_phone1.focus();

      return false;	  

   }  

   

   else if(trim(ch_phone2.value) == '')

   {

      alert('Please enter complete Phone Number');

      ch_phone2.focus();

      return false;	  

   }  

   

   else if(ch_phone2.value.length != 3)

   {

      alert('Please enter 3 digits in the input box');

      ch_phone2.focus();

      return false;	  

   } 

   

   else if(trim(ch_phone3.value) == '')

   {

      alert('Please enter complete Phone Number');

      ch_phone3.focus();

      return false;	  

   }  

   

   else if(ch_phone3.value.length != 4)

   {

      alert('Please enter 4 digits in the input box');

      ch_phone3.focus();

      return false;	  

   } 

   

	

   else if (checkInternationalPhone(ch_phone)==false){

		alert("Please Enter a Valid Phone Number")

		ch_phone1.focus()

		return false

	}

	

	else if(trim(ch_email.value) == '')

   {

      alert('Please enter Your Email Address');

      ch_email.focus();

      return false;	  

   }

   

	else if (!(emailFilter.test(ch_email.value))) { 

       alert("Please enter a valid email address.");

	   ch_email.focus()

	   return false

	}

	

	else if(trim(ch_pdate.value) == '')

   {

      alert('Please enter Preferred Date for Event');

      ch_pdate.focus();

      return false;	  

   }

   /*

   else if(!validateDate(ch_pdate))

   {

      alert('Please enter Valid Date Format in MM/DD/YYYY');

      ch_pdate.focus();

      return false;	  

   } */

   

   else if(!ValidatePDate(ch_pdate))

   {

      //alert('Please enter Valid Date Format in MM/DD/YYYY');

      ch_pdate.focus();

      return false;	  

   } 

	

	else if(trim(ch_event_type.value) == '')

   {

      alert('Please enter Type of event');

      ch_event_type.focus();

      return false;	  

   }  

   

   else if(trim(ch_from_time.value) == '')

   {

      alert('Please enter Event timing from');

      ch_from_time.focus();

      return false;	  

   }  

   

   else if(trim(ch_to_time.value) == '')

   {

      alert('Please enter Event timing to');

      ch_to_time.focus();

      return false;	  

   }  

   

   else if(trim(ch_guests.value) == '')

   {

      alert('Please enter Number of Guests');

      ch_guests.focus();

      return false;	  

   } 

   

   else if(trim(ch_located.value) == '')

   {

      alert('Please enter Venue Location');

      ch_located.focus();

      return false;	  

   } 

   

    else if(!ch_approve_250.checked)

   {

      alert('Please approve to charge $250.00');

      //ch_located.focus();

      return false;	  

   } 

   
	/*
   else if(ch_approve_250.checked && trim(ch_card.value) == '')

   {

      alert('Please enter your name on Credit Card');

      ch_card.focus();

      return false;	  

   }

   

    else if(trim(ch_card.value) != '' && trim(ch_card_address.value) == '')

   {

      alert('Please enter your address');

      ch_card_address.focus();

      return false;	  

   } 

   

   else if(trim(ch_card.value) != '' && trim(ch_city.value) == '')

   {

      alert('Please enter your City, State and Zip');

      ch_city.focus();

      return false;	  

   } 

   

   else if(!valButton2(ch_ctype))

   {

      alert('Please choose Credit Card Type Visa or Master or American or Discover');

      //ch_email.focus();

      return false;	  

   }

   

   else if(valButton2(ch_ctype) && trim(ch_card_no.value) == '')

   {

      alert("You choose " + cardtype + " Please Enter Your Credit Card Number");

      ch_card_no.focus();

      //return false;	  

   }

   

   else if(!isValidCreditCard(cardtype, trim(ch_card_no.value)))

   {

      alert('Please enter Valid Card Number');

      ch_card_no.focus();

      return false;	  

   }

   

   

   else if(trim(ch_card_no.value) != '' && trim(ch_expdate.value)=='')

   {

	   

      alert('Please enter Credit Card Expiry Date');

      ch_expdate.focus();

      return false;	  

   }

   

   else if(trim(ch_card_no.value) != '' && trim(ch_card_code.value)=='')

   {

	   

      alert('Please enter CVV Number ie. Code on back of your Credit Card');

      ch_card_code.focus();

      return false;	  

   }

   

   else if(!IsNumeric(trim(ch_card_code.value)))

   {

	   

      alert('Please enter Numeric');

      ch_card_code.focus();

      return false;	  

   }

   

    else if(!ch_iagree.checked)

   {

      alert('Please choose the agree Checkbox');

      //ch_located.focus();

      return false;	  

   } 

   
*/
	
	else if(trim(ch_name.value) == '')
   {
      alert('Please enter Name');
      ch_name.focus();
      return false;	  
   }
	
	else if(trim(ch_key.value) == '')
   {

      alert('Please enter Captcha word for security');

      ch_key.focus();

      return false;	  

   }

   

   else

   {      

   //alert(ch_resume.value);

	 sform.submit();

      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

 }





//-->















