function changeWizardPage(e,b,a,d,g,f,c){if(a.nodeType=="1"){a.blur()}currentPageElement=document.getElementById(e);newPageElement=document.getElementById(b);currentPageElement.style.display="none";newPageElement.style.display=""}function selectTo(b){if(bulletinBoardPreview==false){for(var a=0;a<document.itinerary.to.options.length;++a){if(document.itinerary.to.options[a].value==b){document.itinerary.to.selectedIndex=a;return}}}return}var prevOpen=new Array();var currOpen=new Array();var navlink="";function foldupRow(d,a,b,f,c){arrayStep=0;selectTo(b);currOpen=new Array();counter=1;while(counter<a){rowId=c+"-"+d+"-"+counter;currOpen[arrayStep]=rowId;arrayStep++;rowElement=document.getElementById(rowId);if(rowElement.style.display=="none"){rowElement.style.display="";f.className="redEDealsDestinationOpen"}else{rowElement.style.display="none";f.className="redEDealsDestinationExpand"}counter++}if(prevOpen[0]!=null){for(var e=0;e<prevOpen.length;e++){if(prevOpen[e]!=currOpen[e]){myElement=document.getElementById(prevOpen[e]);myElement.style.display="none"}}}prevOpen=currOpen;if(navlink!=""&&navlink!=f.id){mylink=document.getElementById(navlink);mylink.className="redEDealsDestinationExpand"}navlink=f.id}function Deal(b,a,d,c){this.fareValue=b;this.fromDate=this.parseFromDate(a);this.toDate=this.parseToDate(d);this.saleType=c}Deal.prototype.parseDate=function(b){var a=b.split("/");return new Date(a[2],(parseInt(a[1],10)-1),parseInt(a[0],10))};Deal.prototype.parseFromDate=function(a){return this.parseDate(a)};Deal.prototype.parseToDate=function(b){var a=this.parseDate(b);a.setHours(23);a.setMinutes(59);a.setSeconds(23);return a};function Destination(b,a){this.cityCode=b;this.cityName=a;this.deals=new Array();this.dealsReturn=new Array()}Destination.prototype.addDeal=function(b,a,d,c){this.deals[this.deals.length]=new Deal(b,a,d,c)};Destination.prototype.addReturnDeal=function(b,a,d,c){this.dealsReturn[this.dealsReturn.length]=new Deal(b,a,d,c)};function RedEDeals(c,b,a,d,e){this.id=c;this.region=b;this.departureCityCode=a;this.departureCityName=d;this.destinations=e;this.tableId_cityNameSorted=this.id+"_cityNameSorted";this.tableId_fareValueSorted=this.id+"_fareValueSorted"}RedEDeals.prototype.sortByDestinationNames=function(){this.destinations.sort(new Function("dest1","dest2","return (dest1.cityName<dest2.cityName?-1:(dest1.cityName>dest2.cityName?1:0));"))};RedEDeals.prototype.comparatorDestinationBlocksByCityNameThenFareValue=function(b,a){return b.fareValue-a.fareValue};RedEDeals.prototype.sortByDestinationNameAndFare=function(b){for(var a=0;a<destinations.length;++a){this.destinations[a].deals.sort(this.comparatorDestinationBlocksByCityNameThenFareValue)}};function helperComparatorByTravelDate(b,a){return b.fromDate.getTime()-a.fromDate.getTime()}RedEDeals.prototype.comparatorDestinationBlocksByCityNameThenFareValue=function(b,a){var d=b.fareValue;var c=a.fareValue;var e=d-c;return((d<c)?e:((d>c)?e:helperComparatorByTravelDate(b,a)))};RedEDeals.prototype.comparatorDestinationBlocksByLowestFareValue=function(a,c){var b=a.deals[0].fareValue-c.deals[0].fareValue;return(b==0?(a.cityName<c.cityName?-1:(a.cityName>c.cityName?1:0)):b)};RedEDeals.prototype.sortDestinationsBlocksByCityNameThenFareValue=function(){for(var a=0;a<this.destinations.length;++a){this.destinations[a].deals.sort(this.comparatorDestinationBlocksByCityNameThenFareValue)}};RedEDeals.prototype.sortDestinationsBlocksByLowestFareValue=function(){this.sortDestinationsBlocksByCityNameThenFareValue();this.destinations.sort(this.comparatorDestinationBlocksByLowestFareValue);this.destinations.sort(this.comparatorDestinationBlocksByLowestFareValue)};function updateRooPosition(){var b=document.getElementById("specialsLine");var d=document.getElementById("imageOnly");var c=650;var a=16;d.style.top=findPosY(b)-a;d.style.left=findPosX(b)+c}function addSale(a){var c=document.getElementById("saleTypesContainer");if(c==null){return true}var e=c.innerHTML;var d="";var b="sale"+a;if(e.indexOf(b)==-1){addHtml='<a class="'+b+'" href="javascript:void(null)" onClick="javascript:window.open(\'/deals/do/dyn/specials/spotsaledetail?spotSaleCode='+spotSaleCode[a-1]+"&dealBundleId="+dealBundleId+"','NewWin','width=640,height=490,status=yes,scrollbars=yes,resizable=yes')\">&nbsp;<img src=\""+spotSaleIcon[a-1]+'" border="0" hspace="5" vspace="0">&nbsp;'+spotSaleText[a-1]+"</a>";c.innerHTML=addHtml+e}}RedEDeals.prototype.writeTable=function(b,p,n){var o=window.document;var g=0;var f=0;var e=0;var a=0;o.write('\n<table class="results" id="'+b+'" cellspacing="0" '+(p?"":'style="display:none;"')+">");o.write('\n<colgroup><col class="first"><col class="second"><col class="third"><col class="fourth"></colgroup>');o.write("\n\t<tr>");if(this.destinations.length==1){if(n=="sortCity"){o.write("\n\t\t<th><strong>"+this.departureCityName+"</strong> to </th>")}else{o.write("\n\t\t<th>"+this.departureCityName+" to </th>")}}else{if(n=="sortCity"){o.write('\n\t\t<th><a class="sortByOn" href="javascript://void" onclick="javascript:changeWizardPage(\''+this.tableId_fareValueSorted+"','"+this.tableId_cityNameSorted+'\',this)" title="sort by city"><strong>'+this.departureCityName+"</strong> to </a></th>")}else{o.write('\n\t\t<th><a class="sortByOff" href="javascript://void" onclick="javascript:changeWizardPage(\''+this.tableId_fareValueSorted+"','"+this.tableId_cityNameSorted+'\',this)" title="sort by city">'+this.departureCityName+" to </a></th>")}}o.write('\n\t\t<th colspan="2">');if(this.destinations.length==1){o.write("One-way price from </th>")}else{if(n=="sortCity"){if(this.region=="au"){o.write('<a class="sortByOff" href="javascript://void" onclick="javascript:changeWizardPage(\''+this.tableId_cityNameSorted+"','"+this.tableId_fareValueSorted+"',this)\">One-way price&nbsp;from</a></th>")}else{o.write('<a class="sortByOff" href="javascript://void" onclick="javascript:changeWizardPage(\''+this.tableId_cityNameSorted+"','"+this.tableId_fareValueSorted+"',this)\">One-way price from</a></th>")}}else{if(this.region=="au"){o.write('<a class="sortByOn"  href="javascript://void" onclick="javascript:changeWizardPage(\''+this.tableId_cityNameSorted+"','"+this.tableId_fareValueSorted+"',this)\"><strong>One-way price&nbsp;from</strong></a></th>")}else{o.write('<a class="sortByOn" href="javascript://void" onclick="javascript:changeWizardPage(\''+this.tableId_cityNameSorted+"','"+this.tableId_fareValueSorted+"',this)\"><strong>One-way price</strong> from</a></th>")}}}o.write('\n\t\t<th class="travelBetween">Travel between</th>');o.write("\n\t</tr>");var q=null;var m=null;var l=null;var k=null;for(var h=0;h<this.destinations.length;++h){q=destinations[h];l=q.deals;for(var c=0;c<l.length;++c){k=l[c];o.write('<tr id="'+n+"-"+h+"-"+c+'"');if(h%2==0){o.write(' class="header"')}if(c>0){o.write(' style="display:none;"')}o.write(">");if(c>0){o.write("<td>&nbsp;</td>")}else{if(c==0&&l.length>1){o.write('<td><a id="navlink'+h+"-"+c+'" class="redEDealsDestinationExpand" href="javascript://void" onClick="javascript:foldupRow('+h+","+l.length+",'"+q.cityCode+"', this, '"+n+"');\">"+q.cityName+"</a></td>")}else{o.write('<td><a class="redEDealsDestination" href="javascript://void" onClick="javascript:selectTo(\''+q.cityCode+"');\">"+q.cityName+"</a></td>")}}o.write("<td ");if(k.saleType=="1"){o.write('class="redEDealsPriceSale1" ');g=1}if(k.saleType=="2"){o.write('class="redEDealsPriceSale2" ');f=1}if(k.saleType=="3"){o.write('class="redEDealsPriceSale3" ');e=1}if(k.saleType=="4"){o.write('class="redEDealsPriceSale4" ');a=1}if(k.saleType!="1"&&k.SaleType!="2"&&k.SaleType!="3"&&k.SaleType!="4"){o.write('class="redEDealsPrice" ')}o.write(">$"+k.fareValue+" </td>");o.write('<td align="left">');if(k.saleType=="1"){o.write('<img src="'+spotSaleIcon[0]+'" title="'+spotSaleText[0]+'" alt="'+spotSaleText[0]+'">')}else{if(k.saleType=="2"){o.write('<img src="'+spotSaleIcon[1]+'" title="'+spotSaleText[1]+'" alt="'+spotSaleText[1]+'">')}else{if(k.saleType=="3"){o.write('<img src="'+spotSaleIcon[2]+'" title="'+spotSaleText[2]+'" alt="'+spotSaleText[2]+'">')}else{if(k.saleType=="4"){o.write('<img src="'+spotSaleIcon[3]+'" title="'+spotSaleText[3]+'" alt="'+spotSaleText[3]+'">')}else{o.write("&nbsp;")}}}}o.write("</td>");if(k.fromDate.format("DD mmm YY")!=k.toDate.format("DD mmm YY")){o.write('<td class="travelDates">'+k.fromDate.format("DD mmm YY")+" - "+k.toDate.format("DD mmm YY")+"</td>")}else{o.write('<td class="travelDates">'+k.fromDate.format("DD mmm YY")+" only</td>")}o.write("\n\t</tr>")}}o.write("</table>");if(g==1){addSale(1)}if(f==1){addSale(2)}if(e==1){addSale(3)}if(a==1){addSale(4)}};RedEDeals.prototype.writeRedEDealsTable=function(){window.document.write('\n<div id="'+this.id+'">');this.sortDestinationsBlocksByCityNameThenFareValue();this.writeTable(this.tableId_cityNameSorted,true,"sortCity");this.sortDestinationsBlocksByLowestFareValue();this.writeTable(this.tableId_fareValueSorted,false,"sortFare");window.document.write("\n</div>")};function RedEDealsValidator(d,b,c,e,a,f){this.serverDate=d;this.redEDeals=b;this.formId=c;this.departCalendar=e;this.returnCalendar=a;this.isFFLoggedIn=f;this.region=b.region;this.depCityName=b.departureCityName;this.destCityName=null;this.destination=null;this.deal=null;this.dealReturn=null;this.form=null;this.isOneWay=null;this.depTs=null;this.depY=null;this.depM=null;this.depD=null;this.depT=null;this.retTs=null;this.retY=null;this.retM=null;this.retD=null;this.retT=null}RedEDealsValidator.prototype.validateDestination=function(){var g=null;var l=null;var c=null;for(var d=0;d<this.redEDeals.destinations.length;++d){g=this.redEDeals.destinations[d];if(g.cityCode==this.form.to.value){var f="";var e="Return flights are valid between ";var m=false;var h=false;this.destination=g;this.destCityName=g.cityName;for(var b=0;b<g.deals.length;++b){c=g.deals[b];if(this.depTs>=c.fromDate.getTime()&&this.depTs<=c.toDate.getTime()){m=true;this.deal=c}f+="\n\t"+c.fromDate.format("DDD D mmm YYYY")+"  ...  "+c.toDate.format("DDD D mmm YYYY")}if(this.isReturn()){if(g.dealsReturn.length>0){for(var a=0;a<g.dealsReturn.length;++a){l=g.dealsReturn[a];if(this.retTs>=l.fromDate.getTime()&&this.retTs<=l.toDate.getTime()){h=true;this.dealReturn=l}e+="\n\t"+l.fromDate.format("DDD D mmm YYYY")+"  ...  "+l.toDate.format("DDD D mmm YYYY")}}else{e="\nAnd there were no return flights found."}}else{e="";h=true}if(m&&(!this.isReturn()||(this.isReturn()&&h))){return true}alert("DATE SELECTION\n\nTravel between "+this.depCityName+" and "+this.destCityName+" is only valid between "+f+"\n\n"+e);return false}if(g.cityCode==this.form.from.value){var f="";var e="Return flights are valid between ";var m=false;var h=false;this.destination=g;this.destCityName=g.cityName;for(var b=0;b<g.deals.length;++b){c=g.deals[b];if(this.depTs>=c.fromDate.getTime()&&this.depTs<=c.toDate.getTime()){m=true;this.deal=c}f+="\n\t"+c.fromDate.format("DDD D mmm YYYY")+"  ...  "+c.toDate.format("DDD D mmm YYYY")}if(this.isReturn()){if(g.dealsReturn.length>0){for(var a=0;a<g.dealsReturn.length;++a){l=g.dealsReturn[a];if(this.retTs>=l.fromDate.getTime()&&this.retTs<=l.toDate.getTime()){h=true;this.dealReturn=l}e+="\n\t"+l.fromDate.format("DDD D mmm YYYY")+"  ...  "+l.toDate.format("DDD D mmm YYYY")}}else{e="\nAnd there were no return flights found."}}else{e="";h=true}if(m&&(!this.isReturn()||(this.isReturn()&&h))){return true}alert("DATE SELECTION\n\nTravel between "+this.depCityName+" and "+this.destCityName+" is only valid between "+f+"\n\n"+e);return false}}alert("Please select an arrival location.");this.form.to.focus();return false};RedEDealsValidator.prototype.validateDates=function(){var a=new Date(this.serverDate.getFullYear(),this.serverDate.getMonth(),this.serverDate.getDate());if(departCalendar.displayDate.getTime()<a.getTime()){alert("DATE SELECTION\n\nDeparture date cannot be before today.");this.form.dep_d.focus();return false}if((returnCalendar.displayDate.getTime()<departCalendar.displayDate.getTime())&&this.isReturn()){alert("DATE SELECTION\n\nReturning date cannot be before departure date.");return false}return true};RedEDealsValidator.prototype.validatePax=function(){var b=parseInt(this.form.adt.value);var e=parseInt(this.form.chd.value);var c=parseInt(this.form.infant.value);var a=b+e+c;var d=9;if(a>d){alert("Only "+d+" passengers can be booked at a time.");this.form.adt.focus();return false}if(c>b){alert("Only 1 infant can be booked for every 1 adult.");this.form.infant.focus();return false}return true};RedEDealsValidator.prototype.isReturn=function(){for(var a=0;a<this.form.tripType.length;++a){if(this.form.tripType[a].value=="R"&&this.form.tripType[a].checked){return true}}return false};RedEDealsValidator.prototype.isFlexibleDate=function(){if(this.form.flexibleDate.checked){return true}return false};RedEDealsValidator.prototype.validateAndSubmit=function(){this.form=document.getElementById(this.formId);var a=this.departCalendar.displayDate;this.depTs=a.getTime();this.depY=a.getFullYear();this.depM=a.getMonth()+1;this.depD=a.getDate();this.depT=a.getHours();a=this.returnCalendar.displayDate;this.retTs=a.getTime();this.retY=a.getFullYear();this.retM=a.getMonth()+1;this.retD=a.getDate();this.retT=a.getHours();if(!this.validateDestination()){return false}if(!this.validateDates()){return false}if(!this.validatePax()){return false}this.setFormProperties();document.itinerary.submit();return true};RedEDealsValidator.prototype.setFormProperties=function(){};RedEDealsValidator.prototype.setSelectionDetailsCke=function(){this.form=document.getElementById(this.formId);var b="Y";if("undefined"!=typeof(document.itinerary.flexibleDate)&&null!=document.itinerary.flexibleDate){if(document.itinerary.flexibleDate.checked){b="Y"}else{b="N"}}var a=document.getElementById("arrangeBy").value;var c="selectionsRed=DATES:"+this.departCalendar.serialize()+","+this.returnCalendar.serialize()+"|TO:"+this.form.to.value+"|PSGRS:"+this.form.adt.value+","+this.form.chd.value+","+this.form.infant.value+"|FLEX:"+b+"|TRIP:"+(redEDealsValidator.isReturn()?"R":"O")+"|SORTBY:"+a+"|REGION:"+this.region;document.cookie=c};RedEDealsValidator.prototype.set=function(b,a){if(a){for(var c=0;c<b.length;c++){if(b.options[c].value==a){b.options[c].selected=true;break}}}};RedEDealsValidator.prototype.setSelections=function(){this.form=document.getElementById(this.formId);if((document.cookie.indexOf("selectionsRed="))!=-1){var o=getCookieValue("selectionsRed");var a=o.indexOf("REGION:");if(a!=-1){var d=o.substring(a+7,a+9);if(d==this.region){var r=o.indexOf("DATES:");var m=o.indexOf("TO:");var l=o.indexOf("PSGRS:");var e=o.indexOf("TRIP:");var q=o.indexOf("FLEX:");var c=o.indexOf("SORTBY:");var k=o.substring(r+6,m-1);var n=k.split(",");var s=n[0];var g=n[1];var i=o.substring(l+6,l+7);var h=o.substring(l+8,l+9);var p=o.substring(l+10,l+11);var b=o.substring(m+3,m+6);var j=o.substring(q+5,q+6);var f=o.substring(e+5,e+6);var t=o.substring(c+7,c+8);if(j=="Y"){this.form.flexibleDate.checked=true}if(f=="R"){this.form.tripType[0].checked=true;this.returnCalendar.setEnabled(true)}else{this.form.tripType[1].checked=true;this.returnCalendar.setEnabled(false)}this.set(this.form.adt,i);this.set(this.form.chd,h);this.set(this.form.infant,p);this.departCalendar.deserialize(s);this.returnCalendar.deserialize(g);this.set(this.form.arrangeBy,t);if(window.navigator.userAgent.toLowerCase().indexOf("msie 5.5")!=-1){document.itinerary.tripType[0].checked=true;returnCalendar.setEnabled(true)}}}}};function gotoRedDealsPage(a){var b=a;departureAirport=b.value;if(departureAirport!=""){document.dealsFormBean.submit()}else{alert("Please select a Red e-Deals departure location.")}}function changeSortDefault(a){var b=document.getElementById("arrangeBy");if(a=="no"){b.selectedIndex=0}else{b.selectedIndex=1}}function switchSort(a){if(a.id=="flexibleDateNo"){changeSortDefault("no")}else{changeSortDefault("yes")}}function submitForm(){redEDealsValidator.setSelectionDetailsCke();redEDealsValidator.validateAndSubmit()}function submitFormValidateOnly(){redEDealsValidator.setSelectionDetailsCke();if(redEDealsValidator.validateAndSubmit(false)){return true}else{return false}};
