var CITIES;var ROUTE_TABLE;function initBooking(){CITIES=eval($F("hdcities"));ROUTE_TABLE=eval("("+$F("hdroute_table")+")");fillCities(CITIES,$("cboOrigin"));fillCities(ROUTE_TABLE[$("cboOrigin").value],$("cboDestination"));this.today=new Date();var thisMonth=this.today.getMonth();var thisDay=this.today.getDate();var thisYear=this.today.getFullYear();initDate($("tmpboardDate"),thisDay,thisMonth+1,thisYear,thisDay);initDate($("tmpretDate"),thisDay,thisMonth+1,thisYear,thisDay);initMonth($("tmpboardMonth"),thisDay,thisMonth+1,thisYear,(formatdate(thisMonth+1)+thisYear));initMonth($("tmpretMonth"),thisDay,thisMonth+1,thisYear,(formatdate(thisMonth+1)+thisYear))}function fillCities(d,g){while(g.length>0){g.remove(0)}for(var c=0;c<d.length;c++){var a=d[c].code;var f=d[c].name;var e=document.createElement("option");e.value=a;e.text=f;try{g.add(e,null)}catch(b){g.add(e)}}g.selectedIndex=0}function ChangeOrigin(c,g){var b=ROUTE_TABLE[c.value];while($("cboDestination").length>0){$("cboDestination").remove(0)}for(var e=0;e<b.length;e++){var a=b[e].code;var h=b[e].name;var f=document.createElement("option");f.value=a;f.text=h;try{$("cboDestination").add(f,null)}catch(d){$("cboDestination").add(f)}}$("cboDestination").selectedIndex=0}function OnDestinationChange(b,a){}function Compare2Date(){var g=$F("tmpboardMonth");var f=$F("tmpretMonth");var c=$F("tmpboardDate")*1;var b=parseInt(g.substr(0,2),10)*1;var e=parseInt(g.substr(3,4),10)*1;var a=$F("tmpretDate")*1;var h=parseInt(f.substr(0,2),10)*1;var d=parseInt(f.substr(3,4),10)*1;if(e>d){return 1}else{if(e<d){return -1}else{if(e==d){if(b>h){return 1}else{if(b<h){return -1}else{if(c>a){return 1}else{if(c<a){return -1}else{return 0}}}}}else{return 1}}}}function formatdate(a){if(a<10){return"0"+a}return a}function initDate(n,p,b,q,t){var s=0;var c=1;var h=1;this.today=new Date();var a=this.today.getMonth()+1;var k=this.today.getDate();var r=this.today.getFullYear();if(b==a&&q==r){c=k}var g=InvDate.getDate();var e=InvDate.getMonth()+1;var j=InvDate.getFullYear();h=getDaysInMonth(b,q);if(b==e&&q==j){h=g}while(n.length>0){n.remove(0)}for(var f=c;f<h+1;f++){var l=document.createElement("option");l.value=f;l.text=f;try{n.add(l,null)}catch(o){n.add(l)}if(f==t){s=f-c}}n.selectedIndex=s}function initMonth(k,p,b,q,t){var s=0;var h=0;this.today=new Date();var a=this.today.getMonth()+1;var r=this.today.getFullYear();var e=a;var f=r;var j=InvDate.getDate();var c=InvDate.getMonth()+1;var l=InvDate.getFullYear();while(k.length>0){k.remove(0)}for(var g=0;g<8;g++){if(e>12){e=1;f=f+1}var n=document.createElement("option");n.value=formatdate(e)+"/"+f;n.text=strMonth[e-1]+"-"+(f+h);if(f<l){try{k.add(n,null)}catch(o){k.add(n)}}else{if(f==l){if(e<=c){try{k.add(n,null)}catch(o){k.add(n)}}}}if((formatdate(e)+f)==t){s=g}++e}k.selectedIndex=s}function OnDayChange(c,a){if(a=="D"){$("boardDate").value=$F("tmpboardMonth").substr(0,2)+"/"+formatdate(c)+"/"+$F("tmpboardMonth").substr(3,4);var b=$("tmpretDate").value;if($F("tmpboardMonth").substr(0,2)*1>=$F("tmpretMonth").substr(0,2)*1){if(b*1<c*1){$("tmpretDate").value=c;$("returnDate").value=$F("tmpretMonth").substr(0,2)+"/"+formatdate(c)+"/"+$F("tmpretMonth").substr(3,4)}}}else{$("returnDate").value=$F("tmpretMonth").substr(0,2)+"/"+formatdate(c)+"/"+$F("tmpretMonth").substr(3,4)}}function OnMonthChange(b,a){if(a=="D"){initDate($("tmpboardDate"),$F("tmpboardDate"),parseInt(b.substr(0,2),10),parseInt(b.substr(3,4),10),0);$("boardDate").value=b.substr(0,2)+"/"+formatdate($F("tmpboardDate"))+"/"+b.substr(3,4);if(parseInt(b.substr(0,2),10)>parseInt($F("tmpretMonth").substr(0,2))||parseInt(b.substr(3,4),10)>parseInt($F("tmpretMonth").substr(3,4))){$("tmpretMonth").value=b;initDate($("tmpretDate"),$F("tmpretDate"),parseInt(b.substr(0,2),10),parseInt(b.substr(3,4),10),0);$("returnDate").value=b.substr(0,2)+"/"+formatdate($F("tmpretDate"))+"/"+b.substr(3,4)}}else{initDate($("tmpretDate"),$F("tmpretDate"),parseInt(b.substr(0,2),10),parseInt(b.substr(3,4),10),0);$("returnDate").value=b.substr(0,2)+"/"+formatdate($F("tmpretDate"))+"/"+b.substr(3,4);if(parseInt(b.substr(0,2),10)<parseInt($F("tmpboardMonth").substr(0,2))||parseInt(b.substr(3,4),10)<parseInt($F("tmpboardMonth").substr(3,4))){$("tmpboardMonth").value=b;initDate($("tmpboardDate"),$F("tmpboardDate"),parseInt(b.substr(0,2),10),parseInt(b.substr(3,4),10),0);$("boardDate").value=b.substr(0,2)+"/"+formatdate($F("tmpboardDate"))+"/"+b.substr(3,4)}}}function OnTypeClick(a){if(a.value=="0"){$("tmpretDate").disabled=true;$("tmpretMonth").disabled=true;$("imgCalendarReturn").disabled=true;$("txtRetDate").disabled=true}else{$("tmpretDate").disabled=false;$("tmpretMonth").disabled=false;$("imgCalendarReturn").disabled=false;$("txtRetDate").disabled=false}}function getRoundTripFlag(){return radioVal(document.form1.roundtripFlag)}function radioVal(c){var a=null;for(var b=0;b<c.length;b++){if(c[b].checked==true){a=c[b].value;break}}return a}var availabilitySvr={search:function(b){var a=JSON.stringify(b);a=encodeURIComponent(a);window.open("aspx/FlightList.aspx?param="+a+"","Popup","toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes, width=800,height=600")}};function OnSearchClick(){var d=parseInt($F("noofSeats"),10);var b=($("noofChild").visible())?parseInt($F("noofChild"),10):0;var a=0;if(d<=0){alert("At lease one adult is required");return}if(a+b>d){alert("An adult can be accompanied only one child or one infant per flight.");return}var c=getRoundTripFlag();if(c=="1"){if(Compare2Date()>0){alert(msgDateErr);return}}var e=d+b;availabilitySvr.search({origin:$F("cboOrigin"),destination:$F("cboDestination"),boarddate:$F("boardDate"),roundtrip:c,returndate:(c=="1")?$F("returnDate"):"",adult:d,child:b})};