/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////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 = "
| " + limitText + " | "; //benefitLimitInnerHtml += ""; //if (instantQuoteResults.InstantQuotes[quoteIndex].BenefitLimits[benefitlimitIndex].HelpText != null) //{ var helpImage = (benefitlimitIndex + 1) % 2 == 0 ? quickQuotePreloadedImages[6] : quickQuotePreloadedImages[7]; //benefitLimitInnerHtml += "
" + 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].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 = "
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 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 = "An adult parent and their dependent children under 18 years (in full time education and/or residing with them).
"; break; case "companion" : groupTypeHelpText = "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 = "| 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 += " | "; } else //Else of if .....IsQuantityLoading == 1) { loadingControls += ",chkLoading_" + TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Id; chkLoadingId = "chkLoading_" + TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Id; addLabelForCheckBox = true; 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;'> | " } //alert(TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].LoadingType == "Winter Sports") //alert(TravellerGroupTypeAndLoadings.IsWinterSportsMandatory == true) if ((TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].LoadingType == "Winter Sports" && TravellerGroupTypeAndLoadings.IsWinterSportsMandatory == true)) loadingHTML += "" if (addLabelForCheckBox) loadingHTML += ""; 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 += "" + TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Name + " " + TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Description + " ','', " + TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Width + "," + TravellerGroupTypeAndLoadings.PolicyLoading[PolicyLoadingIndex].Height + ")\" onmouseout=\"hideddrivetip(); QuoteProcessMM_swapImgRestore()\"> | ";
//} 500, 300
loadingHTML += "