// JavaScript Document var str = unescape(location.search.substring(1, location.search.length)); // 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 || yearmaxYear){ 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 ValidateDate(){ var today = new Date(); // today var d = today.getDate(); var m = (today.getMonth()+1); var y = today.getFullYear(); var cleanToday= new Date(m+"/"+d+"/"+y) var dt=document.limoRequest.EVENT_DT if (isDate(dt.value)==false){ dt.focus() return false } var formdt= new Date(dt.value); if (cleanToday > formdt) { alert('The date you entered already past. Please re-enter a valid date!'); dt.focus(); return false; } return true } /*Browsercheck object*/ function cm_bwcheck(){ //In theory we should use object detection, but this script needs work-arounds for almost every browser... this.ver=navigator.appVersion this.agent=navigator.userAgent.toLowerCase() this.dom=document.getElementById?1:0 this.ns4=(!this.dom && document.layers)?1:0; this.op=window.opera this.moz=(this.agent.indexOf("gecko")>-1 || window.sidebar) this.ie=this.agent.indexOf("msie")>-1 && !this.op if(this.op){ this.op5=(this.agent.indexOf("opera 5")>-1 || this.agent.indexOf("opera/5")>-1) this.op6=(this.agent.indexOf("opera 6")>-1 || this.agent.indexOf("opera/6")>-1) this.op7=this.dom&&!this.op5&&!this.op6 //So all higher opera versions will use it }else if(this.moz) this.ns6 = 1 else if(this.ie){ this.ie4 = !this.dom && document.all this.ie5 = (this.agent.indexOf("msie 5")>-1) this.ie55 = (this.ie5 && this.agent.indexOf("msie 5.5")>-1) this.ie6 = this.dom && !this.ie4 && !this.ie5 && ! this.ie55 } this.mac=(this.agent.indexOf("mac")>-1) this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.op5 || this.op6 || this.op7) this.usedom= this.ns6||this.op7//Use dom creation this.reuse = this.ie||this.op7||this.usedom //Reuse layers this.px=this.dom&&!this.op5?"px":"" return this } function valiRegForm(){ var f = document.forms[0]; prefixitemSelected = f.prefix.selectedIndex; prefix= f.prefix.options[prefixitemSelected].value; if (prefix=='999') { alert("Please select a prefix so that we know how to address you!"); f.prefix.focus(); return false; } if (f.FNAME.value.length == 0){ alert("Please fill in your first name!"); f.FNAME.focus(); return false; }else{ if (!nameOK(f.FNAME.value)){ alert("First name contains invalid characters, such as an apostrophe or a \" or \\\n Please re-enter your information without the invalid character."); f.FNAME.focus(); return false; } } if (f.LNAME.value.length == 0){ alert("Please fill in your last name!"); f.LNAME.focus(); return false; }else{ if (!nameOK(f.LNAME.value)){ alert("Last name contains invalid characters, such as an apostrophe or a \" or \\\n Please re-enter your information without the invalid character."); f.LNAME.focus(); return false; } } if (!nameOK(f.MNAME.value)){ alert("The middle name form field contains invalid characters, such as an apostrophe or a \" or \\\n Please re-enter your information without the invalid character."); f.MNAME.focus(); return false; } ///LETS see if this rsvp is within x hours PUTIMEHRSINDEX = f.PICKUP_TIME_HRS.selectedIndex; PU_TIME_HRS= f.PICKUP_TIME_HRS.options[PUTIMEHRSINDEX].value; PUTIMEMININDEX = f.PICKUP_TIME_MIN.selectedIndex; PU_TIME_MIN= f.PICKUP_TIME_MIN.options[PUTIMEMININDEX].value; if (PU_TIME_HRS=='999') { alert("Please select a pick time!"); f.PICKUP_TIME_HRS.focus(); return false; } var advNotice= "8"; var COMPTODAY = new Date(); // today if (COMPTODAY.getHours() > 21 || (COMPTODAY.getHours() >= 0 && COMPTODAY.getHours() < 8)) { if (COMPTODAY.getHours() > 21) { var hrstilmorning = (24 - COMPTODAY.getHours()) + 8; } else if (COMPTODAY.getHours() >= 0 && COMPTODAY.getHours() < 8) { var hrstilmorning = 8 - COMPTODAY.getHours(); } advNotice=advNotice + hrstilmorning; } if (advNotice !=""){ var PICKUPVAR = new Date(f.EVENT_DT.value + " " + f.PICKUP_TIME_HRS.value + ":" + f.PICKUP_TIME_MIN.value + " " + f.PICKUPTIMEAMORPM.value); var mins = 1000*60; var dtdiff = Math.ceil((PICKUPVAR.getTime()-COMPTODAY.getTime())/(mins)); if (dtdiff <= 0) { alert("The date and time you pick for this event has already past.\n\nPlease select another time or date."); f.PICKUP_TIME_HRS.focus(); return false; } else if (dtdiff < advNotice) { alert("Please call us to make your reservation over the phone or select another time or date.\n\nWe only make online reservations with 8 hours advance notice."); f.PICKUP_TIME_HRS.focus(); return false; } } //end of time routine if(f.PHONE.value.length == 0){ alert("Please fill in your phone number!"); f.PHONE.focus(); return false; }else{ if (!teleOK(f.PHONE.value)){ alert("Please fill in a valid phone number"); f.PHONE.focus(); return false; } } if(f.EMAIL.value.length == 0){ alert("Please fill in your email address!"); f.EMAIL.focus(); return false; }else{ if(!isEmail(f.EMAIL.value)){ alert("The email address that you entered is not valid or contains illegal characters, please check!"); f.EMAIL.focus(); return false; } if(f.EMAIL_2.value.length == 0){ alert("Please re-enter your email address!"); f.EMAIL_2.focus(); return false; }else if (f.EMAIL.value.length != f.EMAIL_2.value.length){ alert("The email address that you provided don't match, please check!"); f.EMAIL_2.focus(); return false; } } itemSelected = document.limoRequest.EVENT_TYPE.selectedIndex; itemText= document.limoRequest.EVENT_TYPE.options[itemSelected].value; if (itemText=='999') { alert("Please select the type of service that you are requesting!"); f.EVENT_TYPE.focus(); return false; } if (itemText=='OE') { alert("Please be more specific and select the type of service that you are requesting!"); f.EVENT_TYPE.focus(); return false; } if(f.EVENT_DT.value.length == 0){ alert("Please tell us the approximate date of your event!"); f.EVENT_DT.focus(); return false; }else{ if (!ValidateDate()){ return false; } } if(f.NUMBEROFPASSENGERS.value.length == 0){ alert("Please tell us the approximate number of passengers!"); f.NUMBEROFPASSENGERS.focus(); return false; }else{ if (!teleOK(f.NUMBEROFPASSENGERS.value)){ alert("Please fill in a valid number of passengers!"); f.NUMBEROFPASSENGERS.focus(); return false; } } if(f.EVENTTOTALHOURS.value.length == 0){ alert("Please tell us the approximate number of hours!"); f.EVENTTOTALHOURS.focus(); return false; }else{ if (!teleOK(f.EVENTTOTALHOURS.value)){ alert("Please fill in a valid number of hours!"); f.EVENTTOTALHOURS.focus(); return false; } } if (f.PICKUP_CITY.value.length == 0){ alert("Please tell us the city where we are picking you up!"); f.PICKUP_CITY.focus(); return false; }else{ if (!nameOK(f.PICKUP_CITY.value)){ alert("The city you entered contains invalid characters, such as an apostrophe or a \" or \\\n Please re-enter your information without the invalid character."); f.PICKUP_CITY.focus(); return false; } } if (f.PICKUP_STATE.value.length == 0){ alert("You must enter a your state!"); f.PICKUP_STATE.focus(); return false; }else{ if (!nameOK(f.PICKUP_STATE.value)){ alert("State field contains invalid characters, such as an apostrophe or a \" or \\\n Please re-enter your information without the invalid character."); f.PICKUP_STATE.focus(); return false; } } if (f.DESTINATION_CITY.value.length == 0){ alert("Please tell us the city of your destination!"); f.DESTINATION_CITY.focus(); return false; }else{ if (!nameOK(f.DESTINATION_CITY.value)){ alert("The city you entered contains invalid characters, such as an apostrophe or a \" or \\\n Please re-enter your information without the invalid character."); f.DESTINATION_CITY.focus(); return false; } } if (f.DESTINATION_STATE.value.length == 0){ alert("You must enter a your state!"); f.DESTINATION_STATE.focus(); return false; }else{ if (!nameOK(f.DESTINATION_STATE.value)){ alert("State field contains invalid characters, such as an apostrophe or a \" or \\\n Please re-enter your information without the invalid character."); f.DESTINATION_STATE.focus(); return false; } } //LET'S SET THE VALUE OF THE HIDDEN FIELDS BEFORE SUBMITTING THE FORM var bw=new cm_bwcheck(); if (!bw.ns4){ document.limoRequest.AIRLINE_H_PICKUP.value=document.limoRequest.AIRLINE_PICKUP.value; document.limoRequest.FLIGHT_H_PICKUP.value=document.limoRequest.FLIGHT_PICKUP.value; document.limoRequest.FLIGHT_H_DROPOFF.value=document.limoRequest.FLIGHT_DROPOFF.value; document.limoRequest.AIRLINE_H_DROPOFF.value=document.limoRequest.AIRLINE_DROPOFF.value; } return true; } function teleOK(s){ var test = "" + s; for (var k = 0; k = 1 character before @, so we // start looking at character position 1 // (i.e. second character) var i = 1; var sLength = s.length; // look for @ while ((i < sLength) && (s.charAt(i) != "@")) { i++ } if ((i >= sLength) || (s.charAt(i) != "@")) return false; else i += 2; //check for apostrophe var test = "" + s; for (var k = 0; k = sLength - 1) || (s.charAt(i) != ".")) return false; else return true; } function nameOK(v){ var test = "" + v; for (var k = 0; k returns style object // given a string containing the id of an object // the function returns the stylesheet of that object // or false if it can't find a stylesheet. Handles // cross-browser compatibility issues. // function getStyleObject(objectId) { // checkW3C DOM, then MSIE 4, then NN 4. // if(document.getElementById && document.getElementById(objectId)) { return document.getElementById(objectId).style; } else if (document.all && document.all(objectId)) { return document.all(objectId).style; } else if (document.layers && document.layers[objectId]) { return document.layers[objectId]; } else { return false; } } function changeObjectVisibility(objectId, newVisibility) { // first get a reference to the cross-browser style object // and make sure the object exists var styleObject = getStyleObject(objectId); if(styleObject) { styleObject.visibility = newVisibility; return true; } else { // we couldn't find the object, so we can't change its visibility return false; } } function load_me() { if (str!="") { document.limoRequest.EVENT_TYPE.options[0].value=str; document.limoRequest.EVENT_TYPE.options[0].text=str; wrInfo(); } } // -->