var clearFocus=true;var IsBanIP=false;var isValidFlightSearch;var isValidDateForAirfare;var oFrm=new Object();oFrm.pWin=null;oFrm.DD1="#txtDepartureDate11";oFrm.DD2="#txtDepartureDate21";oFrm.RD2="#txtReturnDate21";oFrm.DF1="#txtDepartureFrom11";oFrm.DF2="#txtDepartureFrom21";oFrm.TT1="#txtTravelingTo11";oFrm.TT2="#txtTravelingTo21";oFrm.DD3=["#txtDepartureDate31","#txtDepartureDate32","#txtDepartureDate33","#txtDepartureDate34"];oFrm.DF3=["#txtDepartureFrom31","#txtDepartureFrom32","#txtDepartureFrom33","#txtDepartureFrom34"];oFrm.TT3=["#txtTravelingTo31","#txtTravelingTo32","#txtTravelingTo33","#txtTravelingTo34"];oFrm.TxtArr=new Array();oFrm.HandleArr=new Array();oFrm.hs_ClickID="";oFrm.CTextVal="";oFrm.IsSelect=false;oFrm.ValidateID="";oFrm.VHandle=null;oFrm.eMsg=[];oFrm.eMsg.E0010="Please enter a valid city or 3 letter airport code where you are departing from. Do not enter a state or country.";oFrm.eMsg.E0011="Please enter a valid city or 3 letter airport code where you are traveling to. Do not enter a state or country.";oFrm.eMsg.E0020="Departure and destination airport must not be the same airport code.";oFrm.LoadingImg=$("<img>").attr("src",oCFS.RootPath+"images/ajax_load.gif").attr("class","imgWait");oFrm.nextDay=1;oFrm.lastTriptype;function ShowErrorMsg(){$("#bLogo").block({message:$("#errors_div"),css:{width:"450px",minHeight:"300px",cursor:"auto",border:"1px solid #AAAAAA",overflow:"auto",backgroundColor:"#FFFFB3"},overlayCSS:{backgroundColor:"#FFF",opacity:0.4},centerY:true})}function HideErrorMsg(){$("#bLogo").unblock()}function AddErrorMsg(msg){var eli=$(document.createElement("li")).addClass("item").html(msg);$("#errors_div ul li.text").before(eli)}function ClearError(){$("#errors_div ul li.item").remove()}$(document).ready(function(){if(jQuery.blockUI){if(oCFS.IsError){ShowErrorMsg()}}var oneDayMillis=24*60*60*1000;var todayDate=new Date();var nextDept=new Date(todayDate.getTime()+oFrm.nextDay*oneDayMillis);var nextRet=new Date(todayDate.getTime()+(oFrm.nextDay+6)*oneDayMillis);var mtmp=nextDept.getMonth()+1;var dtmp=nextDept.getDate();var deptDateStr=$(oFrm.DD1).val();if(deptDateStr==oCFS.DFDate){deptDateStr=(mtmp<10?"0"+mtmp:mtmp)+"/"+(dtmp<10?"0"+dtmp:dtmp)+"/"+nextDept.getFullYear()}mtmp=nextRet.getMonth()+1;dtmp=nextRet.getDate();var retDateStr=$(oFrm.RD2).val();if(retDateStr==oCFS.DFDate){retDateStr=(mtmp<10?"0"+mtmp:mtmp)+"/"+(dtmp<10?"0"+dtmp:dtmp)+"/"+nextRet.getFullYear()}$(oFrm.DD1).datepicker({minDate:"0",hideIfNoPrevNext:true,duration:"fast",onSelect:function(dateText){HideErrorMsg()},changeMonth:true}).val(deptDateStr);$(oFrm.DD2).datepicker({minDate:"0",onSelect:function(dateText){HideErrorMsg();DateSelectR(oFrm.DD2,oFrm.RD2,dateText)},hideIfNoPrevNext:true,duration:"fast",changeMonth:true}).val(deptDateStr);$(oFrm.RD2).datepicker({minDate:"+2",hideIfNoPrevNext:true,duration:"fast",onSelect:function(dateText){HideErrorMsg()},changeMonth:true}).val(retDateStr);$.each($(".airClear"),function(i,clearLink){$(clearLink).click(function(){var airTxt=$(this).parent().find("input");airTxt.val(oCFS.TextDefault);airTxt.addClass("default");if($(airTxt).is(".error")){airTxt.removeClass("error")}})});var txtDepartDate="";var txtNextDepartDate="";var mtDeptDateStr=deptDateStr;var mtRetDateStr=retDateStr;var mtNextDept=nextDept;var mtNextRet=nextRet;var mtMinDept=new Date(nextDept.getTime()+oneDayMillis);var defaultDateMTTxt="";for(var i=0;i<(oFrm.DD3.length-1);i++){txtDepartDate=oFrm.DD3[i];txtNextDepartDate=oFrm.DD3[i+1];if($(txtDepartDate).datepicker()!=undefined){$(txtDepartDate).datepicker("destroy")}defaultDateMTTxt=$(oFrm.DD3[i]).val();if(defaultDateMTTxt==oCFS.DFDate){defaultDateMTTxt=mtDeptDateStr}$(txtDepartDate).datepicker({minDate:mtMinDept,onSelect:function(dateText){var txtFrom="#"+this.id;var fromIdx=$.inArray(txtFrom,oFrm.DD3);var txtTo=null;if(fromIdx>-1){txtTo=oFrm.DD3.slice(fromIdx+1,oFrm.DD3.length)}HideErrorMsg();DateSelect(txtFrom,txtTo,dateText)},hideIfNoPrevNext:true,duration:"fast",changeMonth:true}).val(defaultDateMTTxt);mtMinDept=new Date(mtNextDept.getTime()+oneDayMillis);mtNextDept=mtNextRet;mtNextRet=new Date(mtNextRet.getTime()+((oFrm.nextDay+6)*oneDayMillis));mtmp=mtNextDept.getMonth()+1;dtmp=mtNextDept.getDate();mtDeptDateStr=(mtmp<10?"0"+mtmp:mtmp)+"/"+(dtmp<10?"0"+dtmp:dtmp)+"/"+mtNextDept.getFullYear();mtmp=mtNextRet.getMonth()+1;dtmp=mtNextRet.getDate();mtRetDateStr=(mtmp<10?"0"+mtmp:mtmp)+"/"+(dtmp<10?"0"+dtmp:dtmp)+"/"+mtNextRet.getFullYear()}defaultDateMTTxt=$(oFrm.DD3[oFrm.DD3.length-1]).val();if(defaultDateMTTxt==oCFS.DFDate){defaultDateMTTxt=mtRetDateStr}$(txtNextDepartDate).datepicker({minDate:mtMinDept,hideIfNoPrevNext:true,duration:"fast",onSelect:function(dateText){HideErrorMsg()},changeMonth:true}).val(defaultDateMTTxt);$("input[name='triptype']").click(function(){ShowTripType();oFrm.lastTriptype=$(this).attr("id")});oFrm.lastTriptype=$("[name=triptype]:checked").attr("id");SetAutoCompleteTextAir(oFrm.DF1);SetAutoCompleteTextAir(oFrm.DF2);SetAutoCompleteTextAir(oFrm.TT1);SetAutoCompleteTextAir(oFrm.TT2);SetFocusText(oFrm.DF1);SetFocusText(oFrm.DF2);SetFocusText(oFrm.TT1);SetFocusText(oFrm.TT2);var txtDepartFrom="";var txtTravelTo="";for(var i=0;i<oFrm.DF3.length;i++){txtDepartFrom=oFrm.DF3[i];txtTravelTo=oFrm.TT3[i];SetAutoCompleteTextAir(txtDepartFrom);SetAutoCompleteTextAir(txtTravelTo);SetFocusText(txtDepartFrom);SetFocusText(txtTravelTo)}$("#chkCreditLoc").attr("checked",$.cookie("uCredit")=="1"||$.cookie("uCredit")==null?true:false);$("#chkTile").attr("checked",$.cookie("uTile")=="1"||$.cookie("uTile")==null?true:false);if(!$("#chkCreditLoc").attr("checked")&&oCFS.IsFilters[0]){$("#btnSearchAlt").hide()}CheckUser();$("#btnFlight,#btnSearchAlt").click(function(){ClearError();window.clearTimeout(oFrm.VHandle);$("div.sResultTop").html(oFrm.LoadingImg).append("Searching Flights..");var tripType=$("[name=triptype]:checked").val();if(ValidateFlight(tripType)){HideErrorMsg();$("#frmFlightSearch,#sResultCmd,#wGetMore,#wSpace").hide();$("#sResult").show();var params=getParamToValidate(tripType);DoSearch(tripType);$.ajax({type:"GET",url:oCFS.RootPath+"Widgets/Service/ValidateLocation.ashx",contentType:"application/json; charset=utf-8",data:params,dataType:"json",success:function(obj){if(obj.VALID){SearchManager(tripType)}else{if(oFrm.pWin!=null){oFrm.pWin.close()}var msgs=obj.Errors;var err=msgs.split(",");$.each(err,function(key,value){AddErrorMsg(oFrm.eMsg[value])});ShowErrorMsg();isValidFlightSearch=false;BackToForm();FillForm(obj)}},error:function(xhr,ajaxOptions,thrownError){DoSearch()}});return false}else{ShowErrorMsg();isValidFlightSearch=false;return false}});$("#chkCreditLoc,#chkTile").click(function(){var oCredit=$("#chkCreditLoc").attr("checked");var oTile=$("#chkTile").attr("checked");if(oCFS.IsFilters[0]){if(oCredit){$("#btnSearchAlt").show()}else{$("#btnSearchAlt").hide()}}$.cookie("uCredit",oCredit?1:0);$.cookie("uTile",oTile?1:0)})});function DoSearch(tripType){isValidFlightSearch=true;var dText;if(tripType=="2"){dText=$(oFrm.DD2).val()}else{dText=$(oFrm.DD1).val()}var MD_Y=dText.substring(6,10);var MD_M=dText.substring(0,2);var MD_D=dText.substring(3,5);var depDate=new Date(MD_Y,MD_M-1,MD_D);var cDate=new Date();cDate.setDate(cDate.getDate()+oFrm.nextDay-1);isValidDateForAirfare=(depDate>=cDate);Pops()}function BackToForm(){$("#sResult,#sResultCmd").hide();$("#frmFlightSearch").show();if(!IsBanIP){$("#wGetMore").show()}$("#sResult div.sResultTop,#sResult div.sResultMiddle").html("")}function FillForm(obj){var formSearch=$("#frmFlightSearch");var tt=obj.TT;var ti=$('input[value="'+obj.TI+'"]',formSearch);var fi=$('input[value="'+obj.FI+'"]',formSearch);$(ti).val(obj.TR);$(fi).val(obj.FR);if(tt!="3"){if(obj.FR==""){$(fi)[0].focus()}else{if(obj.TR==""){$(ti)[0].focus()}}}var timt;var fimt;var frmt;var trmt;var hasFocus=false;for(var i=0;i<4;i++){timt=eval("(obj.TIMT"+(i+1).toString()+")");fimt=eval("(obj.FIMT"+(i+1).toString()+")");frmt=eval("(obj.FRMT"+(i+1).toString()+")");trmt=eval("(obj.TRMT"+(i+1).toString()+")");ti=$('input[value="'+timt+'"]',formSearch);fi=$('input[value="'+fimt+'"]',formSearch);$(ti).val(trmt);$(fi).val(frmt);if(tt=="3"&&!hasFocus){if(frmt==""&&(fimt!=undefined&&$.isArray(fimt)&&fimt.length>0)){$(fimt)[0].focus();hasFocus=true}else{if(trmt==""&&(timt!=undefined&&$.isArray(timt)&&timt.length>0)){$(timt)[0].focus();hasFocus=true}}}}}function DateSelectR(fromdateid,todateid,dateText){$(fromdateid).removeClass("noDate");if(todateid!=""){$(todateid).removeClass("noDate")}var fDate=new Date($(fromdateid).datepicker("getDate"));var sDate=new Date($(fromdateid).datepicker("getDate"));fDate.setDate(fDate.getDate()+1);$(todateid).datepicker("option","minDate",fDate);sDate.setDate(sDate.getDate()+6);$(todateid).datepicker("setDate",sDate)}function DateSelect(fromdateid,todateid,dateText){$(fromdateid).removeClass("noDate");var oneDayMillis=24*60*60*1000;var fDate=new Date($(fromdateid).datepicker("getDate"));var sDate=new Date($(fromdateid).datepicker("getDate"));var tDate=null;var mDate=null;if(!isArray(todateid)){tDate=new Date($(todateid).datepicker("getDate"));if(tDate.getTime()<fDate.getTime()){if(todateid!=""){$(todateid).removeClass("noDate")}fDate.setDate(fDate.getDate()+6);$(todateid).datepicker("option","minDate",fDate);sDate=new Date(fDate.getTime());$(todateid).datepicker("setDate",sDate)}}else{var mtTodate="";for(var i=0;i<todateid.length;i++){mtTodate=todateid[i];tDate=new Date($(mtTodate).datepicker("getDate"));fDate=new Date(fDate.getTime()+oneDayMillis);$(mtTodate).datepicker("option","minDate",fDate);if(tDate.getTime()<fDate.getTime()){if(mtTodate!=""){$(mtTodate).removeClass("noDate")}fDate=new Date(fDate.getTime()+(oneDayMillis*6));$(mtTodate).datepicker("setDate",fDate);var bgColorV=$(mtTodate).css("background-color");$(mtTodate).animate({backgroundColor:"lightpink"},1000);$(mtTodate).animate({backgroundColor:bgColorV},500)}fDate=new Date($(mtTodate).datepicker("getDate"))}}}function ShowTripType(){var ttp=oFrm.lastTriptype.substr(2,1);var txtDep=oFrm.DF1;txtDep=txtDep.substr(0,txtDep.indexOf("1",0));var txtTo=oFrm.TT1;txtTo=txtTo.substr(0,txtTo.indexOf("1",0));var current={From:$(txtDep+ttp+"1").val(),To:$(txtTo+ttp+"1").val()};for(var i=1;i<=3;i++){$(txtDep+i+"1").val(current.From).removeClass(current.From.length>3&&current.From!=oCFS.TextDefault?"default":"");$(txtTo+i+"1").val(current.To).removeClass(current.To.length>3&&current.To!=oCFS.TextDefault?"default":"")}var tt=$("[name=triptype]:checked").val();if(tt=="2"){$("#ss2").show();$("#ss1").hide();$("#ss3").hide()}else{if(tt=="1"){$("#ss1").show();$("#ss2").hide();$("#ss3").hide()}else{if(tt=="3"){$("#ss1").hide();$("#ss2").hide();$("#ss3").show()}}}}function SetFocusText(id){if($(id).val()==oCFS.TextDefault){$(id).addClass("default")}$(id).focus(function(){var txtId="#"+$(this).attr("id");window.clearTimeout(oFrm.HandleArr[txtId]);oFrm.TxtArr[txtId]=$(this).val();if(clearFocus&&!oFrm.IsSelect){$(this).val("");$(this).removeClass("default")}clearFocus=true}).blur(function(){var txtId="#"+$(this).attr("id");if($(this).val()==""){$(this).val(oFrm.TxtArr[txtId])}if($(this).val()==oCFS.TextDefault){$(this).addClass("default")}else{if($(this).val()!=oFrm.TxtArr[txtId]&&!oFrm.IsSelect){oFrm.ValidateID=$(this);oFrm.HandleArr[txtId]=window.setTimeout("ValidateOne();",100)}else{HideErrorMsg()}}})}function ValidateOne(){var inputs=$(oFrm.ValidateID).val();var eid="#"+$(oFrm.ValidateID).attr("ID");$.ajax({type:"GET",url:oCFS.RootPath+"Widgets/Service/ValidateLocation.ashx",contentType:"application/json; charset=utf-8",data:{cn:inputs},dataType:"json",success:function(obj){ClearError();if(obj.VALID){HideErrorMsg();$(eid).val(obj.RS).removeClass("error")}else{var oID=$(eid).attr("ID");if(oID.startsWith("txtDeparture")){AddErrorMsg(oFrm.eMsg.E0010)}else{AddErrorMsg(oFrm.eMsg.E0011)}$(eid).val("");$(eid).val(oCFS.TextDefault);$(eid).addClass("default");FocusFormText(eid);ShowErrorMsg()}},error:function(xhr,ajaxOptions,thrownError){}})}function SetAutoCompleteTextAir(id){var termTemplate="<span class='ui-autocomplete-term'>%s</span>";$(id).autocomplete({minLength:3,source:function(request,response){$.ajax({url:"/Widgets/Travel/MultiSearch/SearchAirports.ashx",dataType:"application/json",data:{limit:30,q:request.term,Country:"",State:"",City:""},success:function(data){data=eval(data);response($.map(data,function(item){var ShowText=item.City;if(item.State!=""){ShowText=ShowText+", "+item.State}if(item.Country!=""){ShowText=ShowText+", "+item.Country}ShowText=ShowText+" - ("+item.AirportCode+") "+item.AirportName;return{label:ShowText,value:ShowText}}))},error:function(XMLHttpRequest,textStatus,errorThrown){if(oCFS.IsDebug){alert(textStatus)}}})},open:function(e,ui){var acData=$(this).data("autocomplete");var styledTerm=termTemplate.replace("%s",acData.term);acData.menu.element.find("li").each(function(index,value){var me=$("a",this);me.html(me.text().replace(acData.term,styledTerm));if((index%2)==1){$(this).addClass("alt")}})},select:function(event,ui){var ShowText=ui.item.value;$(id).val(ShowText).removeClass("error");var idxTxt=$.inArray(id,oFrm.TT3);if(idxTxt>-1&&(idxTxt<oFrm.DF3.length-1)){var nextDeptTxt=oFrm.DF3[idxTxt+1];var nextDeptTxtVal=$(nextDeptTxt).val();if($.trim(nextDeptTxtVal)==""||nextDeptTxtVal==oCFS.TextDefault||nextDeptTxtVal.length<3){$(nextDeptTxt).val(ShowText);$(nextDeptTxt).removeClass("default")}}clearFocus=false;oFrm.IsSelect=true;oFrm.CTextVal=ShowText;window.setTimeout("oFrm.IsSelect = false;",100)}}).data("autocomplete")._renderItem=function(ul,item){return $("<li></li>").data("item.autocomplete",item).append("<a>"+item.label+"</a>").appendTo(ul)}}function ValidateFlight(tripType){var result=true;var completeTripCount=0;$("input.error").each(function(index,element){$(element).removeClass("error")});$("select.error").each(function(index,element){$(element).removeClass("error")});if(tripType=="2"){if(!checkLegValueFrom(oFrm.DF2,"")){result=false}if(!checkLegValueTo(oFrm.TT2,"")){result=false}if($(oFrm.DF2).val()==$(oFrm.TT2).val()){AddErrorMsg("Departure and destination airport must not be the same airport code.");FocusFormText(oFrm.TT2);result=false}if(!validateDate($(oFrm.DD2).get(0))){result=false}if(!validateDate($(oFrm.RD2).get(0))){result=false}if(!DataCompare($(oFrm.DD2).val(),$(oFrm.RD2).val())){AddErrorMsg("Your return date must be after your departure date.");FocusFormText(oFrm.RD2);result=false}completeTripCount=2}else{if(tripType=="1"){if(!checkLegValueFrom(oFrm.DF1,"")){result=false}if(!checkLegValueTo(oFrm.TT1,"")){result=false}if($(oFrm.DF1).val()==$(oFrm.TT1).val()){AddErrorMsg("Departure and destination airport must not be the same airport code.");FocusFormText(oFrm.TT1);result=false}if(!validateDate($(oFrm.DD1).get(0))){FocusFormText(oFrm.DD1);result=false}completeTripCount=1}else{if(tripType=="3"){var dataEnteredTripCount=0;var valid=true;var from="";var to="";for(var i=0;i<oFrm.DF3.length;i++){from=$.trim($(oFrm.DF3[i]).val());to=$.trim($(oFrm.TT3[i]).val());if((from.length>0&&from!=oCFS.TextDefault)||(to.length>0&&to!=oCFS.TextDefault)){dataEnteredTripCount++;if(!validateDate($(oFrm.DD3[i]).get(0))){FocusFormText(oFrm.DD3[i]);valid=false}if(!checkLegValueFrom(oFrm.DF3[i],"")||!checkLegValueTo(oFrm.TT3[i],"")){valid=false}else{if($(oFrm.DF3[i]).val()==$(oFrm.TT3[i]).val()){AddErrorMsg("Departure and destination airport must not be the same airport code.");FocusFormText(oFrm.TT3[i]);valid=false}else{if(!validateDate($(oFrm.DD3[i]).get(0))){valid=false}else{if((i>0)&&(!DataCompare($(oFrm.DD3[i-1]).val(),$(oFrm.DD3[i]).val()))){AddErrorMsg("Your consequent trip date must be later than previous trip date.");FocusFormText(oFrm.DD3[i]);valid=false}else{completeTripCount++}}}}}}if(dataEnteredTripCount==0){AddErrorMsg("Please specified at least one trip for search.")}if(!(completeTripCount>0)||!valid){result=false}}}}if($("#slInfant").length>0){var numInfant=parseInt($("#slInfant").val());var numAdult=parseInt($("#slFlightAdult").val());var numChild=parseInt($("#slFlightChild").val());if(numInfant>numAdult){AddErrorMsg("Number of infant can't be more than number of adult.");result=false;FocusFormText("#slInfant")}else{if(numAdult+numChild+numInfant>9){AddErrorMsg("The number of passenger can't be more than 9 persons.");result=false;FocusFormText("#slFlightAdult");$("#slFlightAdult").addClass("error");$("#slFlightChild").addClass("error");$("#slInfant").addClass("error")}}}if(result){$("#hdTripCount").val(completeTripCount);if(completeTripCount==4){$("#chkTile").removeAttr("checked")}}return result}function FocusFormText(inputId,isSelect){if(isSelect==undefined){isSelect=false}if(($(document.activeElement)==null)||(($(document.activeElement)!=null)&&($(document.activeElement).attr("tagName")!="INPUT"))){$(inputId).focus();if(isSelect){$(inputId).select()}}$(inputId).addClass("error")}function checkLegValueFrom(id,legvalue){var txt=jQuery.trim($(id).val());if((txt=="")||(txt==oCFS.TextDefault)||txt.length<3){AddErrorMsg(legvalue+"Please enter a valid city or 3 letter airport code where you are departing from. Do not enter a state or country.");FocusFormText(id,true);return false}return true}function checkLegValueTo(id,legvalue){var txt=jQuery.trim($(id).val());if((txt=="")||(txt==oCFS.TextDefault)){AddErrorMsg(legvalue+"Please enter a valid city or 3 letter airport code where you are traveling to. Do not enter a state or country.");FocusFormText(id,true);return false}return true}function Pops(){if(!IsBanIP&&isValidFlightSearch&&isValidDateForAirfare&&$("#chkTile").attr("checked")&&($("#chkCreditLoc").attr("checked")||!oCFS.IsFilters[0])){oFrm.pWin=window.open(oCFS.TilePopupURL+"?"+GetParamFlightTile($("[input[name=triptype]:checked").val())+"&back=0","pop","height=700,width=1050,resizable=yes,toolbar=yes,location=yes,menubar=yes,scrollbars=yes,left=50,top=50");try{oFrm.pWin.blur();var agt=navigator.userAgent.toLowerCase();if(agt.indexOf("chrome")!=-1){setTimeout(oFrm.pWin.blur,0)}}catch(ex){}window.focus()}}function GetAirportCode(Airport){var AirportCode="";if(Airport.length>=3){posb=Airport.indexOf("(");pose=Airport.indexOf(")");if((posb>-1)&&(pose>-1)){AirportCode=Airport.substring(posb+1,pose)}else{AirportCode=Airport}}return AirportCode}function ContainsAirport(TxtValue){var defaultText=oCFS.TextDefault;var isFilled=false;isFilled=(TxtValue!=undefined&&TxtValue!=null&&TxtValue!=defaultText&&TxtValue.length>0);return isFilled}function GetParamFlightTile(tripType){var params={Show:"1",cmd:"air",t:tripType,na:$("#slFlightAdult").val(),nc:$("#slFlightChild").val(),ni:$("#slInfant").val()};if(tripType=="2"){params.fn=GetAirportCode($(oFrm.DF2).val());params.tn=GetAirportCode($(oFrm.TT2).val());params.dd=$(oFrm.DD2).val();params.rd=$(oFrm.RD2).val()}else{if(tripType=="1"){params.fn=GetAirportCode($(oFrm.DF1).val());params.tn=GetAirportCode($(oFrm.TT1).val());params.dd=$(oFrm.DD1).val()}else{if(tripType=="3"){var from="";var to="";var depDate="";from=$(oFrm.DF3[0]).val();to=$(oFrm.TT3[0]).val();depDate=$(oFrm.DD3[0]).val();if(ContainsAirport(from)&&ContainsAirport(to)){params.fn=GetAirportCode(from);params.tn=GetAirportCode(to);params.dd=depDate}from=$(oFrm.DF3[1]).val();to=$(oFrm.TT3[1]).val();depDate=$(oFrm.DD3[1]).val();if(ContainsAirport(from)&&ContainsAirport(to)){params.fn2=GetAirportCode(from);params.tn2=GetAirportCode(to);params.dd2=depDate}from=$(oFrm.DF3[2]).val();to=$(oFrm.TT3[2]).val();depDate=$(oFrm.DD3[2]).val();if(ContainsAirport(from)&&ContainsAirport(to)){params.fn3=GetAirportCode(from);params.tn3=GetAirportCode(to);params.dd3=depDate}}}}var str=jQuery.param(params);return str}function getParamToValidate(tripType){var params={};params.tt=tripType;if(tripType=="2"){params.fn=$(oFrm.DF2).val();params.tn=$(oFrm.TT2).val()}else{if(tripType=="1"){params.fn=$(oFrm.DF1).val();params.tn=$(oFrm.TT1).val()}else{if(tripType=="3"){var defaultText=oCFS.TextDefault;var tmpTxt="";tmpTxt=$.trim($(oFrm.DF3[0]).val());params.fnmt1=(tmpTxt==defaultText)?"":tmpTxt;tmpTxt=$.trim($(oFrm.TT3[0]).val());params.tnmt1=(tmpTxt==defaultText)?"":tmpTxt;tmpTxt=$.trim($(oFrm.DF3[1]).val());params.fnmt2=(tmpTxt==defaultText)?"":tmpTxt;tmpTxt=$.trim($(oFrm.TT3[1]).val());params.tnmt2=(tmpTxt==defaultText)?"":tmpTxt;tmpTxt=$.trim($(oFrm.DF3[2]).val());params.fnmt3=(tmpTxt==defaultText)?"":tmpTxt;tmpTxt=$.trim($(oFrm.TT3[2]).val());params.tnmt3=(tmpTxt==defaultText)?"":tmpTxt;tmpTxt=$.trim($(oFrm.DF3[3]).val());params.fnmt4=(tmpTxt==defaultText)?"":tmpTxt;tmpTxt=$.trim($(oFrm.TT3[3]).val());params.tnmt4=(tmpTxt==defaultText)?"":tmpTxt}}}return params}function SetValueToHiddenField(){$("#hdAdult").val($("#slFlightAdult").val());$("#hdChild").val($("#slFlightChild").val());$("#hdInfant").val($("#slInfant").val());$("#hdClass").val($("#slClass").val());$("#hdCreditCard").val($("#chkCreditLoc").attr("checked")?"Y":"N");$("#hdTripType").val($("[name=triptype]:checked").val());if($("[name=triptype]:checked").val()=="3"){var depAirStr="";var retAirStr="";var depDateStr="";var tmpAir="";var DefaultText=oCFS.TextDefault;for(var i=0;i<4;i++){if($(oFrm.DF3[i]).val()==DefaultText){$(oFrm.DF3[i]).val("")}if($(oFrm.TT3[i]).val()==DefaultText){$(oFrm.TT3[i]).val("")}}for(var i=0;i<oFrm.DF3.length;i++){tmpAir=$.trim($(oFrm.DF3[i]).val());if(tmpAir!=""){depAirStr+=$.trim(tmpAir)+(i==(oFrm.DF3.length-1)?"":":")}}for(var i=0;i<oFrm.TT3.length;i++){tmpAir=$.trim($(oFrm.TT3[i]).val());if(tmpAir!=""){retAirStr+=$.trim(tmpAir)+(i==(oFrm.TT3.length-1)?"":":")}}for(var i=0;i<oFrm.DD3.length;i++){tmpAir=$.trim($(oFrm.DD3[i]).val());if(tmpAir!=""){depDateStr+=$.trim(tmpAir)+(i==(oFrm.DD3.length-1)?"":":")}}$("#hdDeparting").val(depDateStr);$("#hdReturning").val("");$("#hdDepTime").val("");$("#hdRetTime").val("")}else{if($("[name=triptype]:checked").val()=="2"){$("#hdDeparting").val($(oFrm.DD2).val());$("#hdReturning").val($(oFrm.RD2).val());$("#hdDepTime").val("");$("#hdRetTime").val("")}else{if($("[name=triptype]:checked").val()=="1"){$("#hdDeparting").val($(oFrm.DD1).val());$("#hdDepTime").val("")}}}}function SearchManager(tripType){var sURL=oCFS.TilePopURL+"?"+GetParamFlightTile($("[input[name=triptype]:checked").val());if(typeof(callServiceSync)!="undefined"){callServiceSync(packServiceWithMic("100046","100047","100048"),null);if($("#chkCreditLoc").attr("checked")){callServiceSync(packServiceWithMic("100010","100011","100012"),null)}if($("#chkTile").attr("checked")){callServiceSync(packServiceWithMic("100016","100017","100018"),null)}else{callServiceSync(packServiceWithMic("100013","100014","100015"),null)}}var tripCountStr=($("#hdTripCount").val());var tripCount=0;try{tripCount=parseInt(tripCountStr)}catch(e){tripCount=0}if(IsBanIP||!(isValidDateForAirfare)){if(tripCount<4){window.location=sURL;return}else{SetValueToHiddenField();$("#hdSkipSearch").val("Y");$("#frmFlightSearch").trigger("submit");return}}if(CheckAirfare()){if($("#chkCreditLoc").attr("checked")==true||!oCFS.IsFilters[0]){SetValueToHiddenField();$("#frmFlightSearch").trigger("submit");return}}else{if(tripCount>3){SetValueToHiddenField();$("#hdSkipSearch").val("Y");$("#frmFlightSearch").trigger("submit");return}}window.location=sURL;return}function CheckAirfare(){if(false==oCFS.IsFilters[1]){return true}var result=false;var on="";var dn="";var fd="";var tripType=$("[input[name=triptype]:checked").val();if(tripType=="2"){on=$(oFrm.DF2).val();dn=$(oFrm.TT2).val();fd=$(oFrm.DD2).val()}else{if(tripType=="1"){on=$(oFrm.DF1).val();fd=$(oFrm.DD1).val()}else{if(tripType=="3"){on=$(oFrm.DF3[0]).val();dn=$(oFrm.TT3[0]).val();fd=$(oFrm.DD3[0]).val()}}}var params="on="+on+"&dn="+dn+"&fd="+fd;$.ajax({type:"GET",url:oCFS.RootPath+"Widgets/AIRFlightsBooking/AirfareSearch/CheckSearchInfo.ashx",contentType:"application/json; charset=utf-8",data:params,dataType:"json",async:false,success:function(obj){if(obj.IsAccept||oCFS.IsDebug){result=true}}});return result}function CheckUser(){if(false==oCFS.IsFilters[0]){$("#wSpace").hide();$("#wGetMore").show();IsBanIP=false;return}$.ajax({type:"GET",url:oCFS.RootPath+"Widgets/AIRFlightsBooking/AirfareSearch/CheckSearchInfo.ashx",contentType:"application/json; charset=utf-8",data:"",dataType:"json",async:true,success:function(obj){if(obj.IsAccept||oCFS.IsDebug){if(typeof(callServiceAsync)!="undefined"&&!oCFS.IsPost){callServiceAsync(packServiceWithMic("100007","100008","100009"),null)}$("#wSpace").hide();$("#wGetMore").show();IsBanIP=false}else{if(typeof(callServiceAsync)!="undefined"&&!oCFS.IsPost){callServiceAsync(packServiceWithMic("100001","100002","100003"),null);callServiceAsync(packServiceWithMic("100004","100005","100006"),null)}IsBanIP=true}if(typeof(E_ValidateUserCompleted)!="undefined"){eval(E_ValidateUserCompleted)}}})}function CheckFocus(ErrorCode){var id="";ErrorCode=ErrorCode.substring(0,9);if(ErrorCode=="REQ_P1011"){id=oFrm.DF1}else{if(ErrorCode=="REQ_P1012"){id=oFrm.TT1}else{if(ErrorCode=="REQ_P1021"){id=oFrm.DF2}else{if(ErrorCode=="REQ_P1022"){id=oFrm.TT2}else{if((ErrorCode=="REQ_P1013")||(ErrorCode=="REQ_P1151")||(ErrorCode=="REQ_P1161")){id=oFrm.DD1}else{if((ErrorCode=="REQ_P1023")||(ErrorCode=="REQ_P1152")||(ErrorCode=="REQ_P1162")){id=oFrm.DD2}else{if((ErrorCode=="REQ_P1024")||(ErrorCode=="REQ_P1153")||(ErrorCode=="REQ_P1163")||(ErrorCode=="REQ_P1143")){id=oFrm.RD2}}}}}}}$(id).focus()}function DataCompare(dateText1,dateText2){var delimChar=(dateText1.indexOf("/")!=-1)?"/":"-";var delim1=dateText1.indexOf(delimChar);var delim2=dateText1.lastIndexOf(delimChar);var MD_Y=parseInt(dateText1.substring(delim2+1),10);var MD_M=parseInt(dateText1.substring(0,delim1),10);var MD_D=parseInt(dateText1.substring(delim1+1,delim2),10);var sDate1=new Date(MD_Y,MD_M-1,MD_D);delimChar=(dateText2.indexOf("/")!=-1)?"/":"-";delim1=dateText2.indexOf(delimChar);delim2=dateText2.lastIndexOf(delimChar);MD_Y=parseInt(dateText2.substring(delim2+1),10);MD_M=parseInt(dateText2.substring(0,delim1),10);MD_D=parseInt(dateText2.substring(delim1+1,delim2),10);var sDate2=new Date(MD_Y,MD_M-1,MD_D);return sDate1<sDate2}function fnDateSelected(dateText,inst){var delimChar=(dateText.indexOf("/")!=-1)?"/":"-";var delim1=dateText.indexOf(delimChar);var delim2=dateText.lastIndexOf(delimChar);var MD_Y=parseInt(dateText.substring(delim2+1),10);var MD_M=parseInt(dateText.substring(0,delim1),10);var MD_D=parseInt(dateText.substring(delim1+1,delim2),10);var sDate=new Date(MD_Y,MD_M-1,MD_D);sDate.setDate(sDate.getDate()+1);$("#dTo,#dFrom").removeClass("noDate");$("#dTo").datepicker("option","minDate",sDate)}function checkDate(fld){var mo,day,yr;var entry=fld.value;var re=/\b\d{1,2}[\/-]\d{1,2}[\/-]\d{4}\b/;if(re.test(entry)){var delimChar=(entry.indexOf("/")!=-1)?"/":"-";var delim1=entry.indexOf(delimChar);var delim2=entry.lastIndexOf(delimChar);mo=parseInt(entry.substring(0,delim1),10);day=parseInt(entry.substring(delim1+1,delim2),10);yr=parseInt(entry.substring(delim2+1),10);var testDate=new Date(yr,mo-1,day);if(testDate.getDate()==day){if(testDate.getMonth()+1==mo){if(testDate.getFullYear()==yr){var today=new Date();today.setDate(today.getDate()-1);if(testDate<today){AddErrorMsg("The date must be greater than or equal today.");return false}return true}else{AddErrorMsg("There is a problem with the year entry.")}}else{AddErrorMsg("There is a problem with the month entry.")}}else{AddErrorMsg("There is a problem with the date entry.")}}else{AddErrorMsg("Incorrect date format. Enter as mm/dd/yyyy.")}$(fld).addClass("noDate");return false}function validateDate(fld){if(!checkDate(fld)){FocusFormText(fld,true);return false}return true}jQuery.cookie=function(name,value,options){if(typeof value!="undefined"){options=options||{};if(value===null){value="";options.expires=-1}var expires="";if(options.expires&&(typeof options.expires=="number"||options.expires.toUTCString)){var date;if(typeof options.expires=="number"){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000))}else{date=options.expires}expires="; expires="+date.toUTCString()}var path=options.path?"; path="+(options.path):"";var domain=options.domain?"; domain="+(options.domain):"";var secure=options.secure?"; secure":"";document.cookie=[name,"=",encodeURIComponent(value),expires,path,domain,secure].join("")}else{var cookieValue=null;if(document.cookie&&document.cookie!=""){var cookies=document.cookie.split(";");for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+"=")){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break}}}return cookieValue}};String.prototype.startsWith=function(str){return(this.indexOf(str)===0)};function isArray(obj){if(obj.constructor.toString().indexOf("Array")==-1){return false}else{return true}};
