var CurrentView=0;var FlightsPerPage=10;var UpdateFrequency=2000;var SearchFinished=false;var AirportsList=new Object();var DefaultInfo=GetDefaultInfo('DefaultInfo');var FlexibleInfo=GetFlexibleInfo('FlexibleInfo');var MyMap=null;var MapVisible=false;var MapAirport=null;var MapIsDep=false;var MapFlights=2;var serverTime=null;try{serverTime=SEARCH_TIME;}catch(ex){}try{serverTime=SERVER_TIME;}catch(ex){}var MonthNames=new Array(TXT_JANUARY,TXT_FEBRUARY,TXT_MARCH,TXT_APRIL,TXT_MAY,TXT_JUNE,TXT_JULY,TXT_AUGUST,TXT_SEPTEMBER,TXT_OCTOBER,TXT_NOVEMBER,TXT_DECEMBER);var MonthAbbr=new Array(TXT_JAN,TXT_FEB,TXT_MAR,TXT_APR,TXT_MAY_SHORT,TXT_JUN,TXT_JUL,TXT_AUG,TXT_SEP,TXT_OCT,TXT_NOV,TXT_DEC);Array.prototype.insert=function(position,newValue){if(position>-1)this.splice(position,0,newValue);elsethis.push(newValue);};function AddMonthGraphFlight(ResultType,DepIata,DestIata,DepDate,Airline,RetDate,Operator,OPID,FLID,Price,OldPrice,Currency,DisplayCurrency,Img,BookURL,OutDepTime,OutArrTime,InDepTime,InArrTime,OutStops,InStops,OutDuration,InDuration,ETicket,TotalPrice,OldTotalPrice,InclTax,Way,IsAlternative,CPC,Adults,Children,Infants,CacheAge){var flight=new FlightResultClass(ResultType,DepIata,DestIata,DepDate,Airline,RetDate,Operator,OPID,FLID,Price,OldPrice,Currency,DisplayCurrency,Img,BookURL,OutDepTime,OutArrTime,InDepTime,InArrTime,OutStops,InStops,OutDuration,InDuration,ETicket,TotalPrice,OldTotalPrice,InclTax,Way,IsAlternative,CPC,Adults,Children,Infants,CacheAge);var dep=new DateObject(flight.DepDate,'dd/MM/yyyy');var monthVal=dep.DateItem.getMonth()+'-'+dep.DateItem.getFullYear();DefaultInfo.GraphData[monthVal]=flight;}function DrawMonthGraph(){if(DefaultInfo.Chart)DefaultInfo.Chart.drawChart(DefaultInfo.GraphData,null,null);}function AddFlight(ResultType,DepIata,DestIata,DepDate,Airline,RetDate,Operator,OPID,FLID,Price,OldPrice,Currency,DisplayCurrency,Img,BookURL,OutDepTime,OutArrTime,InDepTime,InArrTime,OutStops,InStops,OutDuration,InDuration,ETicket,TotalPrice,OldTotalPrice,InclTax,Way,IsAlternative,CPC,Adults,Children,Infants,CacheAge){var flight=new FlightResultClass(ResultType,DepIata,DestIata,DepDate,Airline,RetDate,Operator,OPID,FLID,Price,OldPrice,Currency,DisplayCurrency,Img,BookURL,OutDepTime,OutArrTime,InDepTime,InArrTime,OutStops,InStops,OutDuration,InDuration,ETicket,TotalPrice,OldTotalPrice,InclTax,Way,IsAlternative,CPC,Adults,Children,Infants,CacheAge);flight.WriteTable();AddCommand(flight);}function UpdateFlight(ResultType,DepIata,DestIata,DepDate,Airline,RetDate,Operator,OPID,FLID,Price,OldPrice,Currency,DisplayCurrency,Img,BookURL,OutDepTime,OutArrTime,InDepTime,InArrTime,OutStops,InStops,OutDuration,InDuration,ETicket,TotalPrice,OldTotalPrice,InclTax,Way,IsAlternative,CPC,Adults,Children,Infants,CacheAge){var flight=new FlightResultClass(ResultType,DepIata,DestIata,DepDate,Airline,RetDate,Operator,OPID,FLID,Price,OldPrice,Currency,DisplayCurrency,Img,BookURL,OutDepTime,OutArrTime,InDepTime,InArrTime,OutStops,InStops,OutDuration,InDuration,ETicket,TotalPrice,OldTotalPrice,InclTax,Way,IsAlternative,CPC,Adults,Children,Infants,CacheAge);flight.UpdateFlight();}function FlightResultClass(ResultType,DepIata,DestIata,DepDate,Airline,RetDate,Operator,OPID,FLID,Price,OldPrice,Currency,DisplayCurrency,Img,BookURL,OutDepTime,OutArrTime,InDepTime,InArrTime,OutStops,InStops,OutDuration,InDuration,ETicket,TotalPrice,OldTotalPrice,InclTax,Way,IsAlternative,CPC,Adults,Children,Infants,CacheAge){this.Table='';this.ResultType=ResultType;this.DepIata=DepIata;this.DepAirport=GetAirport(this.DepIata);this.DestIata=DestIata;this.DestAirport=GetAirport(this.DestIata);this.DepDate=DepDate;this.Airline=Airline;this.RetDate=RetDate;this.Operator=Operator;this.OPID=OPID;this.FLID=FLID;this.Price=Price;this.OldPrice=OldPrice;this.Currency=Currency;this.DisplayCurrency=DisplayCurrency;this.Img=Img;this.BookURL=BookURL;this.OutDepTime=OutDepTime;this.OutArrTime=OutArrTime;this.InDepTime=InDepTime;this.InArrTime=InArrTime;this.OutStops=OutStops;this.InStops=InStops;this.OutDuration=OutDuration;this.InDuration=InDuration;this.ETicket=ETicket;this.TotalPrice=TotalPrice;this.OldTotalPrice=OldTotalPrice;this.InclTax=InclTax;this.Way=Way;this.IsAlternative=IsAlternative;this.CPC=CPC;this.IsConverted=false;this.Adults=Adults;this.Children=Children;this.Infants=Infants;this.CacheAge=CacheAge;this.FlexibleFlight=false;this.IsCached=true;this.TableRef=null;this.PriceCell=null;this.UpdateCell=null;this.IsQueued=false;this.IsUpdating=false;this.IsUpdated=false;this.UpdateFailed=false;this.DepDateObj=new DateObject(this.DepDate,'dd/MM/yyyy');this.RetDateObj=new DateObject(this.RetDate,'dd/MM/yyyy');this.DepDay=this.DepDateObj.GetDay();this.DepMonth=this.DepDateObj.GetMonth();this.DepYear=this.DepDateObj.GetYear();this.ShortPrice=new String(this.Price);this.ShortPrice=this.ShortPrice.replace(this.DisplayCurrency,'');if(this.DepAirport&&(!this.DepAirport.CheapestFlight||this.TotalPrice<this.DepAirport.CheapestFlight.TotalPrice)){this.DepAirport.CheapestFlight=this;}if(this.DestAirport&&(!this.DestAirport.CheapestFlight||this.TotalPrice<this.DestAirport.CheapestFlight.TotalPrice)){this.DestAirport.CheapestFlight=this;}if(this.ResultType==1){this.FlexibleFlight=true;SetGraphItem(this);}if(this.Way==null){this.Way=2;}if(this.IsAlternative==null){this.IsAlternative=false;}if(this.CPC==null){this.CPC=0;}if(this.Currency!=this.DisplayCurrency){this.IsConverted=true;}this.GetRedirectLink=function(){var strLink=LANG_ROOT_PATH+'redirect.aspx';strLink+='?opid='+OPID;strLink+='&url=';strLink+='&DepartAirport='+DepIata;strLink+='&DestinationAirport='+DestIata;strLink+='&Adults='+Adults;strLink+='&Children='+Children;strLink+='&Infants='+Infants;strLink+='&DepartureDate='+DepDate;strLink+='&ReturnDate='+RetDate;return strLink;}this.GetShallowRedirectLink=function(){var strLink=LANG_ROOT_PATH+'redirect.aspx';strLink+='?opid='+OPID;strLink+='&url=';return strLink;}this.GetInclTaxes=function(){var strTaxIncl='';if(!this.InclTax){strTaxIncl=TXT_TAX_EXCLUDED;}else if(this.InclTax=='0'){strTaxIncl=TXT_TAX_EXCLUDED;}else if(this.InclTax=='2'){strTaxIncl=TXT_EXCLUDING_TICKET_EMISSION;}else{strTaxIncl=TXT_TAX_INCLUDED;}if(strTaxIncl!=''){strTaxIncl='<br><span class="txtDarkGray">'+strTaxIncl+'</span>';}return strTaxIncl;}this.GetCacheInfo=function(){var html='';try{if(this.CacheAge!=null){var days=0;var hours=0;var mins=0;var cachAgeText=TXT_LAST_UPDATED+': ';var cacheImg='<img src='+IMG_ROOT+'i/clock3.gif width=11 height=11 border=0 align=absmiddle>';this.IsCached=true;if(this.CacheAge.getDate){var timeSpan=serverTime.getTime()-this.CacheAge.getTime();days=(timeSpan<0?0:Math.floor(timeSpan/86400000));hours=(timeSpan<0?0:Math.floor((timeSpan-(days*86400000))/3600000));mins=(timeSpan<0?0:Math.floor((timeSpan-((days*86400000)+(hours*3600000)))/60000));}else{var timeSpan=this.CacheAge.split(':');days=(timeSpan.length>0?parseInt(timeSpan[0]):0);hours=(timeSpan.length>1?parseInt(timeSpan[1]):0);mins=(timeSpan.length>2?parseInt(timeSpan[2]):0);}if(days>0)cachAgeText+=TXT_DAYS_AGO.replace('%1',days);else if(hours>0)cachAgeText+=TXT_HOURS_AGO.replace('%1',hours);else if(mins>0)cachAgeText+=TXT_MINS_AGO.replace('%1',mins);else{cacheImg='<img src='+IMG_ROOT+'i/tick-green.gif width=14 height=15 border=0 align=absmiddle>';cachAgeText=TXT_VERIFIED_AVAILABILITY;this.IsCached=false;}html=cacheImg+' '+cachAgeText;}else{html='<img src='+IMG_ROOT+'i/tick-green.gif width=14 height=15 border=0 align=absmiddle> '+TXT_VERIFIED_AVAILABILITY;this.IsCached=false;}}catch(e){}return html;}this.GetConvertedFromText=function(oldPrice,oldCurrency){var html='<img src="'+IMG_ROOT+'i/asterix.gif" width=12 height=11> '+TXT_CONVERTED_FROM;html=html.replace('%1',oldCurrency);html=html.replace('%2','<b>'+oldPrice+' '+oldCurrency+'</b>');if(TXT_CONVERTED_INFO&& TXT_CONVERTED_INFO.length>0){html+='&nbsp;&nbsp;<img src="'+IMG_ROOT+'i/info4.gif" width=11 height=11 onclick="showInfoBalloon(this, event, \'<b>'+oldCurrency+'</b>\')">';}return html;}this.BuildResult=function(){var content=document.createElement('TABLE');content.className='tbl';content.cellPadding=2;content.cellSpacing=0;content.border=0;content.style.tableLayout='fixed';content.flight=this;this.TableRef=content;try{var rowNum=0;var row1,row2,row3,row4,row5;var depAptHtml,destAptHtml;row1=content.insertRow(rowNum);rowNum++;if(this.Way==2){row2=content.insertRow(rowNum);rowNum++;}var depText=(this.DepAirport&& this.DepAirport.Type!=0?this.DepAirport.City:this.DepIata);depAptHtml='<span title="'+(this.DepAirport?this.DepAirport.GetFullName():this.DepIata)+'">';depAptHtml+=depText+'</span>';var destText=(this.DestAirport&& this.DestAirport.Type!=0?this.DestAirport.City:this.DestIata);destAptHtml='<span title="'+(this.DestAirport?this.DestAirport.GetFullName():this.DestIata)+'">';destAptHtml+=destText+'</span>';row3=content.insertRow(rowNum);rowNum++;var tdR1C1=row1.insertCell(0);tdR1C1.vAlign='top';tdR1C1.width='90px';tdR1C1.innerHTML='&nbsp;';tdR1C1.rowSpan=(this.Way==2)?2:1;var tdR1C2=row1.insertCell(1);tdR1C2.vAlign='top';tdR1C2.width='120px';tdR1C2.innerHTML='&nbsp;';var tdR1C3=row1.insertCell(2);tdR1C3.align='center';tdR1C3.vAlign='top';tdR1C3.className='hideOverflow';tdR1C3.innerHTML='&nbsp;';var tdR1C4=row1.insertCell(3);tdR1C4.vAlign='top';tdR1C4.width='106px';tdR1C4.innerHTML='&nbsp;';var tdR1C5=row1.insertCell(4);tdR1C5.align='center';tdR1C5.vAlign='top';tdR1C5.width='40px';tdR1C5.innerHTML='&nbsp;';var tdR1C6=row1.insertCell(5);tdR1C6.align='center';tdR1C6.vAlign='top';tdR1C6.width='100px';tdR1C6.innerHTML='&nbsp;';tdR1C6.rowSpan=(this.Way==2)?2:1;if(this.Way==2&& row2!=null){var tdR2C2=row2.insertCell(0);tdR2C2.vAlign='top';tdR2C2.innerHTML='<div class="hideOverflow">'+destAptHtml+' >> '+depAptHtml+'</div>';var tdR2C3=row2.insertCell(1);tdR2C3.innerHTML='&nbsp;';var tdR2C4=row2.insertCell(2);tdR2C4.vAlign='top';tdR2C4.innerHTML=this.InDepTime+' >> '+this.InArrTime;var tdR2C5=row2.insertCell(3);tdR2C5.align='center';tdR2C5.vAlign='top';tdR2C5.innerHTML=this.InStops}this.UpdateCell=row3.insertCell(0);this.UpdateCell.vAlign='top';this.UpdateCell.className='UpdateLink';this.UpdateCell.innerHTML='&nbsp;';var tdR3C1=row3.insertCell(1);tdR3C1.vAlign='top';tdR3C1.innerHTML='&nbsp;';tdR3C1.colSpan=2;var tdR3C2=row3.insertCell(2);tdR3C2.vAlign='top';tdR3C2.innerHTML='&nbsp;';var tdR3C3=row3.insertCell(3);tdR3C3.align='center';tdR3C3.vAlign='top';tdR3C3.innerHTML='&nbsp;';var tdR3C4=row3.insertCell(4);tdR3C4.align='center';tdR3C4.vAlign='top';tdR3C4.innerHTML='&nbsp;';var priceHtml=(this.IsQueued||this.IsUpdating?'<img src="'+IMG_ROOT+'i/snake_update.gif" width=16 height=16 border=0 align=right hspace=4>':'');priceHtml+='<span class="ResultPrice">'+this.Price+' '+'</span>';priceHtml+=this.GetInclTaxes();tdR1C1.innerHTML=priceHtml;this.PriceCell=tdR1C1;tdR1C2.innerHTML='<div class="hideOverflow">'+depAptHtml+' >> '+destAptHtml+'</div>';tdR1C3.innerHTML=this.Airline;tdR1C3.title=this.Airline;tdR1C4.innerHTML=this.OutDepTime+' >> '+this.OutArrTime;tdR1C5.innerHTML=this.OutStops;var redirectUrl=this.GetRedirectLink();var tailFin='<img src="'+this.Img+'" alt="'+this.Operator+'" border=0/>';var finLink=document.createElement('A');finLink.href=redirectUrl;finLink.target='_blank';finLink.innerHTML=tailFin;tdR1C6.innerHTML='';tdR1C6.appendChild(finLink);tdR3C1.innerHTML=this.GetCacheInfo();if(this.UpdateFailed){this.UpdateCell.innerHTML=TXT_UPDATE_FAILED;}else if(this.IsQueued){this.UpdateCell.innerHTML=TXT_WAIT;}else if(this.IsUpdating){this.UpdateCell.innerHTML=TXT_UPDATING;}else if(this.IsCached){var dep=new DateObject(this.DepDate,'dd/MM/yyyy');var ret=new DateObject(this.RetDate,'dd/MM/yyyy');var updateJS='UpdateFlightAjax(this, UpdateRender)';var updateHtml='<img src='+IMG_ROOT+'i/update.gif width=11 height=11 border=0 align=absmiddle>&nbsp;';var updateLink=document.createElement('A');updateLink.onclick=new Function(updateJS);updateLink.innerHTML=TXT_UPDATE;updateLink.flight=this;this.UpdateCell.innerHTML=updateHtml;this.UpdateCell.appendChild(updateLink);}var dep=new DateObject(this.DepDate,'dd/MM/yyyy');var altText='<b>'+dep.ToString('d MMM');if(this.Way==2){var ret=new DateObject(this.RetDate,'dd/MM/yyyy');altText+=' - '+ret.ToString('d MMM');}altText+='</b>';tdR3C2.innerHTML='<span class=txtDate>'+altText+'</span>';var opLink=document.createElement('A');opLink.href=redirectUrl;opLink.className='GreenLink';opLink.target='_blank';opLink.innerHTML=this.Operator;tdR3C4.innerHTML='';tdR3C4.appendChild(opLink);if(this.IsConverted){row4=content.insertRow(rowNum);rowNum++;var tdR4C1=row4.insertCell(0);tdR4C1.vAlign='top';tdR4C1.innerHTML='&nbsp;';tdR4C1.colSpan=5;tdR4C1.innerHTML='<span class=txtConverted>'+this.GetConvertedFromText(OldPrice,Currency)+'</span>';}}catch(e){}return content;}this.WriteTable=function(){try{var info=GetSettingsInfo(this.ResultType);this.Table=info.Table;var pos=this.FindPosition(info.Results);if(pos>=0){info.Results.insert(pos,this);}else{info.Results[info.Results.length]=this;}if(!blnUpdating){blnUpdating=true;setTimeout('UpdateWhenFree()',UpdateFrequency);}}catch(e){}}this.UpdateFlight=function(){try{var info=GetSettingsInfo(this.ResultType);this.Table=info.Table;var isUpdated=false;for(var i=0;i<info.Results.length;i++){var item=info.Results[i];var isMatch=(this.OPID==item.OPID&& this.DepIata==item.DepIata&& this.DestIata==item.DestIata&&this.DepDate==item.DepDate&& this.RetDate==item.RetDate&& this.OutDepTime==item.OutDepTime&&this.OutArrTime==item.OutArrTime&& this.InDepTime==item.InDepTime&& this.InArrTime==item.InArrTime)if(isMatch){for(var prop in item){item[prop]=this[prop];}item.IsUpdated=trueisUpdated=true;}}if(!isUpdated){this.WriteTable();AddCommand(this);}}catch(e){}}this.FindPosition=function(SearchArray){if(SearchArray.length==0)return -1;var intStart=0;var intBeginning=0;var intEnd=SearchArray.length;var blnFound=false;if(SearchArray.length>=10){while(!blnFound){var intHalfWay=parseInt((intEnd-intBeginning)/2)+intBeginning;if(this.TotalPrice>SearchArray[intHalfWay].TotalPrice){intBeginning=intHalfWay;}else{intEnd=intHalfWay;}if(intEnd-intBeginning<=3)blnFound=true;}}for(var i=intBeginning;i<SearchArray.length;i++){if(this.TotalPrice<SearchArray[i].TotalPrice){return i;}}}this.GetItemHtml=function(){var opDetail='<img src="'+this.Img+'" border=0>';var redirectUrl=this.GetRedirectLink();var apts=this.DepIata+' >> '+this.DestIata;html='<table width="100%" align=center cellpadding=0 border=0>'html+='<tr><td width="50%" valign="middle">';html+='<span class="ResultPrice">'+this.Price+'</span>'+this.GetInclTaxes()+'</td>';html+='<td width="50%" align="center"><a href="'+redirectUrl+'" target="_blank">'+opDetail+'</a></td></tr>';html+='<tr><td>'+apts+'</td>';html+='<td align="center"><a href="'+redirectUrl+'" target="_blank">'+this.Operator+'</a></td></tr>';html+='<tr><td>'+this.DepDate+'</td>';html+='<td align="center">'+this.OutDepTime+' >> '+this.OutArrTime+'</td></tr>';if(this.Way==2){html+='<tr><td>'+this.RetDate+'</td>';html+='<td align="center">'+this.InDepTime+' >> '+this.InArrTime+'</td></tr>';}html+='</table>';html+='<div style="padding-top:4px;">'+this.GetCacheInfo()+'</div>';return html;}}function UpdateRender(flight){if(flight){if(flight.UpdateCell){if(flight.IsQueued){flight.UpdateCell.innerHTML=TXT_WAIT;}else if(flight.IsUpdating){flight.UpdateCell.innerHTML=TXT_UPDATING;}}if(flight.PriceCell){var currNode=flight.PriceCell;currNode.innerHTML='<img src="'+IMG_ROOT+'i/snake_update.gif" width=16 height=16 border=0 align=right hspace=4>'+currNode.innerHTML;}if(flight.TableRef){var currNode=flight.TableRef;if(currNode.parentNode&& currNode.parentNode.nodeName=='TD'){currNode.parentNode.className='ResultCellUpdate';}}}}function SearchOperator(name,id,fintail,website){this.Name=name;this.OPID=id;this.Fintail=fintail;this.Website=website;this.HasFlights=false;}var blnUpdating=false;function UpdateWhenFree(){UpdateFilter();blnUpdating=false;}function UpdatePageCounts(info){var intPages=parseInt(info.FilteredResults.length/FlightsPerPage);if(info.FilteredResults.length%FlightsPerPage)intPages+=1;var intStartFlight=(info.CurrentPage*FlightsPerPage)-(FlightsPerPage-1);var intEndFlight=(info.CurrentPage*FlightsPerPage>info.FilteredResults.length)?info.FilteredResults.length:info.CurrentPage*FlightsPerPage;DisplayPages(info);}function DisplayPages(info){var strPageLinks='';var clickFunc='';var AllowedPageSpan=5;var blnShowGoToFirst=false;var blnShowGoToLast=false;var intPages=parseInt(info.FilteredResults.length/FlightsPerPage);if(info.FilteredResults.length%FlightsPerPage>0)intPages++;if(info.CurrentPage>intPages)info.CurrentPage=(intPages==0?1:intPages);for(i=1;i<=intPages;i++){var minOffSet=(info.CurrentPage+AllowedPageSpan>intPages)?((intPages-(info.CurrentPage+AllowedPageSpan))*-1):0;var maxOffSet=(info.CurrentPage-AllowedPageSpan<0)?((info.CurrentPage-AllowedPageSpan)*-1):0;if((i>(info.CurrentPage-AllowedPageSpan)-minOffSet)&&(i<(info.CurrentPage+AllowedPageSpan)+maxOffSet)){if(info.CurrentPage==i){strPageLinks+='<span class="ChangePageSelected"><b>'+i+' </b></span> ';}else{clickFunc='GoToPage('+i+','+info.ResultType+')';strPageLinks+='<a class="ChangePage" onclick="'+clickFunc+'">'+i+'</a> ';}}if(info.CurrentPage-AllowedPageSpan>=1)blnShowGoToFirst=true;if(info.CurrentPage+AllowedPageSpan<=intPages)blnShowGoToLast=true;}clickFunc='GoToPage(1,'+info.ResultType+')';var strStart=blnShowGoToFirst?'<a class="ChangePage" onclick="'+clickFunc+'"> '+TXT_FIRST+'</a> ':'';clickFunc='GoToPage('+intPages+','+info.ResultType+')';var strEnd=blnShowGoToLast?'<a class="ChangePage" onclick="'+clickFunc+'">'+TXT_LAST+'</a>':'';GetItemById(info.PagesID).innerHTML=strStart+strPageLinks+strEnd;GetItemById(info.FooterID).style.display='';}function GoToPage(page,type){showLoadingScreen(true);window.scrollTo(0,0);var info=GetSettingsInfo(type);info.CurrentPage=page;setTimeout('UpdateFilter()',80);}function ChangePageSize(){showLoadingScreen(true);FlightsPerPage=GetItemById('PageCountSize').value;ResetCurrentPage();setTimeout('UpdateFilter()',80);}function InsertNoResultsRow(tblID){var table=GetItemById(tblID);var mainrow=table.insertRow(table.rows.length);var cell=mainrow.insertCell(0);cell.className='ResultCell'cell.innerHTML='<div class="ErrorMessage">'+TXT_NO_RESULTS+'</div>';}function InsertFilteredRow(flight){var table=GetItemById(flight.Table);var mainrow=table.insertRow(table.rows.length);var cell=mainrow.insertCell(0);cell.className=(flight.IsUpdating||flight.IsQueued?'ResultCellUpdate':'ResultCell');cell.appendChild(flight.BuildResult());}function DisplayMapPage(info){ClearTableById(info.Table);GetItemById(info.PagesID).innerHTML='';GetItemById(info.FooterID).style.display='';if(info.FilteredResults.length==0){InsertNoResultsRow(info.Table);return;}var dests=new Object();if(MapAirport&& info.FilteredResults.length>0){dests[MapAirport]=info.FilteredResults;UpdatePageCounts(info);InsertMapHeader(info.FilteredResults[0]);for(var i=0;i<FlightsPerPage;i++){var PageOffSet=(info.CurrentPage-1)*FlightsPerPage;if(i+PageOffSet>info.FilteredResults.length-1)break;InsertFilteredRow(info.FilteredResults[i+PageOffSet]);}}else{for(var i=0;i<info.FilteredResults.length;i++){var flight=info.FilteredResults[i];var iata=(MapIsDep?flight.DepIata:flight.DestIata);if(!dests[iata]){dests[iata]=new Array();dests[iata].push(flight);}else if(dests[iata].length<MapFlights){dests[iata].push(flight);}}for(apt in dests){var arr=dests[apt];if(arr.length>0){InsertMapHeader(arr[0]);for(var i=0;i<arr.length;i++){InsertFilteredRow(arr[i]);}}}}}function InsertMapHeader(flight){var apt=(MapIsDep?flight.DepAirport:flight.DestAirport);var city=(MapIsDep?DEP_CITY:DEST_CITY);var table=GetItemById(flight.Table);var spacerow=table.insertRow(table.rows.length);var mainrow=table.insertRow(table.rows.length);var cell=mainrow.insertCell(0);cell.className='mapHeader';var dist=TXT_APPROX_FROM;dist=dist.replace('%1','<b>'+apt.Distance+'km</b>');dist=dist.replace('%2','<b>'+city+'</b>');var html='<div class="mapHeadLeft">';html+='<img src="'+IMG_ROOT+'i/map/apt_sml.gif" width=12 height=18 hspace=4 align=absmiddle>';html+=apt.GetFullName()+', '+apt.Country+' ';html+='('+apt.IATA+')</div>'html+='<div class="mapHeadRight">'+dist+'</div>'cell.innerHTML=html;}function DisplayPage(info){ClearTableById(info.Table);UpdatePageCounts(info);if(info.FilteredResults.length==0){InsertNoResultsRow(info.Table);return;}for(var i=0;i<FlightsPerPage;i++){var PageOffSet=(info.CurrentPage-1)*FlightsPerPage;if(i+PageOffSet>info.FilteredResults.length-1)break;InsertFilteredRow(info.FilteredResults[i+PageOffSet]);}}function ClearTables(){ClearTableById(DefaultInfo.Table);ClearTableById(FlexibleInfo.Table);}var arrAirportsDepNotShown=new Array();var arrAirportsDestNotShown=new Array();var arrOperatorsNotShown=new Array();var arrOperatorsFinished=new Array();var blnNoStop=true;var bln1Stop=true;var bln2Stop=true;var blnInNoStop=true;var blnIn1Stop=true;var blnIn2Stop=true;var TimeDepStart=0;var TimeDepEnd=24;var TimeRetStart=0;var TimeRetEnd=24;function loadVars(info){blnNoStop=(GetItemById(info.NonStopID)?GetItemById(info.NonStopID).checked:true);bln1Stop=(GetItemById(info.OneStopID)?GetItemById(info.OneStopID).checked:true);bln2Stop=(GetItemById(info.TwoStopID)?GetItemById(info.TwoStopID).checked:true);if(info.TimeDepStart)TimeDepStart=parseInt(GetItemById(info.TimeDepStart).value);if(info.TimeDepEnd)TimeDepEnd=parseInt(GetItemById(info.TimeDepEnd).value);if(info.TimeRetStart)TimeRetStart=parseInt(GetItemById(info.TimeRetStart).value);if(info.TimeRetEnd)TimeRetEnd=parseInt(GetItemById(info.TimeRetEnd).value);if(info.OperatorsArray)arrOperatorsNotShown=getOpsNotShown(info.OperatorsID);if(info.DepArray)arrAirportsDepNotShown=getAptsNotShown(info.DepID);if(info.DestArray)arrAirportsDestNotShown=getAptsNotShown(info.DestID);}function getOpsNotShown(id){var filterTable=GetItemById(id);var arr=new Array();if(filterTable==null||filterTable.rows.length==0)return arr;for(var i=0;i<filterTable.rows.length;i++){var node=filterTable.rows[i].cells[0].childNodes[0];if(node.tagName=='INPUT'&& node.type=='checkbox'&&!node.checked){arr.push(node.value);}}return arr;}function getAptsNotShown(id){var filterTable=GetItemById(id);var arr=new Array();if(filterTable==null||filterTable.rows.length==0)return arr;for(var i=0;i<filterTable.rows.length;i++){var node=filterTable.rows[i].cells[0].childNodes[0];if(node.tagName=='INPUT'&& node.type=='checkbox'&&!node.checked){arr.push(node.value);}}return arr;}function selectAll(id,checked){var filterTable=GetItemById(id);if(filterTable==null||filterTable.rows.length==0)return;for(var i=0;i<filterTable.rows.length;i++){var node=filterTable.rows[i].cells[0].childNodes[0];if(node.tagName=='INPUT'&& node.type=='checkbox'){node.checked=checked;}}filter();}function filter(){showLoadingScreen(true);ResetCurrentPage();setTimeout('UpdateFilter()',80);}function UpdateFilter(){showLoadingScreen(true);try{ClearTables();var info;if(CurrentView==0){info=GetSettingsInfo(0);}if(CurrentView==1){info=GetSettingsInfo(1);}if(info){DoFilter(info);DrawAlternativeSearch(info);}}catch(e){}showLoadingScreen(false);}function DoFilter(info){if(info.Chart)info.Chart.drawChart(info.GraphData,info.GraphMonth,info.GraphYear);if(!info.Results)return;FilterResults(info);SetFlightCounts(info);if(MapVisible){DisplayMapPage(info);}else{DisplayPage(info);}}function SetFlightCounts(info){if(info&& info.CountsTextID){try{var countsDIV=GetItemById(info.CountsTextID);var showingNum='<b>'+info.FilteredResults.length+'</b>';var totalNum='<b>'+info.Results.length+'</b>';var operatorNum='<b>'+info.OperatorsArray.length+'</b>';var countsHtml=TXT_RESULTS;countsHtml=countsHtml.replace('%1',showingNum);countsHtml=countsHtml.replace('%2',totalNum);countsHtml=countsHtml.replace('%3',operatorNum);countsDIV.innerHTML='<div class=FilterCounts>'+countsHtml+'</div>';}catch(e){}}}function FilterResults(info){loadVars(info);info.FilteredResults=new Array();var ResultView=info.Results;for(var i=0;i<ResultView.length;i++){var item=ResultView[i];var blnStopsOk=false;var blnAirport1Ok=false;var blnAirport2Ok=false;var blnTime1Ok=false;var blnTime2Ok=false;var blnOperatorOk=false;var blnAllOk=false;if((blnNoStop&&(item.OutStops=='0'||item.OutStops==''))||(bln1Stop&& ResultView[i].OutStops=='1')||(bln2Stop&& ResultView[i].OutStops=='2'))blnStopsOk=true;if(!findStringInArray(arrAirportsDepNotShown,item.DepIata))blnAirport1Ok=true;if(!findStringInArray(arrAirportsDestNotShown,item.DestIata))blnAirport2Ok=true;if(MapVisible&& MapAirport){var apt=(MapIsDep?item.DepIata:item.DestIata);blnAirport2Ok&=(apt==MapAirport);}if(!findStringInArray(arrOperatorsNotShown,item.Operator))blnOperatorOk=true;if((parseFloat(item.OutDepTime)>=TimeDepStart)&&(parseFloat(item.OutDepTime)<TimeDepEnd))blnTime1Ok=true;if(ResultView[i].Way==1||((parseFloat(item.InDepTime)>=TimeRetStart)&&(parseFloat(item.InDepTime)<TimeRetEnd)))blnTime2Ok=true;blnAllOk=blnStopsOk&& blnAirport1Ok&& blnAirport2Ok&& blnTime1Ok&& blnTime2Ok&& blnOperatorOk;if(blnAllOk){info.FilteredResults[info.FilteredResults.length]=item;}else{item.TableRef=null;item.PriceCell=null;item.UpdateCell=null;}}}function AirportObject(city,fullname,iata){this.City=city;this.Full=fullname;this.IATA=iata;}function OperatorObject(opid,operator,url,price,val){this.OPID=opid;this.Operator=operator;this.Url=url;this.Price=price;this.Value=val;}function DateFilterObject(out_date,in_date,alt,price,url,val){this.OutDate=out_date;this.InDate=in_date;this.IsChecked=!alt;this.IsAlternative=alt;this.Price=price;this.Value=val;this.Url=url;this.toString=function(){return this.OutDate.toString()+this.InDate.toString();}function displayText(){var out='';var ret='';var outputString='';out=new DateObject(this.OutDate,'dd/MM/yyyy');outputString=out.ToString('d MMM');if(this.InDate!=null&& this.InDate!=''){ret=new DateObject(this.InDate,'dd/MM/yyyy');outputString+=' - '+ret.ToString('d MMM');}return outputString;}this.displayText=displayText;}function SettingsInfo(){this.ID='';this.View=0;this.ResultType=0;this.CurrentPage=1;this.Table='progressiveResults';this.Results=new Array();this.FilteredResults=new Array();this.AltResults=new Array();this.DepArray=new Array();this.DepID='airportsDep';this.DestArray=new Array();this.DestID='airportsDest';this.DatesID='dateFilter';this.OperatorsArray=new Array();this.OperatorsID='operatorsFilter';this.DrawOperators=null;this.GetAirport=GetAirport;this.NonStopID='chkNonStop';this.OneStopID='chk1Stop';this.TwoStopID='chk2Stop';this.TimeDepStart='depstart';this.TimeDepEnd='depend';this.TimeRetStart='retstart';this.TimeRetEnd='retend';this.CountsTextID='resultsCounts';this.FooterID='tblResFoot';this.PagesID='spanPages';this.TabName='tabCheapest';this.FlexRequest=null;this.GraphData=null;this.Chart=null;this.Way=SEARCH_WAY;this.DepIATA=SEARCH_DEP;this.DestIATA=SEARCH_DEST;this.GraphMonth=SEARCH_MONTH;this.GraphYear=SEARCH_YEAR;this.GetTooltipHtml=function(index){var html='',opDetail='',apts='';if(this.GraphData&& this.GraphData.length>index&& this.GraphData[index]){var item=this.GraphData[index];var html=item.GetItemHtml();}return html;}}function GetDefaultInfo(id){var obj=new SettingsInfo();obj.ID=id;obj.View=1;obj.ResultType=0;obj.DepID='airportsDep1';obj.DestID='airportsDest1';obj.DatesID=null;obj.DrawOperators=null;obj.TimeDepStart=null;obj.TimeDepEnd=null;obj.TimeRetStart=null;obj.TimeRetEnd=null;obj.TabName='tabCheapest';obj.GetAirport=GetAirport;obj.FlexRequest=new FlexibleRequestObject(obj.ResultType);obj.GraphData=new Object();obj.Chart=new MonthChart(id,'flexChart1',null);obj.GetTooltipHtml=function(val){var html='',opDetail='',apts='';if(this.GraphData&& this.GraphData[val]){var item=this.GraphData[val];var html=item.GetItemHtml();}return html;}return obj;}function GetFlexibleInfo(id){var obj=new SettingsInfo();obj.ID=id;obj.View=1;obj.ResultType=1;obj.DatesID=null;obj.DrawOperators=drawOperators;obj.GetAirport=GetAirport;obj.TabName='tabMonth';obj.FlexRequest=new FlexibleRequestObject(obj.ResultType);obj.GraphData=GetEmptyGraphArray(obj);obj.Chart=new BarChart(id,'flexChart1','graphMonthLabel','graphPrevMonthImg');return obj;}function GetSettingsInfo(type){switch(type){case 0:return DefaultInfo;case 1:return FlexibleInfo;}return null;}function ResetCurrentPage(){GetSettingsInfo(0).CurrentPage=1;GetSettingsInfo(1).CurrentPage=1}function AddCommand(item){var info=GetSettingsInfo(item.ResultType);if(info){if(info.DepArray&&!FindAirportInArray(info.DepArray,item.DepIata)){var depapt=info.GetAirport(item.DepIata);if(depapt){info.DepArray.push(depapt);if(CurrentView==info.View)drawAirports(info.DepArray,info.DepID,info,DEP_COUNTRY_CODE);}}if(info.DestArray&&!FindAirportInArray(info.DestArray,item.DestIata)){var destapt=info.GetAirport(item.DestIata);if(destapt){info.DestArray.push(destapt);if(CurrentView==info.View)drawAirports(info.DestArray,info.DestID,info,DEST_COUNTRY_CODE);}}if(info.OperatorsArray&&!findOperatorInArray(info.OperatorsArray,item)){var redirectUrl=item.GetRedirectLink();var operator=new OperatorObject(item.OPID,item.Operator,redirectUrl,item.ShortPrice,item.TotalPrice)info.OperatorsArray.push(operator);if(info.DrawOperators&& CurrentView==info.View)info.DrawOperators(info.OperatorsArray,info.OperatorsID);}}}function RedrawFilters(type){var info=GetSettingsInfo(type);if(info.DepArray)drawAirports(info.DepArray,info.DepID,info,DEP_COUNTRY_CODE);if(info.DestArray)drawAirports(info.DestArray,info.DestID,info,DEST_COUNTRY_CODE);if(info.DrawOperators&& info.OperatorsArray)info.DrawOperators(info.OperatorsArray,info.OperatorsID);}function SetOperatorFinished(opid){for(var i=0;i<arrOperatorsFinished.length;i++){if(opid==arrOperatorsFinished[i])return;}arrOperatorsFinished.push(opid);}function OpIsFinished(opid){for(var i=0;i<arrOperatorsFinished.length;i++){if(opid==arrOperatorsFinished[i])return true;}return false;}function drawOperators(arrOps,id){ClearTableById(id)var operatorsSection=GetItemById(id);arrOps.sort(CompareOperatorArray);for(var i=0;i<arrOps.length;i++){var oprow=operatorsSection.insertRow(operatorsSection.rows.length);var cell1=oprow.insertCell(0);var cell2=oprow.insertCell(1);var cell3=oprow.insertCell(2);WriteOperatorHtml(arrOps[i],cell1,cell2,cell3,i);}}function WriteOperatorHtml(op,cell1,cell2,cell3,i){var link='<a href="'+op.Url+'" target="_blank">';cell1.vAlign=cell2.vAlign=cell3.vAlign='middle';cell1.width='14px';cell3.align='right';cell3.noWrap=true;cell1.innerHTML='<INPUT Type=checkbox onClick="filter()" checked id=chkOp'+i+' value="'+op.Operator+'">';cell2.innerHTML=link+op.Operator+'</a>';cell3.innerHTML=link+'<span id="spanOp'+op.Operator+'">'+op.Price+'</span></a>';}function ClearTableById(id){var mTable=GetItemById(id);if(mTable==null)return;while(mTable.rows[0])mTable.deleteRow(0);}function CompareString(a,b){return((a>b)?1:((a<b)?-1:0));}function CompareName(a,b){return((a.Name>b.Name)?1:((a.Name<b.Name)?-1:0));}function CompareOperatorArray(a,b){var x=null;var y=null;x=b.Operator.toLowerCase();y=a.Operator.toLowerCase();return((x<y)?1:((x>y)?-1:0));}function CompareDatesArray(a,b){var x1=new DateObject(a.OutDate,'dd/MM/yyyy');var x2=new DateObject(a.InDate,'dd/MM/yyyy');var y1=new DateObject(b.OutDate,'dd/MM/yyyy');var y2=new DateObject(b.InDate,'dd/MM/yyyy');if(x1.DateItem<y1.DateItem)return -1;else if(x1.DateItem>y1.DateItem)return 1;else if(x2.DateItem<y2.DateItem)return -1;else if(x2.DateItem>y2.DateItem)return 1;elsereturn 0;}function drawAirports(arr,id,info,country){var airports=GetItemById(id);if(airports==null)return;while(airports.rows[0])airports.deleteRow(0);arr.sort(CompareDistance);for(var i=0;i<arr.length;i++){var oprow,opcell1,opcell2;var aptFull=arr[i].GetFullName();var checked=(arr[i].Checked?' checked':'');var chk='<INPUT Type=checkbox onClick="SetAirportCheck(this.value,this.checked,true)"'+checked+' id=chk'+i+' value="'+arr[i].IATA+'">';var apt=arr[i].City+' ('+arr[i].IATA+')'+(arr[i].Distance<0?'':'<br>'+arr[i].Distance+' KM');oprow=airports.insertRow(airports.rows.length);opcell1=oprow.insertCell(0);opcell1.width='14px';opcell1.vAlign='top';opcell1.title=aptFull;opcell1.innerHTML=chk;opcell2=oprow.insertCell(1);opcell2.className='AptCheckText';opcell2.title=aptFull;opcell2.innerHTML=apt;}}function showLoadingScreen(blnVal){GetItemById('updating').style.display=(blnVal&& SearchFinished?'':'none');if(blnVal){LoadingScreen.show();}else{LoadingScreen.hide();}}function isDateCheckedInArray(arr,item){var dateToFind=item.DepDate+item.RetDate;for(var i=0;i<arr.length;i++){if(arr[i].toString()==dateToFind){return arr[i].IsChecked;}}return false;}function getDateFromArray(arr,dateToFind){for(var i=0;i<arr.length;i++){if(arr[i].toString()==dateToFind)return arr[i];}}function findDateInArray(arr,item){var dateToFind=item.DepDate+item.RetDate;for(var i=0;i<arr.length;i++){if(arr[i].toString()==dateToFind){if(item.TotalPrice<arr[i].Value){arr[i].Url=item.GetRedirectLink();arr[i].Price=item.ShortPrice;arr[i].Value=item.TotalPrice;}return true;}}return false;}function findOperatorInArray(arr,item){for(var i=0;i<arr.length;i++){if(arr[i].OPID==item.OPID){if(item.TotalPrice<arr[i].Value){arr[i].Url=item.GetRedirectLink();arr[i].Price=item.ShortPrice;arr[i].Value=item.TotalPrice;}return true;}}return false;}function findStringInArray(arrString,strToFind){for(var i=0;i<arrString.length;i++){if(arrString[i]==strToFind){return true;}}return false;}function Sort(sortAlg){showLoadingScreen(true);setTimeout('DoSort('+sortAlg+')');filter();}var blnSortByPriceInv=false;var blnSortByAirlineInv=true;var blnSortByOperatorInv=true;var blnSortByDepartTime=true;var blnSortByArriveTime=true;var blnSortByStops=true;function DoSort(sortAlg){switch(sortAlg){case 0:blnSortByPriceInv=!blnSortByPriceInv;GetSettingsInfo(0).Results.sort(ComparePrice);if(GetSettingsInfo(1).Results){GetSettingsInfo(1).Results.sort(ComparePrice);}break;case 1:blnSortByAirlineInv=!blnSortByAirlineInv;GetSettingsInfo(0).Results.sort(CompareAirline);if(GetSettingsInfo(1).Results){GetSettingsInfo(1).Results.sort(CompareAirline);}break;case 2:blnSortByOperatorInv=!blnSortByOperatorInv;GetSettingsInfo(0).Results.sort(CompareOperator);if(GetSettingsInfo(1).Results){GetSettingsInfo(1).Results.sort(CompareOperator);}break;case 3:blnSortByDepartTime=!blnSortByDepartTime;GetSettingsInfo(0).Results.sort(CompareDepartTime);if(GetSettingsInfo(1).Results){GetSettingsInfo(1).Results.sort(CompareDepartTime);}break;case 4:blnSortByArriveTime=!blnSortByArriveTime;GetSettingsInfo(0).Results.sort(CompareArriveTime);if(GetSettingsInfo(1).Results){GetSettingsInfo(1).Results.sort(CompareArriveTime);}break;case 5:blnSortByStops=!blnSortByStops;GetSettingsInfo(0).Results.sort(CompareStops);if(GetSettingsInfo(1).Results){GetSettingsInfo(1).Results.sort(CompareStops);}break;}}function ComparePrice(a,b){var x=null;var y=null;if(!blnSortByPriceInv){x=a.TotalPrice;y=b.TotalPrice;}else{x=b.TotalPrice;y=a.TotalPrice;}return((x<y)?-1:((x>y)?1:0));}function CompareAirline(a,b){var x=null;var y=null;if(!blnSortByAirlineInv){x=a.Airline.toLowerCase();y=b.Airline.toLowerCase();}else{x=b.Airline.toLowerCase();y=a.Airline.toLowerCase();}return((x<y)?-1:((x>y)?1:0));}function CompareOperator(a,b){var x=null;var y=null;if(!blnSortByOperatorInv){x=a.Operator.toLowerCase();y=b.Operator.toLowerCase();}else{x=b.Operator.toLowerCase();y=a.Operator.toLowerCase();}return((x<y)?-1:((x>y)?1:0));}function CompareDepartTime(a,b){var x=null;var y=null;if(!blnSortByDepartTime){x=a.OutDepTime.replace(':','');y=b.OutDepTime.replace(':','');}else{x=b.OutDepTime.replace(':','');y=a.OutDepTime.replace(':','');}return((x<y)?-1:((x>y)?1:0));}function CompareArriveTime(a,b){var x=null;var y=null;if(!blnSortByArriveTime){x=a.OutArrTime.replace(':','');y=b.OutArrTime.replace(':','');}else{x=b.OutArrTime.replace(':','');y=a.OutArrTime.replace(':','');}return((x<y)?-1:((x>y)?1:0));}function CompareStops(a,b){var x1=0,x2=0,y1=0,y2=0;if(!blnSortByStops){x1=a.OutStops;y1=b.OutStops;x2=a.InStops;y2=b.InStops;}else{x1=b.OutStops;y1=a.OutStops;x2=b.InStops;y2=a.InStops;}return((x1<y1)?-1:((x1>y1)?1:(x2<y2)?-1:((x2>y2)?1:0)));}function UpdateFlexible(){if(CurrentView==1){RedrawFilters(1);}setTimeout('UpdateFilter()',80);}function FetchFlexibleDayFlights(day,type,way){showLoadingScreen(true);var info=GetSettingsInfo(type);info.DepArray=new Array();info.DestArray=new Array();info.OperatorsArray=new Array();info.Results=new Array();ClearAirportCheapest();info.FlexRequest.FetchResults('day',info.ResultType,info.DepIATA,info.DestIATA,day,info.GraphMonth,info.GraphYear,SEARCH_ADULTS,SEARCH_CHILDREN,SEARCH_INFANTS,way,CURRENCY_REGION);}function GetNextMonthFlexibleFlights(graphNum){var info=null;if(graphNum==1&& CurrentView==1)info=GetSettingsInfo(1);if(info==null)return;info.GraphMonth++;if(info.GraphMonth>12){info.GraphMonth=1;info.GraphYear++;}info.GraphData=GetEmptyGraphArray(info);FetchFlexibleMonthFlights(info);}function GetPrevMonthFlexibleFlights(graphNum){var info=null;if(graphNum==1&& CurrentView==1)info=GetSettingsInfo(1);if(info==null)return;var now=new Date();var nowMonth=now.getMonth()+1;var nowYear=now.getFullYear();if(info.GraphMonth==nowMonth&& info.GraphYear==nowYear)return;info.GraphMonth--;if(info.GraphMonth<1){info.GraphMonth=12;info.GraphYear--;}info.GraphData=GetEmptyGraphArray(info);FetchFlexibleMonthFlights(info);}function FetchFlexibleMonthFlights(info){showLoadingScreen(true);info.DepArray=new Array();info.DestArray=new Array();info.OperatorsArray=new Array();info.Results=new Array();ClearAirportCheapest();info.FlexRequest.FetchResults('month',info.ResultType,info.DepIATA,info.DestIATA,1,info.GraphMonth,info.GraphYear,SEARCH_ADULTS,SEARCH_CHILDREN,SEARCH_INFANTS,info.Way,CURRENCY_REGION);}function GetEmptyGraphArray(info){var arr=new Array();var dtMonth=new Date(info.GraphYear,(info.GraphMonth-1),1);while(dtMonth.getMonth()==(info.GraphMonth-1)){arr.push(null);dtMonth.setDate(dtMonth.getDate()+1);}return arr;}function SetGraphItem(item){var index=item.DepDay-1;var info=GetSettingsInfo(item.ResultType)if(info.GraphData&&(info.GraphData[index]==null||item.TotalPrice<info.GraphData[index].TotalPrice)){info.GraphData[index]=item;}}function EndSearch(){SearchFinished=true;var info;if(CurrentView==0){RedrawFilters(0);info=GetSettingsInfo(0);}else if(CurrentView==1){RedrawFilters(1);info=GetSettingsInfo(0);}UpdateFilter();}function DrawAlternativeSearch(info){var depArr=info.DepArray;var depChecked=0;for(var i=0;i<depArr.length;i++){depChecked+=(depArr[i].Checked?1:0);}var destArr=info.DestArray;var destChecked=0;for(var i=0;i<destArr.length;i++){destChecked+=(destArr[i].Checked?1:0);}var altPane=GetItemById('pnlAltSearch');var resPane=GetItemById('resultsPane');if(info.FilteredResults.length==0&&((depChecked==0&& depArr.length>0)||(destChecked==0&& destArr.length>0))){var aptIcon='<img src="'+IMG_ROOT+'i/map/apt_sml.gif" width=12 height=18>';var html='<div class="ErrorMessage">';html+=TXT_NO_RESULTS_FOUND+'<br>';html+=TXT_TRY_THESE_AIRPORTS+'</div>';html+='<table align=center cellspacing=5><tr>';html+='<td align=center class="FilterSubTitle">'+TXT_DEPARTURES+'</td>';html+='<td align=center class="FilterSubTitle">'+TXT_DESTINATIONS+'</td></tr>';html+='<tr><td valign=top><table>';for(var i=0;i<depArr.length;i++){var checked=(depArr[i].Checked?' checked':'');html+='<tr><td>'html+='<INPUT Type=checkbox onClick="SetAirportCheck(this.value,this.checked,false)"'+checked+' value="'+depArr[i].IATA+'">';html+='</td><td>'+aptIcon+'</td><td>'html+=depArr[i].GetFullName()+' ('+depArr[i].IATA+') '+depArr[i].Country+'<br>';html+=(depArr[i].Distance<0?'':' '+depArr[i].Distance+' KM from '+DEP_CITY);html+='</td></tr>'}html+='</table></td><td valign=top><table>';for(var i=0;i<destArr.length;i++){var checked=(destArr[i].Checked?' checked':'');html+='<tr><td>'html+='<INPUT Type=checkbox onClick="SetAirportCheck(this.value,this.checked,false)"'+checked+' value="'+destArr[i].IATA+'">';html+='</td><td>'+aptIcon+'</td><td>'html+=destArr[i].GetFullName()+' ('+destArr[i].IATA+') '+destArr[i].Country+'<br>';html+=(destArr[i].Distance<0?'':' '+destArr[i].Distance+' KM from '+DEST_CITY);html+='</td></tr>'}html+='</table></td></tr>';html+='<tr><td colspan=2 align=center>';html+='<br><input type=button value="'+TXT_UPDATE+'" onClick="filter()"></td></tr></table>';altPane.innerHTML=html;resPane.style.display='none';altPane.style.display='';ShowMap(true,info.TabName,false);}else{altPane.style.display='none';resPane.style.display='';}}function SetAirportCheck(iata,checked,update){var apt=GetAirport(iata);if(apt){apt.Checked=checked;if(CurrentView==0){RedrawFilters(0);}else if(CurrentView==1){RedrawFilters(1);}if(update){filter();}}}function DateObject(date_string,format){this.DateItem=new Date();this.DateString=date_string;this.Format=format;this.GetDay=function(){return this.DateItem.getDate();}this.GetMonth=function(){return this.DateItem.getMonth()+1;}this.GetYear=function(){return this.DateItem.getFullYear();}this.GetMonthName=function(month){return MonthNames[month-1];}this.GetMonthAbbr=function(month){return MonthAbbr[month-1];}this.ToString=function(fmt){var d=this.DateItem.getDate();var m=this.DateItem.getMonth()+1;var y=this.DateItem.getFullYear();var outString='';switch(fmt){case'd MMM':outString=d+' '+this.GetMonthAbbr(m);break;case'd MMMM':outString=d+' '+this.GetMonthName(m);break;case'yyyy-m-y':outString=y+'-'+m+'-'+d;break;default:outString=this.DateItem.toLocaleDateString();break;}return outString;}this.ParseDate=function(){if(!this.DateString||!this.Format)return new Date();var d,m,y;var dateParts=this.DateString.split('/');var fmtParts=this.Format.split('/');for(var i=0;i<fmtParts.length;i++){switch(fmtParts[i]){case'd':case'dd':if(i<dateParts.length){d=parseInt(dateParts[i],10);}break;case'M':case'MM':if(i<dateParts.length){m=parseInt(dateParts[i],10)-1;}break;case'yyyy':if(i<dateParts.length){y=parseInt(dateParts[i],10);}break;}}return new Date(y,m,d);}this.DateItem=this.ParseDate();}function GetAirport(iata){return AirportsList[iata];}function AddAirport(iata,city,name,country,countrycode,dist,lat,lon,searchIata,checked,type){new AirportDetails(AirportsList,iata,city,name,country,countrycode,dist,lat,lon,searchIata,checked,type);}function ClearAirportCheapest(){for(var iata in AirportsList){AirportsList[iata].CheapestFlight=null;}}function AirportDetails(obj,iata,city,name,country,countrycode,dist,lat,lon,searchIata,checked,type){this.IATA=iata;this.City=city;this.Name=name;this.Country=country;this.CountryCode=countrycode;this.Distance=dist;this.Latitude=lat;this.Longitude=lon;this.SearchIATA=searchIata;this.Type=type;this.CheapestFlight=null;this.MapPin=null;this.Checked=checked;this.GetFullName=function(){var fullname=this.City;fullname+=(this.Name.length>0?' '+this.Name:'');return fullname;}if(obj[iata]!=null)return;obj[iata]=this;}function CompareDistance(a,b){var x=a.Distance;var y=b.Distance;return((x<y&& x>=0)?-1:((y<x&& y>=0)?1:0));}function FindAirportInArray(arr,iata){for(var i=0;i<arr.length;i++){if(arr[i].IATA==iata)return arr[i];}return null;}function StopSearch(){try{if(window.stop){window.stop();}else{document.execCommand('Stop');}}catch(e){}EndSearch();}function CreateMap(){var map=new mapManager({id:'mapDiv',useLoader:true});map.createMap(DEST_LATITUDE,DEST_LONGITUDE)return map;}function ShowDepartures(){MapIsDep=true;MapAirport=null;GetItemById('mapDeps').style.fontWeight='bold';GetItemById('mapDests').style.fontWeight='';if(MyMap){MyMap.moveTo(DEP_LATITUDE,DEP_LONGITUDE);}filter();}function ShowDestinations(){MapIsDep=false;MapAirport=null;GetItemById('mapDeps').style.fontWeight='';GetItemById('mapDests').style.fontWeight='bold';if(MyMap){MyMap.moveTo(DEST_LATITUDE,DEST_LONGITUDE);}filter();}function ShowMap(visible,tabName,update){MapVisible=visible;MapAirport=null;if(update){UpdateFilter();}if(!tabName&& MapVisible){GetItemById('tabCheapest').className='unselectedTab';GetItemById('tabMonth').className='unselectedTab';}else{GetItemById(tabName).className=(MapVisible?'unselectedTab':'selectedTab');}GetItemById('tabMap').className=(MapVisible?'selectedTab':'unselectedTab');GetItemById('pnlMap').style.display=(MapVisible?'':'none');GetItemById('pnlDefault').style.display=(MapVisible?'none':'');GetItemById('mapNav').style.display=(MapVisible?'':'none');if(MapVisible){if(!MyMap){MyMap=CreateMap()}AddAirportsToMap(MyMap);}}function CreateMarker(point,apt){if(!MyMap){return;}var flight=apt.CheapestFlight;var aptName=apt.GetFullName();var obj={id:apt.IATA,img:null,width:0,height:0,lat:point.lat,lon:point.lon,html:null,title:aptName,visible:true};if(apt.CheapestFlight){obj.img=IMG_ROOT+'i/map/apt.png';obj.width=20;obj.height=34;}else{obj.img=IMG_ROOT+'i/map/aptEmpty.png';obj.width=15;obj.height=24;}var html='<div class="mapResult">';if(flight){var isDep=(flight.DepIata==apt.IATA);var iata=(isDep?flight.DepIata:flight.DestIata);html+='<div class="mapText">'+(flight.DepAirport?flight.DepAirport.GetFullName():flight.DepIata);html+=' to '+(flight.DestAirport?flight.DestAirport.GetFullName():flight.DestIata)+'</div>';html+=apt.CheapestFlight.GetItemHtml();html+='<div style="padding-top:4px;">';html+='<a class="blueText" href="'+flight.GetRedirectLink()+'" target="_blank">';html+=TXT_VERIFY_AVAILABILITY;html+='</a></div>';html+='<div style="padding-top:4px;">';html+='<a class="GreenLink" href="javascript:ShowMapFlightsByAirport(\''+iata+'\','+isDep+')">';html+=(isDep?TXT_MORE_FLIGHTS_FROM:TXT_MORE_FLIGHTS_TO);html+='</a></div>';}else{html+='<div class="mapText">'+aptName+'</div>';}html+='</div>';obj.html=html;MyMap.updateMarkers(obj);return obj;}function AddAirportsToMap(map){for(var iata in AirportsList){var apt=AirportsList[iata];if(apt){var point={lat:apt.Latitude,lon:apt.Longitude};apt.MapPin=CreateMarker(point,apt);}else{arr.push(apt);}}}function ShowMapFlightsByAirport(iata,isDep){MapAirport=iata;MapIsDep=isDep;SetAirportCheck(iata,true,false);filter();}function HideElement(elem){elem.style.display='none';}function GetItemById(id){return(document.all?document.all[id]:document.getElementById(id));}
