var EVT_POLICYTYPECHANGED="dti.PolicyTypeChanged";var EVT_TRAVELAREACHANGED="dti.TravelAreaChanged";var EVT_STARTDATECHANGED="dti.StartDateChanged";var EVT_ENDDATECHANGED="dti.EndDateChanged";var EVT_TRAVELLERSCHANGED="dti.TravellersChanged";var EVT_TRIPLIMITCHANGED="dti.TripLimitChanged";var EVT_WEBSERVICERESPONSE="dti.WebServiceResponse";var EVT_WEBSERVICEERROR="dti.WebServiceError";var EVT_FORMCONFIGURED="dti.FormConfigured";var EVT_DATACHANGED="dti.DataChanged";var EVT_PREPROCESS="dti.PreProcessForm";var EVT_PROCESS="dti.ProcessForm";var RES_DAY=1000*60*60*24;var RES_MONTHS=["January","February","March","April","May","June","July","August","September","October","November","December"];var RES_DAYS=[31,28,31,30,31,30,31,31,30,31,30,31];var CONFIG={};var DATA={};var COUNTRIES={};var activeType=null;var activeConfigurationId=null;var activeFontSize=null;var TMP_OPTION='<option value="{0}">{1}</option>';var TMP_IFRAME='<iframe frameborder="0" class="{0}"></iframe>';var TMP_PROGRESS='<div class="overlayProgress {0}"><div><img src="{1}" /></div><div>{2}</div></div>';var TMP_CALENDAR_DAYS="<tr><th>S</th><th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th></tr>";var TMP_CALENDAR_PREVIOUSDAY='<td class="previousDay {2}"><a href="javascript:void(0);" rel="{0}">{1}</a></td>';var TMP_CALENDAR_DAY='<td class="{2}"><a href="javascript:void(0);" rel="{0}">{1}</a></td>';var TMP_CALENDAR_NEXTDAY='<td class="nextDay {2}"><a href="javascript:void(0);" rel="{0}">{1}</a></td>';var TMP_TABLE_ROW="<tr>{0}</tr>";var TMP_TABLE='<table cellspacing="0">{0}</table>';var TMP_POPUP='<div class="popup {0}"><div class="header"><div class="block"></div><a class="normalFont" href="javascript:void(0);" title="Normal Font"><span>Normal Font</span></a><a class="largerFont" href="javascript:void(0);" title="Larger Font"><span>Larger Font</span></a><a class="largestFont" href="javascript:void(0);" title="Largest Font"><span>Largest Font</span></a><a class="close" href="javascript:void(0);" title="Close"><span>Close</span></a></div><div class="message">{1}</div><div class="footer"></div></div>';var TMP_CALENDAR='<div class="calendarPopup"><div class="header"></div><div class="control"><div class="quickSelect"><select class="monthSelect"></select><select class="yearSelect"></select></div>{0}<div class="todayLink"><a href="javascript:void(0);"><span>Today</span></a></div></div><div class="footer"></div></div>';var TMP_TRAVELAREAFINDER='<div class="finder"><div class="header"><h1>Travel Area</h1><div class="close"><a href="javascript:void(0);" title="Close"><span>Close</span></a></div></div><div class="content"><div class="map-container"><div class="map uk"></div></div><div class="seperator"></div><div class="control"><div class="left"><div class="list"><select id="country" name="country" class="country" multiple="multiple"></select></div><div class="calculateLink"><a href="javascript:void(0);" title="Calculate"><span>Calculate</span></a></div><div class="legend"></div></div><div class="right"><p class="first">Select all the countries you intend on visiting from the list on the left and click ‘Calculate’. Use ‘Ctrl’ + click to select more than one country.</p><p>Your travel area will show below, and the map will highlight all the countries included in that area.</p><p>Once you have found your travel area, please click ‘Proceed’ to continue with your quote.</p><div class="name"></div><div class="proceed"><a href="javascript:void(0);" title="Proceed"><span>Proceed</span></a></div></div><div class="break"></div></div></div><div class="footer"></div></div>';var TMP_COMPOSITION='<p>Please select the relevant category for the travellers:{0}</p><div><select class="groupType"></select></div>';var TMP_INFANTS='<p>Please select how many children travelling are infants under the age of 2:</p><div><select class="infantCount"></select></div>';var TMP_SINGLETYPE='<p>Please note that this quote is applicable to a {0}</p><p>If this is not the case, please <a class="goBack" href="javascript:void(0);">go back</a> and select individual policies.</p>';var TMP_DEFINITIONS='<div class="definitions">{0}</div>';var TMP_POPUPPROCEED='<div class="proceedLink"><a href="javascript:void(0);" title="Proceed"><span>Proceed</span></a></div>';var TMP_AMTCOUPLE='<p>Please note that this quote is applicable to a <strong style="font-weight: bold;">couple</strong>.</p><p>Our defintion of a <strong style="font-weight: bold;">couple</strong> is cohabitating partners / husband and wife living at the same address.</p><p>If this is not the case, please <a class="goBack" href="javascript:void(0);">go back</a> and purchase two separate policies.</p>';var TravellerTypes={Infants:0,Children:1,Adults:2,Seniors:3};var DETAILS={PolicyType:null,TravelArea:null,GroupType:null,StartDate:{Day:null,Month:null,Year:null},EndDate:{Day:null,Month:null,Year:null},Travellers:{Infants:0,Children:0,Adults:0,Seniors:0,Students:0}};var DEF_CONFIG={StartDateOffset:0,StartDateOffsetType:"day",EndDateOffset:4,EndDateOffsetType:"day",ShowEndDate:true,ShowTripLimits:false,ShowUptoDays:true,ShowAdults:true,ShowSeniors:true,ShowChildren:true,ShowStudents:true,TripLimits:null,UptoDays:{Type:"range",Lower:1,Upper:366}};var CONFIGURATIONS={Single:{StartDateOffset:0,StartDateOffsetType:"day",EndDateOffset:4,EndDateOffsetType:"day",TripLimits:null,UptoDays:{Type:"range",Lower:1,Upper:365},FieldClass:null,ShowAdults:true,ShowSeniors:true,ShowChildren:true,ShowStudents:true,TravelAreaConfigs:{UnitedKingdom:{ShowAdults:true,ShowSeniors:true,ShowChildren:true,ShowStudents:true,CssClass:"uk",Description:"United Kingdom"},Europe:{ShowAdults:true,ShowSeniors:true,ShowChildren:true,ShowStudents:true,CssClass:"europe",Description:"Europe"},WorldwideIncUSA:{ShowAdults:true,ShowSeniors:true,ShowChildren:true,ShowStudents:true,CssClass:"worldWideIncUSA",Description:"Worldwide Including<span>USA, Canada &amp The Caribbean</span>"},WorldwideExcUSA:{ShowAdults:true,ShowSeniors:true,ShowChildren:true,ShowStudents:true,CssClass:"worldWideExcUSA",Description:"Worldwide Excluding<span>USA, Canada &amp The Caribbean</span>"}}},SingleWinter:{StartDateOffset:0,StartDateOffsetType:"day",EndDateOffset:6,EndDateOffsetType:"day",TripLimits:null,UptoDays:{Type:"range",Lower:1,Upper:365},FieldClass:null,ShowAdults:true,ShowSeniors:true,ShowChildren:true,ShowStudents:true,TravelAreaConfigs:{UnitedKingdom:{ShowAdults:true,ShowSeniors:true,ShowChildren:true,ShowStudents:true,CssClass:"uk",Description:"United Kingdom"},Europe:{ShowAdults:true,ShowSeniors:true,ShowChildren:true,ShowStudents:true,CssClass:"europe",Description:"Europe"},WorldwideIncUSA:{ShowAdults:true,ShowSeniors:false,ShowChildren:true,ShowStudents:true,CssClass:"worldWideIncUSA",Description:"Worldwide Including<span>USA, Canada &amp The Caribbean</span>"},WorldwideExcUSA:{ShowAdults:true,ShowSeniors:false,ShowChildren:true,ShowStudents:true,CssClass:"worldWideExcUSA",Description:"Worldwide Excluding<span>USA, Canada &amp The Caribbean</span>"}}},Backpacker:{StartDateOffset:0,StartDateOffsetType:"day",EndDateOffset:89,EndDateOffsetType:"day",TripLimits:null,UptoDays:{Type:"collection",Items:[{Key:"0-90",Value:"up to 90"},{Key:"91-120",Value:"91 - 120"},{Key:"121-150",Value:"121 - 150"},{Key:"151-180",Value:"151 - 180"},{Key:"181-210",Value:"181 - 210"},{Key:"211-240",Value:"211 - 240"},{Key:"241-270",Value:"241 - 270"},{Key:"271-300",Value:"271 - 300"},{Key:"301-330",Value:"301 - 330"},{Key:"331-365",Value:"331 - 365"}]},FieldClass:"ex",ShowAdults:true,ShowSeniors:false,ShowChildren:true,ShowStudents:false,TravelAreaConfigs:null},Annual:{StartDateOffset:0,StartDateOffsetType:"day",EndDateOffset:0,EndDateOffsetType:"day",TripLimits:{Type:"collection",Items:[{Key:30,Value:"30 days"},{Key:45,Value:"45 days"},{Key:62,Value:"62 days"}]},UptoDays:null,FieldClass:null,ShowAdults:true,ShowSeniors:true,ShowChildren:true,ShowStudents:true,TravelAreaConfigs:{UnitedKingdom:{ShowAdults:true,ShowSeniors:true,ShowChildren:true,ShowStudents:true,CssClass:"uk",Description:"United Kingdom"},Europe:{ShowAdults:true,ShowSeniors:true,ShowChildren:true,ShowStudents:true,CssClass:"europe",Description:"Europe"},WorldwideIncUSA:{ShowAdults:true,ShowSeniors:false,ShowChildren:true,ShowStudents:true,CssClass:"worldWideIncUSA",Description:"Worldwide Including<span>USA, Canada &amp The Caribbean</span>"},WorldwideExcUSA:{ShowAdults:true,ShowSeniors:false,ShowChildren:true,ShowStudents:true,CssClass:"worldWideExcUSA",Description:"Worldwide Excluding<span>USA, Canada &amp The Caribbean</span>"}}},AnnualWinter:{StartDateOffset:0,StartDateOffsetType:"day",EndDateOffset:0,EndDateOffsetType:"day",TripLimits:{Type:"collection",Items:[{Key:30,Value:"30 days"},{Key:45,Value:"45 days"},{Key:62,Value:"62 days"}]},UptoDays:null,FieldClass:null,ShowAdults:true,ShowSeniors:true,ShowChildren:true,ShowStudents:true,TravelAreaConfigs:{UnitedKingdom:{ShowAdults:true,ShowSeniors:true,ShowChildren:true,ShowStudents:true,CssClass:"uk",Description:"United Kingdom"},Europe:{ShowAdults:true,ShowSeniors:true,ShowChildren:true,ShowStudents:true,CssClass:"europe",Description:"Europe"},AustraliaNZ:{ShowAdults:true,ShowSeniors:true,ShowChildren:true,ShowStudents:true,CssClass:"europeAusNZ",Description:"Australia &amp; New Zealand"},WorldwideIncUSA:{ShowAdults:true,ShowSeniors:false,ShowChildren:true,ShowStudents:true,CssClass:"worldWideIncUSA",Description:"Worldwide Including<span>USA, Canada &amp The Caribbean</span>"},WorldwideExcUSA:{ShowAdults:true,ShowSeniors:false,ShowChildren:true,ShowStudents:true,CssClass:"worldWideExcUSA",Description:"Worldwide Excluding<span>USA, Canada &amp The Caribbean</span>"}}}};var TRAVELAREACONFIGURATIONS={UnitedKingdom:{ShowAdults:true,ShowSeniors:true,ShowChildren:true,ShowStudents:true,CssClass:"uk",Description:"United Kingdom"},Europe:{ShowAdults:true,ShowSeniors:true,ShowChildren:true,ShowStudents:true,CssClass:"europe",Description:"Europe"},AustraliaNZ:{ShowAdults:true,ShowSeniors:true,ShowChildren:true,ShowStudents:true,CssClass:"europeAusNZ",Description:"Australia &amp; New Zealand"},WorldwideIncUSA:{ShowAdults:true,ShowSeniors:false,ShowChildren:true,ShowStudents:true,CssClass:"worldWideIncUSA",Description:"Worldwide Including<span>USA, Canada &amp The Caribbean</span>"},WorldwideExcUSA:{ShowAdults:true,ShowSeniors:false,ShowChildren:true,ShowStudents:true,CssClass:"worldWideExcUSA",Description:"Worldwide Excluding<span>USA, Canada &amp The Caribbean</span>"}};var TRAVELAREADESCRIPTIONS={UnitedKingdom:"<p><strong>United Kingdom</strong>: England, Northern Ireland, Scotland, Wales, The Isle of Man and the Channel Islands.</p>",Europe:"<p><strong>Europe</strong>: All of Europe, including all the countries to the west of the Ural Mountains, the Mediterranean Islands, the Canary Islands, Egypt, Morocco, Algeria, Tunisia, Turkey, Madeira, the Azores and Iceland.</p>",AustraliaNZ:"<p><strong>Australia and New Zealand</strong>: Australia and New Zealand.</p>",WorldwideExcUSA:"<p><strong>Worldwide excluding USA, Canada and Caribbean</strong>: Africa, Asia, Australasia, India, Israel, South America, Middle East, etc.</p>",WorldwideIncUSA:"<p><strong>Worldwide including USA, Canada and Caribbean</strong>: USA, Canada, all Caribbean Islands and all other countries.</p>"};var TYPEDEFINITIONS={Individual:"<p><strong>Individual</strong>: One person on the policy</p>",Couple:"<p><strong>Couple</strong>: Cohabiting partners / husband and wife living at the same address.</p>",Family:"<p><strong>Family</strong>: A <strong>couple</strong> and their dependent children; <strong>Or</strong>{0}: A single parent and their dependent children on one policy.</p>",Group:"<p><strong>Group</strong>: Up to 9 people, all travelling to the same destination for the same duration (not available on Annual Multi-Trip policies).</p>"};var cachedStartDate=null;var cachedEndDate=null;var SetPolicyType=function(a){DETAILS.PolicyType=policyType;$(document).trigger(EVT_POLICYTYPECHANGED,{PolicyType:policyType})};var SetTravelArea=function(a){DETAILS.TravelArea=a;$(document).trigger(EVT_TRAVELAREACHANGED,{TravelArea:a})};var SetStartDate=function(a){DETAILS.StartDate.Day=a.getDate();DETAILS.StartDate.Month=a.getMonth()+1;DETAILS.StartDate.Year=GetYear(a);cachedStartDate=a;$(document).trigger(EVT_STARTDATECHANGED,{Date:a})};var SetEndDate=function(a){DETAILS.EndDate.Day=a.getDate();DETAILS.EndDate.Month=a.getMonth()+1;DETAILS.EndDate.Year=GetYear(a);cachedEndDate=a;$(document).trigger(EVT_ENDDATECHANGED,{Date:a})};var SetInfants=function(a){DETAILS.Travellers.Infants=a;$(document).trigger(EVT_TRAVELLERSCHANGED,{TravellerType:TravellerTypes.Infants,Count:a})};var SetChildren=function(a){DETAILS.Travellers.Children=a;$(document).trigger(EVT_TRAVELLERSCHANGED,{TravellerType:TravellerTypes.Children,Count:a})};var SetAdults=function(a){DETAILS.Travellers.Adults=a;$(document).trigger(EVT_TRAVELLERSCHANGED,{TravellerType:TravellerTypes.Adults,Count:a})};var SetSeniors=function(a){DETAILS.Travellers.Seniors=a;$(document).trigger(EVT_TRAVELLERSCHANGED,{TravellerType:TravellerTypes.Seniors,Count:a})};var GetYear=function(a){var b=a.getYear();return b<1000?(b+1900):b};var IsLeapYear=function(a){return(new Date(a,1,29).getDate()==29)};var GetStartDate=function(){var b=new Date();var c=parseInt($(SCControls.list_StartYear).val());var d=parseInt($(SCControls.list_StartMonth).val())-1;var a=parseInt($(SCControls.list_StartDay).val());b.setFullYear(c,d,a);return b};var GetEndDate=function(){var b=new Date();var c=parseInt($(SCControls.list_EndYear).val());var d=parseInt($(SCControls.list_EndMonth).val())-1;var a=parseInt($(SCControls.list_EndDay).val());b.setFullYear(c,d,a);return b};var DifferenceInDays=function(b,a){var c=Math.round((a-b)/RES_DAY)*1;return c};var IsValidForFullLeapYear=function(c){var b=new Date(NextLeapYear(),1,29);var a=c.addDays2(365);c=c.clone().floor();a=a.clone().floor();if(c<=b&&a>=b){return true}return false};var GetJSON=function(a,b){a=URL_WEBSERVICE+a;$.ajax({type:"GET",url:a.replace("{ext}",CFG_IIS6COMPATIBLEMODE?"."+CFG_MVCEXTENSION:""),dataType:"json",contentType:"application/json; charset=utf-8",data:{timestamp:new Date()},success:function(c){$(document).trigger(EVT_WEBSERVICERESPONSE,{Response:c});if(b){b(c)}},error:function(e,c,d){$(document).trigger(EVT_WEBSERVICEERROR,{XmlHttpRequest:e,Error:c,Message:d})}})};var FormatUrl=function(a){return URL_BASE+a.replace("{ext}",CFG_IIS6COMPATIBLEMODE?"."+CFG_MVCEXTENSION:"")};String.prototype.format=function(){var b=this;for(var a=0;a<arguments.length;a++){b=b.replace("{"+a+"}",arguments[a])}return b};String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")};Date.prototype.addDays2=function(e){var a=this.getDate();var d=this.getMonth();var c=GetYear(this);var b=new Date();b.setFullYear(c,d,a);b.setTime(b.getTime()+(e*RES_DAY));return b};Date.prototype.addMonths=function(a){var b=this.getDate();var e=this.getMonth();var d=GetYear(this);var c=new Date();c.setFullYear(d,e,b);c.setMonth(c.getMonth()+a);return c};Date.prototype.addYears=function(c){var a=this.getDate();var e=this.getMonth();var d=GetYear(this);var b=new Date();b.setFullYear(d,e,a);b.setFullYear(GetYear(b)+c,b.getMonth(),b.getDate());return b};Date.prototype.addOffset=function(c,a){var b=this;if(a=="d"||a=="day"){b=b.addDays2(c)}else{if(a=="m"||a=="month"){b=b.addMonths(c)}else{if(a=="y"||a=="year"){b=b.addYears(c)}}}return b};Date.prototype.floor=function(){var a=this.clone();a.setHours(0,0,0,0);return a};Date.prototype.clone=function(){var a=new Date(GetYear(this),this.getMonth(),this.getDate());a.setHours(this.getHours(),this.getMinutes(),this.getSeconds(),this.getMilliseconds());return a};Date.prototype.compareTo=function(a){return(this<a)?-1:(this>a)?1:0};Array.prototype.itemExists=function(b){for(var a=0;a<this.length;a++){if(this[a]==b){return true}}return false};Array.prototype.each=function(a){if(a){$.each(this,function(b,c){a(b,c)})}};(function(a){a.fn.bindDays=function(g,e){var f=a(this);var h=RES_DAYS[g-1];if(g==2&&IsLeapYear(e)){h=29}var b=0;if(f.get(0).options.length>0){b=f.val();if(b>h){b=h}}f.empty();for(var d=1;d<=h;d++){var c=TMP_OPTION.format(d,d<=9?"0"+d:d);f.append(c)}if(b>0){f.children("option[value="+b+"]").selectOption()}return f};a.fn.bindMonths=function(){var d=a(this);d.empty();for(var c=0;c<RES_MONTHS.length;c++){var b=TMP_OPTION.format(c+1,RES_MONTHS[c]);d.append(b)}return d};a.fn.bindYears=function(d){var e=a(this);e.empty();for(var c=d;c<(d+4);c++){var b=TMP_OPTION.format(c,c);e.append(b)}return e};a.fn.bindSettings=function(e,h,g){var f=a(this);if(!g||!["Annual","AnnualWinter"].itemExists(CONFIG.TripType.Value)){var j=5;if(!h){j=f.val()}f.empty();if(e&&e!=null){if(e.Type=="range"){f.append(TMP_OPTION.format("",""));for(var d=e.Lower;d<=e.Upper;d++){var c=TMP_OPTION.format(d,d);f.append(c)}if(!h){var b=GetStartDate();if(IsValidForFullLeapYear(b)){f.append(TMP_OPTION.format(366,366))}else{if(j==366){j=365}}f.children("option[value="+j+"]").selectOption()}}else{if(e.Type=="collection"){for(var d=0;d<e.Items.length;d++){var c=TMP_OPTION.format(e.Items[d].Key,e.Items[d].Value);f.append(c)}}}}}return f};a.fn.bindCount=function(b){var e=a(this);e.empty();for(var d=0;d<=9;d++){var c=TMP_OPTION.format(d,d);e.append(c)}if(b&&b!=null){e.children("option[value="+b+"]").selectOption()}};a.fn.selectOption=function(){var b=a(this);if(a.browser.msie&&a.browser.version==6){setTimeout(function(){b.attr("selected","selected")})}else{b.attr("selected","selected")}};DONE=true})(jQuery);var ConfigureForm=function(c){CONFIG=c;var i=CONFIGURATIONS[c.TripType.Value];var a=$(SCControls.list_TravelArea);var d=a.val();a.empty();a.append(TMP_OPTION.format("","Please select..."));var l=DEF_DISPLAYTRAVELAREAS!=null?DEF_DISPLAYTRAVELAREAS.split(","):null;$.each(CONFIG.TravelAreas,function(o){var p=CONFIG.TravelAreas[o];if(l==null||l.itemExists(p.Value)){var n=TMP_OPTION.format(p.Value,p.Text);a.append(n)}});if((CONFIG.TripType.Value!="Backpacker")||((CONFIG.TripType.Value=="Backpacker")&&(d=="Europe"||d=="WorldwideIncUSA"))){a.children("option[value="+d+"]").selectOption()}var j=REF_SERVERDATE;if(cachedStartDate!=null){j=cachedStartDate}var k=j.getDate();var g=j.getMonth()+1;var h=GetYear(j);$(SCControls.list_StartDay).bindDays(g,h).children("option[value="+k+"]").selectOption();$(SCControls.list_StartMonth).bindMonths().children("option[value="+g+"]").selectOption();$(SCControls.list_StartYear).bindYears(GetYear(REF_SERVERDATE)).children("option[value="+h+"]").selectOption();$(SCControls.list_StartMonth+", "+SCControls.list_StartYear).change(function(){var o=$(SCControls.list_StartMonth).val();var n=$(SCControls.list_StartYear).val();$(SCControls.list_StartDay).bindDays(o,n)});var f=j.addOffset(i.EndDateOffset,i.EndDateOffsetType);if(cachedEndDate!=null){f=cachedEndDate}var b=f.getDate();var e=f.getMonth()+1;var m=GetYear(f);$(SCControls.list_EndDay).bindDays(e,m).children("option[value="+b+"]").selectOption();$(SCControls.list_EndMonth).bindMonths().children("option[value="+e+"]").selectOption();$(SCControls.list_EndYear).bindYears(GetYear(REF_SERVERDATE)).children("option[value="+m+"]").selectOption();$(SCControls.list_EndMonth+", "+SCControls.list_EndYear).change(function(){var o=$(SCControls.list_EndMonth).val();var n=$(SCControls.list_EndYear).val();$(SCControls.list_EndDay).bindDays(o,n)});if(c.EndDateRequired){$("div.tripLimit").hide();$("div.endDate").show();$("div.uptoDays").show();$("div.uptoDays select").bindSettings(i.UptoDays,true,true);if(i.FieldClass!=null){$("div.uptoDays").addClass(i.FieldClass)}else{$("div.uptoDays").removeAttr("class").addClass("uptoDays")}setTimeout(function(){SetEndDate(f)},10)}else{$("div.tripLimit").show();$("div.endDate").hide();$("div.uptoDays").hide();$("div.tripLimit select").bindSettings(i.TripLimits,true,false)}ResetAgeBox();if(c.TripType.Value=="Annual"||c.TripType.Value=="AnnualWinter"){$(SCControls.label_JourneyStartDate).html("Policy Start Date")}else{$(SCControls.label_JourneyStartDate).html("Journey Start Date")}$(document).trigger(EVT_FORMCONFIGURED,{Configuration:c})};var CreateOverlay=function(b,d){var c=b.offset();var a=TMP_IFRAME.format("controlOverlay");$("body").append(a);$("iframe.controlOverlay").css({position:"absolute",top:c.top,left:c.left,width:b.innerWidth(),height:b.innerHeight(),backgroundColor:"#fff",zIndex:100});if(d){$("iframe.controlOverlay").css("opacity",0.75)}};var CreateOverlayProgress=function(b,d){var c=b.offset();var a=TMP_PROGRESS.format("controlOverlayProgress",URL_BASE+"Images/Progress.gif","Please wait...");$("body").append(a);$("div.controlOverlayProgress").css({position:"absolute",top:c.top,left:c.left,width:b.innerWidth(),height:b.innerHeight(),backgroundColor:"#fff",zIndex:d?d:101})};var CreatePopup=function(j,i,g,b){CreateOverlay($("body"),true);var c=!b||(b&&b=="left");var d=g.offset();var e=TMP_POPUP.format(j,i);$("body").append(e);var a=$("div.popup").css({position:"absolute",top:(c?d.top:(d.top+g.innerHeight()+3)),left:(c?(d.left+g.innerWidth()+3):d.left),zIndex:102});var h=a.offset();var f=$(window);if((h.top+a.height())>(f.height()+f.scrollTop())){a.css({top:((f.height()+f.scrollTop())-a.height()-5)})}$("div.popup .close, div.popup .goBack").click(function(){$("div.popup").remove();DestroyOverlays()});$("div.popup .normalFont").click(function(){$("div.popup .message").removeClass("largerFont largestFont").addClass("normalFont");activeFontSize="normalFont"});$("div.popup .largerFont").click(function(){$("div.popup .message").removeClass("normalFont largestFont").addClass("largerFont");activeFontSize="largerFont"});$("div.popup .largestFont").click(function(){$("div.popup .message").removeClass("normalFont largerFont").addClass("largestFont");activeFontSize="largestFont"});if(activeFontSize!=null){$("div.popup .message").addClass(activeFontSize)}};var CreateHelpPopup=function(b,c,a){CreatePopup("popupHelp",b,c,a)};var CreateErrorPopup=function(b,c,a){CreatePopup("popupError",b,c,a)};var CreateCalendarPopup=function(c,a,g,d,h){CreateOverlay($("body"),true);var f=d.offset();var b=TMP_CALENDAR.format(CreateCalendar(a,g));$("body").append(b);$("div.calendarPopup").css({position:"absolute",top:f.top+d.innerHeight()+3,left:f.left,zIndex:102});$("select.monthSelect").bindMonths().children("option[value="+(a.getMonth()+1)+"]").selectOption();$("select.yearSelect").bindYears(GetYear(a)).children("option[value="+GetYear(a)+"]").selectOption();var e=function(l){var i=$(l).attr("rel").split("_");var j=parseInt(i[0]);var n=parseInt(i[1]);var m=parseInt(i[2]);var k=new Date();k.setFullYear(m,n-1,j);$("div.calendarPopup").remove();DestroyOverlays();h({Date:k})};$("select.monthSelect, select.yearSelect").change(function(){var l=$("select.monthSelect").val();var k=$("select.yearSelect").val();var i=new Date();i.setFullYear(k,(l-1),1);var j=CreateCalendar(i,g);$("div.calendarPopup table").after(j).remove();$("div.calendarPopup table td:not(.invalidDate) a").click(function(){e($(this))})});$("div.calendarPopup table td:not(.invalidDate) a").click(function(){e($(this))});$("div.calendarPopup .todayLink a").click(function(){$("div.calendarPopup").remove();DestroyOverlays();h({Date:new Date()})})};var CreateTravelAreaFinder=function(){CreateOverlay($("body"),true);var f=$(SCControls.list_TravelArea).val();var g=$(window).width();var b=$(window).height();var e=TMP_TRAVELAREAFINDER;$("body").append(e);$("div.finder").css({position:"absolute",left:((g/2)-($("div.finder").width()/2)),top:(((b/2)+$(window).scrollTop())-($("div.finder").height()/2)),zIndex:102});var a=CONFIG.TripType.Value=="Backpacker"?"Backpacker":"";var c=function(i){var j=$("div.finder select");$.each(i,function(l){var m=i[l];var k=TMP_OPTION.format(m.Value,m.Key);j.append(k)});j.show().css({visibility:"visible"});if(DEF_FORCECOUNTRY!=null&&f==""){setTimeout(function(){var k=j.children("option:contains("+DEF_FORCECOUNTRY+")");k.selectOption();setTimeout(function(){var m=h();var l=TRAVELAREACONFIGURATIONS[m];$("div.finder div.name").html(l.Description);$("div.finder div.map").removeAttr("class").addClass("map "+l.CssClass)},100)},100)}};if(COUNTRIES[a]){c(COUNTRIES[a])}else{CreateOverlayProgress($("div.finder div.control"),200);GetCountries(a,function(i){$("div.controlOverlayProgress").remove();COUNTRIES[a]={};$.each(i,function(j){var k=i[j];COUNTRIES[a][k.Key]=k});c(i)})}var h=function(){var j=0;var i="";if(DEF_FORCECOUNTRY!=null){$("div.finder select option:contains("+DEF_FORCECOUNTRY+")").selectOption()}$("div.finder select option:selected").each(function(k){var l=$(this).text();var m=parseInt(COUNTRIES[a][l].Rank);if(m>j){j=m;i=$(this).attr("value")}});if(CONFIG.TripType.Value=="Annual"||CONFIG.TripType.Value=="AnnualWinter"){if(i=="UnitedKingdom"){i="Europe"}else{if(i=="WorldwideExcUSA"){i="WorldwideIncUSA"}}}return i};$("div.finder div.calculateLink a").click(function(){var j=h();var i=TRAVELAREACONFIGURATIONS[j];$("div.finder div.name").html(i.Description);$("div.finder div.map").removeAttr("class").addClass("map "+i.CssClass)});$("div.finder div.proceed a").click(function(){var i=h();$("div.finder").remove();DestroyOverlays();SetTravelArea(i);ValidateTravellers()});$("div.finder div.close a").click(function(){$("div.finder").remove();DestroyOverlays()});if(f!=""){var d=TRAVELAREACONFIGURATIONS[f];$("div.finder div.name").html(d.Description);$("div.finder div.map").removeAttr("class").addClass("map "+d.CssClass)}};var CreateCompositionPopup=function(g){var e="";if(g.Types){if(g.Types.length>1){var d="";g.Types.each(function(h){if(d.length>0){d+=", "}d+=g.Types[h]});d=" "+d+'. <a class="showDefinitions" href="javascript:void(0);">Definition of categories</a>';e+=TMP_COMPOSITION.format(d)}else{e+=TMP_SINGLETYPE.format('<a class="showDefinitions" href="javascript:void(0);">{0}</a>'.format(g.Types[0]));if(CONFIG.TripType.Value=="Annual"||CONFIG.TripType.Value=="AnnualWinter"){if(g.Types[0]=="Couple"){e=TMP_AMTCOUPLE}}}}if(g.Children){e+=TMP_INFANTS}if(g.Types){var a="";$.each(TYPEDEFINITIONS,function(h){if(h=="Family"){if(CONFIG.TripType.Value=="Annual"||CONFIG.TripType.Value=="AnnualWinter"){a+=TYPEDEFINITIONS[h].format(" (at a discounted rate)")}else{a+=TYPEDEFINITIONS[h].format("")}}else{a+=TYPEDEFINITIONS[h]}});e+=TMP_DEFINITIONS.format(a)}e+=TMP_POPUPPROCEED;CreateHelpPopup(e,$("div.smallControl"));var f=$(window);var b=$("div.popup");$("div.popup").css({top:((f.height()/2)-(b.height()/2))+f.scrollTop(),left:((f.width()/2)-(b.width()/2))+f.scrollLeft()});if(g.Types){g.Types.each(function(j){var h=TMP_OPTION.format(g.Types[j],g.Types[j]);$("select.groupType").append(h)})}if(g.Children){for(var c=0;c<=g.Children;c++){var e=TMP_OPTION.format(c,c);$("select.infantCount").append(e)}}$("a.showDefinitions").click(function(){$("div.definitions").toggle();$("div.popup").css({top:((f.height()/2)-(b.height()/2))+f.scrollTop(),left:((f.width()/2)-(b.width()/2))+f.scrollLeft()})});$("div.popup div.proceedLink a").click(function(){var i=0;if(g.Children){i=parseInt($("select.infantCount").val())}if(!g.Types){h="Individual"}else{var h=g.Types.length>1?$("div.popup select.groupType").val():g.Types[0]}$("div.popup").remove();DestroyOverlays();$(document).trigger(EVT_PREPROCESS,{Type:h,Infants:i});$(document).trigger(EVT_PROCESS,{});return false})};var DestroyOverlays=function(){$("iframe.controlOverlay, div.controlOverlayProgress").remove()};var IsValidDate=function(j,h,i,b){var g=GetYear(b);var d=b.getMonth()+1;var e=e=b.getDate();if(i>g){return false}else{if(i==g&&h>d){return false}else{if(i==g&&h==d&&j>e){return false}}}var c=REF_SERVERDATE;var k=GetYear(c);var a=c.getMonth()+1;var f=c.getDate();if(i<k){return false}else{if(i==k&&h<a){return false}else{if(i==k&&h==a&&j<f){return false}}}return true};var NextLeapYear=function(){var b=new Date();var e=GetYear(b);var d=b.getMonth()+1;var a=b.getDate();if(d>2||(d==2&&a==29)){e++}var c=false;while(!c){c=IsLeapYear(e);if(c){break}e++}return e};var CreateCalendar=function(g,b){var n=g.getMonth()+1;var o=GetYear(g);var c=n-1;var e=o;if(c==0){c=12;e-=1}var l=n+1;var p=o;if(l==13){l=1;p+=1}var r=(n==2&&IsLeapYear(o))?29:RES_DAYS[n-1];var h=(c==2&&IsLeapYear(e))?29:RES_DAYS[c-1];var g=new Date();g.setFullYear(o,n-1,1);var k=TMP_CALENDAR_DAYS;var q=1;var f=g.getDay()-1;k+="<tr>";var m=h-(g.getDay()-1);for(var j=m;j<=h;j++){k+=TMP_CALENDAR_PREVIOUSDAY.format(""+j+"_"+c+"_"+e,j,IsValidDate(j,c,e,b)?"":"invalidDate")}var d=6-(h-m);for(var j=1;j<=d;j++){k+=TMP_CALENDAR_DAY.format(""+j+"_"+n+"_"+o,j,IsValidDate(j,n,o,b)?"":"invalidDate");q=j;f+=1}if(f>6){f=6}for(var j=q+1;j<=r;j++){if(f==6){k+="</tr><tr>";f=0}else{f+=1}k+=TMP_CALENDAR_DAY.format(""+j+"_"+n+"_"+o,j,IsValidDate(j,n,o,b)?"":"invalidDate")}var a=1;for(var j=f;j<6;j++){k+=TMP_CALENDAR_NEXTDAY.format(""+a+"_"+l+"_"+p,a,IsValidDate(a,l,p,b)?"":"invalidDate");a+=1}k+="</tr>";return TMP_TABLE.format(k)};var ResetAgeBoxLayout=function(a,d,b,c){if(a){$("#adults").css("visibility","visible");$("#adults select").show()}else{$("#adults").css("visibility","hidden");$("#adults select").hide()}if(b){$("#seniors").css("visibility","visible");$("#seniors select").show()}else{$("#seniors").css("visibility","hidden");$("#seniors select").val("0");$("#seniors select").hide()}if(d){$("#children").css("visibility","visible");$("#children select").show()}else{$("#children").css("visibility","hidden");$("#children select").hide()}if(c){$("#students").css("visibility","visible");$("#students select").show()}else{$("#students").css("visibility","hidden");$("#students select").hide()}};var GetTravelAreas=function(){GetJSON("GetTravelAreas/",function(a){$(document).trigger(EVT_DATACHANGED,{Graph:a})})};var GetCountries=function(a,b){GetJSON("GetCountries/"+a,function(c){b(c)})};var BindDateEvents=function(){$(SCControls.list_StartYear+", "+SCControls.list_StartMonth+", "+SCControls.list_StartDay).change(function(){var b=GetStartDate();SetStartDate(b);var a=CONFIGURATIONS[CONFIG.TripType.Value];$("div.uptoDays select").bindSettings(a.UptoDays,false,true)});$(SCControls.list_EndYear+", "+SCControls.list_EndMonth+", "+SCControls.list_EndDay).change(function(){var a=GetEndDate();SetEndDate(a)});$(SCControls.list_UptoDays).change(function(){var b=GetStartDate();var e=0;if(CONFIGURATIONS[CONFIG.TripType.Value].UptoDays.Type=="range"){e=parseInt($(this).val())-1}else{if(CONFIGURATIONS[CONFIG.TripType.Value].UptoDays.Type=="collection"){e=parseInt($(this).val().split("-")[1])-1}}if(!isNaN(e)){b=b.addDays2(e);var a=b.getDate();var d=b.getMonth()+1;var c=GetYear(b);$(SCControls.list_EndDay).bindDays(d,c).children("option[value="+a+"]").selectOption();$(SCControls.list_EndMonth+" option[value="+d+"]").selectOption();$(SCControls.list_EndYear+" option[value="+c+"]").selectOption();SetEndDate(b)}});$(document).bind(EVT_STARTDATECHANGED,function(b,a){var c=DifferenceInDays(a.Date,GetEndDate())+1;if(!["Annual","AnnualWinter"].itemExists(CONFIG.TripType.Value)){if(CONFIGURATIONS[CONFIG.TripType.Value].UptoDays.Type=="range"){$("div.uptoDays select > option[value="+c+"]").selectOption()}else{if(CONFIGURATIONS[CONFIG.TripType.Value].UptoDays.Type=="collection"){$("div.uptoDays select > option").each(function(e){var g=$(this);var h=g.val().split("-");var d=parseInt(h[0]);var f=parseInt(h[1]);if(c>=d&&c<=f){g.selectOption()}})}}}});$(document).bind(EVT_ENDDATECHANGED,function(b,a){var c=DifferenceInDays(GetStartDate(),a.Date)+1;if(!["Annual","AnnualWinter"].itemExists(CONFIG.TripType.Value)){if(CONFIGURATIONS[CONFIG.TripType.Value].UptoDays.Type=="range"){$("div.uptoDays select > option[value="+c+"]").selectOption()}else{if(CONFIGURATIONS[CONFIG.TripType.Value].UptoDays.Type=="collection"){$("div.uptoDays select > option").each(function(e){var g=$(this);var h=g.val().split("-");var d=parseInt(h[0]);var f=parseInt(h[1]);if(c>=d&&c<=f){g.selectOption()}})}}}})};var BindGraphEvents=function(){$(document).bind(EVT_DATACHANGED,function(d,c){DATA=c.Graph;var a=DEF_DISPLAYPOLICYTYPES==null?null:DEF_DISPLAYPOLICYTYPES.split(",");var f=DEF_POLICYTYPE;var b=0;var e=$(SCControls.list_PolicyType);$.each(DATA,function(h){var j=DATA[h];if(a==null||a.itemExists(j.TripType.Value)){var g=TMP_OPTION.format(h,j.TripType.Text);e.append(g)}if(j.TripType.Value==f){b=h}});e.children("option[value="+b+"]").selectOption();activeConfigurationId=b;ConfigureForm(DATA[b]);DestroyOverlays();BindHelpMessages();$(SCControls.link_Submit).removeAttr("disabled");$("div.defaultOverlay").remove();$(".innerContent select").css({visibility:"visible"});$(".footer-desc a, .footer-proceed a").css({visibility:"visible"})})};var BindControlEvents=function(){$(SCControls.list_PolicyType).change(function(){var a=parseInt($(this).val());activeConfigurationId=a;ConfigureForm(DATA[a])});$(SCControls.list_TravelArea).change(function(){$(document).trigger(EVT_TRAVELAREACHANGED,{TravelArea:$(this).val()})});$("#link_TravelArea").click(function(){CreateTravelAreaFinder()});$("select[id$='_list_TripLimit']").change(function(){$(document).trigger(EVT_TRIPLIMITCHANGED,{TripLimit:parseInt($(this).val())})});$(document).bind(EVT_TRAVELAREACHANGED,function(b,a){if(a.TravelArea&&a.TravelArea!=""&&a.TravelArea!=null){$(SCControls.list_TravelArea).children("option[value="+a.TravelArea+"]").selectOption()}ResetAgeBox();setTimeout(function(){ValidateTravelArea()},100)});$(document).bind(EVT_TRIPLIMITCHANGED,function(b,a){if(a.TravelArea&&a.TravelArea!=""&&a.TravelArea!=null){$(SCControls.list_TravelArea).children("option[value="+a.TravelArea+"]").selectOption()}ResetAgeBox()})};var ResetAgeBox=function(){var b=CONFIGURATIONS[CONFIG.TripType.Value];var d=$(SCControls.list_TravelArea).val();var c=((CONFIG.TripType.Value=="Annual"||CONFIG.TripType.Value=="AnnualWinter")&&parseInt($("select[id$='_list_TripLimit']").val())>31)?true:false;if(d!=null&&d!=""){var a=b.TravelAreaConfigs!=null?b.TravelAreaConfigs[d]:null;if(a&&a!=null){ResetAgeBoxLayout(b.ShowAdults&a.ShowAdults,b.ShowChildren&a.ShowChildren,b.ShowSeniors&a.ShowSeniors&!c,b.ShowStudents&a.ShowStudents)}else{ResetAgeBoxLayout(b.ShowAdults,b.ShowChildren,b.ShowSeniors&!c,b.ShowStudents)}}else{ResetAgeBoxLayout(b.ShowAdults,b.ShowChildren,b.ShowSeniors&!c,b.ShowStudents)}ValidateTravellers()};var BindCalendarEvents=function(){$("#startDateCalendar a").click(function(){CreateCalendarPopup(new Date(),GetStartDate(),GetStartDate().addMonths(18),$(SCControls.list_StartMonth),function(a){var b=a.Date.getDate();var d=a.Date.getMonth()+1;var c=GetYear(a.Date);$(SCControls.list_StartDay).bindDays(d,c).children("option[value="+b+"]").selectOption();$(SCControls.list_StartMonth+" option[value="+d+"]").selectOption();$(SCControls.list_StartYear+" option[value="+c+"]").selectOption();SetStartDate(a.Date)})});$("#endDateCalendar a").click(function(){CreateCalendarPopup(GetStartDate(),GetEndDate(),GetStartDate().addDays2(365),$(SCControls.list_EndMonth),function(a){var b=a.Date.getDate();var d=a.Date.getMonth()+1;var c=GetYear(a.Date);$(SCControls.list_EndDay).bindDays(d,c).children("option[value="+b+"]").selectOption();$(SCControls.list_EndMonth+" option[value="+d+"]").selectOption();$(SCControls.list_EndYear+" option[value="+c+"]").selectOption();SetEndDate(a.Date)})})};var BindHelpMessages=function(){$("#policyTypeState .help").click(function(){var a="<p><strong>Single Trip</strong>: A policy for a one off trip/holiday that starts and ends in the UK.<p><p><strong>Single Trip with Winter Sports</strong>: A policy for a Single Trip that includes skiing, snowboarding, and/or other winter sports activities.</p><p><strong>Annual Multi-Trip</strong>: A 12 month policy that covers multiple trips, allowing you to travel as many times as you like during that time.</p><p><strong>Annual Multi-Trip with Winter Sports</strong>: A 12 month policy that covers multiple trips, and includes skiing, snowboarding, and/or other winter sports activities for up to 17 days per trip.</p><p><strong>Backpacker/Longstay</strong>: A policy designed for long trips, with flexible and extendable cover.</p>";CreateHelpPopup(a,$(this))});$("#travelAreaState .help").click(function(){var a="";$.each(CONFIG.TravelAreas,function(b){var c=CONFIG.TravelAreas[b];a+=TRAVELAREADESCRIPTIONS[c.Value]});CreateHelpPopup(a,$(this))});$("#startDateState .help").click(function(){var a="";if(CONFIG.TripType.Value=="Annual"||CONFIG.TripType.Value=="AnnualWinter"){a="<p>Cancellation cover commences from the <strong>policy start date</strong>.</p>"}else{a="<p>The <strong>journey start date</strong> must be the day you start your journey. Cancellation cover (if purchased) automatically commences from the purchase date.</p>"}CreateHelpPopup(a,$(this))});$("#tripLimitState .help").click(function(){var a="<p>The trip limit is the maximum number of days you can travel per trip. This applies whenever the policyholder travels.</p><p>Other named travellers can travel independently of the policyholder for a maximum of 21 days per trip.</p><p>There is no limit on the number of trips that can be taken in the year.</p>";CreateHelpPopup(a,$(this))});$("#ageState .help").click(function(){var c=true;var h=true;var d=true;var g=true;var b=CONFIGURATIONS[CONFIG.TripType.Value];var a=b.TravelAreaConfigs!=null?b.TravelAreaConfigs[$(SCControls.list_TravelArea).val()]:false;var f=((CONFIG.TripType.Value=="Annual"||CONFIG.TripType.Value=="AnnualWinter")&&parseInt($("select[id$='_list_TripLimit']").val())>31)?true:false;if(!(a&&(b.ShowAdults&a.ShowAdults)||!a&&b.ShowAdults)){c=false}if(!(a&&(b.ShowSeniors&a.ShowSeniors&!f)||!a&&b.ShowSeniors)){g=false}if(!(a&&(b.ShowChildren&a.ShowChildren)||!a&&b.ShowChildren)){d=false}if(!(a&&(b.ShowStudents&a.ShowStudents)||!a&&b.ShowStudents)){h=false}var e;if(CONFIG.TripType.Value=="Annual"||CONFIG.TripType.Value=="AnnualWinter"){e="Please select the age group categories that apply at the policy start date.</p>"}else{e="Please select the age group categories that apply today.</p>"}e+="<p>The age group categories are as follows:<br />";if(d){e+='<strong style="font-weight: bold;">Children</strong>: Aged 0-18 inclusive.<br />'}if(h){e+='<strong style="font-weight: bold;">Students</strong>: Aged 19-22 inclusive, and in full-time education.<br />'}if(c){if(CONFIG.TripType.Value=="Backpacker"){e+='<strong style="font-weight: bold;">Adults</strong>: Aged 19-36 inclusive.<br />'}else{e+='<strong style="font-weight: bold;">Adults</strong>: Aged 19-65 inclusive.<br />'}}if(g){e+='<strong style="font-weight: bold;">Senior Citizens</strong>: Aged 66-75 inclusive.'}e+="</p>";CreateHelpPopup(e,$(this))});$("div.footer-desc a").click(function(){var a="<p>You must be a UK resident. This means that your main home must be in the United Kingdom and you must be registered with a medical practitioner in the United Kingdom.</p><p>We are unable to insure:<br />a) Foreign Au Pairs working in the UK.<br />b) Foreign Nationals - unless you have been in the UK at least 6 months, have a permanent National Insurance number and are registered with a medical practitioner in the UK.<br />";CreateHelpPopup(a,$(this),"bottom")})};var BindValidationEvents=function(){$(document).bind(EVT_STARTDATECHANGED,function(b,a){ValidateStartDate()});$(document).bind(EVT_ENDDATECHANGED,function(b,a){setTimeout(function(){ValidateEndDate()},100)});$("div.ages select").change(function(){ValidateTravellers()})};var ValidateStartDate=function(){var a=REF_SERVERDATE;var d=GetStartDate();if(d.compareTo(a)==-1){$("#startDateState .help").hide();$("#startDateState .error").css("display","block").unbind("click").click(function(){CreateErrorPopup("<p>The journey start date cannot be in the past. Please amend the incorrect date(s).</p>",$(this))});return false}else{var b=parseInt($(SCControls.list_Seniors).val());if(b>0){var c=a.addMonths(12);if(d.compareTo(c)==1){$("#startDateState .help").hide();if(CONFIG.TripType.Value=="Single"||CONFIG.TripType.Value=="SingleWinter"){$("#startDateState .error").css("display","block").unbind("click").click(function(){CreateErrorPopup("<p>Policies cannot be issued more than 12 months in advance.</p>",$(this))})}else{if(CONFIG.TripType.Value=="Annual"||CONFIG.TripType.Value=="AnnualWinter"){$("#startDateState .error").css("display","block").unbind("click").click(function(){CreateErrorPopup("<p>Annual Multi-Trip policies must start within 12 months of purchase.</p>",$(this))})}}return false}else{$("#startDateState .help").css("display","block");$("#startDateState .error").hide()}}else{var c=a.addMonths(18);if(d.compareTo(c)==1){$("#startDateState .help").hide();if(CONFIG.TripType.Value=="Single"||CONFIG.TripType.Value=="SingleWinter"||CONFIG.TripType.Value=="Backpacker"){$("#startDateState .error").css("display","block").unbind("click").click(function(){CreateErrorPopup("<p>Policies cannot be issued more than 18 months in advance.</p>",$(this))})}else{if(CONFIG.TripType.Value=="Annual"||CONFIG.TripType.Value=="AnnualWinter"){$("#startDateState .error").css("display","block").unbind("click").click(function(){CreateErrorPopup("<p>Annual Multi-Trip policies must start within 18 months of purchase.</p>",$(this))})}}return false}else{$("#startDateState .help").css("display","block");$("#startDateState .error").hide()}}}ValidateEndDate();return true};var ValidateEndDate=function(){if(CONFIG.TripType.Value=="Annual"||CONFIG.TripType.Value=="AnnualWinter"){$("#endDateState .help").css("display","block");$("#endDateState .error").hide();return true}var f=GetStartDate();var a=GetEndDate();var b=new Date(NextLeapYear(),1,29).addDays2(1);if(f.compareTo(a)==1){$("#endDateState .help").hide();$("#endDateState .error").css("display","block").unbind("click").click(function(){CreateErrorPopup("<p>The policy end date cannot be before the policy start date. Please correct the incorrect date(s).</p>",$(this))});return false}else{if(CONFIG.TripType.Value=="Backpacker"||CONFIG.TripType.Value=="Single"||CONFIG.TripType.Value=="SingleWinter"){var d=parseInt($(SCControls.list_Seniors).val());if(d>0&&CONFIG.TripType.Value!="Backpacker"&&DifferenceInDays(f,a)>=31){$("#endDateState .help").hide();$("#endDateState .error").css("display","block").unbind("click").click(function(){CreateErrorPopup("<p>We are only able to insure trips that last for a maximum period of 31 days.</p>",$(this))});return false}else{var c=IsValidForFullLeapYear(f)&&CONFIG.TripType.Value!="Backpacker";var e=f.addDays2(c?365:364);if(a.compareTo(e)>0){$("#endDateState .help").hide();$("#endDateState .error").css("display","block").unbind("click").click(function(){CreateErrorPopup("<p>We are only able to insure trips that last for a maximum period of "+(c?"366":"365")+" days.</p>",$(this))});return false}else{$("#endDateState .help").css("display","block");$("#endDateState .error").hide()}}}else{$("#endDateState .help").css("display","block");$("#endDateState .error").hide()}}return true};var ValidateTravellers=function(){var e=0;var c=0;var g=0;var h=0;var d=0;var b=CONFIGURATIONS[CONFIG.TripType.Value];var a=b.TravelAreaConfigs!=null?b.TravelAreaConfigs[$(SCControls.list_TravelArea).val()]:false;var f=((CONFIG.TripType.Value=="Annual"||CONFIG.TripType.Value=="AnnualWinter")&&parseInt($("select[id$='_list_TripLimit']").val())>31)?true:false;if(a&&(b.ShowAdults&a.ShowAdults)||!a&&b.ShowAdults){c=parseInt($(SCControls.list_Adults).val());e+=c}if(a&&(b.ShowSeniors&a.ShowSeniors&!f)||!a&&b.ShowSeniors){g=parseInt($(SCControls.list_Seniors).val());e+=g}if(a&&(b.ShowChildren&a.ShowChildren)||!a&&b.ShowChildren){d=parseInt($(SCControls.list_Children).val());e+=d}if(a&&(b.ShowStudents&a.ShowStudents)||!a&&b.ShowStudents){h=parseInt($(SCControls.list_Students).val());e+=h}if(e==0||e>9){$("#ageState .help").hide();$("#ageState .error").css("display","block").unbind("click").click(function(){CreateErrorPopup("<p>Number of travellers must be between 1 and 9.</p>",$(this))});return false}if(CONFIG.TripType.Value!="Single"&&CONFIG.TripType.Value!="SingleWinter"&&CONFIG.TripType.Value!="Backpacker"){if((c+g)>2||((c+g)==0&&((h+d)>1))){$("#ageState .help").hide();$("#ageState .error").css("display","block").unbind("click").click(function(){CreateErrorPopup("<p>Annual Multi-Trip policies are only available for individual <strong>Adults</strong>/<strong>Senior Citizens</strong>, <strong>couples</strong> or <strong>families</strong>.</p>",$(this))});return false}}$("#ageState .help").css("display","block");$("#ageState .error").hide();return true};var GetGroupValidationRule=function(){var c=parseInt($(SCControls.list_Adults).val());var f=parseInt($(SCControls.list_Seniors).val());var d=parseInt($(SCControls.list_Children).val());var h=parseInt($(SCControls.list_Students).val());var e=((CONFIG.TripType.Value=="Annual"||CONFIG.TripType.Value=="AnnualWinter")&&parseInt($("select[id$='_list_TripLimit']").val())>31)?true:false;if(e){f=0}var g={};var b=((c+f)==1||(c+f)==2);var a=CONFIG.TripType.Value=="Backpacker";if(a){b=false}if(CONFIG.TripType.Value=="Single"||CONFIG.TripType.Value=="SingleWinter"||CONFIG.TripType.Value=="Backpacker"){if((d+h)>0){if(((c+f)==1||(c+f)==2)&&!a){g=$.extend(true,g,{Types:["Family","Group"]})}}else{if((c+f)==2&&!a){g=$.extend(true,g,{Types:["Couple","Group"]})}}if(d>0){g=$.extend(true,g,{Children:d})}}else{if(b){if((d+h)==0){if((c+f)==2){g=$.extend(true,g,{Types:["Couple"]})}}else{$.extend(true,g,{Types:["Family"]});if(d>0){g=$.extend(true,g,{Children:d})}}}}return g};var ValidateTravelArea=function(){var b=$(SCControls.list_TravelArea).val();var a=false;if(b&&b!=null){b=b.trim();if(b!=""){a=true;$("#travelAreaState .help").css("display","block");$("#travelAreaState .error").hide()}}if(!a){$("#travelAreaState .help").hide();$("#travelAreaState .error").css("display","block").unbind("click").click(function(){var c="<p>Please select a Travel Area</p>";CreateErrorPopup(c,$(this))})}return a};var Validate=function(){var c=CONFIGURATIONS[CONFIG.TripType.Value];var b=c.TravelAreaConfigs!=null?c.TravelAreaConfigs[$(SCControls.list_TravelArea).val()]:false;var d=((CONFIG.TripType.Value=="Annual"||CONFIG.TripType.Value=="AnnualWinter")&&parseInt($("select[id$='_list_TripLimit']").val())>31)?true:false;if(!(b&&(c.ShowAdults&b.ShowAdults)||!b&&c.ShowAdults)){$(SCControls.list_Adults).val(0)}if(!(b&&(c.ShowSeniors&b.ShowSeniors&!d)||!b&&c.ShowSeniors)){$(SCControls.list_Seniors).val(0)}if(!(b&&(c.ShowChildren&b.ShowChildren)||!b&&c.ShowChildren)){$(SCControls.list_Children).val(0)}if(!(b&&(c.ShowStudents&b.ShowStudents)||!b&&c.ShowStudents)){$(SCControls.list_Students).val(0)}var a=ValidateStartDate()&&ValidateEndDate()&&ValidateTravelArea()&&ValidateTravellers();return a};var PreloadImages=function(){for(var a=0;a<arguments.length;a++){var b=$("<img />").attr("src",arguments[a]).css({display:"none"});$("body").append(b)}};$(document).bind("riaSmallControl",function(b){var a=AC_FL_RunContent("codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0","width","670","height","480","src","ria/AsSmallControl","flashVars",flashVars,"quality","high","pluginspage","http://www.macromedia.com/go/getflashplayer","align","middle","play","true","loop","true","scale","showall","wmode","transparent","devicefont","false","id","Landing","bgcolor","#ffffff","name","Landing","menu","true","allowFullScreen","false","allowScriptAccess","sameDomain","movie","ria/AsSmallControl","salign","");$(".content").append("<div id='riaContainer' style='position:absolute; top:4px; left:-185px;'></div>");$("#riaContainer").append(a);$("#travelInfoLeft").append("<div id='htmlMessage' style='line-height:100%; font-size:11px; text-align:center; margin-top:15px;'>For html version <a id='riaToggle' style='cursor:pointer;'>click here</a></div>");$("#riaToggle").click(function(c){$(".innerContent").toggle();$(".footer-desc").toggle();$(".footer-proceed").toggle();$("#Landing").toggle();if(!riaDisplay){$(".content").css("height","400px");riaDisplay=true}else{$(".content").css("height","283px");riaDisplay=false}if(!htmlDisplay){initHtml()}$("#displayedSmallControlType").val("HTML-USERREQUESTED");$("#htmlMessage").hide()})});var riaDisplay=false;var htmlDisplay=false;var initHtml=function(){$(SCControls.link_Submit).attr("disabled","disabled");PreloadImages(URL_BASE+"Images/SmallControl/PopupSprite.jpg",URL_BASE+"Images/SmallControl/TravelAreaFinderSprite.jpg");BindDateEvents();BindGraphEvents();BindControlEvents();BindCalendarEvents();BindValidationEvents();$("#adults select").bindCount(1);$("#children select, #seniors select, #students select").bindCount();GetTravelAreas();$("div.footer-proceed a").click(function(){if(Validate()){var a=GetGroupValidationRule();if(a.Types||a.Children){CreateCompositionPopup(a)}else{$(document).trigger(EVT_PREPROCESS,{Type:"Individual",Infants:0});$(document).trigger(EVT_PROCESS,{})}}return false});$(document).bind(EVT_PREPROCESS,function(b,a){$(SCControls.hidden_GroupType).val(a.Type);$(SCControls.hidden_PolicyType).val(CONFIG.TripType.Value);$(SCControls.hidden_Infants).val(a.Infants)});$(document).bind(EVT_PROCESS,function(b,a){__doPostBack(CTRL_SUBMIT,"")});htmlDisplay=true};$(function(){var a=$("#riaContent");var b=$("#btn-add-table");if(riaOn){$("#requestedSmallControlType").val("RIA");if(DetectFlashVer(9,0,0)){$(document).trigger("riaSmallControl");$(".innerContent").toggle();$(".footer-desc").toggle();$(".footer-proceed").toggle();$(".content").css("height","400px");$("#displayedSmallControlType").val("RIA");riaDisplay=true}else{$("#displayedSmallControlType").val("HTML-NOFLASH");initHtml()}}else{$("#requestedSmallControlType").val("HTML");$("#displayedSmallControlType").val("HTML");initHtml()}});