/**
* DD_belatedPNG: Adds IE6 support: PNG images for CSS background-image and HTML <IMG/>.
* Author: Drew Diller
* Email: drew.diller@gmail.com
* URL: http://www.dillerdesign.com/experiment/DD_belatedPNG/
* Version: 0.0.8a
* Licensed under the MIT License: http://dillerdesign.com/experiment/DD_belatedPNG/#license
*
* Example usage:
* DD_belatedPNG.fix('.png_bg'); // argument is a CSS selector
* DD_belatedPNG.fixPng( someNode ); // argument is an HTMLDomElement
**/
var DD_belatedPNG={ns:"DD_belatedPNG",imgSize:{},delay:10,nodesFixed:0,createVmlNameSpace:function(){if(document.namespaces&&!document.namespaces[this.ns]){document.namespaces.add(this.ns,"urn:schemas-microsoft-com:vml")}},createVmlStyleSheet:function(){var b,a;b=document.createElement("style");b.setAttribute("media","screen");document.documentElement.firstChild.insertBefore(b,document.documentElement.firstChild.firstChild);if(b.styleSheet){b=b.styleSheet;b.addRule(this.ns+"\\:*","{behavior:url(#default#VML)}");b.addRule(this.ns+"\\:shape","position:absolute;");b.addRule("img."+this.ns+"_sizeFinder","behavior:none; border:none; position:absolute; z-index:-1; top:-10000px; visibility:hidden;");this.screenStyleSheet=b;a=document.createElement("style");a.setAttribute("media","print");document.documentElement.firstChild.insertBefore(a,document.documentElement.firstChild.firstChild);a=a.styleSheet;a.addRule(this.ns+"\\:*","{display: none !important;}");a.addRule("img."+this.ns+"_sizeFinder","{display: none !important;}")}},readPropertyChange:function(){var b,c,a;b=event.srcElement;if(!b.vmlInitiated){return}if(event.propertyName.search("background")!=-1||event.propertyName.search("border")!=-1){DD_belatedPNG.applyVML(b)}if(event.propertyName=="style.display"){c=(b.currentStyle.display=="none")?"none":"block";for(a in b.vml){if(b.vml.hasOwnProperty(a)){b.vml[a].shape.style.display=c}}}if(event.propertyName.search("filter")!=-1){DD_belatedPNG.vmlOpacity(b)}},vmlOpacity:function(b){if(b.currentStyle.filter.search("lpha")!=-1){var a=b.currentStyle.filter;a=parseInt(a.substring(a.lastIndexOf("=")+1,a.lastIndexOf(")")),10)/100;b.vml.color.shape.style.filter=b.currentStyle.filter;b.vml.image.fill.opacity=a}},handlePseudoHover:function(a){setTimeout(function(){DD_belatedPNG.applyVML(a)},1)},fix:function(a){if(this.screenStyleSheet){var c,b;c=a.split(",");for(b=0;b<c.length;b++){this.screenStyleSheet.addRule(c[b],"behavior:expression(DD_belatedPNG.fixPng(this))")}}},applyVML:function(a){a.runtimeStyle.cssText="";this.vmlFill(a);this.vmlOffsets(a);this.vmlOpacity(a);if(a.isImg){this.copyImageBorders(a)}},attachHandlers:function(i){var d,c,g,e,b,f;d=this;c={resize:"vmlOffsets",move:"vmlOffsets"};if(i.nodeName=="A"){e={mouseleave:"handlePseudoHover",mouseenter:"handlePseudoHover",focus:"handlePseudoHover",blur:"handlePseudoHover"};for(b in e){if(e.hasOwnProperty(b)){c[b]=e[b]}}}for(f in c){if(c.hasOwnProperty(f)){g=function(){d[c[f]](i)};i.attachEvent("on"+f,g)}}i.attachEvent("onpropertychange",this.readPropertyChange)},giveLayout:function(a){a.style.zoom=1;if(a.currentStyle.position=="static"){a.style.position="relative"}},copyImageBorders:function(b){var c,a;c={borderStyle:true,borderWidth:true,borderColor:true};for(a in c){if(c.hasOwnProperty(a)){b.vml.color.shape.style[a]=b.currentStyle[a]}}},vmlFill:function(e){if(!e.currentStyle){return}else{var d,f,g,b,a,c;d=e.currentStyle}for(b in e.vml){if(e.vml.hasOwnProperty(b)){e.vml[b].shape.style.zIndex=d.zIndex}}e.runtimeStyle.backgroundColor="";e.runtimeStyle.backgroundImage="";f=true;if(d.backgroundImage!="none"||e.isImg){if(!e.isImg){e.vmlBg=d.backgroundImage;e.vmlBg=e.vmlBg.substr(5,e.vmlBg.lastIndexOf('")')-5)}else{e.vmlBg=e.src}g=this;if(!g.imgSize[e.vmlBg]){a=document.createElement("img");g.imgSize[e.vmlBg]=a;a.className=g.ns+"_sizeFinder";a.runtimeStyle.cssText="behavior:none; position:absolute; left:-10000px; top:-10000px; border:none; margin:0; padding:0;";c=function(){this.width=this.offsetWidth;this.height=this.offsetHeight;g.vmlOffsets(e)};a.attachEvent("onload",c);a.src=e.vmlBg;a.removeAttribute("width");a.removeAttribute("height");document.body.insertBefore(a,document.body.firstChild)}e.vml.image.fill.src=e.vmlBg;f=false}e.vml.image.fill.on=!f;e.vml.image.fill.color="none";e.vml.color.shape.style.backgroundColor=d.backgroundColor;e.runtimeStyle.backgroundImage="none";e.runtimeStyle.backgroundColor="transparent"},vmlOffsets:function(d){var h,n,a,e,g,m,f,l,j,i,k;h=d.currentStyle;n={W:d.clientWidth+1,H:d.clientHeight+1,w:this.imgSize[d.vmlBg].width,h:this.imgSize[d.vmlBg].height,L:d.offsetLeft,T:d.offsetTop,bLW:d.clientLeft,bTW:d.clientTop};a=(n.L+n.bLW==1)?1:0;e=function(b,p,q,c,s,u){b.coordsize=c+","+s;b.coordorigin=u+","+u;b.path="m0,0l"+c+",0l"+c+","+s+"l0,"+s+" xe";b.style.width=c+"px";b.style.height=s+"px";b.style.left=p+"px";b.style.top=q+"px"};e(d.vml.color.shape,(n.L+(d.isImg?0:n.bLW)),(n.T+(d.isImg?0:n.bTW)),(n.W-1),(n.H-1),0);e(d.vml.image.shape,(n.L+n.bLW),(n.T+n.bTW),(n.W),(n.H),1);g={X:0,Y:0};if(d.isImg){g.X=parseInt(h.paddingLeft,10)+1;g.Y=parseInt(h.paddingTop,10)+1}else{for(j in g){if(g.hasOwnProperty(j)){this.figurePercentage(g,n,j,h["backgroundPosition"+j])}}}d.vml.image.fill.position=(g.X/n.W)+","+(g.Y/n.H);m=h.backgroundRepeat;f={T:1,R:n.W+a,B:n.H,L:1+a};l={X:{b1:"L",b2:"R",d:"W"},Y:{b1:"T",b2:"B",d:"H"}};if(m!="repeat"||d.isImg){i={T:(g.Y),R:(g.X+n.w),B:(g.Y+n.h),L:(g.X)};if(m.search("repeat-")!=-1){k=m.split("repeat-")[1].toUpperCase();i[l[k].b1]=1;i[l[k].b2]=n[l[k].d]}if(i.B>n.H){i.B=n.H}d.vml.image.shape.style.clip="rect("+i.T+"px "+(i.R+a)+"px "+i.B+"px "+(i.L+a)+"px)"}else{d.vml.image.shape.style.clip="rect("+f.T+"px "+f.R+"px "+f.B+"px "+f.L+"px)"}},figurePercentage:function(d,c,f,a){var b,e;e=true;b=(f=="X");switch(a){case"left":case"top":d[f]=0;break;case"center":d[f]=0.5;break;case"right":case"bottom":d[f]=1;break;default:if(a.search("%")!=-1){d[f]=parseInt(a,10)/100}else{e=false}}d[f]=Math.ceil(e?((c[b?"W":"H"]*d[f])-(c[b?"w":"h"]*d[f])):parseInt(a,10));if(d[f]%2===0){d[f]++}return d[f]},fixPng:function(c){c.style.behavior="none";var g,b,f,a,d;if(c.nodeName=="BODY"||c.nodeName=="TD"||c.nodeName=="TR"){return}c.isImg=false;if(c.nodeName=="IMG"){if(c.src.toLowerCase().search(/\.png$/)!=-1){c.isImg=true;c.style.visibility="hidden"}else{return}}else{if(c.currentStyle.backgroundImage.toLowerCase().search(".png")==-1){return}}g=DD_belatedPNG;c.vml={color:{},image:{}};b={shape:{},fill:{}};for(a in c.vml){if(c.vml.hasOwnProperty(a)){for(d in b){if(b.hasOwnProperty(d)){f=g.ns+":"+d;c.vml[a][d]=document.createElement(f)}}c.vml[a].shape.stroked=false;c.vml[a].shape.appendChild(c.vml[a].fill);c.parentNode.insertBefore(c.vml[a].shape,c)}}c.vml.image.shape.fillcolor="none";c.vml.image.fill.type="tile";c.vml.color.fill.on=false;g.attachHandlers(c);g.giveLayout(c);g.giveLayout(c.offsetParent);c.vmlInitiated=true;g.applyVML(c)}};try{document.execCommand("BackgroundImageCache",false,true)}catch(r){}DD_belatedPNG.createVmlNameSpace();DD_belatedPNG.createVmlStyleSheet();



var flightsForm = Array({"field" : "sector1_o", "method" : "validateTextField"},
                          {"field" : "sector1_d", "method" : "validateTextField"},
                          {"field" : "MARKET1_DATE", "method" : "validateTextField"},
                          {"field" : "MARKET2_DATE", "method" : "validateTextField"}
                          );


function openPopUp(url) {
  window.open(url,'pop2','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,height=500,width=800');
}

function FlightsPage(container) {
  
  this.container = container;
  this.cookie = "flightPageCookie";
  this.browserBackCookie = "FlightsBrowserBackCookie";
  
  //reset values

  // ajax widgets
  this.travelDeals = new TravelDeals("flight", document.getElementById("tdOutput"), document.getElementById("tdLoader"),     document.getElementById("tdMessage"), document.getElementById("tdError"));
  this.travelDeals.getDeals();

  var o = this;
  this.travelDeals.onload = function() {
    o.resultCountLoaded();
  }
  
  //right side panels
  this.panel1 = new GenericPanel("whereFrom1", "Where from?", "area1", 3, airports, "perfectDealForm","","");
  this.panel2 = new GenericPanel("whereTo1", "Where to?", "area2", 4, airports, "perfectDealForm","161","");
  
  document.getElementById("whereFrom1").getElementsByTagName("div")[0].setAttribute('style', 'float:left; position:relative;z-index:97;');
  document.getElementById("whereTo1").getElementsByTagName("div")[0].setAttribute('style', 'float:left; position:relative;z-index:96;');
  document.getElementById("whereTo1").setAttribute('style', 'float:left;');
  var cookie = getCookie(this.cookie);

  
  //set seeDeals link
  var seeDeals = document.getElementById("seeDeals");
  seeDeals.innerHTML = '';

  if (navigator.userAgent.indexOf("Firefox") != -1) {
    seeDeals.setAttribute('style', 'margin: 0pt; padding: 4px 0 0 0; position: relative; font-size: 12px;');
  }

  $("seeDeals").onclick = function() { 
    o.panel2.reset(); 
    o.filter1();
  }
 
  var jsInput = this.getElementsByClassName($("whereTo1"), "div", "jsInput");
  jsInput[0].setAttribute('style','padding-right:0px;margin:0 4px 0 0;');

  //parse url parameters, preset minibooker
  var urlVars = getURLParameters();

  if(urlVars.from || urlVars.to) {
    if (urlVars.from) {
      this.panel1.preset(urlVars.from);
      if (urlVars.to)
        this.panel2.preset(urlVars.to);
      this.filter1();
    }
  }
  else {
    this.travelDeals.getDeals();
    this.panel1.onItemSelect.subscribe(this.filter1, this, true); 
    this.panel2.onItemSelect.subscribe(this.getDeals, this, true);
  }

  this.panel1.onItemSelect.subscribe(this.filter1, this, true); 
  this.panel2.onItemSelect.subscribe(this.getDeals, this, true);


  if(cookie) {
    var jar = document.getElementsByClassName("cookieJar", this.container);
    var cookieObject = eval(cookie);
    jar[0].appendChild(document.createTextNode("Recent search: "));
    var link = document.createElement("a");
    link.href = "#";
    link.id = "prepopMB";
 	
    link.title = cookieObject[0].fields[0].value + " to " + 
                 cookieObject[0].fields[1].value + " on " + 
                 cookieObject[0].fields[2].value + " returning " + 
                 cookieObject[0].fields[3].value + " - " + 
                 cookieObject[0].fields[4].value + ", " + 
                 cookieObject[0].fields[5].value + ", ";

    link.appendChild(document.createTextNode(cookieObject[0].displayValue));
	 
    jar[0].appendChild(link);
    //recent search link
    $("prepopMB").onclick = function() { 
      o.prepopMB(cookieObject[0].fields[0].value,cookieObject[0].fields[1].value,cookieObject[0].fields[2].value,cookieObject[0].fields[3].value,cookieObject[0].fields[4].value,cookieObject[0].fields[5].value,cookieObject[0].fields[7].value,cookieObject[0].fields[8].value,cookieObject[0].fields[9].value,cookieObject[0].fields[6].value); 
    }
  }  
     
  //TB Awards CheckBox
  /*var tbAwards = $("TbAwards").getElementsByTagName("input")[0];
  tbAwards.onclick = function() {
    if (this.checked == true) { 
      document.flightsForm.mode.value='OAR'; 
      $("selectObj_2").style.display ='none';
      $("lbFl1").style.display = 'none'; 
      $("fare_cat").value = "LOWEST";
    } 
    else { 
      document.flightsForm.mode.value=''; 
      $("selectObj_2").style.display ='block';
      $("lbFl1").style.display = 'block';
    }
  }
   */ 
  initLightbox();
}

FlightsPage.prototype.setPromoPrice = function() {
	//get all prices and put it into array
	var ul = document.getElementById("dealsList");
	var li = ul.getElementsByTagName("li");
	var price = Array();

	for(i=0;i<li.length;i++) {
		var div = li[i].getElementsByTagName("div");
		var img = div[0].getElementsByTagName("img");
		price.push(img[0].alt);
	}

	
	//sort array
        for(var i=0;i<price.length;i++) //Hold the first element
	{
		for(var j=i+1;j<price.length;j++) //Hold the next element from the first element
		{
			if(Number(price[i]) > Number(price[j]))	//comparing first and next element
			{
				tempValue = price[j];	
				price[j] = price[i];
				price[i] = tempValue;
			}
		}
	}

	var banner = document.getElementById("main-banner");

	var img = banner.getElementsByTagName("img");
	img[1].src = "/i/traveldeals/promos/Flights/num/" + price[0] + ".png";
	img[1].style.display = 'block';
	DD_belatedPNG.fix('.price');	

}


FlightsPage.prototype.getElementsByClassName = function(oElm, strTagName, strClassName) {
  var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
  var arrReturnElements = new Array();
  strClassName = strClassName.replace(/\-/g, "\\-");
  var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
  var oElement;
  
  for(var i=0; i<arrElements.length; i++) {
    oElement = arrElements[i];
    if(oRegExp.test(oElement.className)) {
      arrReturnElements.push(oElement);
    }
  }
  return (arrReturnElements);
}

FlightsPage.prototype.filter1 = function(e) {
  var panel1Value = this.panel1.getValue()
  var panel2Value = this.panel2.getValue();
  var newCodes = eval("a" + panel1Value);
  var newSet = new Array();
  var reselect = false; 
  
  for(var i=0; i<newCodes.length; i++) {
    newSet.push(new Array(newCodes[i], eval("s" + newCodes[i]), i ) );
  }
    
    if(panel2Value != "") {
      for(var i=0; i<newCodes.length; i++) {
        if(panel2Value == newCodes[i]) {
          reselect = true;
               break;
        }
      }
    }

    this.panel2.set = newSet;
    this.panel2.searchSet = newSet;
    this.panel2.render();

    if(reselect) {
      this.panel2.highlight(this.panel2.getAfromKey(panel2Value));
    }
    else { 
      this.panel2.reset();
    }
   this.getDeals();
   showToWhere(this.panel1.getValue());
}

FlightsPage.prototype.submitForm = function() {
  var result = this.validator.validate();
  var cookieObject = new Object();

  if(result.length === undefined) {
    if ((eval(this.adults.getValue()) + eval(this.children.getValue())) > 9){
      alert("You are allowed a maximum of " + 9 + " passengers\nper booking online. If your party is larger\nthan this, please call our reservation center.")
      return false 
     }

    if(this.calPair.getReadable1() == this.calPair.getReadable2()) 
      if(!confirm("Your return date is the same as your departure date. Is such a short trip intentional?"))
        return false;  

    var todayDate = new Date(); 
    var todayDate = todayDate.getMonth() + 1 + "/" + todayDate.getDate() + "/" + todayDate.getFullYear();

    if(todayDate == this.calPair.getValue1()) {
      alert("Because you've selected today's date, only flights that leave at least 1 hour and 30 minutes from the current time will be shown on the next page.");
    }

    if(parseInt(this.adults.getValue()) == 0 && parseInt(this.children.getValue()) > 0) {
      alert("\n\nChildren between the ages of 5 and under 14 years who will be traveling alone are considered unaccompanied minors.\n\nUnaccompanied minors may only travel on nonstop or direct flights (flight that make a stop but do not change aircraft). No connecting flights.\n\nFlights booked before May 1, 2008, are subject to a \04450 fee per person each way for unaccompanied minors. Effective May 1, 2008, the fee will be \04475.\n\nOnce booked, please call 1-800-JETBLUE (538-2583) to provide us with the name, address and phone number, as it appears on the photo ID, of the person dropping off and picking up the child. The fee will also be assessed at that time.\n");
    } 

    if(parseInt(this.adults.getValue()) == 0 && parseInt(this.children.getValue()) == 0) {
      alert("You must enter at least one passenger.");
      return false;
    }

   /* if($('multicity').checked == true) {
      if(this.panelPair.panel1.getValue() != this.MultiCityPanelPair.panel2.getValue() && this.MultiCityPanelPair.panel1.getValue() != this.panelPair.panel2.getValue()) {
        alert("\n\nThe multi-city function must include\nitineraries connected via one airport.\nThis can be either your originating or\nreturn airport. For all other multi-city\nflights please book separate one-way\nreservations.\n");
        return false;
      }

      if(this.MultiCityPanelPair.panel1.getValue() == "" || this.MultiCityPanelPair.panel2.getValue() == "") {
        alert("\nYou have selected a multi-city search, but you have\nnot entered a complete city pair for the return flight.\nPlease choose both cities.\n");
        return false;
      }
    }
   */
    this.skylightsFormatting();

    //TripType Multicity or Roundtrip
    var tripType = "";
    if($('rt').checked == true)
      tripType = 0;
    if($('ow').checked == true)
      tripType = 1;
    //if($('multicity').checked == true)
      //tripType = 3;


   if ( tripType == 1 ) {
      OWAlert( $("sector1_d").value );
   }

    

    //create recent search cookie
    cookieObject.displayValue = this.panelPair.panel1.getValue() + " to " + this.panelPair.panel2.getValue();
    cookieObject.fields = new Array();

    cookieObject.fields.push({"value" : this.panelPair.panel1.getValue()});
    cookieObject.fields.push({"value" : this.panelPair.panel2.getValue()});
    cookieObject.fields.push({"value" : this.calPair.getValue1()});
    cookieObject.fields.push({"value" : this.calPair.getValue2() });
    cookieObject.fields.push({"value" : this.adults.getValue()});
    cookieObject.fields.push({"value" : this.children.getValue()});
    cookieObject.fields.push({"value" : this.fares.getValue()});
    cookieObject.fields.push({"value" : tripType});
    cookieObject.fields.push({"value" : ""});
    cookieObject.fields.push({"value" : ""});

    //save cookie
    addTracking(this.cookie, cookieObject);

    return true;
    }
  else
    return false;
  }


FlightsPage.prototype.skylightsFormatting = function() {
  var parts = this.calPair.getValue1().split("/");
 
  var month1 = parts[0];
  // add leading zero
  month1 = (month1 < 10) ? "0" + parts[0] : parts[0];
  
  var day1 = parts[1];
  // add leading zero
  day1 = (day1 < 10) ? "0" + parts[1] : parts[1];
 
  var year1 = parts[2];

  parts = this.calPair.getValue2().split("/");
 
  var month2 = parts[0];
  // add leading zero
  month2 = (month2 < 10) ? "0" + parts[0] : parts[0];
  
  var day2 = parts[1];
  // add leading zero
  day2 = (day2 < 10) ? "0" + parts[1] : parts[1];
  var year2 = parts[2];

  document["flightsForm"].m1.value = year1 + month1 + day1 + this.panelPair.panel1.getValue() + this.panelPair.panel2.getValue();
  document["flightsForm"].sector1_o.value = this.panelPair.panel1.getValue();
  document["flightsForm"].sector_1_d.value = day1;
  document["flightsForm"].sector_1_m.value = "" + month1 + year1;
  
  if (this.calPair.getValue2() == "xxx") {
    document["flightsForm"].m2.value="";
    document["flightsForm"].nom.value="1";
  }
  else {
    document["flightsForm"].m2.value = year2 + month2 + day2 + this.panelPair.panel2.getValue() + this.panelPair.panel1.getValue();
    document["flightsForm"].sector1_d.value = this.panelPair.panel2.getValue();
    document["flightsForm"].sector_2_d.value = day2;
    document["flightsForm"].sector_2_m.value = "" + month2 + year2;
    document["flightsForm"].nom.value="2";
  }
	
  document["flightsForm"].pT.value = document["flightsForm"].CHILD.value + "CHILD" + document["flightsForm"].ADULT.value + "ADULT";

  document.dest1Form.dIndex.value = document["flightsForm"].sector1_d.selectedIndex;
}

FlightsPage.prototype.getDeals = function(e) {
  if(this.panel1.getValue() != "" && this.panel2.getValue() == "") {
     this.travelDeals.getDeals(this.panel1.getValue(), "");
     showToWhere(this.panel1.getValue());     
  }
  else if(this.panel1.getValue() != "" && this.panel2.getValue() != "") {
    this.travelDeals.getDeals(this.panel1.getValue(), this.panel2.getValue());
  }
  else if(this.panel1.getValue() == "" && this.panel2.getValue() != "") {
   this.travelDeals.getDeals("", this.panel2.getValue());
  }

  this.showResultCount();
}

FlightsPage.prototype.resultCountLoaded = function(e) {
  this.showResultCount();
}

FlightsPage.prototype.showResultCount = function() {
  var el = document.getElementById("countDisplay");
  if (document.getElementById("hdnCount") != null) {
      var count = document.getElementById("hdnCount").value;
      message = "We found " + count + " deals from " + this.panel1.getReadable();
      el.innerHTML = message;

  }
  if($("area2").value != "") {
    el.innerHTML += " to " + this.panel2.getReadable(); 
    $("seeDeals").innerHTML = "<a href='#'>See all deals from " + $("area1").value + "</a>";
  }  

  var tdHeader = document.getElementById("cityToContainer"); 
	
  this.setPromoPrice(); 
}

function showToWhere(place) {
  
  var container = document.getElementById("cityToContainer");
  container.className = container.className.replace("off-left ", "");
}

FlightsPage.prototype.prepopMB = function(fromCity, toCity, fromdt, todt, adults,children,tripType,Multicityfrom,Multicityto,fare) {
  this.panelPair.panel1.preset(fromCity);
  this.panelPair.panel2.preset(toCity);
  this.adults.presetAdults(adults);
  this.children.preset(children);
  this.calPair.preset0(fromdt);

  if(todt != "")
    this.calPair.preset1(todt);

  if(todt != "xxx")
    this.calPair.preset1(todt);
  
   if(tripType == '0') {
     $('rt').checked = true;
   }
   else  {
     $('ow').checked = true;  
     this.calPair.disableCal(); 
   }
   //else {
     //this.MultiCityPanelPair.panel1.preset(Multicityfrom);
     //this.MultiCityPanelPair.panel2.preset(Multicityto);
     //$("multiCityDiv").style.display = 'block';
     //this.calPair.reenableCal();
     //$('multicity').checked = true;
  //}
        
}



// Dean Edwards/Matthias Miller/John Resig

function initFlightsPage() {
  // quit if this function has already been called
  if (arguments.callee.done) return;

  // flag this function so we don't do the same thing twice
  arguments.callee.done = true;

  // kill the timer
  if (_timer) clearInterval(_timer);

  var page = new FlightsPage("tdFlBookerTop");

};

/* for Mozilla/Opera9 */
if (document.addEventListener) {
  document.addEventListener("DOMContentLoaded", initFlightsPage, false);
}

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
  document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
  var script = document.getElementById("__ie_onload");
  script.onreadystatechange = function() {
    if (this.readyState == "complete") {
      init(); // call the onload handler
    }
  };
/*@end @*/

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
  var _timer = setInterval(function() {
    if (/loaded|complete/.test(document.readyState)) {
      initFlightsPage(); // call the onload handler
    }
  }, 10);
}

/* for other browsers */
window.onload = initFlightsPage;
