if(typeof (IXIGO)=="undefined"){IXIGO={}}IXIGO.FlightMain=function(){var B=null;this.monthAbr=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
this.date=new Date();this.mapView=null;this.flightSort=new IXIGO.FlightSort();this.showOnly=25;this.results;
this.sortedResponses=[];this.map;this.currentTab="contentMap";this.originLat=0;this.originLong=0;this.init=function(){B=this;
this.loadLeavingCombo();this.flightSort.init(B);$(this.flightSort).change(B.updateSort);$("input[@name='showNumResults']").click(function(){$("#updateIndicator").show();
$("#updateError").hide();B.showOnly=$("input[@name='showNumResults']:checked").val();$(B.flightSort).trigger("change")
});if($("#headingResults").length>0){$("#headingResults").html("lowest fares for flights departing from "+$('select[@name="fareMapperForm:origin"] option[@selected]').text()+" in "+$('select[@name="fareMapperForm:leaveTimeBox"] option[@selected]').text())
}$("#contentBox").corner("bottom").corner("tr");$("#FaresButton").mouseover(function(E){IXIGO.buttonHover("#FaresButton","b-","-bg-3")
}).mouseout(function(E){IXIGO.buttonHover("#FaresButton","b-","-bg-3")});$("#fareMapperForm\\:origin , #fareMapperForm\\:leaveTimeBox, #fareMapperForm\\:destination").change(function(){$("#updateError").hide();
B.map=null;$("#updateIndicator").show();if($("#headingResults").length>0){$("#headingResults").html("lowest fares for flights departing from "+$('select[@name="fareMapperForm:origin"] option[@selected]').text()+" in "+$('select[@name="fareMapperForm:leaveTimeBox"] option[@selected]').text())
}if(B.mapView===null||!B.mapView){B.loadGMapScript()}else{this.initializeMap()}B.updateOutlookGraph()
});$("#loadingIndicator").show();B.loadGMapScript();$("#contentTabContainer").click(function(E){B.oncontentTabClick(this,E)
});$("#contentMapTabLink").corner("top");B.updateOutlookGraph();$("#shareFareMap, #shareTripPlan").click(function(){var F=(window.location.href.indexOf("planner")<0?"iXiGO Fare Mapper":"iXiGO Flight Planner");
var E="/html/info/tell-a-friend.ixi?provider=email&channel=email&id=200811273773&link="+window.location+"&title="+document.title+"&custom={'tool':'"+F+"'}";
window.open(E,"iXiGO","scrollbars=no,menubar=no,width=490,height=520,resizable=no,toolbar=no,location=no,status=no,screenX=200,screenY=100,left=200,top=100");
return false});$("#contentTabContainer, #contentBox").css("position","")};this.loadGMapScript=function(){if(location.hostname.indexOf("ixigo")!==-1){var E=document.createElement("script");
E.type="text/javascript";E.src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAaFkhHqRKxmIC55Cw5dS1cRSVVb5P-P-81vc8SJK_4LEGVkGjEhSfxXw_tms7NnWvDcBG8yfIUb1Mxw&async=2&callback=window.searchResult.initializeMap";
$("body")[0].appendChild(E)}};this.initializeMap=function(){if(B.mapView===null||!B.mapView){var E=document.createElement("script");
E.type="text/javascript";E.src="/static/js/ixigo/label_marker.js";$("body")[0].appendChild(E)}var F=$("#fareMapperForm\\:origin").val();
var G=$("#fareMapperForm\\:leaveTimeBox").val();$.ajax({type:"GET",url:"/action/content/faremap?searchFor=faremap&origin="+F+"&duration="+G,dataType:"html",success:function(I){if($("#loadingIndicator").css("display")!="block"){$("#updateIndicator").show()
}B.results=Ajax.evalJSON(I);if(GBrowserIsCompatible()&&B.results[0]){for(var H=0;H<B.results.length;H++){if(B.results[H].originCode===B.results[H].destinationCode){B.originLat=B.results[H].latitude;
B.originLong=B.results[H].longitude;break}}if(B.originLat!=0&&B.originLong!=0){$(B.flightSort).trigger("change")
}else{B.map=new GMap2(document.getElementById("map"),{size:new GSize(583,400)});$("#updateIndicator, #loadingIndicator, #resultList").hide();
$("#allResults").html("");$("#updateTextError").html("Not enough searches on this route");$("#updateError").show()
}}else{B.map=new GMap2(document.getElementById("map"),{size:new GSize(583,400)});$("#updateIndicator, #loadingIndicator, #resultList").hide();
$("#allResults").html("");$("#contentBox").css("height","400px");$("#updateTextError").html("Not enough searches on this route");
$("#updateError").show()}},error:function(H){$("#updateTextError").html("Not enough searches on this route");
B.map=new GMap2(document.getElementById("map"),{size:new GSize(583,400)});$("#updateIndicator, #loadingIndicator, #resultList").hide();
$("#contentBox").css("height","400px");$("#allResults").html("");$("#updateError").show();setTimeout('$("#updateError").hide();',3000)
},beforeSend:function(H){H.setRequestHeader("Accept","text/javascript")}})};this.updateSort=function(){if(B.results.length>0){B.results.sort(B.flightSort.comparator);
B.showResults(B.results)}else{$("#updateIndicator, #loadingIndicator").hide();$("#updateError").show();
if(window.location.href.indexOf("planner")>0){$("#contentBox").css("height","400px")}}};this.createPolyline=function(K,J,I,H,G){var E={geodesic:true};
var F=new GPolyline([new GLatLng(K,J),new GLatLng(I,H)],"#0686fe",3,0.3,E);G.addOverlay(F)};this.createMarker=function(K,E,F,J,I,M){var G=new GLatLng(K,E);
var L=new GIcon();L.image="/img/x.gif";L.iconSize=new GSize(0,0);L.iconAnchor=new GPoint(1,12);L.infoWindowAnchor=new GPoint(0,16);
opts={"icon":L,"clickable":true,"title":M,"labelText":J,"labelClass":"label","labelOffset":new GSize(-489,-231)};
var H=new LabeledMarker(G,opts);F.addOverlay(H);GEvent.addListener(H,"click",function(){H.openInfoWindowHtml(I,{maxWidth:"200"})
})};this.loadLeavingCombo=function(){var H=B.date.getMonth();var I="<option id='optionOne' value=''>anytime</option>";
for(var F=0,E=0;F<6;F++,E++){if(H+E>12){H=1;E=0}B.date.setMonth(H+E);var G=""+(B.date.getMonth()+1);if(G.length==1){G="0"+G
}I+='<option value="'+(G+B.date.getFullYear())+'">'+(B.monthAbr[B.date.getMonth()]+" "+B.date.getFullYear())+"</option>"
}$("#option1").hide();$("#fareMapperForm\\:leaveTimeBox").append(I)};this.fillMapData=function(H){B.map=new GMap2(document.getElementById("map"),{size:new GSize(583,400)});
$("#contentBox").css("height","400px");B.map.addControl(new GSmallZoomControl());B.map.setCenter(new GLatLng(B.originLat,B.originLong),this.isWithinRange());
var F='<div id="ixiTipWrapper" style="width: 100px; top: 204px; left: 449px; display: block;">'+'<div class="ixiTip" style="top: 18px; left: 33px;">'+'<div style="margin: 0pt 0px; overflow: hidden; height: 1px; background-color: #ffaa00; width: 14px; float: none;"></div>'+'<div style="margin: 0pt 1px; overflow: hidden; height: 1px; background-color: #ffaa00; width: 12px; float: none;"></div>'+'<div style="margin: 0pt 2px; overflow: hidden; height: 1px; background-color: #ffaa00; width: 10px; float: none;"></div>'+'<div style="margin: 0pt 3px; overflow: hidden; height: 1px; background-color: #ffaa00; width: 8px; float: none;"></div>'+'<div style="margin: 0pt 4px; overflow: hidden; height: 1px; background-color: #ffaa00; width: 6px; float: none;"></div>'+'<div style="margin: 0pt 5px; overflow: hidden; height: 1px; background-color: #ffaa00; width: 4px; float: none;"></div>'+'<div style="margin: 0pt 6px; overflow: hidden; height: 1px; background-color: #ffaa00; width: 2px; float: none;"></div>'+'<div class="clear"></div>'+"</div>"+'<div class="ixiTipBody">'+'<div class="cnMap left"></div>'+'<div class="ixiTipBodyContent semi" style="background: #ffaa00;color: #444;">';
var E="</div>"+'<div class="cnMap right"></div>'+'<div class="clear"></div>'+"</div>"+"</div>";for(var G=0;
G<H.length;G++){if(H[G].destinationCode!=$("#fareMapperForm\\:origin").val()&&G<parseInt(B.showOnly)){var I='<div style="line-height:18px;font-family:verdana;color#444;">'+'<div style="font-weight:bold;">'+H[G].origin+" - "+H[G].destination+"</div>"+'<div style="font-weight:bold;">'+H[G].providers[0]+"</div>"+'<div style="float:left;width:110px;">'+Date.fromFlatDate(H[G].startDate).toDateString()+"</div>"+'<div style="float:right;">'+'<span style="color:#666;font-size:9pt;">Rs. </span>'+'<span style="font-weight:bold;font-size:11pt;color:#444;">'+parseInt(H[G].adultTotal,10).toFixed(0)+"</span>"+"</div>"+'<div class="clear"></div>'+'<div style="text-align:right;">'+'<a target="_blank" href="/search/result/flight/'+$("#fareMapperForm\\:origin").val()+"/"+H[G].destinationCode+"/"+H[G].startDate+'//1/0/0/e">search flight</a>'+"</div>"+"</div>";
B.createMarker(H[G].latitude,H[G].longitude,B.map,F+'<span style="color:#666;font-size:10px;">Rs.</span><b>'+parseInt(H[G].adultTotal).toFixed(0)+"</b>"+E,I,"flight to "+H[G].destination);
B.createPolyline(B.originLat,B.originLong,H[G].latitude,H[G].longitude,B.map)}}$("#updateIndicator, #loadingIndicator").hide();
setTimeout('$("#copyright").css("font-size", "9px");',2000)};this.showResults=function(F){var G="&#160;";
if(window.location.href.indexOf("planner")<0){for(var E=0;E<F.length;E++){if(F[E].destinationCode!=$("#fareMapperForm\\:origin").val()&&E<parseInt(B.showOnly)){G+='<div id="result_'+F[E].destinationCode+'" class="resultsDisplay" style="background:#fff;"><a target="_blank" id="result_'+F[E].destinationCode+'Link" style="text-decoration:none;color:#666;background:#fff;" href="/search/result/flight/'+$("#fareMapperForm\\:origin").val()+"/"+F[E].destinationCode+"/"+F[E].startDate+'//1/0/0/e"><div id="result_'+F[E].destinationCode+'Div" class="round_all" style="cursor:pointer;font-family:verdana;background:#eee;color:#444;">'+'<div style="float:left;width:120px;font-weight:bold;margin-top:2px;padding:10px 0px 10px 10px;">'+F[E].destination+"</div>"+'<div style="float:left;width:120px;margin-top:2px;padding:10px 0px;" title="'+Date.fromFlatDate(F[E].startDate).toDateString()+'">'+Date.fromFlatDate(F[E].startDate).toDateString().substring(4,10)+'<span class="ixiGray"> ('+Date.fromFlatDate(F[E].startDate).toDateString().substring(0,3)+')</span></div><div style="float:left;margin-top:2px;padding:10px 0px;">found '+C(F[E].searchedOn)+' on <span style="color:#ff7800;">'+F[E].providers[0]+'</span></div><div style="text-align:right;padding:10px 10px 10px 0px;"><span class="currency">Rs. </span><span class="adultTotal" style="color:#000;">'+parseInt(F[E].adultTotal,10).toFixed(0)+'</span></div><div class="clear"/></div></a></div><br/>'
}}$("#resultList").show();$("#allResults").html(G).show();$("div.resultsDisplay").hover(function(){$("#"+$(this).attr("id")+"Div").css("background","#dedede")
},function(){$("#"+$(this).attr("id")+"Div").css("background","#eee")});$("#allResults div.round_all").corner()
}if(!this.flightSort.updateMap){B.fillMapData(F)}};function D(E){return E.getDate()+" "+E.getSmallMonthName()
}function A(E){newDate=E.replace("-","");newDate=newDate.replace("-","");return newDate}function C(F){var H=0;
var E=Date.today();var G;H=(E-F)/(1000*60*60*24);if(parseInt(H)>0){G=parseInt(H)+(parseInt(H)>1?" days ago":" day ago")
}else{if(parseInt(H*24)>0){G=parseInt(H*24)+(parseInt(H*24)>1?" hrs ago":" hr ago")}else{G=parseInt(H*1440)+(parseInt(H*1440)>1?" mins ago":" min ago")
}}return G}this.oncontentTabClick=function(H,G){var E="";var F=G.target;while(F&&F!==H&&!F.getAttribute("action")){F=F.parentNode
}if(F&&F.getAttribute("action")){E=F.getAttribute("action");E=E.lastIndexOf("/")!==-1?E.substring(E.lastIndexOf("/")+1):E;
this.selectTab(E)}if(F.getAttribute("action")==="contentGraph"){$("#radioShowResults").hide();$("#destCity").fadeIn();
$("#optionOne").html("next 30 days");$("#contentBox").css("height","400px")}else{$("#destCity").hide();
$("#optionOne").html("anytime");$("#radioShowResults").fadeIn();$("#contentBox").css("height","400px")
}};this.selectTab=function(E){if(this.currentTab===E){return }this.hideTab(this.currentTab);this.showTab(E);
this.currentTab=E};this.hideTab=function(E){E="#"+E;$(E).hide();$(E+"TabLink").attr("class","tripDetailTabTitle")
};this.showTab=function(E){E="#"+E;$(E).show();$(E+"TabLink").attr("class","tripDetailTabTitleSelected");
$(E+"TabLink").corner("top")};this.updateOutlookGraph=function(){var F=$("#fareMapperForm\\:origin").val();
var E=$("#fareMapperForm\\:destination").val();var G=$("#fareMapperForm\\:leaveTimeBox").val().substring(0,2)+$("#fareMapperForm\\:leaveTimeBox").val().substring(2,6);
if(F!=E){$("#contentGraph").html('<br/><div style="float:left;color:#666;margin-left:40px;margin-bottom:10px;">30 day fare outlook for <b>'+F+" - "+E+'</b> flights</div><br/><iframe scrolling="no" height="320" frameborder="0" width="580" src="/html/search/result/flights/flightplanner.ixi?orig='+F+"&amp;des="+E+"&amp;month="+G+'&amp;page=tripPlanner" id="iframe_outlookBig"/>')
}else{if(E==="DEL"){$("#contentGraph").html('<br/><div style="float:left;color:#666;margin-left:40px;margin-bottom:10px;">30 day fare outlook for <b>'+F+' - BOM</b> flights</div><br/><iframe scrolling="no" height="320" frameborder="0" width="580" src="/html/search/result/flights/flightplanner.ixi?orig='+F+"&amp;des=BOM&amp;month="+G+'&amp;page=tripPlanner" id="iframe_outlookBig"/>');
$("#fareMapperForm\\:destination").val("BOM")}else{if(E==="BOM"){$("#contentGraph").html('<br/><div style="float:left;color:#666;margin-left:40px;margin-bottom:10px;">30 day fare outlook for <b>'+F+' - DEL</b> flights</div><br/><iframe scrolling="no" height="320" frameborder="0" width="580" src="/html/search/result/flights/flightplanner.ixi?orig='+F+"&amp;des=DEL&amp;month="+G+'&amp;page=tripPlanner" id="iframe_outlookBig"/>');
$("#fareMapperForm\\:destination").val("DEL")}else{$("#contentGraph").html("");$("#updateTextError").html("Please select a destination");
$("#updateError").show()}}}};this.isWithinRange=function(){var L=0;for(var I=0;I<parseInt(B.showOnly);
I++){var G=parseFloat(B.originLat);var K=parseFloat(B.originLong);var H=6371;var F=parseFloat(B.results[I]?B.results[I].latitude:0);
var J=parseFloat(B.results[I]?B.results[I].longitude:0);var N=(F-G)*Math.PI/180;var E=(J-K)*Math.PI/180;
var P=Math.sin(N*0.5)*Math.sin(N*0.5)+Math.cos(G*Math.PI/180)*Math.cos(F*Math.PI/180)*Math.sin(E/2)*Math.sin(E/2);
var O=2*Math.atan2(Math.sqrt(P),Math.sqrt(1-P));var M=H*O;if(B.results[I]){L=L>M?L:M}}L=L<500?6:L<1000?5:(L<4000?4:(L<8000?3:(L<11000?2:1)));
return L}};IXIGO.FlightSort=function(){var B=this;this.flightResult=null;this.comparator=null;this.priceSortDesc=true;
this.sortDesc=true;this.arrow="&#8595;";var A=false;this.init=function(C){B=this;this.flightResult=C;
$("#sortDestination").html("<span>destination</span>");$("#sortDepart").html("<span>depart</span>");$("#sortAirline").html("<span>airline</span>");
$("#sortPrice").html("<span>price per adult*</span>");this.sort(B.priceComparator,$("#sortPrice"),"first");
$("#sortDepart").click(function(){B.sort(B.departComparator,$("#sortDepart"))});$("#sortDestination").click(function(){B.sort(B.arrivalComparator,$("#sortDestination"))
});$("#sortPrice").click(function(){B.sort(B.priceComparator,$("#sortPrice"))});$("#sortAirline").click(function(){B.sort(B.airlineComparator,$("#sortAirline"))
})};this.departComparator=function(D,C){var E=Date.fromFlatDate(D.startDate)-Date.fromFlatDate(C.startDate);
if(E===0){return B.priceComparator(D,C)}E=B.sortDesc?E:-E;return E};this.arrivalComparator=function(D,C){var E=String.compareIgnoreCase(D.destination,C.destination);
if(E===0){return B.priceComparator(D,C)}E=B.sortDesc?E:-E;return E};this.airlineComparator=function(D,C){var E=C.searchedOn-D.searchedOn;
if(E===0){return B.priceComparator(D,C)}E=B.sortDesc?E:-E;return E};this.priceComparator=function(D,C){var E=D.adultTotal-C.adultTotal;
E=B.priceSortDesc?E:-E;if(E===0){return(D.startDate-C.startDate)}return E};this.sort=function(F,E,D){if(D!="first"){$("#updateIndicator").show()
}this.priceSortDesc=true;if(this.comparator!=F){this.comparator=F;this.sortDesc=true}else{this.sortDesc=!this.sortDesc
}if(this.comparator===this.priceComparator){this.priceSortDesc=this.sortDesc}this.arrow=this.sortDesc?"<span style='color:#000;'>&#8595;</span>":"<span style='color:#000;'>&#8593;</span>";
$("#sortDestination").html("<span>destination</span>");$("#sortDepart").html("<span>depart</span>");$("#sortAirline").html("<span>found on</span>");
$("#sortPrice").html("<span>price per adult*</span>");if(E){var C=E.html().lastIndexOf(">");var G=E.html().substring(E.html().indexOf("<"),C+1);
E.html(B.arrow+G+B.arrow);A=true}$(this).trigger("change")}};$(document).ready(function(){window.searchResult=new IXIGO.FlightMain();
window.searchResult.init()});