function createCookie(name,value,days){if(days){var date=new Date;date.setTime(date.getTime()+days*24*60*60*1e3);var expires="; expires="+date.toGMTString()}else var expires="";document.cookie=name+"="+value+expires+"; path=/"}function readCookie(name){for(var nameEQ=name+"=",ca=document.cookie.split(";"),i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==" ")c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length)}return null}function eraseCookie(name){createCookie(name,"",-1)}var _shimmer,_overlay_togglesGE,_shimmer_loading,_overlay_loadingGE,_overlay_loading_paddingLeft=180;function setupShimmer(){_shimmer=document.createElement("iframe");_overlay_togglesGE=document.getElementById("overlay_togglesGE");_shimmer.style.position="absolute";_shimmer.style.width="206px";_shimmer.style.height="24px";_shimmer.style.top=_overlay_togglesGE.style.top;_shimmer.style.left=_overlay_togglesGE.style.left;_shimmer.style.zIndex=999;_shimmer.style.opacity=0;_shimmer.setAttribute("frameborder","0");_shimmer.setAttribute("src","javascript:false;");_shimmer.style.visibility="hidden";document.body.appendChild(_shimmer);_shimmer_loading=document.createElement("iframe");_overlay_loadingGE=document.getElementById("overlay_loadingGE");_shimmer_loading.style.position="absolute";_shimmer_loading.style.width="206px";_shimmer_loading.style.height="24px";_shimmer_loading.style.top=_overlay_loadingGE.style.top;_shimmer_loading.style.left=_overlay_loadingGE.style.left;_shimmer_loading.style.zIndex=999;_shimmer_loading.style.opacity=0;_shimmer_loading.setAttribute("frameborder","0");_shimmer_loading.setAttribute("src","javascript:false;");_shimmer_loading.style.visibility="hidden";shimmerResize();document.body.appendChild(_shimmer_loading)}function showShimmersLoading(toShow){if(toShow){_overlay_loadingGE.style.visibility="visible";_shimmer_loading.style.visibility="visible"}else{_overlay_loadingGE.style.visibility="hidden";_shimmer_loading.style.visibility="hidden";_overlay_togglesGE.style.visibility="visible";_shimmer.style.visibility="visible"}}function shimmerResize(){var size=getSize(),newLeft=size[0]/2+_overlay_loading_paddingLeft-206/2+"px";_shimmer_loading.style.left=newLeft;_overlay_loadingGE.style.left=newLeft}window.onresize=shimmerResize;PolylineEncoder=function(numLevels,zoomFactor,verySmall,forceEndpoints){var i;if(!numLevels)numLevels=18;if(!zoomFactor)zoomFactor=2;if(!verySmall)verySmall=1e-5;if(!forceEndpoints)forceEndpoints=true;this.numLevels=numLevels;this.zoomFactor=zoomFactor;this.verySmall=verySmall;this.forceEndpoints=forceEndpoints;this.zoomLevelBreaks=new Array(numLevels);for(i=0;i<numLevels;i++)this.zoomLevelBreaks[i]=verySmall*Math.pow(zoomFactor,numLevels-i-1)};PolylineEncoder.prototype.dpEncode=function(points){var absMaxDist=0,stack=[],dists=new Array(points.length),maxDist,maxLoc,temp,first,last,current,i,encodedPoints,encodedLevels,segmentLength;if(points.length>2){stack.push([0,points.length-1]);while(stack.length>0){current=stack.pop();maxDist=0;segmentLength=Math.pow(points[current[1]].lat()-points[current[0]].lat(),2)+Math.pow(points[current[1]].lng()-points[current[0]].lng(),2);for(i=current[0]+1;i<current[1];i++){temp=this.distance(points[i],points[current[0]],points[current[1]],segmentLength);if(temp>maxDist){maxDist=temp;maxLoc=i;if(maxDist>absMaxDist)absMaxDist=maxDist}}if(maxDist>this.verySmall){dists[maxLoc]=maxDist;stack.push([current[0],maxLoc]);stack.push([maxLoc,current[1]])}}}encodedPoints=this.createEncodings(points,dists);encodedLevels=this.encodeLevels(points,dists,absMaxDist);return {encodedPoints:encodedPoints,encodedLevels:encodedLevels,encodedPointsLiteral:encodedPoints.replace(/\\/g,"\\\\")}};PolylineEncoder.prototype.dpEncodeToJSON=function(points,color,weight,opacity){var result;if(!opacity)opacity=.9;if(!weight)weight=3;if(!color)color="#0000ff";result=this.dpEncode(points);return {color:color,weight:weight,opacity:opacity,points:result.encodedPoints,levels:result.encodedLevels,numLevels:this.numLevels,zoomFactor:this.zoomFactor}};PolylineEncoder.prototype.dpEncodeToGPolyline=function(points,color,weight,opacity){if(!opacity)opacity=.9;if(!weight)weight=3;if(!color)color="#0000ff";return new GPolyline.fromEncoded(this.dpEncodeToJSON(points,color,weight,opacity))};PolylineEncoder.prototype.dpEncodeToGPolygon=function(pointsArray,boundaryColor,boundaryWeight,boundaryOpacity,fillColor,fillOpacity,fill,outline){var i,boundaries;if(!boundaryColor)boundaryColor="#0000ff";if(!boundaryWeight)boundaryWeight=3;if(!boundaryOpacity)boundaryOpacity=.9;if(!fillColor)fillColor=boundaryColor;if(!fillOpacity)fillOpacity=boundaryOpacity/3;if(fill==undefined)fill=true;if(outline==undefined)outline=true;boundaries=new Array(0);for(i=0;i<pointsArray.length;i++)boundaries.push(this.dpEncodeToJSON(pointsArray[i],boundaryColor,boundaryWeight,boundaryOpacity));return new GPolygon.fromEncoded({polylines:boundaries,color:fillColor,opacity:fillOpacity,fill:fill,outline:outline})};PolylineEncoder.prototype.distance=function(p0,p1,p2,segLength){var u,out;if(p1.lat()===p2.lat()&&p1.lng()===p2.lng())out=Math.sqrt(Math.pow(p2.lat()-p0.lat(),2)+Math.pow(p2.lng()-p0.lng(),2));else{u=((p0.lat()-p1.lat())*(p2.lat()-p1.lat())+(p0.lng()-p1.lng())*(p2.lng()-p1.lng()))/segLength;if(u<=0)out=Math.sqrt(Math.pow(p0.lat()-p1.lat(),2)+Math.pow(p0.lng()-p1.lng(),2));if(u>=1)out=Math.sqrt(Math.pow(p0.lat()-p2.lat(),2)+Math.pow(p0.lng()-p2.lng(),2));if(0<u&&u<1)out=Math.sqrt(Math.pow(p0.lat()-p1.lat()-u*(p2.lat()-p1.lat()),2)+Math.pow(p0.lng()-p1.lng()-u*(p2.lng()-p1.lng()),2))}return out};PolylineEncoder.prototype.createEncodings=function(points,dists){for(var dlat,dlng,plat=0,plng=0,encoded_points="",i=0;i<points.length;i++)if(dists[i]!=undefined||i==0||i==points.length-1){var point=points[i],lat=point.lat(),lng=point.lng(),late5=Math.floor(lat*1e5),lnge5=Math.floor(lng*1e5);dlat=late5-plat;dlng=lnge5-plng;plat=late5;plng=lnge5;encoded_points+=this.encodeSignedNumber(dlat)+this.encodeSignedNumber(dlng)}return encoded_points};PolylineEncoder.prototype.computeLevel=function(dd){var lev;if(dd>this.verySmall){lev=0;while(dd<this.zoomLevelBreaks[lev])lev++;return lev}};PolylineEncoder.prototype.encodeLevels=function(points,dists,absMaxDist){var i,encoded_levels="";if(this.forceEndpoints)encoded_levels+=this.encodeNumber(this.numLevels-1);else encoded_levels+=this.encodeNumber(this.numLevels-this.computeLevel(absMaxDist)-1);for(i=1;i<points.length-1;i++)if(dists[i]!=undefined)encoded_levels+=this.encodeNumber(this.numLevels-this.computeLevel(dists[i])-1);if(this.forceEndpoints)encoded_levels+=this.encodeNumber(this.numLevels-1);else encoded_levels+=this.encodeNumber(this.numLevels-this.computeLevel(absMaxDist)-1);return encoded_levels};PolylineEncoder.prototype.encodeNumber=function(num){var encodeString="",nextValue,finalValue;while(num>=32){nextValue=(32|num&31)+63;encodeString+=String.fromCharCode(nextValue);num>>=5}finalValue=num+63;encodeString+=String.fromCharCode(finalValue);return encodeString};PolylineEncoder.prototype.encodeSignedNumber=function(num){var sgn_num=num<<1;if(num<0)sgn_num=~sgn_num;return this.encodeNumber(sgn_num)};PolylineEncoder.latLng=function(y,x){this.y=y;this.x=x};PolylineEncoder.latLng.prototype.lat=function(){return this.y};PolylineEncoder.latLng.prototype.lng=function(){return this.x};PolylineEncoder.pointsToLatLngs=function(points){var i,latLngs;latLngs=new Array(0);for(i=0;i<points.length;i++)latLngs.push(new PolylineEncoder.latLng(points[i][0],points[i][1]));return latLngs};PolylineEncoder.pointsToGLatLngs=function(points){var i,gLatLngs;gLatLngs=new Array(0);for(i=0;i<points.length;i++)gLatLngs.push(new GLatLng(points[i][0],points[i][1]));return gLatLngs};String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")};String.prototype.reverse=function(){splitext=this.split("");revertext=splitext.reverse();reversed=revertext.join("");return reversed};function createMarker2(point,place,desc,icon,notSetCenter){var marker=new GMarker(point,icon),html="<b>"+place+"</b>"+desc;GEvent.addListener(marker,"click",function(){marker.openInfoWindowHtml(html,{maxWidth:500});!notSetCenter&&map.setCenter(marker.getPoint())});return marker}function createIcon2(iconPath,iconWidth,iconHeight){var icon=new GIcon(null,iconPath);icon.iconSize=new GSize(iconWidth,iconHeight);icon.shadowSize=new GSize(iconWidth,iconHeight);icon.iconAnchor=new GPoint(iconWidth/2,iconHeight/2);icon.infoWindowAnchor=new GPoint(iconWidth/2,0);return icon}var _overlays=null,polylineEncoder=new PolylineEncoder;function KMLparser(path,map,flyIntoView){var request=GXmlHttp.create();request.open("GET",path,true);request.onreadystatechange=function(){if(request.readyState==4){_overlays!=null&&removeMapOverlays(true);_overlays=[];var boundary=new GLatLngBounds,data=request.responseText;if(data=="")return;for(var json=eval("("+data+")"),i=0;i<json.markers.length;i++){var marker=json.markers[i],point=new GLatLng(marker.pointLon,marker.pointLat);boundary.extend(point);var name=marker.name,desc=marker.description,iconPath=marker.iconhref,iconWidth=marker.iconw,iconHeight=marker.iconh,icon=createIcon2(iconPath,24,24),marker=createMarker2(point,name,desc,icon);_overlays.push(marker)}for(var i=0;i<json.lines.length;i++){var line=json.lines[i],polyline=GPolyline.fromEncoded(line);_overlays.push(polyline)}if(flyIntoView){map.setCenter(boundary.getCenter());map.setZoom(map.getBoundsZoomLevel(boundary))}addMapOverlays()}};request.send(null)}function removeMapOverlays(setNull){if(_overlays!=null){for(var k=0;k<_overlays.length;k++)map.removeOverlay(_overlays[k]);if(setNull)_overlays=null}}function addMapOverlays(){for(var k=0;k<_overlays.length;k++)map.addOverlay(_overlays[k]);_loadingInProgress=false;searchButtonEnabled(true)}function getControl(ctrlName){var ctrl=document.getElementById(ctrlName);return ctrl}function originTextBox(){return getControl("ctl00_ctl00_body_bodyleft_SearchControl1_originTextBox")}function destinationTextBox(){return getControl("ctl00_ctl00_body_bodyleft_SearchControl1_destinationTextBox")}function viaTextBox(){return getControl("ctl00_ctl00_body_bodyleft_SearchControl1_viaTextBox")}function onTextBox(){return getControl("ctl00_ctl00_body_bodyleft_SearchControl1_onTextBox")}function nearbyOriginCheckBox(){return getControl("ctl00_ctl00_body_bodyleft_SearchControl1_incNearOriginsCheckBox")}function nearbyDestinationCheckBox(){return getControl("ctl00_ctl00_body_bodyleft_SearchControl1_incNearDestinationsCheckBox")}function roundtripCheckBox(){return getControl("ctl00_ctl00_body_bodyleft_SearchControl1_roundtripCheckBox")}function clearButton(){return getControl("clearButton")}function originError(){return getControl("originError")}function destinationError(){return getControl("destinationError")}function viaError(){return getControl("viaError")}function resultsGrid(){return getControl("resultsGrid")}function kmButton(){return getControl("kmButton")}function milButton(){return getControl("milButton")}function amazonBox(){return getControl("amazonBox")}function overlay_loadingGE(){return getControl("overlay_loadingGE")}google.load("maps","2",{other_params:"sensor=false"});google.load("earth","1");var map,mapDiv,_ge,_reqUrl=null,_previousView=null,_loadingInProgress=false,GOOGLE_EARTH_NOT_LOADED="Google Earth plugin is not loaded. If you have it installed please wait until it is loaded. Alternatively, switch to Map view.",GOOGLE_MAPS_NOT_SUPPORTED="Your browser is not able to display Google Maps. Please use newest version of Firefox, Safari or Internet Explorer in order to browse our site",CONST_KM="KM",CONST_MIL="MIL",_lengthUnit=CONST_KM,_defaultMapType=null,_gridResults=null;function initialize(){if(GBrowserIsCompatible()){if(document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#SVG","1.1")){_mSvgEnabled=true;_mSvgForced=true}var autoSearch=originTextBox().value!=""&&destinationTextBox().value!="";mapDiv=document.getElementById("map");map=new GMap2(mapDiv);map.addControl(new GHierarchicalMapTypeControl);map.addControl(new GLargeMapControl);map.enableScrollWheelZoom();map.setCenter(new GLatLng(47.7275,-90.1984),3);_previousView=G_NORMAL_MAP;map.addMapType(G_PHYSICAL_MAP);map.setMapType(G_PHYSICAL_MAP);if(_defaultMapType!=null){_previousView=_defaultMapType;map.setMapType(_defaultMapType)}if(readCookie("mapType")=="E"&&!autoSearch)_previousView=G_SATELLITE_3D_MAP;map.addMapType(G_SATELLITE_3D_MAP);if(google.earth.isInstalled()){!autoSearch&&_previousView==G_SATELLITE_3D_MAP&&map.setMapType(G_SATELLITE_3D_MAP);map.getEarthInstance(getEarthInstanceCB);GEvent.addListener(map,"maptypechanged",function(){if((_previousView==G_NORMAL_MAP||_previousView==G_SATELLITE_MAP||_previousView==G_HYBRID_MAP||_previousView==G_PHYSICAL_MAP)&&map.getCurrentMapType()!=G_SATELLITE_3D_MAP)return;if(map.getCurrentMapType()==G_SATELLITE_3D_MAP)createCookie("mapType","E",365);else createCookie("mapType","M",365);addNeededOverlays()})}setupShimmer();if(readCookie("lengthUnit")==CONST_MIL)_lengthUnit=CONST_MIL;var cookieMapHeight=readCookie("mapHeight");cookieMapHeight!=null&&setMapHeight(cookieMapHeight);if(autoSearch)setTimeout(searchButtonClicked,200);else _previousView!=G_SATELLITE_3D_MAP&&addWelcomeMarker()}else alert(GOOGLE_MAPS_NOT_SUPPORTED)}var _callDraw=false;function getEarthInstanceCB(pluginInstance){_ge=pluginInstance;var autoSearch=originTextBox().value!=""&&destinationTextBox().value!="";!autoSearch&&addWelcomeMarker();_callDraw&&map.getCurrentMapType()==G_SATELLITE_3D_MAP&&addNeededOverlays();_callDraw=false}var _welcomeMarker;function addWelcomeMarker(){var point=new GLatLng(38.6275,-90.1984),html='<div id="infoPopupTable" style="width:220px; padding-right:0px;"><b>Welcome to Optifly!</b><br /><br/>To start, just enter your origin, destination and click on search button.<br /><br />For additional information on how to use Optifly, watch <a href="javascript:openVideoWindow();">Video Tutorials</a> or read <a href="javascript:openFaqWindow();">Help</a>.',icon=createIcon2("http://optifly.com/Images/airport_blue_transit.png",24,24);_welcomeMarker=createMarker2(point,"",html,icon,true);map.addOverlay(_welcomeMarker);_welcomeMarker.openInfoWindowHtml(html)}function onClientItemSelected(source,args){var code=args._text.substr(1,3);if(code.charAt(2)==")")code=code.substr(0,2);source._element.value=code}var kmlChildEarth=null,kmlChildMaps=null;function searchButtonClicked(){if(_previousView==G_SATELLITE_3D_MAP&&_ge==null){alert(GOOGLE_EARTH_NOT_LOADED);return false}var origin=null,destination=null,via=null,onAirline=null,nearbyOrigin=nearbyOriginCheckBox().checked,nearbyDestination=nearbyDestinationCheckBox().checked,roundtrip=roundtripCheckBox().checked;originError().style.visibility="hidden";destinationError().style.visibility="hidden";viaError().style.visibility="hidden";var errors=false;try{origin=parseAirportCode(originTextBox().value,false)}catch(e){originError().style.visibility="visible";errors=true}try{destination=parseAirportCode(destinationTextBox().value,false)}catch(e){destinationError().style.visibility="visible";errors=true}try{via=parseAirportCode(viaTextBox().value,true)}catch(e){viaError().style.visibility="visible";errors=true}if(errors)return false;searchButtonEnabled(false);setTimeout("performSearch();",10)}function performSearch(){var origin=parseAirportCode(originTextBox().value,false),destination=parseAirportCode(destinationTextBox().value,false),via=parseAirportCode(viaTextBox().value,true),onAirline=null,nearbyOrigin=nearbyOriginCheckBox().checked,nearbyDestination=nearbyDestinationCheckBox().checked,roundtrip=false;if(roundtripCheckBox().selectedIndex==1)roundtrip=true;OptiFly.Services.FunctionalityService.OptimalRoute(origin,destination,via,onAirline,nearbyOrigin,nearbyDestination,roundtrip,onOptimalRouteComplete,onOptimalRouteTimeout,onOptimalRouteError);var root=document.location.protocol+"//"+document.location.host;if(document.location.pathname.toLowerCase().startsWith("/optifly"))root+="/OptiFly";_reqUrl=root+format("/Services/RouteKML.ashx?origin={0}&destination={1}&via={2}&on={3}&nearbyOrigin={4}&nearbyDestination={5}&roundtrip={6}",origin,destination,via,onAirline,nearbyOrigin,nearbyDestination,roundtrip);if(kmlChildEarth!=null){_ge.getFeatures().removeChild(kmlChildEarth);kmlChildEarth=null}removeMapOverlays(true);if(_welcomeMarker!=null){map.clearOverlays();_welcomeMarker=null}addNeededOverlays();destinationTextBox().focus();return false}function addNeededOverlays(){if(map.getCurrentMapType()==G_SATELLITE_3D_MAP){_previousView=G_SATELLITE_3D_MAP;if(_reqUrl==null)return;if(_ge==null&&_reqUrl!=null){_callDraw=_reqUrl!=null;return}if(_ge==null){alert(GOOGLE_EARTH_NOT_LOADED);return}removeMapOverlays(false);if(kmlChildEarth==null&&_reqUrl!=null){var link=_ge.createLink("");link.setHref(_reqUrl);var networkLink=_ge.createNetworkLink("");networkLink.setDescription("NetworkLink open to fetched content");networkLink.setName("Open NetworkLink");_overlays==null&&networkLink.setFlyToView(true);networkLink.setLink(link);kmlChildEarth=networkLink;_ge.getFeatures().appendChild(kmlChildEarth)}else _reqUrl!=null&&_ge.getFeatures().appendChild(kmlChildEarth)}else{if(_reqUrl!=null){_loadingInProgress=true;searchButtonEnabled(false)}function abc(){_previousView=G_NORMAL_MAP;if(_overlays==null&&_reqUrl!=null){var flyIntoView=kmlChildEarth==null;KMLparser(_reqUrl+"&writer=map&segments=20",map,flyIntoView)}else _reqUrl!=null&&addMapOverlays()}setTimeout(abc,10)}}function parseAirportCode(text,isOptional){if(text.length===0&&isOptional)return text;else if(text.length!==3)throw"Invalid airport code length";return text}function searchButtonEnabled(isEnabled){var btn=document.getElementById("searchButton");btn.disabled=!isEnabled;if(isEnabled)btn.value="Search for Flights";else btn.value="Loading... please wait...";showShimmersLoading(!isEnabled)}function format(str){for(i=1;i<arguments.length;i++)str=str.replace("{"+(i-1)+"}",arguments[i]);return str}function onOptimalRouteComplete(args){clearResultsGrid();if(args==null){alert("Invalid airport code pair submitted. Please enter valid airport codes.");searchButtonEnabled(true);return}if(args.Routes.length==0){alert("It is not possible to travel between these two cities only by flying");searchButtonEnabled(true);return}_gridResults=args;amazonBox().src="http://rcm.amazon.com/e/cm?t=optifly-20&o=1&p=12&l=st1&mode=books&fc1=000000&lt1=&lc1=3366FF&bg1=FFFFFF&f=ifr&lt1=_new&search="+_gridResults.Destination.Country+" travel guide";amazonBox().style.display="";drawResultsGrid(_gridResults)}function refresh_ads(){var a=$$('iframe[name="google_ads_frame"]');if(a.first()&&google_ad_url)a.first().src=google_ad_url+"&"+(new Date).getTime()}function drawResultsGrid(args){var dateNow=new Date;dateNow.setDate(dateNow.getDate()+14);var expediaBaseLink="http://www.expedia.com/pub/agent.dll?affcid=cj3412338&qscr=fexp&flag=q&qryt=1&trpt=3&",originAirport=args.Origin,destinationAirport=args.Destination,viaAirport=args.via,roundtrip=args.Roundtrip,searchUrl=args.SearchUrl,priceUrl=args.PriceUrl,expediaHeaderLink=format(expediaBaseLink+"city1={0}&citd1={1}&date1={2}/{3}/{4}&time1=362",originAirport.Code,destinationAirport.Code,dateNow.getMonth()+1,dateNow.getDate(),dateNow.getFullYear());if(roundtrip){var rtrDate=new Date;rtrDate.setDate(rtrDate.getDate()+28);expediaHeaderLink=expediaHeaderLink.replace("&trpt=3&","&trpt=2&")+format("&date2={0}/{1}/{2}&time2=362",rtrDate.getMonth()+1,rtrDate.getDate(),rtrDate.getFullYear())}for(var resultsHeader=format('Results for {0} ({1}) - {2} ({3}) <span style="margin-left: 10px;"><a href="{4}" target="_blank"><img border="0" style="vertical-align: bottom; font-size: 2pt;" src="Images/expedia_click.png" /></a></span>',originAirport.CityName,originAirport.Code,destinationAirport.CityName,destinationAirport.Code,expediaHeaderLink,expediaHeaderLink),routes=args.Routes,allRowsString="",i=0;i<routes.length;i++){for(var rowString="",or=routes[i],colorCell=format('<td style="{2}" align="center" rowspan="{0}"><img src="Images/{1}.png" /></td>',or.Flights.length,or.ColorRoute,"border-top:solid 1px black;border-left:solid 0px black;border-right:solid 1px black;border-bottom:solid 0px black;"),expediaLink=expediaBaseLink,j=0;j<or.Flights.length;j++){var dt=new Date;dt.setDate(dt.getDate()+14+j);var flightDate=dt,orf=or.Flights[j];rowString+=format('<tr class="d{0}">',i%2);if(j==0)rowString+=colorCell;var viaAirportCode=viaAirport==null?"":viaAirport.Code,fromAirport=format("{0} (<a href=\"airport-flight-travel-info-{2}-{3}-{4}.aspx\" style=\"color: DarkBlue;\" onmouseover=\"showtip(this, event,'Click to get city information and weather')\" onmouseout='hidetip()' target='_blank'>{1}</a>)",orf.Origin.CityName,orf.Origin.Code,orf.Origin.CityName,orf.Origin.Country,orf.Origin.Code);if(orf.Origin.Code==originAirport.Code||orf.Origin.Code==viaAirportCode||orf.Origin.Code==destinationAirport.Code)fromAirport="<b>"+fromAirport+"</b>";var toAirport=format("{0} (<a href=\"airport-flight-travel-info-{2}-{3}-{4}.aspx\" style=\"color: DarkBlue;\" onmouseover=\"showtip(this, event,'Click to get city information and weather')\" onmouseout='hidetip()' target='_blank'>{1}</a>)",orf.Destination.CityName,orf.Destination.Code,orf.Destination.CityName,orf.Destination.Country,orf.Destination.Code);if(orf.Destination.Code==originAirport.Code||orf.Destination.Code==viaAirportCode||orf.Destination.Code==destinationAirport.Code)toAirport="<b>"+toAirport+"</b>";rowString+=format("<td align='center'>{0} to {1}</td>",fromAirport,toAirport);for(var airlinesString="",k=0;k<orf.Airlines.length;k++){var al=orf.Airlines[k],days=getDaysString(al.FlightDays);if(al.LowCost)days="(Low cost carrier) "+days;airlinesString+=format("<a href='Link.aspx?{0}' target='_blank' onmouseover=\"showtip(this, event,'{2}')\" style=\"color: {3};\" onmouseout='hidetip()'>{1}</a>",al.AirlineUrl,al.AirlineName,days,al.LowCost?"DarkOrange":"DarkBlue");if(k<orf.Airlines.length-1)airlinesString+=" | "}expediaLink+=format("city{0}={1}&citd{6}={2}&date{7}={3}/{4}/{5}&time{8}=362&",j+1,orf.Origin.Code,orf.Destination.Code,flightDate.getMonth()+1,flightDate.getDate(),flightDate.getFullYear(),j+1,j+1,j+1);rowString+=format("<td>{0}</td>",airlinesString);if(j==0)rowString+=format('<td rowspan="{0}" style="width: 30px; text-align: center; vertical-align:middle;"><a style="color:blue; font-size:9px; text-align: center;" href="TICKETS_LINK" target="_blank"><img border="0" style="text-decoration:none;" src="Images/expedia.ico" /><br />check prices</a></td>',or.Flights.length);var flightLength=getLength(orf.FlightLength);rowString+=format('<td align="center">{0}</td>',flightLength);if(j==0){var totalLength=getLength(or.TotalLength),totalCell=format('<td style="{2}" align="center" rowspan="{0}">{1}</td>',or.Flights.length,totalLength,"border-top:solid 1px black;border-left:solid 0px black;border-right:solid 0px black;border-bottom:solid 0px black;");rowString+=totalCell}rowString+="</tr>"}allRowsString+=rowString.replace("TICKETS_LINK",expediaLink)}var tableHtml='<div class="controlBorder" style="padding: 0px; width:99%; margin-top: 10px;"><div class="controlHeader"><table cellpadding="0" cellspacing="0" width="100%"><tr><td>'+resultsHeader+'</td><td style="width: 110px; font-size:10pt; vertical-align: center; font-weight: normal;"><a id="kmButton" href="javascript:resultsKm();" class="measureButton">km</a> | <a id="milButton" href="javascript:resultsMil();" class="measureButton">miles</a></td></tr></table></div><table class="resultsTable" cellpadding="0" cellspacing="0" width="100%"><tr class="headerRow"><td width="50" align="center">Color</td><td width="300" align="center">Flight Segment</td><td align="center" colspan="2">Airlines (hover over for flight days)</td><td width="80" align="center">Segment Distance</td><td width="80" align="center" style="border-right: solid 0px black;">Total Distance</td></tr>'+allRowsString+'</table><div class="controlHeader" style="font-size: 12px;"><table cellpadding="0" cellspacing="0" width="100%"><tr><td width="50%">Direct Search URL:<br /><a class="lightgraylink" href="'+searchUrl+'">'+searchUrl+'</a></td><td width="50%">Direct Prices URL:<br /><a class="lightgraylink" href="'+priceUrl+'" target="_blank">'+priceUrl+'</a></td><td width="100px"><a href="javascript:printResultsGrid();"><img src="Images/print.png" style="border-width:0px; margin-right:10px;" alt="Print results" /></a></td></tr></table></div></div>';resultsGrid().innerHTML=tableHtml;if(_lengthUnit==CONST_KM){kmButton().style.fontSize="13pt";kmButton().style.fontWeight="bold";milButton().style.fontSize="10pt";milButton().style.fontWeight="normal"}else{kmButton().style.fontSize="10pt";kmButton().style.fontWeight="normal";milButton().style.fontSize="13pt";milButton().style.fontWeight="bold"}!_loadingInProgress&&searchButtonEnabled(true)}function printResultsGrid(){var htmlToWrite=resultsGrid().innerHTML.replace('href="javascript:printResultsGrid();">','style="display: none;">'),htmlToWrite=htmlToWrite.replace(/font-size: 2pt;/i,"display: none;"),wi=window.open("","printWindow","width=900,height=500,resizable=yes,scrollbars=yes,toolbar=no,location=no","");wi.document.write('<html><head><title>Print preview</title><style type="text/css">a {color:blue;} input { font-size: 11px; } .controlBorder{\tbackground-color: #efefef;\tborder-left: solid 1px black;\tborder-right: solid 1px black;}    .controlHeader{\tpadding-top: 10px;\tpadding-bottom: 10px;\tpadding-left: 5px;\tborder-top: solid 1px black;\tborder-bottom: solid 1px black;}.controlHeader td {\tfont-size: 13px;}td{\tfont-family: Tahoma;\tfont-size: 11px;}.headerRow td{\tborder-top: solid 0 black;\tborder-left: solid 0 black;\tborder-right: solid 1px black;\tborder-bottom: solid 0 black;\tpadding: 2px;}.d0{\tbackground-color: #fff;}.d0 td{\tborder-top: solid 1px black;\tborder-left: solid 0 black;\tborder-right: solid 1px black;\tborder-bottom: solid 0 black;\tpadding: 2px;}.d1{\tbackground-color: #efefef;}.d1 td{\tborder-top: solid 1px black;\tborder-left: solid 0 black;\tborder-right: solid 1px black;\tborder-bottom: solid 0 black;\tpadding: 2px;}</style><script type="text/javascript">    function showtip(a, b, c) {    }    function hidetip() {    }  function resultsMil() { }   function resultsKm() { }</script></head><body><table width="100%"><tr><td>Best viewed if printed in Landscape orientation</td><td width="50px"><input type="button" value="Click here to print page" onClick="window.print()"></td></tr></table><br />');wi.document.write(htmlToWrite);wi.document.write("</body></html>");wi.document.close()}function getLength(len){return _lengthUnit==CONST_KM?len:(len*.621371192).toFixed(0)}function resultsKm(){_lengthUnit=CONST_KM;createCookie("lengthUnit",CONST_KM,365);drawResultsGrid(_gridResults)}function resultsMil(){_lengthUnit=CONST_MIL;createCookie("lengthUnit",CONST_MIL,365);drawResultsGrid(_gridResults)}function clearResultsGrid(){resultsGrid().innerHTML="";amazonBox().style.display="none"}var daysArray=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];function getDaysString(arg){if(arg=="YYYYYYY")return "All days";for(var res="",i=0;i<7;i++)if(arg.charAt(i)=="Y")res+=daysArray[i]+", ";if(res.length>0)return res.substr(0,res.length-2);else return ""}function onOptimalRouteTimeout(args){searchButtonEnabled(true)}function onOptimalRouteError(args){searchButtonEnabled(true)}function connectingFlights(code){alert("Ordinary: "+code)}function connectingFlightsLowCost(code){alert("Low cost: "+code)}function clearForm(){originTextBox().value="";destinationTextBox().value="";viaTextBox().value="";nearbyOriginCheckBox().checked=false;nearbyDestinationCheckBox().checked=false;roundtripCheckBox().checked=false;clearButton().style.display="none";originTextBox().focus()}var curHeight=0,curPos=0,newPos=0,mouseStatus="up",resizingElement="map",minHeight=370,maxHeight=650;function setPos(e){curevent=typeof event=="undefined"?e:event;mouseStatus="down";curPos=curevent.clientY;tempHeight=document.getElementById(resizingElement).style.height;heightArray=tempHeight.split("p");curHeight=parseInt(heightArray[0])}function getPos(e){if(mouseStatus=="down"){curevent=typeof event=="undefined"?e:event;newPos=curevent.clientY;var pxMove=parseInt(newPos-curPos),newHeight=parseInt(curHeight+pxMove);if(newHeight<minHeight)newHeight=minHeight;if(newHeight>maxHeight)newHeight=maxHeight;createCookie("mapHeight",newHeight,365);setMapHeight(newHeight)}}function setMapHeight(newHeight){document.getElementById(resizingElement).style.height=newHeight+"px";try{var newShimmerPosition=newHeight/2+35+"px";_shimmer_loading.style.top=newShimmerPosition;_overlay_loadingGE.style.top=newShimmerPosition}catch(e){}}
