/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////JavaScript functions for QuickQuote control. See QuickQuote.onInit() ///////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// var instantQuoteRequestIndex = 0; var quickQuoteStateChanged = false; var groupTypeHelpText = ""; /*** Function to show "Getting Quote..." message to user ***/ function ShowInstantQuoteProgress() { // if (alertSetIntervalId != null) // clearInterval(alertSetIntervalId); //document.getElementById("QuickQuoteStateChanged").innerHTML = ""; //document.getElementById("QuoteRate").innerHTML = "

Getting Quote...

"; //var d = new Date(); //m = d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + ":" + d.getMilliseconds(); //document.getElementById("QuoteRate").innerHTML += "

" + m + "

"; } ////////////////////////////////////////// var instantQuoteResults; var getQuickQuotes = false; /*** Function to do callbacks on click of "Get Quote Now" click ***/ function OnGetQuickQuoteClick(txtDurationId) { if (document.getElementById(txtDurationId) != null) if (document.getElementById(txtDurationId).value.length == 0 || parseInt(document.getElementById(txtDurationId).value) == 0 ) document.getElementById(txtDurationId).value = oldDurationValue; //alert(document.getElementById("quotes").className); if (document.getElementById("quotes").className == "hidden_div") { RequestGroupType('GroupType', ++groupTypeRequestIndex); //RequestInstantQuote('InstantQuote', ++instantQuoteRequestIndex); getQuickQuotes = true; } else { DisableInstantQuotes(); RequestGroupType('GroupType', ++groupTypeRequestIndex); } } /*** Function to process QuickQuote callback result, to display quotes. It displays quotes along with benefit limits. Background image of the div that displays the quotes depends on the number of InstantQuotes returned. ***/ function ReceiveInstantQuote(arg, context) { instantQuoteResults = eval("(" + arg + ")"); quickQuoteStateChanged = false; var focusOnQuote = false; //Show Get Quote Now button document.getElementById(instantQuoteResults.InstantQuoteButtonClientId).src = quickQuotePreloadedImages[0]; //alert(instantQuoteResults.InstantQuoteRequestId); if(instantQuoteResults.InstantQuoteRequestId == instantQuoteRequestIndex) { var quoteHTML = ""; var errorMessages = ""; var errorId = 0; if (instantQuoteResults.ValidationErrors.length > 0) //Validation Error { for(errorIndex = 0; errorIndex < instantQuoteResults.ValidationErrors.length; errorIndex++) if (instantQuoteResults.ValidationErrors[errorIndex] != "Departure date should not exceed Agent-scheme LastDeparture date") { errorId++; if (errorId <= 2) //Show maximum 2 error messages errorMessages += instantQuoteResults.ValidationErrors[errorIndex] + ".
"; else break; } document.getElementById(instantQuotesControls[instantQuotesControls.length - 1]).innerHTML = errorMessages; //document.getElementById("quotes").className = "hidden_div"; } else if (instantQuoteResults.InstantQuotes.length > 0) { document.getElementById(instantQuotesControls[instantQuotesControls.length - 1]).innerHTML = ""; if (document.getElementById("quotes").className == "hidden_div") focusOnQuote = true; document.getElementById("quotes").className = "visible_div"; //document.getElementById("instantQuoteBackground").className = "quotes_bg" + instantQuoteResults.InstantQuotes.length; var bgImage = "url('siteimages/bg" + instantQuoteResults.InstantQuotes.length + "_quote.gif')"; document.getElementById("quotes").style.backgroundImage = bgImage; //instantQuoteBackground for(quoteIndex = 0; quoteIndex < instantQuoteResults.InstantQuotes.length; quoteIndex++) { if (instantQuoteResults.InstantQuotes[quoteIndex].SchemeName.length <= 20) document.getElementById(instantQuotesControls[(quoteIndex * 3)]).innerHTML = "" + instantQuoteResults.InstantQuotes[quoteIndex].SchemeName + "
" + instantQuoteResults.InstantQuotes[quoteIndex].CoverLevelName + "
" else document.getElementById(instantQuotesControls[(quoteIndex * 3)]).innerHTML = "" + instantQuoteResults.InstantQuotes[quoteIndex].SchemeName + " - " + instantQuoteResults.InstantQuotes[quoteIndex].CoverLevelName + "" document.getElementById(instantQuotesControls[(quoteIndex * 3) + 1]).innerHTML = "

" + instantQuoteResults.InstantQuotes[quoteIndex].DestinationName + "

" document.getElementById(instantQuotesControls[(quoteIndex * 3) + 2]).innerHTML = "

£" + instantQuoteResults.InstantQuotes[quoteIndex].GrandTotal.toFixed(2) + "

" // for(var ratingIndex = 1; ratingIndex <= instantQuoteResults.InstantQuotes[quoteIndex].Rating; ratingIndex++) // document.getElementById('dot_' + (quoteIndex + 1) + "_" + ratingIndex).style.display = ""; //block // // for(ratingIndex = instantQuoteResults.InstantQuotes[quoteIndex].Rating + 1; ratingIndex <= 5; ratingIndex++) // document.getElementById('dot_' + (quoteIndex + 1) + "_" + ratingIndex).style.display = "none"; // // document.getElementById("lnkBuy" + (quoteIndex + 1)).disabled = false; // document.getElementById("lnkSave" + (quoteIndex + 1)).disabled = false; // document.getElementById('lnkBuy' + (quoteIndex + 1)).style.display = ""; //block // document.getElementById('lnkSave' + (quoteIndex + 1)).style.display = ""; //block document.getElementById(instantQuoteBuyButtons[quoteIndex]).disabled = false; document.getElementById(instantQuoteBuyButtons[quoteIndex]).style.display = ""; if (document.getElementById(instantQuoteSaveButtons[quoteIndex])) //If Save buttons are not hidden { document.getElementById(instantQuoteSaveButtons[quoteIndex]).disabled = false; document.getElementById(instantQuoteSaveButtons[quoteIndex]).style.display = ""; } document.getElementById('btn_buy_grey_' + (quoteIndex + 1)).style.display = "none"; document.getElementById("btn_save_disabled_" + (quoteIndex+1)).style.display = "none"; //DisplayBenefitLimits if (instantQuoteResults.InstantQuotes[quoteIndex].BenefitLimits.length > 0) { //alert(instantQuoteResults.InstantQuotes[quoteIndex].BenefitLimits.length); var benefitlimit_name = document.getElementById("benefitlimit_name"); var benefitLimitInnerHtml = ""; if (quoteIndex == 0) //BenefitLimit names - only in first column { for(var benefitlimitIndex = 0; benefitlimitIndex < instantQuoteResults.InstantQuotes[quoteIndex].BenefitLimits.length; benefitlimitIndex++) { benefitLimitInnerHtml += "
" + instantQuoteResults.InstantQuotes[quoteIndex].BenefitLimits[benefitlimitIndex].Name; if (benefitlimitIndex == 0) benefitLimitInnerHtml += ""; benefitLimitInnerHtml += "
"; var helpImage = (benefitlimitIndex + 1) % 2 == 0 ? quickQuotePreloadedImages[6] : quickQuotePreloadedImages[7]; //benefitLimitInnerHtml += "
" + " "; benefitLimitInnerHtml += "
" + " "; benefitLimitInnerHtml += "
"; //benefitLimitInnerHtml += "
"; if (benefitlimitIndex != instantQuoteResults.InstantQuotes[quoteIndex].BenefitLimits.length - 1) benefitLimitInnerHtml += "
"; } benefitlimit_name.innerHTML = benefitLimitInnerHtml; } //Each InstantQuote will have BenefitLimits, display all BenefitLimit texts for current InstantQuote var benefitlimit_limittext = document.getElementById("benefitlimit_limittext" + (quoteIndex + 1)); benefitLimitInnerHtml = ""; for(var benefitlimitIndex = 0; benefitlimitIndex < instantQuoteResults.InstantQuotes[quoteIndex].BenefitLimits.length; benefitlimitIndex++) { var limitText = instantQuoteResults.InstantQuotes[quoteIndex].BenefitLimits[benefitlimitIndex].LimitText; if (limitText == "No Cover") limitText = "No Cover"; else if(limitText == "Included" || limitText == "Optional") limitText = "" + limitText + ""; //limitText = "Included"; if (instantQuoteResults.InstantQuotes[quoteIndex].BenefitLimits[benefitlimitIndex].HelpText != null) { //
//benefitLimitInnerHtml += "
" + instantQuoteResults.InstantQuotes[quoteIndex].BenefitLimits[benefitlimitIndex].LimitText //+ "
"; benefitLimitInnerHtml += "
"; //benefitLimitInnerHtml += ""; //if (instantQuoteResults.InstantQuotes[quoteIndex].BenefitLimits[benefitlimitIndex].HelpText != null) //{ var helpImage = (benefitlimitIndex + 1) % 2 == 0 ? quickQuotePreloadedImages[6] : quickQuotePreloadedImages[7]; //benefitLimitInnerHtml += "
" benefitLimitInnerHtml += "
" + limitText + " 
"; benefitLimitInnerHtml += "
"; //benefitLimitInnerHtml += "
"; } else benefitLimitInnerHtml += "
" + limitText + "
"; //benefitLimitInnerHtml += "
"; } benefitLimitInnerHtml += "
"; //benefitLimitInnerHtml += "
"; benefitlimit_limittext.innerHTML = benefitLimitInnerHtml; var bottompremium = document.getElementById("bottompremium" + (quoteIndex + 1)); bottompremium.innerHTML = "

£" + instantQuoteResults.InstantQuotes[quoteIndex].GrandTotal.toFixed(2) + "

"; } else alert("No benefitlimits"); //end DisplayBenefitLimits } //END for(quoteIndex = 0; quoteIndex < instantQuoteResults.InstantQuotes.length; ........ for(quoteIndex = instantQuoteResults.InstantQuotes.length; quoteIndex < 4; quoteIndex++) { document.getElementById(instantQuotesControls[(quoteIndex * 3)]).innerHTML = ""; //Scheme Name and Cover Level Name document.getElementById(instantQuotesControls[(quoteIndex * 3) + 1]).innerHTML = ""; //Area of travel document.getElementById(instantQuotesControls[(quoteIndex * 3) + 2]).innerHTML = ""; //Total // for(var ratingIndex = 1; ratingIndex <= 5; ratingIndex++) // document.getElementById('dot_' + (quoteIndex + 1) + "_" + ratingIndex).style.display = "none"; document.getElementById("benefitlimit_limittext" + (quoteIndex + 1)).innerHTML = ""; var bottompremium = document.getElementById("bottompremium" + (quoteIndex + 1)); bottompremium.innerHTML = ""; // document.getElementById('lnkBuy' + (quoteIndex + 1)).style.display = "none"; // document.getElementById('lnkSave' + (quoteIndex + 1)).style.display = "none"; document.getElementById(instantQuoteBuyButtons[quoteIndex]).style.display = "none"; if (document.getElementById(instantQuoteSaveButtons[quoteIndex])) //If Save buttons are not hidden document.getElementById(instantQuoteSaveButtons[quoteIndex]).style.display = "none"; document.getElementById('btn_buy_grey_' + (quoteIndex + 1)).style.display = "none"; document.getElementById("btn_save_disabled_" + (quoteIndex+1)).style.display = "none"; } //For IFrame implementation of the control if (instantQuoteResults.CallIFrameJavaScript) { resetiframe(true); if (focusOnQuote) { if (document.getElementById(instantQuoteSaveButtons[0])) setTimeout("document.getElementById(instantQuoteSaveButtons[0]).focus();document.getElementById(instantQuoteSaveButtons[0]).blur();", 200); else setTimeout("document.getElementById(instantQuoteBuyButtons[0]).focus();document.getElementById(instantQuoteBuyButtons[0]).blur();", 200); } } if (focusOnQuote) { if (document.getElementById(instantQuoteSaveButtons[0])) //If Save buttons are not hidden { document.getElementById(instantQuoteSaveButtons[0]).focus(); document.getElementById(instantQuoteSaveButtons[0]).blur(); } else if (document.getElementById(instantQuoteBuyButtons[0])) { document.getElementById(instantQuoteBuyButtons[0]).focus(); document.getElementById(instantQuoteBuyButtons[0]).blur(); } //document.getElementById('quotes').focus(); //document.getElementById('lnkSave1').focus(); } else { if (document.getElementById("txtQuoteFocus"))//(document.getElementById(quickQuoteControls[2].split("$")[0])) { document.getElementById("txtQuoteFocus").focus(); } } } else //Unexpected Error { document.getElementById(instantQuotesControls[instantQuotesControls.length - 1]).innerHTML = "Sorry, could not generate a quick quote. Please try again."; } } } ////////////////////////////////////// /* function to return BenefitLimitText based on given instantQuoteIndex and benefitLimitIndex from instantQuoteResults.InstantQuotes */ function GetDescriptionForBenefitLimit(instantQuoteIndex, benefitLimitIndex) { if (instantQuoteResults != null && instantQuoteResults.InstantQuotes.length > 0) { return "
" + instantQuoteResults.InstantQuotes[instantQuoteIndex].BenefitLimits[benefitLimitIndex].Name + "

" + instantQuoteResults.InstantQuotes[instantQuoteIndex].BenefitLimits[benefitLimitIndex].Description + "

"; } } ////////////////////////////////////// /* function to return HelpText for BenefitLimit based on given instantQuoteIndex and benefitLimitIndex from instantQuoteResults.InstantQuotes */ function GetHelpTextForBenefitLimit(instantQuoteIndex, benefitLimitIndex) { if (instantQuoteResults != null && instantQuoteResults.InstantQuotes.length > 0) return "
" + instantQuoteResults.InstantQuotes[instantQuoteIndex].BenefitLimits[benefitLimitIndex].LimitText + "

" + instantQuoteResults.InstantQuotes[instantQuoteIndex].BenefitLimits[benefitLimitIndex].HelpText; } ////////////////////////////////////// /*** Function to process errors during callback ***/ function ReceiveInstantQuoteError(arg, context) { //alert(arg); //document.getElementById("QuoteRate").innerHTML = ""; document.getElementById(instantQuotesControls[instantQuotesControls.length - 1]).innerHTML = ""; alert("Sorry, an unexpected error has occured. Please try again."); } ////////////////////////////////////////// /*** Function called when the user clicks on any of the "Buy" button on instant quotes ***/ function BuyInstantQuote(instantQuoteId) { if (instantQuoteResults != null) { //instantQuoteResults has the callback result, See ReceiveInstantQuote() var instantQuote = instantQuoteResults.InstantQuotes[instantQuoteId - 1]; BuyQuote(instantQuote.SchemeId, instantQuote.CoverLevelId, instantQuote.AreaOfTravelId, instantQuote.DestinationName, instantQuote.DestinationInternalName, instantQuoteResults.QuoteSetId, instantQuoteResults.QuickQuoteButtonClientId); } } function BuyQuote(schemeId, coverLevelId, areaOfTravelId, destinationName, destinationInternalName, quoteSetId, btnQuickQuoteId) { //alert(coverLevelId); var eventArg = schemeId + "|" + coverLevelId + "|" + areaOfTravelId + "|" + destinationName + "|" + destinationInternalName + "|" + quoteSetId; document.getElementById("__EVENTARGUMENT").value = eventArg; //document.getElementById(btnQuickQuoteId).click(); //__doPostBack(btnQuickQuoteId, eventArg); } ////////////////////////////////////////// /*** Function called when the user clicks on any of the "Save" button on instant quotes ***/ function SaveInstantQuote(instantQuoteId) { if (instantQuoteResults != null) { //instantQuoteResults has the callback result, See ReceiveInstantQuote() var instantQuote = instantQuoteResults.InstantQuotes[instantQuoteId - 1]; SaveQuote(instantQuote.SchemeId, instantQuote.CoverLevelId, instantQuote.AreaOfTravelId, instantQuote.DestinationName, instantQuote.DestinationInternalName, instantQuoteResults.QuoteSetId, instantQuoteResults.SaveQuickQuoteButtonClientId); } } /*** Function called from SaveInstantQuote() ***/ function SaveQuote(schemeId, coverLevelId, areaOfTravelId, destinationName, destinationInternalName, quoteSetId, btnSaveQuickQuoteId) { //alert(coverLevelId); var eventArg = schemeId + "|" + coverLevelId + "|" + areaOfTravelId + "|" + destinationName + "|" + destinationInternalName + "|" + quoteSetId; __doPostBack(btnSaveQuickQuoteId, eventArg); } ////////////////////////////////////////// var oldNumberOfTravellers; var newNumberOfTravellers; function SaveNumberOfTravellers(txtAgeBand) { oldNumberOfTravellers = txtAgeBand.value; } function CompareNumberOfTravellers(txtAgeBand) { newNumberOfTravellers = txtAgeBand.value; return (oldNumberOfTravellers != newNumberOfTravellers); } var groupTypeRequestIndex = 0; /*** Function called onKeyUp of when ageband textboxes ***/ function GetGroupType(txtAgeBand) { //txtAgeBand.value.length > 0 && if (! isNaN(txtAgeBand.value)) // && CompareNumberOfTravellers(txtAgeBand)) { RequestGroupType('GroupType', ++groupTypeRequestIndex); } return true; } ////////////////////////////////////////// var TravellerGroupTypeAndLoadings; var policyLoadingSelections = ""; /*** Function to process Group Type callback result. ***/ function ReceiveGroupType(arg, context) { //alert("ReceiveGroupType : " + arg) if (groupTypeControls != null && groupTypeControls.length > 0) { var groupTypeTableRow = groupTypeControls[0]; var groupTypeLabel = groupTypeControls[1]; //var groupTypeCheckBox = groupTypeControls[2]; var groupTypeRadioButtonList = groupTypeControls[2]; var groupTypeHelpPopup = groupTypeControls[5]; var hdnGroupTypeId = groupTypeControls[6]; TravellerGroupTypeAndLoadings = eval("(" + arg + ")"); if (TravellerGroupTypeAndLoadings.GroupType.length > 0) { var groupTypeId = TravellerGroupTypeAndLoadings.GroupType.split("|")[0]; var groupTypeName = TravellerGroupTypeAndLoadings.GroupType.split("|")[1]; var groupTypContextId = TravellerGroupTypeAndLoadings.GroupType.split("|")[2]; if (groupTypContextId == groupTypeRequestIndex) { document.getElementById(groupTypeLabel).style.width = "100%"; document.getElementById(groupTypeLabel).innerHTML = "Travelling as " + groupTypeName + "?"; //"Do you qualify for our " + groupTypeName + " discount?"; switch(groupTypeName.toLowerCase()) { case "couple" : groupTypeHelpText = "

Couple

The main insured and their spouse/common law partner, having resided at the same address for at least six months prior to the date of purchase.

"; break; case "family" : groupTypeHelpText = "

Family

Family cover - includes the main insured, their spouse or common law partner, and their dependent children under 18 years (in full time education and/or residing with them).

"; break; case "spf" : groupTypeHelpText = "

Single Parent Family

An adult parent and their dependent children under 18 years (in full time education and/or residing with them).

"; break; case "companion" : groupTypeHelpText = "

Companion

2 Insured persons on the same policy and travelling together on a Trip.

" break; default : groupTypeHelpText = ""; break; } document.getElementById(groupTypeRadioButtonList + "_0").style.border = "none"; document.getElementById(groupTypeRadioButtonList + "_1").style.border = "none"; document.getElementById(groupTypeRadioButtonList + "_0").value = groupTypeId; document.getElementById(groupTypeRadioButtonList + "_0").checked = false; document.getElementById(groupTypeRadioButtonList + "_1").value = ""; document.getElementById(groupTypeRadioButtonList + "_1").checked = true; document.getElementById(groupTypeRadioButtonList).style.display = "block"; document.getElementById(groupTypeHelpPopup).style.display = "block"; //Restore GroupType state, if new GroupType is same as old one hdnGroupTypeId = document.getElementById(hdnGroupTypeId); //alert("hdnGroupTypeId.value : " + hdnGroupTypeId.value) if (hdnGroupTypeId != null) { if (hdnGroupTypeId.value.length > 0) { if (hdnGroupTypeId.value.split(",")[0] == groupTypeId && hdnGroupTypeId.value.split(",")[1] == "true") { //document.getElementById(groupTypeCheckBox).checked = true; document.getElementById(groupTypeRadioButtonList + "_0").checked = true; } else hdnGroupTypeId.value = ""; } } } //end if (groupTypContextId == groupTypeRequestIndex) } else { document.getElementById(groupTypeLabel).innerHTML = ""; document.getElementById(groupTypeRadioButtonList).style.display = "none"; document.getElementById(groupTypeRadioButtonList + "_0").value = ""; document.getElementById(groupTypeRadioButtonList + "_0").checked = false; document.getElementById(groupTypeRadioButtonList + "_1").value = ""; document.getElementById(groupTypeRadioButtonList + "_1").checked = false; document.getElementById(groupTypeHelpPopup).style.display = "none"; //Clear old GroupType selection hdnGroupTypeId = document.getElementById(hdnGroupTypeId); if (hdnGroupTypeId != null) hdnGroupTypeId.value = ""; } //end if (TravellerGroupTypeAndLoadings.GroupType.length > 0) } //end if (groupTypeControls != null DisplayPolicyLoadings(arg); if (instantQuoteResults != null || getQuickQuotes == true) //&& instantQuoteResults.InstantQuotes.length > 0) { DisableInstantQuotes(); getQuickQuotes == false; setTimeout("RequestInstantQuote('InstantQuote', ++instantQuoteRequestIndex)", 5); } } //END ReceiveGroupType() /////////////////////////////////////// /*** Function to process Group Type callback error. ***/ function ReceiveGroupTypeError(arg, context) { //alert(arg); document.getElementById(instantQuotesControls[instantQuotesControls.length - 1]).innerHTML = ""; alert("Sorry, an unexpected error has occured. Please try again."); } ////////////////////////////////////// /*** Function to show policy loadings for selected scheme ***/ function DisplayPolicyLoadings(travellerGroupTypeAndLoadings) { //alert(travellerGroupTypeAndLoadings); var addLabelForCheckBox = false; var chkLoadingId; TravellerGroupTypeAndLoadings = eval("(" + travellerGroupTypeAndLoadings + ")"); //Display PolicyLoadings //alert(TravellerGroupTypeAndLoadings.PolicyLoading.length) policyLoadingSelections = ""; //Reset old loadingSelections once new types are received from server selectedPolicyLoadingHiddenField = TravellerGroupTypeAndLoadings.SelectedPolicyLoadingHiddenField; document.getElementById(selectedPolicyLoadingHiddenField).value = ""; var loadingHTML = ""; var loadingControls = ""; if (TravellerGroupTypeAndLoadings.PolicyLoading.length > 0) { loadingHTML = ""; //loadingHTML += ""; for(PolicyLoadingIndex = 0; PolicyLoadingIndex < TravellerGroupTypeAndLoadings.PolicyLoading.length; PolicyLoadingIndex++) { addLabelForCheckBox = false; loadingHTML += "" //alert(TravellerGroupTypeAndLoadings.PolicyLoading[quoteIndex].IsQuantityLoading) if (TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].IsQuantityLoading == 1) { loadingHTML += ""; } else //Else of if .....IsQuantityLoading == 1) { loadingControls += ",chkLoading_" + TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Id; chkLoadingId = "chkLoading_" + TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Id; addLabelForCheckBox = true; loadingHTML += "" } //alert(TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].LoadingType == "Winter Sports") //alert(TravellerGroupTypeAndLoadings.IsWinterSportsMandatory == true) if ((TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].LoadingType == "Winter Sports" && TravellerGroupTypeAndLoadings.IsWinterSportsMandatory == true)) loadingHTML += "" //Winter sports help tooltip //if ((TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].LoadingType == "Winter Sports" && TravellerGroupTypeAndLoadings.IsWinterSportsMandatory != true)) //{ if (TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Description != null && TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Description.length > 0) loadingHTML += ""; //} 500, 300 loadingHTML += "" } //end for loadingHTML += "
Additional Benefits (applicable to all Insured)
" if (TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].QuantityMinimum > 0 && TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].QuantityMaximum > 0) { //Create DropDownList //alert(TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Quantity) loadingControls += ",ddlLoading_" + TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Id; loadingHTML += ""; } else { loadingControls += ",txtLoading_" + TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Id; loadingHTML += " 0) loadingHTML += TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Quantity; loadingHTML += "'"; loadingHTML += " onFocus=\"SaveControlState(this.id, 'text');\" " loadingHTML += " onKeyUp=\"CompareControlState(this.id, 'text');\" " loadingHTML += " onBlur=\"GetSelectedLoadingType(" + TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Id + ",this,'textbox');\"> " loadingHTML += TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Unit; } loadingHTML += " 0) loadingHTML += " checked "; if (TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].LoadingType == "Winter Sports" && TravellerGroupTypeAndLoadings.IsWinterSportsMandatory == true) loadingHTML += " checked style='display:none;' "; loadingHTML += " onFocus=\"SaveControlState(this.id, 'checkbox');\" onClick=\"GetSelectedLoadingType(" + TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Id + ",this,'checkbox');CompareControlState(this.id, 'checkbox');\" style='border:none;'> " else loadingHTML += "" if (addLabelForCheckBox) loadingHTML += ""; loadingHTML += "" + TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Name + "

" + TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Description + "

','', " + TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Width + "," + TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Height + ")\" onmouseout=\"hideddrivetip(); QuoteProcessMM_swapImgRestore()\">
" //alert(loadingHTML); } //end if (TravellerGroupTypeAndLoadings.TravellerLoading.length > 0) if ( (loadingHTML.length > 0 && TravellerGroupTypeAndLoadings.IsWinterSportsMandatory == false) || (TravellerGroupTypeAndLoadings.IsWinterSportsMandatory == true && TravellerGroupTypeAndLoadings.PolicyLoading.length > 1) ) loadingHTML = "

Optional extras

" + loadingHTML; document.getElementById("QuickQuotePolicyLoadings").innerHTML = loadingHTML; /*** Get the current state of policy loadings in selectedPolicyLoadingHiddenField ***/ var newloadingControls = loadingControls.split(","); for(var loadingControlIndex = 1; loadingControlIndex < newloadingControls.length; loadingControlIndex++) { var loadingId; var cntrl; var cntrlType; loadingId = newloadingControls[loadingControlIndex].split("_")[1]; cntrl = document.getElementById(newloadingControls[loadingControlIndex]); if (newloadingControls[loadingControlIndex].indexOf("ddlLoading_") != -1) cntrlType = "select"; else if (newloadingControls[loadingControlIndex].indexOf("txtLoading_") != -1) cntrlType = "textbox"; else cntrlType = "checkbox"; //alert(newloadingControls[loadingControlIndex]); GetSelectedLoadingType(loadingId, cntrl, cntrlType); //cntrl.onfocus = SaveControlState; //cntrl.onblur = CompareControlState; } //alert(document.getElementById(selectedPolicyLoadingHiddenField).value); } //END DisplayPolicyLoadings(); ////////////////////////////////////// /*** Function to save selected loading type to selectedPolicyLoadingHiddenField ***/ function GetSelectedLoadingType(loadingId, cntrl, cntrlType) { //alert(cntrlType); switch(cntrlType) { case "textbox" : if (isNaN(cntrl.value)) { alert("Please enter a number"); cntrl.focus(); return false; } RemoveLoadingFromSelection(loadingId, policyLoadingSelections); if (cntrl.value.length > 0) policyLoadingSelections += "|," + loadingId + ",1," + cntrl.value; break; case "checkbox" : RemoveLoadingFromSelection(loadingId, policyLoadingSelections); if (cntrl.checked > 0) policyLoadingSelections += "|," + loadingId + ",0,1" //+ cntrl.checked; break; case "select" : RemoveLoadingFromSelection(loadingId, policyLoadingSelections); policyLoadingSelections += "|," + loadingId + ",1," + cntrl.options[cntrl.selectedIndex].value; break; } //alert("policyLoadingSelections : " + policyLoadingSelections); document.getElementById(selectedPolicyLoadingHiddenField).value = policyLoadingSelections; //alert(document.getElementById(selectedPolicyLoadingHiddenField).value); } ////////////////////////////////////// /*** Function to clear old loading selection ***/ function RemoveLoadingFromSelection(loadingId, currentLoadingSelection) { var newLoadingSelection = ""; //alert("currentLoadingSelection : " + currentLoadingSelection); //alert("loadingId : " + loadingId); if (currentLoadingSelection.indexOf("|," + loadingId + ",") != -1) { var loadingSelection = currentLoadingSelection.split("|"); //alert(loadingSelection); for(loadingIndex = 1; loadingIndex < loadingSelection.length; loadingIndex++) { //alert("loadingSelection[loadingIndex] : " + loadingSelection[loadingIndex]); if (loadingSelection[loadingIndex].indexOf(loadingId + ",") == -1) newLoadingSelection += "|" + loadingSelection[loadingIndex]; } policyLoadingSelections = newLoadingSelection; } } ////////////////////////////////////////// /*** Function to display next year's date in endDatePicker based on startDatePicker value ***/ function UpdateEndDateForYear(startDatePickerId, endDatePickerId) { var startDatePickerTextBox = startDatePickerId + "_input" var endDatePickerTextBox = endDatePickerId + "_input" var noOfDaysToAdd = 364; var startDateValues = document.getElementById(startDatePickerTextBox).value.split("/"); var startMonth = startDateValues[1]; var endDateValues = (DateAdd(document.getElementById(startDatePickerTextBox).value, noOfDaysToAdd)).split("/"); var endYear = endDateValues[2]; //if start month is greater than Feb (>1 in JavaScript) and end year is a leap year if (parseInt(startMonth) > 1 && checkleapyear(endYear)) noOfDaysToAdd = 365; //alert(noOfDaysToAdd); document.getElementById(endDatePickerTextBox).value = DateAdd(document.getElementById(startDatePickerTextBox).value, noOfDaysToAdd) } ////////////////////////////////////////// // function checkleapyear(datea) { datea = parseInt(datea); if(datea%4 == 0) { if(datea%100 != 0) { return true; } else { if(datea%400 == 0) return true; else return false; } } return false; } // ////////////////////////////////////////// /*** Function to save GroupType Id and state and use this to populate new grouptype with old state if both are same ***/ function SaveGroupTypeSelection(chkGroupType, hdnGroupTypeId) { if (document.getElementById(hdnGroupTypeId) != null) document.getElementById(hdnGroupTypeId).value = (chkGroupType.value.length > 0 ? chkGroupType.value + "," + chkGroupType.checked : ",false") ; //alert("In SaveGroupTypeSelection : " + document.getElementById(hdnGroupTypeId).value); } ////////////////////////////////////////// var oldStateofControl, newStateofControl; var showAlertForNewQuote = false; var alertSetIntervalId; /** Function to get the current state of given control **/ function GetControlValue(controlName, controlType) { var currentStateofControl if (controlName.indexOf("_StartDatePicker") != -1 || controlName.indexOf("_EndDatePicker") != -1 ) { var datePickerTextBox = controlName + "_input" currentStateofControl = document.getElementById(datePickerTextBox).value; } else if (controlName.indexOf("_txtDuration") != -1 ) currentStateofControl = document.getElementById(controlName).value; else { switch (controlType) { case "text" : currentStateofControl = document.getElementById(controlName).value; break; case "select-one" : currentStateofControl = document.getElementById(controlName).selectedIndex; break; case "checkbox" : case "radio" : currentStateofControl = document.getElementById(controlName).checked; break; default : currentStateofControl = ""; break; } } return currentStateofControl; } /** Function to save the state of a control onFocus of it **/ function SaveControlState(controlName, controlType) { oldStateofControl = GetControlValue(controlName, controlType); //alert("old state :" + oldStateofControl); //alert(oldStateofControl + "," + newStateofControl); } //END SaveControlState() ////////////////////////////////////////// /*** Function to compare the new state of the control with oldStateofControl(captured on onFocus), on onKeyUp/onChange/onBlur of the control ***/ function CompareControlState(controlName ,controlType) { var updateQuote = false; //alert(controlName); newStateofControl = GetControlValue(controlName, controlType); //alert("new state :" + newStateofControl); //alert(oldStateofControl + "," + newStateofControl); if (controlName.indexOf("chkLoading_") != -1 || controlName.indexOf("ddlLoading_") != -1 || controlName.indexOf("ddlAreaOfTravel") != -1 ) updateQuote = true; if (controlName.indexOf("_txtDuration") != -1) if (document.getElementById(controlName).value.length == 0 || isNaN(document.getElementById(controlName).value)) { //alert("1") //document.getElementById(controlName).value = oldDurationValue; DisableInstantQuotes(); return; } if (controlName.indexOf("_StartDatePicker") != -1 || controlName.indexOf("_EndDatePicker") != -1 ) if (oldStateofControl == "") oldStateofControl = newStateofControl; if ((newStateofControl != oldStateofControl) || updateQuote) { if (instantQuoteResults != null) if (instantQuoteResults.InstantQuotes.length > 0) { //Disable all next buttons instead of hiding all quickquotes if (instantQuoteResults != null) if (instantQuoteResults.InstantQuotes.length > 0) for(btnNextIndex = 0; btnNextIndex < instantQuoteResults.InstantQuotes.length; btnNextIndex++) { document.getElementById(instantQuoteBuyButtons[btnNextIndex]).disabled = true; document.getElementById(instantQuoteBuyButtons[btnNextIndex]).style.display = "none"; document.getElementById("img_greybuy_" + (btnNextIndex+1)).src = instantQuoteGreyButtons[0]; document.getElementById("btn_buy_grey_" + (btnNextIndex+1)).style.display = "block"; if (document.getElementById(instantQuoteSaveButtons[quoteIndex])) //If Save buttons are not hidden { document.getElementById(instantQuoteSaveButtons[btnNextIndex]).disabled = true; document.getElementById(instantQuoteSaveButtons[btnNextIndex]).style.display = "none"; document.getElementById("img_greysave_" + (btnNextIndex+1)).src = instantQuoteGreyButtons[1]; document.getElementById("btn_save_disabled_" + (btnNextIndex+1)).style.display = "block"; } quickQuoteStateChanged = true; } } RequestGroupType('GroupType', ++groupTypeRequestIndex); } oldStateofControl = ""; newStateofControl = ""; } //END CompareControlState() ////////////////////////////////////////// //See global.js QuoteProcessMM_preloadImages for "quickQuotePreloadedImages" initialization. //QuoteProcessMM_preloadImages is called from QuoteManager.OnPreRender() function SwapQuickQuoteImage(btnGetQuickQuoteId) { QuoteProcessMM_swapImage(btnGetQuickQuoteId,'', quickQuotePreloadedImages[1]); //Get Quote Now (Faded) } function RestoreQuickQuoteImage(btnGetQuickQuoteId) { document.getElementById(btnGetQuickQuoteId).src = quickQuotePreloadedImages[0]; //Get Quote Now } ////////////////////////////////////////// /*** Reset duration text when enddate is changed by user ***/ function EndDateChanged(datePickerId, txtDurationId) { if (datePickerId.indexOf("_StartDatePicker") != -1) { var startDatePickerTextBox = datePickerId + "_input" var endDatePickerTextBox = startDatePickerTextBox.replace("_StartDatePicker", "_EndDatePicker") } else //_EndDatePicker { var endDatePickerTextBox = datePickerId + "_input" var startDatePickerTextBox = endDatePickerTextBox.replace("_EndDatePicker", "_StartDatePicker") } var startDay = document.getElementById(startDatePickerTextBox).value.split("/")[0]; var startMonth = document.getElementById(startDatePickerTextBox).value.split("/")[1]; var startYear = document.getElementById(startDatePickerTextBox).value.split("/")[2]; var endDay = document.getElementById(endDatePickerTextBox).value.split("/")[0]; var endMonth = document.getElementById(endDatePickerTextBox).value.split("/")[1]; var endYear = document.getElementById(endDatePickerTextBox).value.split("/")[2]; var startDate = new Date(startYear, startMonth - 1, startDay); var endDate = new Date(endYear, endMonth - 1, endDay); var noOfDays = (endDate - startDate) / (24*60*60*1000) if (noOfDays < 0) { alert("End date can not be less than start date"); document.getElementById(endDatePickerTextBox).value = document.getElementById(startDatePickerTextBox).value; EndDateChanged(datePickerId, txtDurationId); } else document.getElementById(txtDurationId).value = parseInt(noOfDays) + 1; } ////////////////////////////////////////// /*** Reset enddate when startdate is changed by user ***/ function StartDateChanged(endDatePickerId, txtDurationId) { DurationUpdated(txtDurationId, endDatePickerId); } ////////////////////////////////////////// /*** Save current value of duration, onFocus of duration texbox ***/ var oldDurationValue = 3; function SaveDurationValue(txtDurationId) { oldDurationValue = document.getElementById(txtDurationId).value.length == 0 || parseInt(document.getElementById(txtDurationId).value) == 0 ? 3 : document.getElementById(txtDurationId).value; } /*** Reset duration textbox, onBlur, if empty ***/ function ResetDurationText(txtDurationId, endDatePickerId) { if (document.getElementById(txtDurationId).value.length == 0 || parseInt(document.getElementById(txtDurationId).value) == 0 ) { document.getElementById(txtDurationId).value = oldDurationValue; DurationUpdated(txtDurationId, endDatePickerId); } } /*** Reset enddate when duration is changed by user ***/ function DurationUpdated(txtDurationId, endDatePickerId) { var endDatePickerTextBox = endDatePickerId + "_input" var startDatePickerTextBox = endDatePickerTextBox.replace("_EndDatePicker", "_StartDatePicker") var endDay = document.getElementById(endDatePickerTextBox).value.split("/")[0]; var endMonth = document.getElementById(endDatePickerTextBox).value.split("/")[1]; var endYear = document.getElementById(endDatePickerTextBox).value.split("/")[2]; var endDate = new Date(endYear, endMonth - 1, endDay); //if (document.getElementById(txtDurationId).value.length == 0 || parseInt(document.getElementById(txtDurationId).value) == 0 ) //document.getElementById(txtDurationId).value = oldDurationValue; if (parseInt(document.getElementById(txtDurationId).value) > 0) document.getElementById(endDatePickerTextBox).value = DateAdd(document.getElementById(startDatePickerTextBox).value, parseInt(document. getElementById(txtDurationId).value - 1)) return true; } ////////////////////////////////////////// /*** DateAdd - Add "duration" days to given startDate and returns new date***/ function DateAdd(startDate, duration) { var day = startDate.substring(0,2); var month = startDate.substring(3,5); var year = startDate.substring(6,10); day = Number(day) + duration; var endDate = new Date(year, month - 1, day); day = endDate.getDate(); month = endDate.getMonth() + 1; year = endDate.getFullYear(); day = ((day + "").length == 1) ? ("0" + (day + "")) : (day + ""); month = ((month + "").length == 1) ? ("0" + (month + "")) : (month + ""); return ( day + "/" + month + "/" + year ); } ////////////////////////////////////////// /** Function to process discount ref code callback result **/ function ValidateVoucherCodeResult(result, context) { //alert(result) if (result == "valid" || result == "can be valid" || result == "empty voucher code") document.getElementById(instantQuotesControls[instantQuotesControls.length - 1]).innerHTML = ""; if (result == "valid" || result == "empty voucher code") { if (instantQuoteResults != null && instantQuoteResults.InstantQuotes.length > 0) setTimeout("RequestInstantQuote('InstantQuote', ++instantQuoteRequestIndex)", 5); } else if (result == "invalid") document.getElementById(instantQuotesControls[instantQuotesControls.length - 1]).innerHTML = "Please enter a valid discount code."; // for the Scheme"; //"The Voucher code is invalid"; //"Invalid discount ref code"; //alert("Invalid voucher code"); } ////////////////////////////////////////// /** Function to process discount ref code callback error **/ function ValidateVoucherCodeError(error, context) { alert(error) } ////////////////////////////////////////// /** Function to disable instant quotes, before making a callback to update quotes**/ function DisableInstantQuotes() { if (instantQuoteResults != null) if (instantQuoteResults.InstantQuotes.length > 0) for(var btnNextIndex = 0; btnNextIndex < instantQuoteResults.InstantQuotes.length; btnNextIndex++) { document.getElementById(instantQuoteBuyButtons[btnNextIndex]).disabled = false; document.getElementById(instantQuoteBuyButtons[btnNextIndex]).style.display = "none"; document.getElementById("img_greybuy_" + (btnNextIndex+1)).src = instantQuoteGreyButtons[0]; document.getElementById("btn_buy_grey_" + (btnNextIndex+1)).style.display = "block"; if (document.getElementById(instantQuoteSaveButtons[btnNextIndex])) //If Save buttons are not hidden { document.getElementById(instantQuoteSaveButtons[btnNextIndex]).disabled = false; document.getElementById(instantQuoteSaveButtons[btnNextIndex]).style.display = "none"; document.getElementById("img_greysave_" + (btnNextIndex+1)).src = instantQuoteGreyButtons[1]; document.getElementById("btn_save_disabled_" + (btnNextIndex+1)).style.display = "block"; } } } ////////////////////////////////////////// /*** function to redirect user to selected policy page, when a new policy is selected from the policy dropdown list ***/ function RedirectToScheme(ddlPolicyType) { var url = location.href + "@ptype=" + ddlPolicyType.options[ddlPolicyType.selectedIndex].value; if (ddlPolicyType.options[ddlPolicyType.selectedIndex].text == "Winter Sports") url += "&ml=1"; location.href = url; return; }