function tripAndPageType(){var qs=new Querystring();var departingDate="";var returningDate="";var displayType=qs.get("displayType");var tripType=qs.get("tripType");var origin=qs.get("origin");var destination=qs.get("destination");var originMC=qs.get("originMC");var destinationMC=qs.get("destinationMC");departingDate=qs.get("depDate");returningDate=qs.get("retDate");var adults=qs.get("adults");var child=qs.get("child");if(tripType=="undefined"||tripType==undefined){tripType="";}if(origin=="undefined"||origin==undefined){origin="";}if(destination=="undefined"||destination==undefined){destination="";}if(originMC=="undefined"||originMC==undefined){originMC="";}if(destinationMC=="undefined"||destinationMC==undefined){destinationMC="";}if(departingDate=="undefined"||departingDate==undefined){departingDate="";}if(returningDate=="undefined"||returningDate==undefined){returningDate="";}if(adults=="undefined"||adults==undefined){adults="";}if(child=="undefined"||child==undefined){child="";}if(displayType==""){document.seachFlightForm.elements["fareFormatType"].value="Dollars";}else{document.seachFlightForm.elements["fareFormatType"].value=displayType;myFormElem=document.seachFlightForm.elements["fareFormatType"];if(myFormElem[0].value==displayType){myFormElem[0].checked=true;}else{if(myFormElem[1].value==displayType){myFormElem[1].checked=true;}}}if(origin==""){document.seachFlightForm.elements["origin"].value="";document.seachFlightForm.elements["origin"].options[0].selected=true;}else{document.seachFlightForm.elements["origin"].value=origin;myFormElem=document.getElementById("origin");for(var i=0;i<myFormElem.options.length;i++){if(myFormElem.options[i].value==origin){myFormElem.options[i].selected=true;if(destination==""){redirect(i);}}}}if(destination==""){document.seachFlightForm.elements["destination"].value="";document.seachFlightForm.elements["destination"].options[0].selected=true;}else{document.seachFlightForm.elements["destination"].value=destination;myFormElem=document.getElementById("destination");for(var i=0;i<myFormElem.options.length;i++){if(myFormElem.options[i].value==destination){myFormElem.options[i].selected=true;}}}if(originMC==""){document.seachFlightForm.elements["originMC"].value="";document.seachFlightForm.elements["originMC"].options[0].selected=true;}else{document.seachFlightForm.elements["originMC"].value=originMC;myFormElem=document.getElementById("originMC");for(var i=0;i<myFormElem.options.length;i++){if(myFormElem.options[i].value==originMC){myFormElem.options[i].selected=true;if(destinationMC==""){redirectMC(i);}}}}if(destinationMC==""){document.seachFlightForm.elements["destinationMC"].value="";document.seachFlightForm.elements["destinationMC"].options[0].selected=true;}else{document.seachFlightForm.elements["destinationMC"].value=destinationMC;myFormElem=document.getElementById("destinationMC");for(var i=0;i<myFormElem.options.length;i++){if(myFormElem.options[i].value==destinationMC){myFormElem.options[i].selected=true;}}}if(departingDate==""){document.seachFlightForm.elements["departingDate"].value=(new Date().getMonth()+1)+"/"+new Date().getDate()+"/"+new Date().getFullYear();}else{document.seachFlightForm.elements["departingDate"].value=departingDate;}if(returningDate==""){document.seachFlightForm.elements["returningDate"].value=(new Date().getMonth()+1)+"/"+new Date().getDate()+"/"+new Date().getFullYear();}else{document.seachFlightForm.elements["returningDate"].value=returningDate;}if(adults==""){document.seachFlightForm.elements["Adults"].value="1";document.seachFlightForm.elements["Adults"].options[0].selected=true;}else{document.seachFlightForm.elements["Adults"].value=adults;myFormElem=document.getElementById("Adults");for(var i=0;i<myFormElem.options.length;i++){if(myFormElem.options[i].value==adults){myFormElem.options[i].selected=true;}}}if(child==""){document.seachFlightForm.elements["Children"].value="0";document.seachFlightForm.elements["Children"].options[0].selected=true;}else{document.seachFlightForm.elements["Children"].value=child;myFormElem=document.getElementById("Children");for(var i=0;i<myFormElem.options.length;i++){if(myFormElem.options[i].value==child){myFormElem.options[i].selected=true;}}}if(tripType==""){document.seachFlightForm.elements["tripType"].value="ow";document.seachFlightForm.elements["tripType"].options[0].selected=true;showTripDetails(0);}else{document.seachFlightForm.elements["tripType"].value=tripType;myFormElem=document.getElementById("tripType");for(var i=0;i<myFormElem.options.length;i++){if(myFormElem.options[i].value==tripType){myFormElem.options[i].selected=true;}}}if(tripType=="ow"){showTripDetails(0);}if(tripType=="rt"){showTripDetails(1);}if(tripType=="mc"){showTripDetails(2);}}var fixedConfiguratedDate="03/31/2010";var subFlag="";var onLoadSubFlag="";var ORIOption=new Option("","From:");var DESOption=new Option("","To:");var BOSOption=new Option("BOS","Boston, MA(BOS)");var FLLOption=new Option("FLL","Fort Lauderdale, FL(FLL)");var LASOption=new Option("LAS","Las Vegas, NV(LAS)");var SNAOption=new Option("SNA","Orange County, CA");var LAXOption=new Option("LAX","Los Angeles, CA(LAX)");var JFKOption=new Option("JFK","New York, NY(JFK)");var SANOption=new Option("SAN","San Diego, CA(SAN)");var SFOOption=new Option("SFO","San Francisco, CA(SFO)");var SEAOption=new Option("SEA","Seattle, WA(SEA)");var IADOption=new Option("IAD","Washington, DC(IAD)");var group=new Array(13);group[0]=new Array(ORIOption);group[1]=new Array(LASOption,LAXOption,SNAOption,SFOOption,SEAOption);group[2]=new Array(LASOption,LAXOption,SNAOption,SFOOption,SEAOption);group[3]=new Array(BOSOption,FLLOption,JFKOption,SFOOption,SEAOption,IADOption);group[4]=new Array(BOSOption,FLLOption,JFKOption,SFOOption,SEAOption,IADOption);group[5]=new Array(LASOption,FLLOption,LAXOption,SNAOption,SFOOption,SEAOption);group[6]=new Array(LASOption,LAXOption,SFOOption,SEAOption,IADOption);group[7]=new Array(BOSOption,FLLOption,JFKOption,SFOOption,SEAOption,IADOption);group[8]=new Array(BOSOption,FLLOption,LASOption,LAXOption,JFKOption,SNAOption,SANOption,SEAOption,IADOption);group[9]=new Array(BOSOption,FLLOption,LASOption,LAXOption,JFKOption,SNAOption,SANOption,SFOOption);group[10]=new Array(LASOption,LAXOption,SNAOption,SANOption,SFOOption,SEAOption);group[11]=new Array(ORIOption,BOSOption,FLLOption,LASOption,LAXOption,JFKOption,SNAOption,SANOption,SEAOption,IADOption);group[12]=new Array(DESOption,BOSOption,FLLOption,LASOption,LAXOption,JFKOption,SNAOption,SANOption,SEAOption,IADOption);var tempD1=document.seachFlightForm.elements["origin"];var temp1=document.seachFlightForm.elements["destination"];var tempMC1=document.seachFlightForm.elements["destinationMC"];function showTripDetails(tripTp){if(tripTp=="0"){document.getElementById("returningDIV").style.display="none";document.getElementById("multicityDIVhdr").style.display="none";document.getElementById("multicityDIV").style.display="none";}else{if(tripTp=="1"){document.getElementById("returningDIV").style.display="block";document.getElementById("multicityDIVhdr").style.display="none";document.getElementById("multicityDIV").style.display="none";}else{if(tripTp=="2"){document.getElementById("returningDIV").style.display="block";document.getElementById("multicityDIVhdr").style.display="block";document.getElementById("multicityDIV").style.display="block";}}}}function redirect(x,val){var selVal=val;var salValueFlg=0;if(x==""){x=12;}if(x!="0"){for(m=temp1.options.length-1;m>0;m--){temp1.options[m]=null;}for(i=0;i<group[x].length;i++){temp1.options[i]=new Option(group[x][i].value,group[x][i].text);if(group[x][i].value==selVal){salValueFlg=i;}}temp1.options[salValueFlg].selected=true;}}function redirectMC(x,val){var selValMC=val;var salValueFlgMC=0;if(x==""){x=12;}if(x!="0"){for(m=tempMC1.options.length-1;m>0;m--){tempMC1.options[m]=null;}for(i=0;i<group[x].length;i++){tempMC1.options[i]=new Option(group[x][i].value,group[x][i].text);if(group[x][i].value==selValMC){salValueFlgMC=i;}}tempMC1.options[salValueFlgMC].selected=true;}}var dtCh="/";var minYear=1900;var maxYear=2100;function isInteger(s){var i;for(i=0;i<s.length;i++){var c=s.charAt(i);if(((c<"0")||(c>"9"))){return false;}}return true;}function stripCharsInBag(s,bag){var i;var returnString="";for(i=0;i<s.length;i++){var c=s.charAt(i);if(bag.indexOf(c)==-1){returnString+=c;}}return returnString;}function daysInFebruary(year){return(((year%4==0)&&((!(year%100==0))||(year%400==0)))?29:28);}function DaysArray(n){for(var i=1;i<=n;i++){this[i]=31;if(i==4||i==6||i==9||i==11){this[i]=30;}if(i==2){this[i]=29;}}return this;}function isDate(dtStr){var daysInMonth=DaysArray(12);var pos1=dtStr.indexOf(dtCh);var pos2=dtStr.indexOf(dtCh,pos1+1);var strMonth=dtStr.substring(0,pos1);var strDay=dtStr.substring(pos1+1,pos2);var strYear=dtStr.substring(pos2+1);strYr=strYear;if(strDay.charAt(0)=="0"&&strDay.length>1){strDay=strDay.substring(1);}if(strMonth.charAt(0)=="0"&&strMonth.length>1){strMonth=strMonth.substring(1);}for(var i=1;i<=3;i++){if(strYr.charAt(0)=="0"&&strYr.length>1){strYr=strYr.substring(1);}}month=parseInt(strMonth);day=parseInt(strDay);year=parseInt(strYr);if(pos1==-1||pos2==-1){alert("The date format should be : mm/dd/yyyy");return false;}if(strMonth.length<1||month<1||month>12){alert("Please enter a valid month");return false;}if(strDay.length<1||day<1||day>31||(month==2&&day>daysInFebruary(year))||day>daysInMonth[month]){alert("Please enter a valid day");return false;}if(strYear.length!=4||year==0||year<minYear||year>maxYear){alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);return false;}if(dtStr.indexOf(dtCh,pos2+1)!=-1||isInteger(stripCharsInBag(dtStr,dtCh))==false){alert("Please enter a valid date");return false;}var dateEnter=new Date(year,month-1,day);var currentDate=new Date();return true;}function ValidateForm(){var dateDeparting=document.seachFlightForm.departingDate;var dateReturning=document.seachFlightForm.returningDate;var tripType=document.seachFlightForm.tripType;if(isDate(dateDeparting.value)==false){dateDeparting.focus();}else{if(tripType.value!="ow"){if(isDate(dateReturning.value)==false){dateReturning.focus();}else{document.seachFlightForm.action="http://www.virginamerica.com/va/searchflights.do";document.seachFlightForm.submit();}}else{document.seachFlightForm.action="http://www.virginamerica.com/va/searchflights.do";document.seachFlightForm.submit();}}}tripAndPageType();