var global_location = "/modustpl/_secureXMLReq.php"; var global_url = ""; function contact_us(a, b) { if(a) { divShowIsShown = false; divShowWaitStop(); divShowWaitMask.style.display = "none"; divShowIframe.style.display = "none"; if(b == "0") { // blacklisted IP address, blacklisted words or phrases, missing, invalid or maxlength fields var error_message = req.responseXML.getElementsByTagName("error_message")[0].firstChild.data; var error_field = req.responseXML.getElementsByTagName("error_field")[0].firstChild.data; alert(error_message); document.getElementById(error_field).focus(); document.getElementById('cu_submit').disabled = false; } else if(b == "1") { // success alert("Your request more information form has been submitted."); document.getElementById("cu_submit").disabled = false; } else if(b == "2") { // email failed, requires confirmation var error_message = req.responseXML.getElementsByTagName("error_message")[0].firstChild.data; var error_field = req.responseXML.getElementsByTagName("error_field")[0].firstChild.data; var yes = confirm(error_message); if(yes) { divShowIsShown = true; divShowWaitStart(); var url_tmp = global_url + "&email_verify=1"; lXML(global_location, url_tmp); } else { document.getElementById(error_field).focus(); document.getElementById('cu_submit').disabled = false; } } } else { divShowIsShown = true; document.getElementById("cu_submit").disabled = true; var return_flag = true; var focus_flag = true; var url = "pid=6"; var error_message = "A problem with the fields listed below was encountered:\n\n"; if(document.getElementById("cu_firstName").value.length > 0) { url += "&cu_firstName=" + encodeURIComponent(document.getElementById("cu_firstName").value); } else { if(focus_flag) { focus_flag = false; document.getElementById("cu_firstName").focus(); } error_message += "'First Name' field missing content.\n"; return_flag = false; } if(document.getElementById("cu_lastName").value.length > 0) { url += "&cu_lastName=" + encodeURIComponent(document.getElementById("cu_lastName").value); } else { if(focus_flag) { focus_flag = false; document.getElementById("cu_lastName").focus(); } error_message += "'Last Name' field missing content.\n"; return_flag = false; } if(document.getElementById("cu_phoneDay").value.length > 0) { url += "&cu_phoneDay=" + encodeURIComponent(document.getElementById("cu_phoneDay").value); } else { if(focus_flag) { focus_flag = false; document.getElementById("cu_phoneDay").focus(); } error_message += "'Daytime Phone' field missing content.\n"; return_flag = false; } if(document.getElementById("cu_email").value.length > 0) { if((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,7})+$/.test(document.getElementById("cu_email").value))) { url += "&cu_email=" + encodeURIComponent(document.getElementById("cu_email").value); } else { if(focus_flag) { focus_flag = false; document.getElementById("cu_email").focus(); } error_message += "\'Email\' field invalid.\n"; return_flag = false; } } else { if(focus_flag) { focus_flag = false; document.getElementById("cu_email").focus(); } error_message += "'Email' field missing content.\n"; return_flag = false; } if(ismaxlength(document.getElementById("cu_otherInformation").value, 1024)) { url += "&cu_otherInformation=" + encodeURIComponent(document.getElementById("cu_otherInformation").value); } else { if(focus_flag) { focus_flag = false; document.getElementById("cu_otherInformation").focus(); } error_message += "'Other Information' field exceeded its maximum length of 1024 characters.\n"; return_flag = false; } if(!return_flag) { alert(error_message); document.getElementById("cu_submit").disabled = false; return false; } else { url += "&cu_aproxNumberOfTravelers=" + encodeURIComponent($("#cu_aproxNumberOfTravelers").val()); url += "&cu_howOftenDoYouTravel=" + encodeURIComponent($("#cu_howOftenDoYouTravel").val()); url += "&cu_phoneEvening=" + encodeURIComponent(document.getElementById("cu_phoneEvening").value); url += "&cu_departure=" + encodeURIComponent(document.getElementById("cu_departure").value); url += "&cu_destination=" + encodeURIComponent(document.getElementById("cu_destination").value); url += "&cu_departureDate=" + encodeURIComponent(document.getElementById("cu_departureDate").value); global_url = url; var url_tmp = global_url + "&emailVerify=0"; divShowWaitStart(); //lXML(global_location, url_tmp); $.ajax({ type: "POST", async: false, data: url_tmp, url: "/moduslib/bis/company_contact_submit.php", success: function (dat) { alert(dat); } }); divShowWaitStop(); } } } // Given two dates (in seconds) find out if date1 is bigger, date2 is bigger or they're // the same, taking only the dates, not the time into account. In other words, different // times on the same date returns equal. returns -1 for date1 bigger, 1 for date2 is bigger // 0 for equal. function compareDatesOnly(date1, date2) { var year1 = date1.getYear(); var year2 = date2.getYear(); var month1 = date1.getMonth(); var month2 = date2.getMonth(); var day1 = date1.getDate(); var day2 = date2.getDate(); if(year1 > year2) { return -1; } if(year2 > year1) { return 1; } //years are equal if(month1 > month2) { return -1; } if(month2 > month1) { return 1; } //years and months are equal if(day1 > day2) { return -1; } if(day2 > day1) { return 1; } //days are equal return 0; } // Cant choose days after the end date if it is choosen, hilights start and end dates with one style and dates between them with another. function packagesNotBeforeToday(date) { //disable days prior to today var today = new Date(); var compareToday = compareDatesOnly(date, today); if(compareToday > 0) { return(true); } // all other days are enabled return false; } Zapatec.Calendar.setup({ weekNumbers:false, electric:false, inputField:"cu_departureDate", button:"cu_departureDateImg", ifFormat:"%Y-%m-%d", daFormat:"%Y-%m-%d", //numberMonths:3, //controlMonth:1, dateStatusFunc:packagesNotBeforeToday // function to call });