var Events={PolicyTypeChanged:"dti.PolicyTypeChanged",TravelAreaChanged:"dti.TravelAreaChanged",StartDateChanged:"dti.StartDateChanged",EndDateChanged:"dti.EndDateChanged",TravellersChanged:"dti.TravellersChanged",Loading:"dti.Loading",Loaded:"dti.Loaded",Initialise:"dti.Initialise",BeforeSubmit:"dti.BeforeSubmit",Submit:"dti.Submit",ServiceLoaded:"dti.ServiceLoaded",ServiceError:"dti.ServiceError"};var References={DefaultPolicyType:"Single",Day:86400000,Days:[31,28,31,30,31,30,31,31,30,31,30,31],Months:["January","February","March","April","May","June","July","August","September","October","November","December"]};var Templates={Option:'<option value="{0}">{1}</option>',IFrame:'<iframe frameborder="0" class="{0}"></iframe>',Progress:'<div class="overlayProgress {0}"><div><img src="{1}" /></div><div>{2}</div></div>',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>",PreviousDay:'<td class="previousDay {2}"><a href="javascript:void(0);" rel="{0}">{1}</a></td>',Day:'<td class="{2}"><a href="javascript:void(0);" rel="{0}">{1}</a></td>',NextDay:'<td class="nextDay {2}"><a href="javascript:void(0);" rel="{0}">{1}</a></td>',Popup:'<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>'},Table:{Table:'<table cellspacing="0">{0}</table>',Row:"<tr>{0}</tr>"},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>',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"></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="legend"></div></div><div class="right"><p class="first">Please select all the countries you intend on visiting from the list on the left.  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>',Compositions:{Category:'<p>Please select the relevant category for the travellers. {0}</p><div><select class="groupType"></select></div>',Infants:'<p>Please select how many children travelling are infants under the age of 2:</p><div><select class="infantCount"></select></div>',SingleType:'<p>Please note that this quote is applicable to a {0} living together at the same address.</p><p>If this is not the case, please <a class="goBack" href="javascript:void(0);">go back</a> and select individual policies.</p>',Definitions:'<div class="definitions">{0}{1}</div>',NonAMTFootnote:"<p><br />All travellers must be travelling to the same destination for the same duration.</p>",Proceed:'<div class="proceedLink"><a href="javascript:void(0);" title="Proceed"><span>Proceed</span></a></div>',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 an individual and his or her partner provided they live together.  A partner would include a civil partner.</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 TravellerType={Infants:0,Children:1,Student:2,Adult:3,Seniors:4};var Configurations={Single:{Key:"Single",Description:"Single Trip",StartOffset:{Value:0,Type:"day"},EndOffset:{Value:4,Type:"day"},Modifier:{Type:"days",SubType:"range",Lower:1,Upper:365,SupportLeapYear:true},Travellers:{Infants0to1:true,Children2to18:true,Students19to22:true,Adults19to36:false,Adults19to40:true,Adults41to65:true,Adults66to75:true}},SingleWinter:{Key:"SingleWinter",Description:"Single Trip with Winter Sports",StartOffset:{Value:0,Type:"day"},EndOffset:{Value:6,Type:"day"},Modifier:{Type:"days",SubType:"range",Lower:1,Upper:365,SupportLeapYear:true},Travellers:{Infants0to1:true,Children2to18:true,Students19to22:true,Adults19to36:false,Adults19to40:true,Adults41to65:true,Adults66to75:true,Areas:{WorldwideIncUSA:{Infants0to1:true,Children2to18:true,Students19to22:true,Adults19to36:false,Adults19to40:true,Adults41to65:true,Adults66to75:false},WorldwideExcUSA:{Infants0to1:true,Children2to18:true,Students19to22:true,Adults19to36:false,Adults19to40:true,Adults41to65:true,Adults66to75:false}}}},Backpacker:{Key:"Backpacker",Description:"Backpacker/Longstay",StartOffset:{Value:0,Type:"day"},EndOffset:{Value:89,Type:"day"},Modifier:{Type:"days",SubType:"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"}],SupportLeapYear:false,Class:"ex"},Travellers:{Infants0to1:true,Children2to18:true,Students19to22:false,Adults19to36:true,Adults19to40:false,Adults41to65:false,Adults66to75:false}},Annual:{Key:"Annual",Description:"Annual Multi-Trip",StartOffset:{Value:0,Type:"day"},Modifier:{},Travellers:{Infants0to1:true,Children2to18:true,Students19to22:true,Adults19to36:false,Adults19to40:true,Adults41to65:true,Adults66to75:true,Areas:{WorldwideIncUSA:{Infants0to1:true,Children2to18:true,Students19to22:true,Adults19to36:false,Adults19to40:true,Adults41to65:true,Adults66to75:false},WorldwideExcUSA:{Infants0to1:true,Children2to18:true,Students19to22:true,Adults19to36:false,Adults19to40:true,Adults41to65:true,Adults66to75:false}}}},AnnualWinter:{Key:"AnnualWinter",Description:"Annual Multi-Trip with Winter Sports",StartOffset:{Value:0,Type:"day"},Modifier:{},Travellers:{Infants0to1:true,Children2to18:true,Students19to22:true,Adults19to36:false,Adults19to40:true,Adults41to65:true,Adults66to75:true,Areas:{WorldwideIncUSA:{Infants0to1:true,Children2to18:true,Students19to22:true,Adults19to36:false,Adults19to40:true,Adults41to65:true,Adults66to75:false},WorldwideExcUSA:{Infants0to1:true,Children2to18:true,Students19to22:true,Adults19to36:false,Adults19to40:true,Adults41to65:true,Adults66to75:false}}}}};var TAFConfigurations={UnitedKingdom:{Description:"United Kingdom",FullDescription:"<p><strong>United Kingdom</strong>: England, Northern Ireland, Scotland, Wales, The Isle of Man and the Channel Islands.</p>",Class:"uk"},Europe:{Description:"Europe",FullDescription:"<p><strong>Europe</strong>: All of Europe, including all the countries to the west of the Ural Mountains, the Mediterranean Islands, the Canary Islands, Turkey, Madeira, the Azores and Iceland.</p>",Class:"europe"},AustraliaNZ:{Description:"Australia &amp; New Zealand",FullDescription:"<p><strong>Australia and New Zealand</strong>: Australia and New Zealand.</p>",Class:"europeAusNZ"},WorldwideExcUSA:{Description:"Worldwide Excluding<span>USA, Canada &amp The Caribbean</span>",FullDescription:"<p><strong>Worldwide excluding USA, Canada and Caribbean</strong>: Africa, Asia, Australasia, South America, India, Israel, Egypt, Tunisia, Morocco, Algeria, Middle East, etc.</p>",Class:"worldWideExcUSA"},WorldwideIncUSA:{Description:"Worldwide Including<span>USA, Canada &amp The Caribbean</span>",FullDescription:"<p><strong>Worldwide including USA, Canada and Caribbean</strong>: USA, Canada, all Caribbean Islands and all other countries.</p>",Class:"worldWideIncUSA"}};var TypeDefinitions={Individual:"<p><strong>Individual</strong>: One person on the policy</p>",Couple:"<p><strong>Couple</strong>: An individual and his or her partner provided they live together.  A partner would include a civil partner.</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 (not available on Annual Multi-Trip policies).</p>"};var Global={Validators:{},Filter:{PolicyTypes:null,TravelAreas:null,DefaultPolicyType:null},Data:{PolicyType:null,TravelArea:null,StartDate:null,EndDate:null,UpToDays:null,Travellers:{Infants0to1:0,Children2to18:0,Students19to22:0,Adults19to36:0,Adults19to40:0,Adults41to65:0,Adults66to75:0}},Configuration:null,Cache:{TravelAreas:{},Countries:{}},IsLargeControl:false};var $C=function(d){if(arguments.length>1){var a="";for(var b=0;b<arguments.length;b++){var c=arguments[b];if(b>0){a+=", "}if(typeof(SCControls)!="undefined"){a+="#"+SCControls[c]}else{a+="#"+c}}return $(a)}else{if(typeof(SCControls)!="undefined"){return $("#"+SCControls[d])}return $("#"+d)}};$.fn.AddValidator=function(b){var a=$(this);var d=a.attr("id");if(Global.Validators[d]){var c=Global.Validators[d];Global.Validators[d]=function(e){return c(e)&b(e)}}else{Global.Validators[d]=b}};$.fn.Validate=function(){var b=$(this);var d=b.attr("id");var a=b.selector;if(a=="form"){var c=true;b.children("input, textarea, select").each(function(){var f=$(this);var e=f.attr("id");if(Global.Validators[e]){c=c&Global.Validators[e](f)}else{c=c&true}});return c}else{if(Global.Validators[d]){return Global.Validators[d](b)}return true}};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.Clone=function(){var b=this.getTime();var a=new Date();a.setTime(b);return a};Date.prototype.AddDays=function(c){var a=this.Clone();a.setHours(12);var b=a.getTime();a.setTime(b+(c*References.Day));a.setHours(0);return a};Date.prototype.AddMonths=function(b){var a=this.Clone();var c=this.getMonth();a.setMonth(c+b);return a};Date.prototype.AddYears=function(b){var a=this.Clone();a.setFullYear(a.GetYear()+b,a.getMonth(),a.getDate());return a};Date.prototype.AddOffset=function(a,b){if(a=="day"){return this.AddDays(b)}else{if(a=="month"){return this.AddMonths(b)}else{if(a=="year"){return this.AddYears(b)}}}return this.Clone()};Date.prototype.CompareTo=function(a){return(this<a)?-1:(this>a)?1:0};Date.prototype.GetYear=function(){var a=this.getYear();return a<1000?(a+1900):a};Date.prototype.Floor=function(){var a=this.Clone();a.setHours(0,0,0,0);return a};Date.prototype.Valid=function(b){var i=this.GetYear();var h=this.getMonth()+1;var j=this.getDate();var g=b.GetYear();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=System.ServerDate;var k=c.GetYear();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};Array.prototype.Contains=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)})}};$.fn.Select=function(){var a=$(this);Defer(function(){a.attr("selected","selected")},100)};var DifferenceInDays=function(b,a){return Math.round((a-b)/References.Day)*1};var IsLeapYear=function(a){return(new Date(a,1,29).getDate()==29)};var NextLeapYear=function(){var c=System.ServerDate;var e=c.GetYear();var d=c.getMonth();var b=c.getDate();if(d>1||(d==1&&b==29)){e++}var a=false;while(!a){a=IsLeapYear(e);if(a){break}e++}return e};var IsValidDate=function(a,d,c,e){var b=new Date();b.setFullYear(c,d-1,a);b=b.Floor();return b.Valid(e)};var IsValidForFullLeapYear=function(c){var b=new Date(NextLeapYear(),1,29);var a=c.AddYears(1);c=c.Floor();a=a.Floor();return((c<=b)&&(a>=b))?true:false};var GetStartDate=function(){return Global.Data.StartDate};var SetStartDate=function(b,a,d,c){Global.Data.StartDate=b;Defer(function(){$(document).trigger(Events.StartDateChanged,{Date:b,RefreshStart:a,RefreshEnd:d,RefreshDays:c})},100)};var GetEndDate=function(){return Global.Data.EndDate};var SetEndDate=function(b,a,d,c){Global.Data.EndDate=b;Defer(function(){$(document).trigger(Events.EndDateChanged,{Date:b,RefreshStart:a,RefreshEnd:d,RefreshDays:c})},100)};var SetTravelArea=function(b,c){var a=Global.Data.TravelArea;Global.Data.TravelArea=b;$(document).trigger(Events.TravelAreaChanged,{Existing:a,New:b,Validate:c})};var CreateMonthControl=function(a){a.empty();References.Months.Each(function(c,d){var b=Templates.Option.Format(c+1,References.Months[c]);a.append(b)})};var CreateDayControl=function(d,e,c){d.empty();var f=References.Days[e];if(e==1&&IsLeapYear(c)){f=29}for(var b=1;b<=f;b++){var a=Templates.Option.Format(b,b<=9?"0"+b:b);d.append(a)}};var RefreshDayControl=function(c,d,b){var e=References.Days[d];if(d==1&&IsLeapYear(b)){e=29}var a=c.val();if(a>e){a=e}CreateDayControl(c,d,b);c.children("option[value="+a+"]").Select()};var CreateNumericalList=function(d,f,a,e){d.empty();if(e<f||e>a){e=f}for(var c=f;c<a;c++){var b=Templates.Option.Format(c,c);d.append(b)}d.children("option[value="+e+"]").Select()};var CreateTravelAreaFinder=function(){CreateOverlay(null,true);var c=Global.Configuration;var g=$(window);var f=g.width();var b=g.height();var d=Templates.TravelAreaFinder;$("body").append(d);var e=$("div.finder");e.css({position:"absolute",left:((f/2)-(e.width()/2)),top:((b/2)-(e.height()/2)),zIndex:102});var a=$C("list_PolicyType").val()=="Backpacker"?"Backpacker":"";$(".map").addClass(a=="Backpacker"?" bp":"");if(Global.Cache.Countries!=null&&Global.Cache.Countries[a]){BindCountries(Global.Cache.Countries[a])}else{CreateProgressOverlay($("div.finder div.control"));Async("GetCountries/"+a,function(h){$("div.controlOverlayProgress").remove();Global.Cache.Countries[a]={};$.each(h,function(j,k){Global.Cache.Countries[a][k.Key]=k});BindCountries(Global.Cache.Countries[a])})}$("#country").change(function(){var i=GetBestTravelArea();var h=TAFConfigurations[i];$("div.finder div.name").html(h.Description);$("div.finder div.map").removeAttr("class").addClass("map "+h.Class+((Global.Configuration.Key=="Backpacker")?" bp":""))});$("div.finder div.proceed a").click(function(){var h=GetBestTravelArea();$("div.finder").remove();DestroyOverlays();if(h!=""){SetTravelArea(h,true);$C("list_TravelArea").children("option[value="+h+"]").Select()}});$("div.finder div.close a").click(function(){$("div.finder").remove();DestroyOverlays()})};var CreateProgressOverlay=function(b){var c=b.offset();var a=Templates.Progress.Format("controlOverlayProgress","/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:200})};var GenerateCalendar=function(g,b){var n=g.getMonth()+1;var o=g.GetYear();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:References.Days[n-1];var h=(c==2&&IsLeapYear(e))?29:References.Days[c-1];var g=new Date();g.setFullYear(o,n-1,1);var k=Templates.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+=Templates.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+=Templates.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+=Templates.Calendar.Day.Format(""+j+"_"+n+"_"+o,j,IsValidDate(j,n,o,b)?"":"invalidDate")}var a=1;for(var j=f;j<6;j++){k+=Templates.Calendar.NextDay.Format(""+a+"_"+l+"_"+p,a,IsValidDate(a,l,p,b)?"":"invalidDate");a+=1}k+="</tr>";return Templates.Table.Table.Format(k)};var CreateCalendarPopup=function(d,b,a,h,k){CreateOverlay(null,true);var c=h.offset();var f=Templates.Calendar.Popup.Format(GenerateCalendar(b,a));$("body").append(f);$("div.calendarPopup").css({position:"absolute",top:c.top+h.innerHeight()+3,left:c.left,zIndex:102});CreateMonthControl($("select.monthSelect"));var e=System.ServerDate.GetYear();CreateNumericalList($("select.yearSelect"),e,e+4,b.GetYear());var i=b.getMonth()+1;var g=b.GetYear();$("select.monthSelect").children("option[value="+i+"]").Select();$("select.yearSelect").children("option[value="+g+"]").Select();var j=function(o){var l=$(o).attr("rel").split("_");var m=parseInt(l[0]);var q=parseInt(l[1]);var p=parseInt(l[2]);var n=new Date();n.setFullYear(p,q-1,m);$("div.calendarPopup").remove();DestroyOverlays();k({Date:n})};$("select.monthSelect, select.yearSelect").change(function(){var o=$("select.monthSelect").val();var n=$("select.yearSelect").val();var l=new Date();l.setFullYear(n,(o-1),1);var m=GenerateCalendar(l,a);$("div.calendarPopup table").after(m).remove();$("div.calendarPopup table td:not(.invalidDate) a").click(function(){j($(this))})});$("div.calendarPopup table td:not(.invalidDate) a").click(function(){j($(this))});$("div.calendarPopup .todayLink a").click(function(){$("div.calendarPopup").remove();DestroyOverlays();k({Date:new Date()})})};var CreateCompositionPopup=function(j){var b=Global.Configuration;var f="";if(j.Types){if(j.Types.length>1){var g="";j.Types.Each(function(k){if(g.length>0){g+=", "}g+=j.Types[k]});g='<a class="showDefinitions" href="javascript:void(0);">Definition of categories</a>';f+=Templates.Compositions.Category.Format(g)}else{f+=Templates.Compositions.SingleType.Format('<a class="showDefinitions" href="javascript:void(0);">{0}</a>'.format(j.Types[0]));if(b.Key=="Annual"||b.Key=="AnnualWinter"){if(j.Types[0]=="Couple"){f=Templates.Compositions.AMTCouple}}}}if(j.Children){f+=Templates.Compositions.Infants}if(j.Types){var c="";$.each(TypeDefinitions,function(k){if(k=="Family"){if(b.Key=="Annual"||b.Key=="AnnualWinter"){c+=TypeDefinitions[k].format(" (at a discounted rate)")}else{c+=TypeDefinitions[k].format("")}}else{c+=TypeDefinitions[k]}});var h="";if(b.Key!="Annual"&&b.Key!="AnnualWinter"){h=Templates.Compositions.NonAMTFootnote}f+=Templates.Compositions.Definitions.Format(c,h)}f+=Templates.Compositions.Proceed;CreateHelpPopup(f,$("div.smallControl"),PopupPosition.CenterWindow);var e=$(window);var a=$("div.popup");$("div.popup").css({top:((e.height()/2)-(a.height()/2))+e.scrollTop(),left:((e.width()/2)-(a.width()/2))+e.scrollLeft()});if(j.Types){j.Types.Each(function(l){var k=Templates.Option.Format(j.Types[l],j.Types[l]);$("select.groupType").append(k)})}if(j.Children){for(var d=0;d<=j.Children;d++){var f=Templates.Option.Format(d,d);$("select.infantCount").append(f)}}$("a.showDefinitions").click(function(){$("div.definitions").toggle();$("div.popup").css({top:((e.height()/2)-(a.height()/2))+e.scrollTop(),left:((e.width()/2)-(a.width()/2))+e.scrollLeft()})});$("div.popup div.proceedLink a").click(function(){var k=0;if(j.Children){k=parseInt($("select.infantCount").val())}if(!j.Types){i="Individual"}else{var i=j.Types.length>1?$("div.popup select.groupType").val():j.Types[0]}$("div.popup").remove();DestroyOverlays();$(document).trigger(Events.BeforeSubmit,{Type:i,Infants:k});$(document).trigger(Events.Submit,{});return false})};var Defer=function(a){if($.browser.msie&&$.browser.version==6){setTimeout(a,100)}else{a()}};var ForceDefer=function(a){setTimeout(a,100)};var Async=function(c,b){var a=System.Url;if(a.substr(a.length-1)!="/"){a+="/"}a+=c;$.ajax({type:"GET",url:a,dataType:"json",contentType:"application/json; charset=utf-8",cache:false,success:function(d){$(document).trigger(Events.ServiceLoaded,{Result:d});if(b){b(d)}},error:function(f,d,e){$(document).trigger(Events.ServiceError,{XmlHttpRequest:f,Error:d,Message:e})}})};var BindPolicyTypes=function(){var a=$C("list_PolicyType");if(Global.Filter.PolicyTypes!=null){Global.Filter.PolicyTypes.split(",").Each(function(c,d){var b=Configurations[d];a.append(Templates.Option.Format(b.Key,b.Description))})}else{$.each(Configurations,function(b,c){a.append(Templates.Option.Format(c.Key,c.Description))})}if(Global.Filter.DefaultPolicyType){a.children("option[value="+Global.Filter.DefaultPolicyType+"]").Select()}a.change(function(){$(document).trigger(Events.PolicyTypeChanged,{Existing:Global.Configuration.Key,New:a.val()})})};var BindTravelAreas=function(){var a=$C("list_TravelArea");a.empty();Global.Cache.TravelAreas.Each(function(b,c){if(c.TripType.Value==Global.Configuration.Key){a.append(Templates.Option.Format("","Please select..."));c.TravelAreas.Each(function(e,d){if(!Global.Filter.TravelAreas||Global.Filter.TravelAreas.split(",").Contains(d.Value)){a.append(Templates.Option.Format(d.Value,d.Text))}})}});a.change(function(){$(document).trigger(Events.TravelAreaChanged,{Existing:Global.Data.TravelArea,New:a.val(),Validate:true})})};var RebindTravelAreas=function(){var a=$C("list_TravelArea");var b=a.val();a.unbind("change");BindTravelAreas();a.children("option[value="+b+"]").Select();Defer(function(){var c=a.val();if(c==""){Global.Data.TravelArea=null}},100)};var BindCountries=function(d){var c=$("div.finder select");var b=$C("list_TravelArea").val();$.each(d,function(e,f){c.append(Templates.Option.Format(f.Value,f.Key))});c.show().css({visibility:"visible"});if(Global.Filter.TravelAreas!=null&&b==""){Defer(function(){c.children("option:contains("+Global.Filter.TravelAreas+")").Select();var f=GetBestTravelArea();var e=TAFConfigurations[f];$("div.finder div.name").html(e.Description);$("div.finder div.map").removeAttr("class").addClass("map "+e.Class)},100)}else{if(b!=""){var a=TAFConfigurations[b];$("div.finder div.name").html(a.Description);$("div.finder div.map").removeAttr("class").addClass("map "+a.Class)}}};var GetBestTravelArea=function(){var c=0;var b="";var a=$C("list_PolicyType").val()=="Backpacker"?"Backpacker":"";if(Global.Filter.TravelAreas!=null){$("div.finder select option:contains("+Global.Filters.TravelAreas+")").Select()}$("div.finder select option:selected").each(function(d){var e=$(this).text();var f=parseInt(Global.Cache.Countries[a][e].Rank,10);if(f>c){c=f;b=$(this).attr("value")}});if(Global.Configuration.Key=="Annual"||Global.Configuration.Key=="AnnualWinter"){if(b=="UnitedKingdom"){b="Europe"}else{if(b=="WorldwideExcUSA"){b="WorldwideIncUSA"}}}return b};var BindDateControls=function(g){var d=System.ServerDate;if(Global.Configuration.StartDateOffset){d=d.AddOffset(Global.Configuration.StartDateOffset.Type,Global.Configuration.StartDateOffset.Value)}if(Global.Data.StartDate){d=Global.Data.StartDate}var c=d.getDate();var f=d.getMonth();var e=d.GetYear();var b=System.ServerDate.GetYear();if(!g||g=="start"){CreateDayControl($C("list_StartDay"),f,e);CreateMonthControl($C("list_StartMonth"));CreateNumericalList($C("list_StartYear"),b,b+4,e);$C("list_StartDay").children("option[value="+c+"]").Select();$C("list_StartMonth").children("option[value="+(f+1)+"]").Select();$C("list_StartYear").children("option[value="+e+"]").Select()}if(!g||g=="end"){var a=d.Clone();if(Global.Configuration.EndOffset){a=a.AddOffset(Global.Configuration.EndOffset.Type,Global.Configuration.EndOffset.Value)}if(Global.Data.EndDate){a=Global.Data.EndDate}if(Global.Configuration.Modifier.Type=="days"){c=a.getDate();f=a.getMonth();year2=a.GetYear();CreateDayControl($C("list_EndDay"),f,year2);CreateMonthControl($C("list_EndMonth"));CreateNumericalList($C("list_EndYear"),b,b+4,year2);$C("list_EndDay").children("option[value="+c+"]").Select();$C("list_EndMonth").children("option[value="+(f+1)+"]").Select();$C("list_EndYear").children("option[value="+year2+"]").Select()}}if(!g||g=="start"){$C("list_StartMonth","list_StartYear").change(function(){var i=parseInt($C("list_StartMonth").val(),10);var h=parseInt($C("list_StartYear").val(),10);RefreshDayControl($C("list_StartDay"),i-1,h);Defer(function(){var j=parseInt($C("list_StartDay").val(),10);var m=parseInt($C("list_StartMonth").val(),10)-1;var l=parseInt($C("list_StartYear").val(),10);var k=new Date(l,m,j);SetStartDate(k,false,false,true)})});$C("list_StartDay").change(function(){Defer(function(){var h=parseInt($C("list_StartDay").val(),10);var k=parseInt($C("list_StartMonth").val(),10)-1;var j=parseInt($C("list_StartYear").val(),10);var i=new Date(j,k,h);SetStartDate(i,false,false,true)})})}if(!g||g=="end"){$C("list_EndMonth","list_EndYear").change(function(){var i=parseInt($C("list_EndMonth").val(),10);var h=parseInt($C("list_EndYear").val(),10);RefreshDayControl($C("list_EndDay"),i-1,h);Defer(function(){var j=parseInt($C("list_EndDay").val(),10);var m=parseInt($C("list_EndMonth").val(),10)-1;var l=parseInt($C("list_EndYear").val(),10);var k=new Date(l,m,j);SetEndDate(k,false,false,true)})});$C("list_EndDay").change(function(){Defer(function(){var h=parseInt($C("list_EndDay").val(),10);var k=parseInt($C("list_EndMonth").val(),10)-1;var j=parseInt($C("list_EndYear").val(),10);var i=new Date(j,k,h);SetEndDate(i,false,false,true)})})}};var RebindDateControls=function(a){if(a){if(a=="start"){$C("list_StartDay").unbind("change");$C("list_StartMonth","list_StartYear").unbind("change")}else{if(a=="end"){$C("list_EndDay").unbind("change");$C("list_EndMonth","list_EndYear").unbind("change")}}}else{$C("list_StartDay","list_EndDay").unbind("change");$C("list_StartMonth","list_StartYear").unbind("change");$C("list_EndMonth","list_EndYear").unbind("change")}BindDateControls(a)};var BindDaysControl=function(){var d=$C("list_UptoDays");var b=Global.Configuration;d.empty();if(b.Modifier.SubType=="range"){for(var c=b.Modifier.Lower;c<=b.Modifier.Upper;c++){d.append(Templates.Option.Format(c,c))}if(b.Key=="Single"||b.Key=="SingleWinter"){var a=GetStartDate();if(IsValidForFullLeapYear(a)){d.append(Templates.Option.Format(366,366))}}}else{if(b.Key=="Backpacker"){b.Modifier.Items.Each(function(e,f){d.append(Templates.Option.Format(f.Key,f.Value))})}}if(b.Modifier.Class){$("div.uptoDays").addClass(b.Modifier.Class)}else{$("div.uptoDays").removeAttr("class").addClass("uptoDays")}d.change(function(){var g=Global.Configuration;var h=d.val();var f=h;if(g.Modifier.SubType=="collection"){f=parseInt(h.split("-")[1],10)}else{f=parseInt(h,10)}f=f-1;var e=GetStartDate();var i=e.AddDays(f);SetEndDate(i,false,true,false)})};var CalculateDateDifference=function(){ForceDefer(function(){var a=GetStartDate();var d=GetEndDate();var c=DifferenceInDays(a,d)+1;var b=Global.Configuration;if(b.Modifier.SubType=="range"){$C("list_UptoDays").children("option[value="+c+"]").Select()}else{$.each($C("list_UptoDays").children("option"),function(f,h){var j=h.value;var e=parseInt(j.split("-")[0],10);var g=parseInt(j.split("-")[1],10);if(c>=e&&c<=g){$C("list_UptoDays").children("option[value="+e+"-"+g+"]").Select()}})}},100)};var RebindDaysControl=function(){var b=$C("list_UptoDays");var c=b.val();b.unbind("change");BindDaysControl();if(c=="366"){var a=GetStartDate();if(!IsValidForFullLeapYear(a)){c="365";var d=GetStartDate().AddDays(364);SetEndDate(d,false,true,true)}}b.children("option[value="+c+"]").Select()};var BindAgeControl=function(b,a){b.empty();b.append(a)};var BindAgeControls=function(){var b="";for(var a=0;a<10;a++){b=b+Templates.Option.Format(a,a)}BindAgeControl($C("list_Adults_19_36"),b);BindAgeControl($C("list_Adults_19_40"),b);BindAgeControl($C("list_Adults_41_65"),b);BindAgeControl($C("list_Adults_66_75"),b);BindAgeControl($C("list_Infants_0_1"),b);BindAgeControl($C("list_Children_2_18"),b);BindAgeControl($C("list_Students_19_22"),b)};var RebindAgeControls=function(){var b=$C("list_Adults_19_36").val();var g=$C("list_Adults_19_40").val();var a=$C("list_Adults_41_65").val();var f=$C("list_Adults_66_75").val();var e=$C("list_Infants_0_1").val();var c=$C("list_Children_2_18").val();var d=$C("list_Students_19_22").val();BindAgeControls();$C("list_Adults_19_36").children("option[value="+b+"]").Select();$C("list_Adults_19_40").children("option[value="+g+"]").Select();$C("list_Adults_41_65").children("option[value="+a+"]").Select();$C("list_Adults_66_75").children("option[value="+f+"]").Select();$C("list_Infants_0_1").children("option[value="+e+"]").Select();$C("list_Children_2_18").children("option[value="+c+"]").Select();$C("list_Students_19_22").children("option[value="+d+"]").Select()};var SetConfiguration=function(a){if(Configurations[a]){Global.Configuration=Configurations[a]}else{Global.Configuration=Configurations[References.DefaultPolicyType]}Global.Data.PolicyType=Global.Configuration.Key};var reconfigureCount=0;var ConfigureLayout=function(a){if(a){reconfigureCount++}var b=Global.Configuration;if(Global.Configuration.Key=="Annual"||Global.Configuration.Key=="AnnualWinter"){Global.Data.EndDate=Global.Data.StartDate.AddYears(1).AddDays(-1)}else{Global.Data.EndDate=Global.Data.StartDate.AddDays(Global.Configuration.EndOffset.Value)}if(System.Source=="QuotationFunnel"){$("div.modifier").addClass("amtModifier");$("div.ageSelection").addClass("amtModifier2")}if(Global.Configuration.Key=="Annual"||Global.Configuration.Key=="AnnualWinter"){$("div.amtAgeNotice").show();if(System.Source=="LandingPage"){$("div.modifier").addClass("amtModifier");$("div.ageSelection").addClass("amtModifier2")}else{$("div.stAgeNotice").hide()}}else{$("div.amtAgeNotice").hide();if(System.Source=="LandingPage"){$("div.modifier").removeClass("amtModifier");$("div.ageSelection").removeClass("amtModifier2")}else{$("div.stAgeNotice").show()}}if(b.Modifier.Type=="days"){if(!a){$("div.uptoDays").show();$("div.endDate").show()}else{if(Global.IsLargeControl&&System.Effects&&!($.browser.msie&&$.browser.version==6)){$("div.modifier, div.uptoDays, div.endDate").slideDown("normal")}else{$("div.uptoDays").show();$("div.endDate").show()}}BindDaysControl()}else{if(!a){$("div.uptoDays").hide();$("div.endDate").hide()}else{if(Global.IsLargeControl&&System.Effects&&!($.browser.msie&&$.browser.version==6)){$("div.modifier").slideUp("normal")}else{$("div.uptoDays").hide();$("div.endDate").hide()}}}if(a){if(b.Key=="Backpacker"){Defer(function(){$C("list_Adults_19_36").children("option[value=1]").Select();$C("list_Infants_0_1").children("option[value=0]").Select();$C("list_Children_2_18").children("option[value=0]").Select();SetTravelArea(null,false);$C("list_TravelArea").val("")},100)}else{Defer(function(){var c=GetTravellers();if(c.Total==0){$C("list_Adults_19_40").children("option[value=1]").Select()}},100)}RebindAgeControls();if(reconfigureCount>1){Defer(function(){InvokeTravellerEvent()},100)}}else{BindAgeControls()}if(b.Key=="Annual"||b.Key=="AnnualWinter"){$C("label_JourneyStartDate").html("Policy Start Date")}else{$C("label_JourneyStartDate").html("Journey Start Date")}Defer(function(){CalculateDateDifference()},100);if((!Global.IsLargeControl&&a)||(Global.IsLargeControl&&a&&reconfigureCount>1)){Defer(function(){ValidateTravellers()},150)}};var ConfigureAgeControls=function(){var a=AssesTravellerInclusion();ConfigureAgeControlLayout(a.PolicyType,a.Adults19to36,a.Adults19to40,a.Adults41to65,a.Adults66to75,a.Infants0to1,a.Children2to18,a.Students19to22)};var SetAgeControlVisibility=function(a,b){if(a){if(b=="adults_66_75"){$("#"+b+", #"+b+" select").css("visibility","visible")}else{$("#"+b).removeClass("hidden");$("#"+b+" select").css("visibility","visible")}}else{if(b=="adults_66_75"){$("#"+b+", #"+b+" select").css("visibility","hidden")}else{Defer(function(){$("#"+b).addClass("hidden");$("#"+b+" select").css("visibility","hidden")},100)}}};var ConfigureAgeControlLayout=function(c,b,h,a,g,f,d,e){SetAgeControlVisibility(b,"adults_19_36");SetAgeControlVisibility(h,"adults_19_40");SetAgeControlVisibility(a,"adults_41_65");SetAgeControlVisibility(g,"adults_66_75");SetAgeControlVisibility(f,"infants_0_1");SetAgeControlVisibility(d,"children_2_18");SetAgeControlVisibility(e,"students_19_22");if(c=="Backpacker"){$("#infants_0_1").addClass("clear").removeClass("right");$("#children_2_18").addClass("clear").removeClass("right")}else{$("#infants_0_1").addClass("right").removeClass("clear");$("#children_2_18").addClass("right").removeClass("clear")}};var AssesTravellerInclusion=function(){var b=Global.Configuration;var d=Global.Data.TravelArea;var c=(b.Travellers.Areas&&b.Travellers.Areas[d])?b.Travellers.Areas[d]:null;var a={PolicyType:Global.Data.PolicyType,Adults19to36:b.Travellers.Adults19to36&&(c==null?true:c.Adults19to36),Adults19to40:b.Travellers.Adults19to40&&(c==null?true:c.Adults19to40),Adults41to65:b.Travellers.Adults41to65&&(c==null?true:c.Adults41to65),Adults66to75:b.Travellers.Adults66to75&&(c==null?true:c.Adults66to75),Infants0to1:b.Travellers.Infants0to1&&(c==null?true:c.Infants0to1),Children2to18:b.Travellers.Children2to18&&(c==null?true:c.Children2to18),Students19to22:b.Travellers.Students19to22&&(c==null?true:c.Students19to22)};return a};var ValidateStartDate=function(){var b=Global.Configuration;var a=System.ServerDate;var e=GetStartDate();if(e.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),PopupPosition.OwnerLeft)});return false}else{var c=parseInt($C("list_Adults_66_75").val());if(c>0){var d=a.AddMonths(12);if(e.CompareTo(d)==1){$("#startDateState .help").hide();if(b.Key=="Single"||b.Key=="SingleWinter"){$("#startDateState .error").css("display","block").unbind("click").click(function(){CreateErrorPopup("<p>Policies cannot be issued more than 12 months in advance.</p>",$(this),PopupPosition.OwnerLeft)})}else{if(b.Key=="Annual"||b.Key=="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),PopupPosition.OwnerLeft)})}}return false}else{$("#startDateState .help").css("display","block");$("#startDateState .error").hide()}}else{var d=a.AddMonths(18);if(e.CompareTo(d)==1){$("#startDateState .help").hide();if(b.Key=="Single"||b.Key=="SingleWinter"||b.Key=="Backpacker"){$("#startDateState .error").css("display","block").unbind("click").click(function(){CreateErrorPopup("<p>Policies cannot be issued more than 18 months in advance.</p>",$(this),PopupPosition.OwnerLeft)})}else{if(b.Key=="Annual"||b.Key=="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),PopupPosition.OwnerLeft)})}}return false}else{$("#startDateState .help").css("display","block");$("#startDateState .error").hide()}}}ValidateEndDate();return true};var ValidateEndDate=function(){var b=Global.Configuration;if(b.Key=="Annual"||b.Key=="AnnualWinter"){$("#endDateState .help").css("display","block");$("#endDateState .error").hide();return true}var g=GetStartDate();var a=GetEndDate();var c=new Date(NextLeapYear(),1,29).AddDays(1);if(g.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),PopupPosition.OwnerLeft)});return false}else{if(b.Key=="Backpacker"||b.Key=="Single"||b.Key=="SingleWinter"){var e=parseInt($C("list_Adults_66_75").val(),10);if(e>0&&b.Key!="Backpacker"&&DifferenceInDays(g,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),PopupPosition.OwnerLeft)});return false}else{var d=IsValidForFullLeapYear(g)&&b.Key!="Backpacker";var f=g.AddDays(d?365:364);if(a.CompareTo(f)>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 "+(d?"366":"365")+" days.</p>",$(this),PopupPosition.OwnerLeft)});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 d=Global.Configuration;var a=AssesTravellerInclusion();var h=0;var i=0;var g=0;var e=0;var c=0;var j=0;var b=0;var f=0;if(a.Adults19to36){i=parseInt($C("list_Adults_19_36").val());h+=i}if(a.Adults19to40){g=parseInt($C("list_Adults_19_40").val());h+=g}if(a.Adults41to65){e=parseInt($C("list_Adults_41_65").val());h+=e}if(a.Adults66to75){c=parseInt($C("list_Adults_66_75").val());h+=c}if(a.Infants0to1){j=parseInt($C("list_Infants_0_1").val());h+=j}if(a.Children2to18){b=parseInt($C("list_Children_2_18").val());h+=b}if(a.Students19to22){f=parseInt($C("list_Students_19_22").val());h+=f}if(h==0||h>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),PopupPosition.OwnerLeft)});return false}if(d.Key!="Single"&&d.Key!="SingleWinter"&&d.Key!="Backpacker"){if((g+e+c)>2||((g+e+c)==0&&((f+b+j)>1))||(j>0&&j==h)){$("#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),PopupPosition.OwnerLeft)});return false}}$("#ageState .help").css("display","block");$("#ageState .error").hide();return true};var ValidateTravelArea=function(){var b=Global.Data.TravelArea;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),PopupPosition.OwnerLeft)})}return a};var Validate=function(){var b=AssesTravellerInclusion();if(!b.Adults19to36){$C("list_Adults_19_36 > option[value=0]").Select()}if(!b.Adults19to40){$C("list_Adults_19_40 > option[value=0]").Select()}if(!b.Adults41to65){$C("list_Adults_41_65 > option[value=0]").Select()}if(!b.Adults66to75){$C("list_Adults_66_75 > option[value=0]").Select()}if(!b.Infants0to1){$C("list_Infants_0_1 > option[value=0]").Select()}if(!b.Children2to18){$C("list_Children_2_18 > option[value=0]").Select()}if(!b.Students19to22){$C("list_Students_19_22 > option[value=0]").Select()}var a=ValidateStartDate()&&ValidateEndDate()&&ValidateTravelArea()&&ValidateTravellers();return a};var GetGroupValidationRule=function(){var d=Global.Configuration;var a=AssesTravellerInclusion();var l=0;var m=0;var i=0;var e=0;var c=0;var n=0;var b=0;var g=0;if(a.Adults19to36){m=parseInt($C("list_Adults_19_36").val());l+=m}if(a.Adults19to40){i=parseInt($C("list_Adults_19_40").val());l+=i}if(a.Adults41to65){e=parseInt($C("list_Adults_41_65").val());l+=e}if(a.Adults66to75){c=parseInt($C("list_Adults_66_75").val());l+=c}if(a.Infants0to1){n=parseInt($C("list_Infants_0_1").val());l+=n}if(a.Children2to18){b=parseInt($C("list_Children_2_18").val());l+=b}if(a.Students19to22){g=parseInt($C("list_Students_19_22").val());l+=g}var k={};var f=d.Key=="Backpacker";var j=m+i+e+c;var h=n+b+g;var o=(j==1||j==2);if(f){o=false}if(d.Key=="Single"||d.Key=="SingleWinter"||d.Key=="Backpacker"){if((h)>0){if((j==1||j==2)&&!f){k=$.extend(true,k,{Types:["Family","Group"]})}}else{if(j==2&&!f){k=$.extend(true,k,{Types:["Couple","Group"]})}}if((b+n)>0){k=$.extend(true,k,{Children2to18:b,Infants0to1:n})}}else{if(o){if(h==0){if(j==2){k=$.extend(true,k,{Types:["Couple"]})}}else{$.extend(true,k,{Types:["Family"]});if((b+n)>0){k=$.extend(true,k,{Children2to18:b,Infants0to1:n})}}}}return k};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),PopupPosition.OwnerLeft)});$("#travelAreaState .help").click(function(){var b="";var a=Global.Configuration;var c=null;Global.Cache.TravelAreas.Each(function(d,e){if(e.TripType.Value==a.Key){c=e}});$.each(c.TravelAreas,function(d,e){b+=TAFConfigurations[e.Value].FullDescription});CreateHelpPopup(b,$(this),PopupPosition.OwnerLeft)});$("#startDateState .help").click(function(){var a=Global.Configuration;var b="";if(a.Key=="Annual"||a.Key=="AnnualWinter"){b="<p>Please note that Cancellation cover (if purchased) commences from the Policy Start Date.</p>"}else{b="<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(b,$(this),PopupPosition.OwnerLeft)});$("#ageState .help").click(function(){var b=AssesTravellerInclusion();var a=Global.Configuration;var c;if(a.Key=="Annual"||a.Key=="AnnualWinter"){c="Please select the age group categories that apply at the policy start date.</p>"}else{c="Please select the age group categories that apply today.</p>"}c+="<p>The age group categories are as follows:<br />";if(b.Infants0to1){c+='<strong style="font-weight: bold;">Infants</strong>: Aged 0-1 inclusive.<br />'}if(b.Children2to18){c+='<strong style="font-weight: bold;">Children</strong>: Aged 2-18 inclusive.<br />'}if(b.Students19to22){c+='<strong style="font-weight: bold;">Students</strong>: Aged 19-22 inclusive, and in full-time education.<br />'}if(b.Adults19to36){c+='<strong style="font-weight: bold;">Adults</strong>: Aged 19-36 inclusive.<br />'}else{if(b.Adults66to75){c+='<strong style="font-weight: bold;">Adults</strong>: Aged 19-75 inclusive.<br />'}else{if(b.Adults41to65){c+='<strong style="font-weight: bold;">Adults</strong>: Aged 19-65 inclusive.<br />'}}}c+="</p>";CreateHelpPopup(c,$(this),PopupPosition.OwnerLeft)});$("div.footer-desc a").click(function(){var a="<p>You must be a UK resident.</p><p>You and all other persons insured on this policy must have your main home in the United Kingdom and have a United Kingdom National Insurance number and be registered with a doctor in the United Kingdom at the time you buy or renew this policy.</p><p>Residents of the Channel Islands and the Isle of Man must have their main home in the Channel Islands or Isle of Main respectively and be registered with a local doctor.</p>";CreateHelpPopup(a,$(this),PopupPosition.OwnerBottom)});$("#studentInfo").click(function(){var a='A "student" is a person that is aged between 19 and 22 years inclusive, who is also in full-time further education.';CreateHelpPopup(a,$(this),PopupPosition.OwnerLeft)})};var SetDefaultData=function(){if(typeof(UserData)!="undefined"){if(UserData.Previous){if(UserData.Previous.PolicyType&&UserData.Previous.PolicyType!=null){$C("list_PolicyType > option[value="+UserData.Previous.PolicyType+"]").Select();$(document).trigger(Events.PolicyTypeChanged,{New:UserData.Previous.PolicyType});SetConfiguration(UserData.Previous.PolicyType);Defer(function(){if(UserData.Previous.TravelArea&&UserData.Previous.TravelArea!=null){$C("list_TravelArea > option[value="+UserData.Previous.TravelArea+"]").Select();SetTravelArea(UserData.Previous.TravelArea,true)}},100)}if(UserData.Previous.StartDate&&UserData.Previous.StartDate!=null){UserData.Previous.StartDate=eval(UserData.Previous.StartDate.replace(/\/Date\((.+)\)\//,"new Date($1)"));UserData.Previous.StartDate=UserData.Previous.StartDate.Floor();SetStartDate(UserData.Previous.StartDate,true,false,false)}if(UserData.Previous.EndDate&&UserData.Previous.EndDate!=null){UserData.Previous.EndDate=eval(UserData.Previous.EndDate.replace(/\/Date\((.+)\)\//,"new Date($1)"));UserData.Previous.EndDate=UserData.Previous.EndDate.Floor();SetEndDate(UserData.Previous.EndDate,false,true,true)}if(UserData.Previous.Travellers&&UserData.Previous.Travellers!=null){Defer(function(){$C("list_Adults_19_36 > option[value="+UserData.Previous.Travellers.Adults19to36+"]").Select();$C("list_Adults_19_40 > option[value="+UserData.Previous.Travellers.Adults19to40+"]").Select();$C("list_Adults_41_65 > option[value="+UserData.Previous.Travellers.Adults41to65+"]").Select();$C("list_Adults_66_75 > option[value="+UserData.Previous.Travellers.Seniors+"]").Select();$C("list_Students_19_22 > option[value="+UserData.Previous.Travellers.Students+"]").Select();$C("list_Children_2_18 > option[value="+UserData.Previous.Travellers.Children+"]").Select();$C("list_Infants_0_1 > option[value="+UserData.Previous.Travellers.Infants+"]").Select()},100)}}}};$(function(){PreloadImages("/Images/SmallControl/TravelAreaFinderSprite.jpg");if(typeof(System)!="undefined"){if(System.ServerDate&&System.ServerDate!=null){System.ServerDate=eval(System.ServerDate.replace(/\/Date\((.+)\)\//,"new Date($1)"));System.ServerDate=System.ServerDate.Floor();Global.Data.StartDate=System.ServerDate}Global.IsLargeControl=(System.Source=="QuotationFunnel")}$(document).trigger(Events.Initialise,{});$(document).trigger(Events.Loading,{})});$(document).bind(Events.Initialise,function(b,a){if(typeof(UserData)!="undefined"){SetConfiguration(UserData.Filter.DefaultPolicyType);if(UserData.Filter){Global.Filter.PolicyTypes=UserData.Filter.PolicyTypes;Global.Filter.TravelAreas=UserData.Filter.TravelAreas;Global.Filter.DefaultPolicyType=UserData.Filter.DefaultPolicyType}}else{Global.Configuration=Configurations[References.DefaultPolicyType]}BindHelpMessages()});$(document).bind(Events.Loading,function(b,a){if(!Global.Configuration||Global.Configuration==null){return}BindPolicyTypes();Async("GetTravelAreas/",function(c){Global.Cache.TravelAreas=c;BindDateControls();BindTravelAreas();$(document).trigger(Events.Loaded,{})})});$(document).bind(Events.PolicyTypeChanged,function(c,b){var a=b.New;SetConfiguration(a);RebindTravelAreas();RebindDateControls();ConfigureLayout(true);ConfigureAgeControls()});$(document).bind(Events.TravelAreaChanged,function(b,a){Global.Data.TravelArea=a.New;Defer(function(){ConfigureAgeControls();Defer(function(){if(a.Validate){ValidateTravelArea();ValidateTravellers()}if(Global.IsLargeControl&&reconfigureCount>1){InvokeTravellerEvent()}},100)},100)});$(document).bind(Events.StartDateChanged,function(d,c){if(c.RefreshStart||c.RefreshEnd){var b=(c.RefreshStart&&c.RefreshEnd)?undefined:(c.RefreshStart)?"start":"end";RebindDateControls(b)}if(c.RefreshDays){RebindDaysControl()}var a=Global.Configuration;if(a.Key!="Annual"&&a.Key!="AnnualWinter"){CalculateDateDifference()}Defer(function(){ValidateStartDate()},100)});$(document).bind(Events.EndDateChanged,function(d,c){var a=Global.Configuration;if(c.RefreshDays){if(a.Key!="Annual"&&a.Key!="AnnualWinter"){CalculateDateDifference()}}if(c.RefreshStart||c.RefreshEnd){var b=(c.RefreshStart&&c.RefreshEnd)?undefined:(c.RefreshStart)?"start":"end";RebindDateControls(b)}if(c.RefreshDays){RebindDaysControl()}ValidateEndDate()});$(document).bind(Events.Loaded,function(c,b){ConfigureLayout(false);ConfigureAgeControls();var a=Global.Configuration;if(a.Key!="Annual"&&a.Key!="AnnualWinter"){CalculateDateDifference()}$("#adults_19_40 select option[value=1]").Select();$("#adults_19_36 select option[value=1]").Select();$C("link_TravelArea").click(function(){CreateTravelAreaFinder()});$("#startDateCalendar a").click(function(){CreateCalendarPopup(System.ServerDate,GetStartDate(),GetStartDate().AddMonths(18),$C("list_StartMonth"),function(d){SetStartDate(d.Date,true,false,true)})});$("#endDateCalendar a").click(function(){CreateCalendarPopup(GetStartDate(),GetEndDate(),GetStartDate().AddDays(364),$C("list_EndMonth"),function(d){SetEndDate(d.Date,false,true,true)})});$C("list_Adults_19_36","list_Adults_19_40","list_Adults_41_65","list_Adults_66_75","list_Infants_0_1","list_Children_2_18","list_Students_19_22").change(function(){ValidateTravellers();ValidateStartDate();InvokeTravellerEvent()});$("div.footer-proceed a").click(function(){if(Validate()){var d=GetGroupValidationRule();if(d.Types||d.Children){CreateCompositionPopup(d)}else{$(document).trigger(Events.BeforeSubmit,{Type:"Individual",Infants:0});$(document).trigger(Events.Submit,{})}}return false});$("div.defaultOverlay").remove();$("div.innerContent select").css({visibility:"visible"});$("div.age").each(function(){var d=$(this);var e=d.css("visibility");d.find("select").css("visibility",e)});$("div.footer-desc a, div.footer-proceed a").css({visibility:"visible"});SetDefaultData()});$(document).bind(Events.BeforeSubmit,function(b,a){$C("hidden_GroupType").val(a.Type);$C("hidden_PolicyType").val(Global.Configuration.Key)});$(document).bind(Events.Submit,function(b,a){Defer(function(){if(System.Form!=null){$("form#"+System.Form).submit()}else{$("form").submit()}},100)});var InvokeTravellerEvent=function(){var a=GetTravellers();$(document).trigger(Events.TravellersChanged,{Travellers:a})};var GetTravellers=function(){var c=AssesTravellerInclusion();var h=!c.Adults19to36?0:parseInt($C("list_Adults_19_36").val(),10);var g=!c.Adults19to40?0:parseInt($C("list_Adults_19_40").val(),10);var e=!c.Adults41to65?0:parseInt($C("list_Adults_41_65").val(),10);var b=!c.Adults66to75?0:parseInt($C("list_Adults_66_75").val(),10);var f=!c.Students19to22?0:parseInt($C("list_Students_19_22").val(),10);var a=!c.Children2to18?0:parseInt($C("list_Children_2_18").val(),10);var i=!c.Infants0to1?0:parseInt($C("list_Infants_0_1").val(),10);var d={Adults19to36:h,Adults19to40:g,Adults41to65:e,Adults66to75:b,Students19to22:f,Children2to18:a,Infants0to1:i,Total:(h+g+e+b+f+a+i)};return d};
