var options; var posX = 0; var posY = 0; var qeIbuttonX = '
'; function addCorners() { var cornerSizeTop = document.qeForm.qeCornerSizeTop.value; var cornerSizeBottom = document.qeForm.qeCornerSizeBottom.value; if (cornerSizeTop > 0) { $('div.qeCollectionLabel').corner('top '+cornerSizeTop+'px'); } if (cornerSizeBottom > 0) { $('div.qeCollectionBody').corner('bottom '+cornerSizeBottom+'px'); } } function fadeCheck() { if (isExisting(document.qeForm.qeFadeEffectON)) { if (document.qeForm.qeFadeEffectON.value == "Y") { return true; } else { return false; } } else { return true; } } // wait for the DOM to be loaded $(document).ready(function() { $('body').append(''); if (fadeCheck()) { $("#qeTrips").fadeIn(1500); } options = { beforeSubmit: preSubmitForm, success: validateForm // post-submit callback }; addCorners(); // bind form using ajaxForm $('#qeForm').ajaxForm(options); $('#qeTrips').click(function(e) { posX = e.pageX-10; posY = e.pageY-10; }); $("#qeAlertMSG").dialog({ autoOpen: false, bgiframe: true, modal: true, buttons: { OK: function() { $(this).dialog('close'); showAllSelectBoxs(); } } }); $("#qeConfirmMSG").dialog({ autoOpen: false, bgiframe: true, modal: true, buttons: { OK: function() { $(this).dialog('close'); showAllSelectBoxs(); }, Cancel: function() { $(this).dialog('close'); showAllSelectBoxs(); } } }); $("#qeLoadingMSG").dialog({ autoOpen: false, bgiframe: true, modal: true }); }); function returnToQuote(stepNumber) { var stepID = stepNumber; var qeEvent = "getStep_"+stepNumber; var tripsID = document.qeForm.tripsID.value; var currentStep = document.qeForm.currentStep.value; if (fadeCheck()) { $("#qeTrips").fadeOut(2000); } document.location = currentStep+"?tripsID="+tripsID+"&stepID="+stepID+"&qeEvent="+qeEvent; } function getEmailAQuoteForm() { document.qeForm.qeEvent.value = "redirectToEmailAQuoteForm"; $('#qeForm').submit(); document.qeForm.qeEvent.value = "validateForm"; } function newQuote() { document.qeForm.qeEvent.value = "newQuote"; $('#qeForm').submit(); document.qeForm.qeEvent.value = "validateForm"; } function storeQuote() { document.qeForm.qeEvent.value = "storeQuote"; $('#qeForm').submit(); document.qeForm.qeEvent.value = "validateForm"; } function saveQuote() { document.qeForm.qeEvent.value = "saveQuote"; $('#qeForm').submit(); document.qeForm.qeEvent.value = "validateForm"; } function getPreviousStep(stepIDtoUse) { var previousStep; var qeEvent; var tripsID = document.qeForm.tripsID.value; var agentCode = document.qeForm.agentCode.value; var sourceCode = document.qeForm.sourceCode.value; var responseCode = document.qeForm.responseCode.value; var stepID = stepIDtoUse; if (stepID == undefined) { stepID = document.qeForm.stepID.value - 1; } qeEvent = "getStep_"+stepID; if (stepID == 1 || stepID == "CD1" || stepID == "PA1" || stepID == "KH1") { previousStep = document.qeForm.entryPointURL.value; } else if (stepID == "KH2") { previousStep = document.qeForm.khStep2URL.value; } else { previousStep = document.qeForm.previousStep.value; } if (fadeCheck()) { $("#qeTrips").fadeOut(2000); } document.location = previousStep+"?tripsID="+tripsID+"&stepID="+stepID+"&qeEvent="+qeEvent+"&agentCode="+agentCode+"&sourceCode="+sourceCode+"&responseCode="+responseCode; } function getCurrentStep(stepIDtoUse) { var currentStep; var qeEvent; var tripsID = document.qeForm.tripsID.value; var agentCode = document.qeForm.agentCode.value; var sourceCode = document.qeForm.sourceCode.value; var responseCode = document.qeForm.responseCode.value; var stepID = stepIDtoUse; if (stepID == undefined) { stepID = document.qeForm.stepID.value; } qeEvent = "getStep_"+stepID; currentStep = document.qeForm.currentStep.value; if (fadeCheck()) { $("#qeTrips").fadeOut(2000); } document.location = currentStep+"?tripsID="+tripsID+"&stepID="+stepID+"&qeEvent="+qeEvent+"&agentCode="+agentCode+"&sourceCode="+sourceCode+"&responseCode="+responseCode; } function showAlertMSG(alertMSG) { hideAllSelectBoxs(); $("#qeAlertMSG").html(alertMSG); $("#qeAlertMSG").dialog('open'); }; function loadingScreen(loadingType) { if (loadingType == 'start') { // $("#qeForm").fadeOut(500); // $("#qeForm").fadeTo(500,.5); } // add an else if (loadingType == 'nextPage') else { // $("#qeForm").fadeIn(1); $("#qeLoadingMSG").dialog('close'); } } function logThisUpdate() { var formAction = document.qeForm.action; if (formAction.search("/?")) { formAction = formAction+"&"; } else { formAction = formAction+"?"; } formAction = formAction+"haveLoggedStep_"+document.qeForm.stepID.value+"=false"; document.qeForm.action = formAction; return true; } function preSubmitForm() { $('span[class="server-help"]').hide(); $('span[class="server-general"]').hide(); if (isExisting(document.qeForm.localValidation) && document.qeForm.localValidation.value == "true" && document.qeForm.qeEvent.value == "validateForm") { if (localValidation()) { loadingScreen("start"); return true; } else { return false; } } else { loadingScreen("start"); return true; } } function getParameterByName(name) { var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search); return match && decodeURIComponent(match[1].replace(/\+/g, ' ')); } function validateForm(responseText, statusText) { var responseText = xmlTidy(responseText); loadingScreen("end"); var effectOptions = {}; if (left(responseText,9) == 'redirect:') { loadingScreen("start"); if (fadeCheck()) { $("#qeTrips").fadeOut(2000); } var redirectURL = responseText.substring(9); if (getParameterByName("isIframed") == "true") { document.write(''); } else { document.location = redirectURL; } } else if (left(responseText,12) == 'redirect3DS:') { createModelFor3DS(responseText) } else if (left(responseText,12) == 'redirectGBP:') { createModelForGlobalPay(responseText) } else if (left(responseText,8) == 'refresh:') { location.reload(true); } else if (left(responseText,8) == 'errMSGs:') { var errorMSGs = $.parseJSON('[' + responseText.substring(8) + ']'); for(var i = 0; i < errorMSGs.length; i++) { $("#"+errorMSGs[i].id).html(errorMSGs[i].errMSG); $("#"+errorMSGs[i].id).show(); } $('html,body').animate({scrollTop: $('#genericMSG').offset().top}); } else if (left(responseText,12) == 'generalMSGs:') { var generalMSGs = $.parseJSON('[' + responseText.substring(12) + ']'); for(var i = 0; i < generalMSGs.length; i++) { $("#"+generalMSGs[i].id).html(generalMSGs[i].generalMSG); $("#"+generalMSGs[i].id).show(); } $('#generalMSGs').show(); $('html,body').animate({scrollTop: $('#generalMSGs').offset().top}); } else { showAlertMSG(responseText); } // need to rebind $('#qeForm').ajaxForm(options); } function xmlTidy(xmlText) { return trim(xmlText.replace(/&/g,'&')); } function resetMultiSelect(objID){ var selObject=document.getElementById(objID) for (i=0;i 0) { $('div.qeIbuttonTitle').corner('top '+cornerSizeTop+'px'); } if (cornerSizeBottom > 0) { $('div.qeIbuttonText').corner('bottom '+cornerSizeBottom+'px'); } $('#qeIbuttonX').click(function() { $('#qeIbuttonCollection').hide(); showAllSelectBoxs(); }); }); } function getHoverTip(translationMode,iButtonName,iButtonValue, tip) { var iButtonCall = document.qeForm.iButtonPath.value+"&iButton="+iButtonName+"_"+iButtonValue+"&translationMode="+translationMode+"&style=hover"; $.get(iButtonCall, function (data) { tip.html(data); }); return ''; } function hideAllSelectBoxs() { /*@cc_on @if (@_jscript_version <= 5.6) var x = document.getElementsByTagName("select"); for (i = 0; i < x.length; i++) { x[i].style.display = "none"; } /*@end @*/ } function showAllSelectBoxs() { /*@cc_on @if (@_jscript_version <= 5.6) var x = document.getElementsByTagName("select"); for (i = 0; i < x.length; i++) { x[i].style.display = "block"; } /*@end @*/ } function left(str, n){ if (n <= 0) return ""; else if (n > String(str).length) return str; else return String(str).substring(0,n); } function right(str, n){ if (n <= 0) return ""; else if (n > String(str).length) return str; else { var iLen = String(str).length; return String(str).substring(iLen, iLen - n); } } function isExisting(obj){ return typeof(eval(obj))!='undefined'; } function lTrim(str) { var whitespace = new String(" \t\n\r"); var s = new String(str); if (whitespace.indexOf(s.charAt(0)) != -1) { var j=0, i = s.length; while (j < i && whitespace.indexOf(s.charAt(j)) != -1) j++; s = s.substring(j, i); } return s; } function rTrim(str) { var whitespace = new String(" \t\n\r"); var s = new String(str); if (whitespace.indexOf(s.charAt(s.length-1)) != -1) { var i = s.length - 1; while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) i--; s = s.substring(0, i+1); } return s; } function trim(str) { return rTrim(lTrim(str)); } function updatePrivacy() { if (isExisting(document.qeForm.privacyCatcher)) { if (document.qeForm.privacyCatcher.checked) { document.qeForm.privacy.value = "Y"; } else { document.qeForm.privacy.value = "N"; } } } function updateWinterSports() { if (isExisting(document.qeForm.winterSportsCatcher)) { if (document.qeForm.winterSportsCatcher.checked) { document.qeForm.winterSports.value = "Y"; } else { document.qeForm.winterSports.value = "N"; } } } function updateMarketingProfile() { if (isExisting(document.qeForm.marketingProfileCatcher)) { if (document.qeForm.marketingProfileCatcher.checked) { document.qeForm.marketingProfile.value = "Y"; } else { document.qeForm.marketingProfile.value = "N"; } } } function updateCardConsent() { if (isExisting(document.qeForm.cardConsentCatcher)) { if (document.qeForm.cardConsentCatcher.checked) { document.qeForm.cardConsent.value = "N"; } else { document.qeForm.cardConsent.value = "Y"; } } } function updateMarketingConsent() { if (isExisting(document.qeForm.marketingConsentCatcher)) { if (document.qeForm.marketingConsentCatcher.checked) { document.qeForm.marketingConsent.value = "N"; } else { document.qeForm.marketingConsent.value = "Y"; } } } function updateMarketingConsentEAQ() { if (isExisting(document.qeForm.marketingConsentCatcherEAQ)) { if (document.qeForm.marketingConsentCatcherEAQ.checked) { document.qeForm.marketingConsentEAQ.value = "Y"; } else { document.qeForm.marketingConsentEAQ.value = "N"; } } } function updateMarketingConsentNoEAQ() { if (isExisting(document.qeForm.marketingConsentCatcherEAQ)) { if (document.qeForm.marketingConsentCatcherEAQ.checked) { document.qeForm.marketingConsentEAQ.value = "N"; } else { document.qeForm.marketingConsentEAQ.value = "Y"; } } } /* use jQuery as container for more convenience */ (function($) { /** * Create a popunder * * @param sUrl Url to open as popunder * * @return jQuery */ $.popunder = function(sUrl,iWidth,iHeight) { var bSimple = $.browser.msie, run = function() { $.popunderHelper.open(sUrl, bSimple, iWidth, iHeight); }; (bSimple) ? run() : window.setTimeout(run, 1); return $; }; /* several helper functions */ $.popunderHelper = { /** * Helper to create a (optionally) random value with prefix * * @param string name * @param boolean rand * * @return string */ rand: function(name, rand) { var p = (name) ? name : 'pu_'; return p; //return p + (rand === false ? '' : Math.floor(89999999*Math.random()+10000000)); }, /** * Open the popunder * * @param string sUrl The URL to open * @param boolean bSimple Use the simple popunder * * @return boolean */ open: function(sUrl, bSimple, iWidth, iHeight) { var _parent = self, sToolbar = (!$.browser.webkit && (!$.browser.mozilla || parseInt($.browser.version, 10) < 12)) ? 'yes' : 'no', sOptions, popunder; if (top != self) { try { if (top.document.location.toString()) { _parent = top; } } catch(err) { } } /* popunder options */ sOptions = 'toolbar=' + sToolbar + ',scrollbars=yes,location=yes,statusbar=yes,menubar=no,resizable=1,width=' + iWidth.toString(); sOptions += ',height=' + iHeight.toString() + ',screenX=0,screenY=0,left=0,top='+(screen.availHeight - (iHeight+50)).toString(); /* create pop-up from parent context */ popunder = _parent.window.open(sUrl, $.popunderHelper.rand(), sOptions); if (popunder) { popunder.blur(); if (bSimple) { /* classic popunder, used for ie*/ window.focus(); try { opener.window.focus(); } catch (err) { } } else { /* popunder for e.g. ff4+, chrome */ try { popunder.init = function(e) { with (e) { (function() { if (typeof window.mozPaintCount != 'undefined') { var x = window.open('about:blank'); x.close(); } try { opener.window.focus(); } catch (err) { } })(); } }; popunder.params = { url: sUrl }; popunder.init(popunder); } catch(err) {} } } return true; } }; })(jQuery); // return the value of the radio button that is checked // return an empty string if none are checked, or // there are no radio buttons function getCheckedValue(radioObj) { if(!radioObj) return ""; var radioLength = radioObj.length; if(radioLength == undefined) if(radioObj.checked) return radioObj.value; else return ""; for(var i = 0; i < radioLength; i++) { if(radioObj[i].checked) { return radioObj[i].value; } } return ""; } // set the radio button with the given value as being checked // do nothing if there are no radio buttons // if the given value does not exist, all the radio buttons // are reset to unchecked function setCheckedValue(radioObj, newValue) { if(!radioObj) return; var radioLength = radioObj.length; if(radioLength == undefined) { radioObj.checked = (radioObj.value == newValue.toString()); return; } for(var i = 0; i < radioLength; i++) { radioObj[i].checked = false; if(radioObj[i].value == newValue.toString()) { radioObj[i].checked = true; } } } function setContexturalHelp() { $("fieldset span").on( { click: function () { $('fieldset').removeClass('highlighted'); $('span.help').hide(); $(this).parent('fieldset').addClass('highlighted'); $(this).children('span.help').fadeIn('fast'); if ($('#policyTypeOptionHelpText').is(':visible')) { $('#policyTypeOptionHelpText').hide(); } }, focusin: function () { $(this).parent('fieldset').addClass('highlighted'); $(this).children('span.help').fadeIn('fast'); }, focusout: function () { $(this).parent('fieldset').removeClass('highlighted'); $('.help').fadeOut('fast'); }, blur: function () { $(this).parent('fieldset').removeClass('highlighted'); $('.help').fadeOut('fast'); } }); } /* * Date Format 1.2.3 * (c) 2007-2009 Steven Levithan * MIT license * * Includes enhancements by Scott Trenda * and Kris Kowal * * Accepts a date, a mask, or a date and a mask. * Returns a formatted version of the given date. * The date defaults to the current date/time. * The mask defaults to dateFormat.masks.default. */ var dateFormat = function () { var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g, timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, timezoneClip = /[^-+\dA-Z]/g, pad = function (val, len) { val = String(val); len = len || 2; while (val.length < len) val = "0" + val; return val; }; // Regexes and supporting functions are cached through closure return function (date, mask, utc) { var dF = dateFormat; // You can't provide utc if you skip other args (use the "UTC:" mask prefix) if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) { mask = date; date = undefined; } // Passing date through Date applies Date.parse, if necessary date = date ? new Date(date) : new Date; if (isNaN(date)) throw SyntaxError("invalid date"); mask = String(dF.masks[mask] || mask || dF.masks["default"]); // Allow setting the utc argument via the mask if (mask.slice(0, 4) == "UTC:") { mask = mask.slice(4); utc = true; } var _ = utc ? "getUTC" : "get", d = date[_ + "Date"](), D = date[_ + "Day"](), m = date[_ + "Month"](), y = date[_ + "FullYear"](), H = date[_ + "Hours"](), M = date[_ + "Minutes"](), s = date[_ + "Seconds"](), L = date[_ + "Milliseconds"](), o = utc ? 0 : date.getTimezoneOffset(), flags = { d: d, dd: pad(d), ddd: dF.i18n.dayNames[D], dddd: dF.i18n.dayNames[D + 7], m: m + 1, mm: pad(m + 1), mmm: dF.i18n.monthNames[m], mmmm: dF.i18n.monthNames[m + 12], yy: String(y).slice(2), yyyy: y, h: H % 12 || 12, hh: pad(H % 12 || 12), H: H, HH: pad(H), M: M, MM: pad(M), s: s, ss: pad(s), l: pad(L, 3), L: pad(L > 99 ? Math.round(L / 10) : L), t: H < 12 ? "a" : "p", tt: H < 12 ? "am" : "pm", T: H < 12 ? "A" : "P", TT: H < 12 ? "AM" : "PM", Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""), o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4), S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10] }; return mask.replace(token, function ($0) { return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1); }); }; }(); // Some common format strings dateFormat.masks = { "default": "ddd mmm dd yyyy HH:MM:ss", shortDate: "m/d/yy", mediumDate: "mmm d, yyyy", longDate: "mmmm d, yyyy", fullDate: "dddd, mmmm d, yyyy", shortTime: "h:MM TT", mediumTime: "h:MM:ss TT", longTime: "h:MM:ss TT Z", isoDate: "yyyy-mm-dd", isoTime: "HH:MM:ss", isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" }; // Internationalization strings dateFormat.i18n = { dayNames: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], monthNames: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ] }; // For convenience... Date.prototype.format = function (mask, utc) { return dateFormat(this, mask, utc); }; function isLeapYear(yr) {return !((yr % 4) || (!(yr % 100) && (yr % 400)));} function getMaxDayInMonth(yyyy, mm) { var maxDay = 31; if (mm == 2) { if (isLeapYear(yyyy)) { maxDay = 29; } else { maxDay = 28; } } else if (mm == 4 || mm == 6 || mm == 9 || mm == 11) { maxDay = 30; } return maxDay; } function updateDate() { var thisDate = $(this).prop("id").split("_")[0]; var dayTMP = $("#"+thisDate+"_Day").val(); var monthTMP = $("#"+thisDate+"_Month").val(); var yearTMP = $("#"+thisDate+"_Year").val(); var maxDay = getMaxDayInMonth(yearTMP,monthTMP); if (dayTMP > maxDay) { dayTMP = maxDay; $("#"+thisDate+"_Day").val(dayTMP); } var newDate = new Date(yearTMP,monthTMP-1,dayTMP); $("#"+thisDate+"_unformatted").val(newDate.format("yyyy-mm-dd")); $("#"+thisDate).val(newDate.format($("#dateFormat").val())); } function iefixes() { if ($('html').hasClass('ie8')) { $(".form label").click(function() { $(this).closest('.form').find('label').removeClass('active'); $(this).addClass('active'); }); $("input[type='radio']").each(function(){ if ($(this).is(':checked')) { $(this).find('+ label').addClass('active'); } }); $('.modal-close').click(function() { $('.modal-window').css('display', 'none'); }); } } function setQeEvent(qeEvent) { document.qeForm.qeEvent.value = qeEvent; return true; } function modalEmailAQuote() { setQeEvent('redirectToEmailAQuoteForm'); options.success = createModelForEmailAQuote; if (isExisting(document.qeForm.qeButtonBuyNow)) { document.qeForm.qeButtonBuyNow.disabled=true; } $('#qeForm').submit(); if (isExisting(document.qeForm.qeButtonBuyNow)) { document.qeForm.qeButtonBuyNow.disabled=false; } options.success = validateForm; document.qeForm.qeEvent.value = "validateForm"; } function createModelForEmailAQuote(responseText, statusText) { loadingScreen("end"); responseText2 = xmlTidy(responseText); if (left(responseText2,9) == 'redirect:') { var redirectURL = responseText2.substring(9); $('#qeForm').ajaxForm(options); $('#emailAQuoteModalIFrame').attr('src',redirectURL); $('#emailAQuoteModal').prop('checked', true); $('body').addClass('modal-open'); if ($('html').hasClass('ie8')) { $('.modal-window').css('display', 'block'); } return true; } else { validateForm(responseText, "") } } function closeModalFromIFrame(modalCloseButton) { $('body').removeClass('modal-open'); if ($('html').hasClass('ie8')) { $('.modal-window').css('display', 'none'); } var btnClose = parent.document.getElementById(modalCloseButton); btnClose.click(); return false; } function getParameterByName(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, " ")); }