var spanFromCountryList;var spanToCountryList;var spanFromPortList;var spanToPortList;var spanFareList;var reloadPortData;var LocationType={From:1,To:2};function initLowCost(b,a,e,c,d){spanFromCountryList=$get(b);spanToCountryList=$get(a);spanFromPortList=$get(e);spanToPortList=$get(c);spanFareList=$get(d);bindCountryData(LocationType.From,"")}function ShowLoading(a){a.innerHTML='<IMG src="/img/loading.gif" />'}function FromSetSelected(a){SetSelected(a,"From");bindCountryData(LocationType.To,a);reloadPortData=true}function ToSetSelected(a){SetSelected(a,"To");bindPortData(LocationType.To,bindPortToResults)}function SetSelected(c,b){$("#list"+b+" li:odd").removeClass("selected");$("#list"+b+" li:even").removeClass("selected").addClass("alt");$get("txt"+b+"CountryName").value=c;var a=$get("li"+b+c.replace(" ","_"));if(a!=null){a.className="selected"}bindPriceData()}function bindPriceData(){if(spanFareList){ShowLoading(spanFareList);var a="/JSON/GetSalesFareData/"+$get("txtFromCountryName").value+"/"+$get("txtToCountryName").value;$.getJSON(a,bindFareDataResults)}}function bindFareDataResults(d){var b=new Sys.StringBuilder();var c="";b.append("<ul>");for(var a=0;a<d.length;a++){c="";if(a%2==0){c='class="alt"'}b.append("<li "+c+"'><img src=\"/img/airline-logos/lcc/"+d[a].AirlineCode+'.gif" align="absmiddle" style="margin-right:20px;"/>$'+d[a].FromPrice+"</li>")}b.append("</ul>");spanFareList.innerHTML=b}function bindPortData(b){var c;if(spanFromPortList&&spanToPortList){if(b==LocationType.From){c=bindPortFromResults;ShowLoading(spanFromPortList)}else{c=bindPortToResults;ShowLoading(spanToPortList)}countryNameFrom=$get("txtFromCountryName").value;countryNameTo=$get("txtToCountryName").value;var a="/JSON/GetPortData/"+b+"/"+countryNameFrom;if(countryNameTo.length!=0){a+="/"+countryNameTo}$.getJSON(a,c)}}function bindPortFromResults(a){BindResults(false,a,spanFromPortList,"")}function bindPortToResults(a){BindResults(false,a,spanToPortList,"")}function bindCountryData(b,d){if(spanToCountryList&&spanFromCountryList){var c;if(b==LocationType.From){ShowLoading(spanFromCountryList);c=bindCountryFromResults}else{ShowLoading(spanToCountryList);c=bindCountryToResults}var a="/JSON/GetSalesCountryData/"+d;$.getJSON(a,c)}}function bindCountryFromResults(a){BindResults(true,a,spanFromCountryList,"From");countryName=$get("txtFromCountryName").value;if(spanFromPortList){bindPortData(LocationType.From)}bindCountryData(LocationType.To,countryName)}function bindCountryToResults(a){BindResults(true,a,spanToCountryList,"To");if(spanToPortList){bindPortData(LocationType.To,bindPortToResults);if(reloadPortData){bindPortData(LocationType.From,bindPortToResults)}}bindPriceData()}function BindResults(a,h,g,f){var d=new Sys.StringBuilder();var e="";var c="";d.append('<ul id="list'+f+'">');for(var b=0;b<h.length;b++){e="";if(b%2==0){e='class="alt"'}if(b==0){e='class="selected"';if(a){$get("txt"+f+"CountryName").value=h[b]}}if(a){c="<a href='javascript:"+f+'SetSelected("'+h[b]+"\");'>"+h[b]+"</a>"}else{c=h[b]}d.append("<li "+e+" id='li"+f+h[b].replace(" ","_")+"'>"+c+"</li>")}d.append("</ul>");g.innerHTML=d};
