/* Release 5.1 */

var homePageCheck = false;
var dynamicOpenAirportLink = 'http://travel.united.com/ube/aiportcitylookup.do';
var writeFFprotocol = "http"; if(document.location.href.indexOf('https://') !=- 1){writeFFprotocol = "https";}

/* Update the Flight Status date select */
function updateDateList() {
	var today = (new Date),
		i = 0,
		rangeStart = (new Date).dateAdd('d',-2),
		numOfDays = 3,
		i = 0,
		thisDate = 0,
		thisVal = 0,
		thisDisplay = 0,
		selected = 0,
		selObj = document.getElementById('flightStatusSelect');
		
	if (typeof ualhpDate != 'undefined') {
		var tmpDate = new Date(ualhpDate);
		if (ua.utils.isDate(tmpDate)) today = tmpDate;
	}
	today = today.dateFormat('yyyymmdd');
	selObj.length = 0;
	
	for (i=0; i<numOfDays; i++){
		thisDate = rangeStart.dateAdd('d',1);
		thisVal = thisDate.dateFormat('yyyymmdd');
		thisDisplay = thisDate.dateFormat('mm/dd/yyyy');
		/* If the value is today, we select it by default */
		if (thisVal == today) { selected = true; }
		else { selected = false; }
		selObj.options[i] = new Option (thisDisplay,thisVal,selected);
	}
}

function getEl(id){
	return document.getElementById(id);
}

ua.utils.attachEvent(window, 'load', ff29init);

function ff29click(currTab) {
	var i = 0;
	
	ff29modes = currTab;
	// START -- FSNE Part 1 Changes
	if (homePageCheck) {
		oCalPopD.ShowCal(false);
		oCalPopR.ShowCal(false);
	}
	// Start - FSN Part 2 Tab to button conversion
	chgBtn1 = document.getElementById('ff29b1')
	chgBtn2 = document.getElementById('ff29b2')
	chgBtn3 = document.getElementById('ff29b3')
	if(currTab == 1){
		chgBtn1.innerHTML = "<a style='text-decoration:none;color:black;' href='javascript:ff29click(1)'>Flights</a>";
		chgBtn2.innerHTML = "<a style='text-decoration:none;color:#0038A5;' href='javascript:ff29click(2)'>Check-in</a>";
		chgBtn3.innerHTML = "<a style='text-decoration:none;color:#0038A5;' href='javascript:ff29click(3)'>Flight Status</a>";
		chgBtn1.className = 'ff29on';
		chgBtn2.className = '';
		chgBtn3.className = '';
	}
	if(currTab == 2){
		chgBtn1.innerHTML = "<a style='text-decoration:none;color:#0038A5;' href='javascript:ff29click(1)'>Flights</a>";
		chgBtn2.innerHTML = "<a style='text-decoration:none;color:black;' href='javascript:ff29click(2)'>Check-in</a>";
		chgBtn3.innerHTML = "<a style='text-decoration:none;color:#0038A5;' href='javascript:ff29click(3)'>Flight Status</a>";
		chgBtn1.className = '';
		chgBtn2.className = 'ff29on';
		chgBtn3.className = '';
	}
	if(currTab == 3){
		chgBtn1.innerHTML = "<a style='text-decoration:none;color:#0038A5;' href='javascript:ff29click(1)'>Flights</a>";
		chgBtn2.innerHTML = "<a style='text-decoration:none;color:#0038A5;' href='javascript:ff29click(2)'>Check-in</a>";
		chgBtn3.innerHTML = "<a style='text-decoration:none;color:black;' href='javascript:ff29click(3)'>Flight Status</a>";
		chgBtn1.className = '';
		chgBtn2.className = '';
		chgBtn3.className = 'ff29on';
	}
	// End - FSN Part 2 Tab to button conversion
	for(i = 1; i < 4; i++){
		document.getElementById("ff29pane" + i).style.display = "none";
	}
    document.getElementById("ff29pane"+ff29modes).style.display="block";
}


function ff29init(){
	getEl('flightADTmain').selectedIndex = 0;
	if (getEl('wayOne').checked){
		ff29ToggleReturn('wayOne');
	}
	if (getEl('wayRound').checked){
		ff29ToggleReturn('wayRound');
	}
	if ( (getEl('SearchBySCHEDULE').checked==false) && (getEl('SearchByPRICE').checked==false) && (getEl('SearchByFLEXDATE').checked==false) ){
		getEl('SearchByPRICE').checked=true;
	}
}



//Button2Tab Conversion
ff29modes = 1; // global var of what mode the book travel mode is in (1,2,3)
ff29hptabs = new Array();
ff29hptabs[0]  = new Image(122,33); ff29hptabs[0].src = "http://www.united.com/ual/asset/hpff_bookflight_on_state_124x31.gif";
ff29hptabs[1]  = new Image(122,28); ff29hptabs[1].src = "http://www.united.com/ual/asset/hpff_bookflight_off_state_125x31.gif";
ff29hptabs[2]  = new Image(122,28); ff29hptabs[2].src = "http://www.united.com/ual/asset/hpff_bookflight_over_state_125x31.gif";
ff29hptabs[3]  = new Image(121,33); ff29hptabs[3].src = "http://www.united.com/ual/asset/hpff_redeemmiles_on_state_123x31.gif";
ff29hptabs[4]  = new Image(121,28); ff29hptabs[4].src = "http://www.united.com/ual/asset/hpff_redeemmiles_off_state_124x31.gif";
ff29hptabs[5]  = new Image(121,28); ff29hptabs[5].src = "http://www.united.com/ual/asset/hpff_redeemmiles_over_state124x31.gif";

/*End - FSN Part 2*/

/* element variables below can be found on the home page too after the HTML is defined - adding here so the code works for other pages too*/
var mploginLink, bestpricinglogin, beloggedinstate;
$(document).ready(function(){
	beloggedinstate = getEl("bempLoggedin");
	mpLoginOn = getEl("mpLogin");
	bestpricinglogin = getEl("bestPricing");																				
	mploginNowblock = getEl("loginNowblock");
	mploginLink=getEl("ffloginTxt");
	redeemonlytxt=getEl("redeemonly");
	expandCollapseLogin=getEl("ffloginimg");
});

function ffredeemlogintxt(getTab){
	if (mploginLink){
		if (getTab==1){
			mploginLink.innerHTML=mploginLink1txt;
			redeemonlytxt.style.display="none";
		} else {
			mploginLink.innerHTML=mploginLink2_3txt;
			redeemonlytxt.style.display="none";
		}
	}
}

function validateMPlogin(){
	if(ua.utils.getCookie('rememberProfile') === '') {
		ffredeemlogintxt(affType);
		if(bestpricinglogin && bestpricinglogin.style.display === 'none'){
			mpLoginOn.style.display='block';
			if(beloggedinstate) beloggedinstate.style.display="none";
		}
	} else {
		mpLoginOn.style.display = 'none';
		if(beloggedinstate){
			beloggedinstate.style.display = 'block';
			if(affType === 1)
				beloggedinstate.innerHTML = beloggedIntxt;
			else
				beloggedinstate.innerHTML=mploggedintxt;
		}
	}
}

var isVacationClicked = false;
function showVactions(tsMode){
	isVacationClicked = true;
	getEl("headingBookfliRedeem").style.display = "none";
	getEl("ff29pane1sub1a").style.display = "none";
	getEl("affFltSrch").style.display = "none";
	getEl("childseniorcompact").style.display = "none";
	getEl("affFltSrchOpts").style.display = "none";
	getEl("childseniorfull").style.display = "none";
	getEl("ff29pane1sub1b").style.display = "none";

	/* ADDED for DYN AIR START  */
	getEl("cabinOB").style.display = "none";
	getEl("cabinIB").style.display = "none";

	getEl("ff29FDlabel").style.display = "none";
	/* ADDED for DYN AIR END  */

	getEl('arrow_multicity').style.display = 'block';
	getEl('newSubscript').style.display = 'none';

	getEl("affAwdSrch").style.display = "none";
	getEl("affAwdSrchOptsNew").style.display = "none";
	if (getEl("loginNowblock")) {
		getEl("loginNowblock").style.display = "none";
	}
	if (getEl("milesloginblock")) {
		getEl("milesloginblock").style.display = "none";
	}
	
	getEl("ff29pane1sub4a").style.display = "block";
	getEl("ff29pane1sub4b").style.display = "block";
	getEl("flights1").style.display = "block";
	getEl("cars1").style.display = "block";
	getEl("hotels1").style.display = "block";
	getEl("showVacations").style.display = "none";
	getEl("cars2").style.display = "none";
	getEl("hotels2").style.display = "none";
	getEl("advancedSearch").style.display = "none";
	getEl("moreSearchOption").style.display = "block";
	getEl("shop_departtime").style.display = "none";
	getEl("shop_arrivetime").style.display = "none";
			
	/* START: Added for cruise link to not show when vacations is clicked  */
	getEl("cruises1").style.display = "none";
	$('#tabbedHeaderUL').css('margin-left','34px');
	/* END: Cruise link */		

	getEl('vacationO').value = getEl("shop_from0").value;
	getEl('vacationD').value = getEl("shop_to0").value;
}
/*End - FSN Part 2 - Added for vacations tab to open*/

/*Start FSN Part 2 - Added for flights tab to open*/
function showBookFlights(){
	getEl("advancedSearch").style.display = "block";
	getEl("moreSearchOption").style.display = "none";
	getEl("shop_departtime").style.display = "block";
	getEl("shop_arrivetime").style.display = "block";
	getEl("headingBookfliRedeem").style.display = "block";
	getEl("ff29pane1sub1a").style.display = "block";
	getEl("affFltSrch").style.display = "block";
	getEl("childseniorcompact").style.display = "block";
	getEl("affFltSrchOpts").style.display = "block";
	getEl("ff29pane1sub1b").style.display = "block";

	document.images['ff29bttab1'].src=ff29hptabs[0].src;
	document.images['ff29bttab2'].src=ff29hptabs[4].src;

	getEl("ff29pane1").style.display = "block";
	getEl("showVacations").style.display = "block";
	getEl("flights1").style.display = "none";
	getEl("cars1").style.display = "none";
	getEl("hotels1").style.display = "none";
	getEl("cars2").style.display = "block";
	getEl("hotels2").style.display = "block";
	
	/* ADDED for CRUISE LINK TO SHOW WHEN FLIGHTS IS CLICKED  */
	 
			//$('#tabbedHeaderUL').css('position','static');
			$('#tabbedHeaderUL').css('margin-left','0px');
			getEl("cruises1").style.display = "block";
			
			
	/* ADDED for CRUISE LINK TO SHOW WHEN FLIGHTS IS CLICKED END  */	
	
	
	getEl("ff29pane1sub4a").style.display = "none";
	getEl("ff29pane1sub4b").style.display = "none";
	if (getEl("wayRound")) {

		if (getEl("wayRound").checked == true ){
			getEl("ff29Ritem").style.display="block";
			getEl("ff29Rlabel").style.display="block";
		} else {
			getEl("ff29Ritem").style.display="none";
			getEl("ff29Rlabel").style.display="none";
		}
	}
}
/*End - FSN Part 2 - Added for flights tab to open*/


/*code added for advanced search link - fsne part 2- starts*/
/* added lang param to support espanol funciton SHD and SSM 3/29/2011*/

function ff29AdvSearch(lang){
	var telescopeQuery = '';
	
	telescopeQuery+="http://travel.united.com/ube/core/us/shop.do?Log=1";
	
	if (typeof lang != "undefined"){
		telescopeQuery+="&lang="+lang;
	} else {
		telescopeQuery+="&lang=en";
	}
	telescopeQuery+="&shop_departmonth0="+getEl("shop_departmonth").value;
	telescopeQuery+="&shop_departday0="+getEl("shop_departday").value;
	telescopeQuery+="&shop_departtime0="+getEl("shop_departtime").value;

	var shopFrom0Val = getEl("shop_from0").value;
	var shopTo0Val = getEl("shop_to0").value;
	shopFrom0Val = shopFrom0Val.replace("(","");
	shopTo0Val = shopTo0Val.replace("(","");

	getEl("shop_from0").value=shopFrom0Val;
	getEl("shop_to0").value=shopTo0Val;
	telescopeQuery+="&shop_from0="+getEl("shop_from0").value;

	if (getEl("wayRound")) {
		if (getEl("wayRound").checked==true ) {
			telescopeQuery+="&shop_to0="+getEl("shop_to0").value;
			telescopeQuery+="&shop_triptype=roundtrip";
			telescopeQuery+="&shop_arrivemonth0="+getEl("shop_arrivemonth").value;
			telescopeQuery+="&shop_arriveday0="+getEl("shop_arriveday").value;
			telescopeQuery+="&shop_arrivetime0="+getEl("shop_arrivetime").value;
		} else if (getEl("wayOne").checked==true) {
			telescopeQuery+="&shop_triptype=oneway";
		}
	}
	if(getEl("SearchBySCHEDULE").checked==true) {telescopeQuery+="&shop_viewresults=SCHEDULE";}
	if(getEl("SearchByPRICE").checked==true) {telescopeQuery+="&shop_viewresults=PRICE";}
	if(getEl("SearchByFLEXDATE").checked==true) {telescopeQuery+="&shop_viewresults=PRICE";}
	
	if(flightschildandseniorvisible!=true){
		telescopeQuery+="&shop_passenger0="+getEl("flightADTmain").value;
		telescopeQuery+="&shop_passenger1=0-SRC";
		telescopeQuery+="&shop_passenger2=0-CNN";
	} else {
		telescopeQuery+="&shop_passenger0="+getEl("flightADT").value;
		telescopeQuery+="&shop_passenger1="+getEl("flightSRC").value;
		telescopeQuery+="&shop_passenger2="+getEl("flightCNN").value;
	}
	var isRefundable="off";
	var tempServiceVal = getEl("serviceclass").value;
	if(getEl("refundable").checked){
		isRefundable="on";
		var tempServiceVal = getEl("serviceclass").value +"-REFUNDABLE";
	} else {
		isRefundable="off";
		var tempServiceVal = getEl("serviceclass").value +"-NON-REFUNDABLE";
		//getEl("serviceclass").value = tempServiceVal;
	}

	telescopeQuery+="&shop_serviceclass="+tempServiceVal;
	telescopeQuery+="&shop_cabinrefundable="+isRefundable;
	telescopeQuery+="&shop_cabinclass="+ getEl("serviceclass").value;
	telescopeQuery+="&shop_promotioncode="+getEl("flightPromocode").value;

	window.location=telescopeQuery;
}

//code added for advanced search link - fsne part 2- ends
//variable to control one-way on and off : true -- on , false -- off
var isFltTypesOn=true;

function ff29AffSubmit(typeOfsearch,linkName){
	var ff29tsMode = 1;
	//Code added for flight and vacation search - FSNE Part 2 - start
	if (getEl("moreSearchOption").style.display === "none"){
		ff29tsMode = 1;
	}
	if (getEl("moreSearchOption").style.display === "block"){
		ff29tsMode = 4;
	}
	//Code added for flight and vacation search - FSNE Part 2 - end

	if (ff29tsMode === 1){
		if (typeOfsearch === "normal"){
			if (getEl("shop_from0_temp").value === "") {
				if (getEl("shop_from0").value === "" && affType !== 3) {
					alert("Departing location (From) is a required field.")
					return false;
				}
			} else {
				if (getEl("shop_from0").value === "") {
					getEl("shop_from0").value = getEl("shop_from0_temp").value;
				}
			}
			if (getEl("shop_to0_temp").value === "") {
				if (getEl("shop_to0").value === "" && affType !== 3) {
					alert("Destination location (To) is a required field")
					return false;
				}
			} else {
				if (getEl("shop_to0").value === "") {
					getEl("shop_to0").value = getEl("shop_to0_temp").value;
				}
			}
			
            if (!checkForDate()) {
                return false;
            }
			
			// query flights and ping site metrics (insight first)
			var telescopeQuery="";
			var tempServiceVal = "";

			/*Code added for MP login - FSNE Part 2 - Starts */
			var isMpLogin = false;
			if (getEl("bestPricing") && getEl("bestPricing").style.display == "block" && (affType==1 || affType==2 || affType==3)){
				if((getEl("mpnumber") && getEl("mpnumber").value!="") || (getEl("mppassword") && getEl("mppassword").value!="")){
					var mpNum = getEl("mpnumber").value;
					var pwd = getEl("mppassword").value;
					if(ValidateUserId3(mpNum,pwd)){
						isMpLogin = true;
						
						if(affType==2 || affType==3){
							if(DASwitch){
								telescopeQuery="https://www.ua2go.com/ci/DoLogin.jsp?return_to=mp_award_ibe_bridge&fwdPath=compactSearch&Log=1&switch=true";
							} else {
								telescopeQuery="https://www.ua2go.com/ci/DoLogin.jsp?return_to=core_ibe_bridge&fwdPath=compactSearch&Log=1&switch=true";
							}								
						} else {
							telescopeQuery="https://www.ua2go.com/ci/DoLogin.jsp?return_to=core_ibe_bridge&fwdPath=compactSearch&Log=1&switch=true";
						} 
						
						if(getEl('remMP1') && getEl('remMP1').checked == true){
							if(isEmail(mpNum)){
								remEMAIL(mpNum);
								rememberMEC('E');
							} else {
								remMP(mpNum);
								rememberMEC('M');
							}
						} else if(getEl('remMP1') && getEl('remMP1').checked == false){
							ua.utils.deleteCookie('getMP');
							ua.utils.deleteCookie('rememberME');
							ua.utils.deleteCookie('rememberEMAIL');
						}
					} else {
						return false;
					}
				}
			}

			/*Code added for MP login - FSNE Part 2 - Ends */
			
			if (affType==1) {
				if(telescopeQuery == "") telescopeQuery+="http://travel.united.com/ube/core/"+affCtryCode+"/compactSearch.do?Log=1&switch=true&";
				
				//Code added for FSNE Part 2 - starts
				var isRefundable="off";
				tempServiceVal = getEl("serviceclass").value;
				if(getEl("refundable").checked){
					isRefundable="on";
					tempServiceVal = tempServiceVal +"-REFUNDABLE";
				} else {
					isRefundable="off";
					tempServiceVal = tempServiceVal +"-NON-REFUNDABLE";
				}
				telescopeQuery+="&shop_serviceclass="+tempServiceVal;
				telescopeQuery+="&shop_cabinrefundable="+isRefundable;
				telescopeQuery+="&shop_cabinclass="+ getEl("serviceclass").value;
			}

			if (affType==2) {
				//telescopeQuery+="http://travel.united.com/ube/award/"+affCtryCode+"/compactSearch.do?Log=1&switch=true&";
				//https://www.mileageplus.com/ube/core/us/compactSearch.do
				if(telescopeQuery === "") {
					if(DASwitch){
						telescopeQuery+="https://www.mileageplus.com/awardbooking/award/"+affCtryCode+"/compactSearch.do?Log=1";
					}else{
						telescopeQuery+="http://travel.united.com/ube/core/"+affCtryCode+"/compactSearch.do?Log=1&switch=true&";
					}
				}
				if(DASwitch){														
					telescopeQuery+="&shop_serviceclass="+getEl("shop_serviceclass_outbound").value;
					telescopeQuery+="&shop_serviceclass_inbound="+getEl("shop_serviceclass_inbound").value;
					if(getEl('flex_date_check') && getEl('flex_date_check').checked){
							telescopeQuery+='&flex_date_check=true&shop_viewresults=FLEXDATE';
					}else{
						telescopeQuery+="&flex_date_check=false&shop_viewresults=SCHEDULE";
					}
				} else {							
					//Code added for FSNE Part 2 - starts
					var isRefundable="off";
					tempServiceVal = getEl("serviceclass").value;
					if(getEl("refundable").checked){
						isRefundable="on";
						tempServiceVal = tempServiceVal +"-REFUNDABLE";
					} else {
						isRefundable="off";
						tempServiceVal = tempServiceVal +"-NON-REFUNDABLE";
					}
					telescopeQuery+="&shop_serviceclass="+tempServiceVal;
					telescopeQuery+="&shop_cabinrefundable="+isRefundable;
					telescopeQuery+="&shop_cabinclass="+ getEl("serviceclass").value;	
				}
				telescopeQuery+="&shop_stops="+getEl("affstops").value;
			}

			if (affType==3) {
				if(telescopeQuery == "") telescopeQuery+="http://travel.united.com/ube/award/"+affCtryCode+"/awardShop.do?Log=1&switch=true&";  //switch=true will prevent default num of pax from being selected
			}

			telescopeQuery+="&submitingShopInputForm=true";
			telescopeQuery+="&shop_flightCount=2";
			telescopeQuery+="&changeLanguage=false";
			telescopeQuery+="&actionType=search";
			telescopeQuery+="&waiting=true";

			if (getEl("wayRound")) {
				if (!isFltTypesOn) {
					if (getEl("wayRound").checked == true) {
						telescopeQuery += "&shop_triptype=roundtrip";
					} else {
						if (getEl("wayOne").checked == true) {
							telescopeQuery += "&shop_triptype=oneway";
						}
					}
				} else {
					if (getEl("wayRound").checked == true) {
						telescopeQuery += "&shop_triptype=roundtrip";
					} else {
						if (getEl("wayOne").checked == true) {
							telescopeQuery += "&shop_triptype=oneway";
						}
					}
				}
			} else {
				//mp fare-finder
				telescopeQuery+="&shop_triptype=roundtrip";
			}

			var shopFrom0Val = getEl("shop_from0").value;
			var shopTo0Val = getEl("shop_to0").value;
			shopFrom0Val = shopFrom0Val.replace("(","");
			shopTo0Val = shopTo0Val.replace("(","");
			telescopeQuery+="&shop_from0="+shopFrom0Val;
			telescopeQuery+="&shop_to0="+shopTo0Val;

			if (getEl("fromnearby1")) {
				if (getEl("fromnearby1").checked==true) {
					telescopeQuery+="&shop_fromnearbyairport0=on";
				}
				if (getEl("tonearby1").checked==true) {
					telescopeQuery+="&shop_tonearbyairport0=on";
				}
			}

			telescopeQuery+="&shop_departtime0="+getEl("shop_departtime").value;
			telescopeQuery+="&shop_arrivetime0="+getEl("shop_arrivetime").value;

			if(!isMpLogin){
				telescopeQuery+="&shop_arriveday0="+getEl("shop_arriveday").value;
				telescopeQuery+="&shop_departmonth0="+getEl("shop_departmonth").value;
				telescopeQuery+="&shop_departday0="+getEl("shop_departday").value;
				telescopeQuery+="&shop_arrivemonth0="+getEl("shop_arrivemonth").value;
			}

			if(typeof flightschildandseniorvisible === 'boolean') {
				if(flightschildandseniorvisible != true){
					telescopeQuery+="&shop_passenger0="+getEl("flightADTmain").value;
					telescopeQuery+="&shop_passenger1=0-SRC";
					telescopeQuery+="&shop_passenger2=0-CNN";
				} else {
					telescopeQuery+="&shop_passenger0="+getEl("flightADT").value;
					telescopeQuery+="&shop_passenger1="+getEl("flightSRC").value;
					telescopeQuery+="&shop_passenger2="+getEl("flightCNN").value;
				}
			} else {
				//mp fare-finder
				telescopeQuery+="&shop_passenger0="+getEl("flightADTmain").value;
				telescopeQuery+="&shop_passenger1=0-SRC";
				telescopeQuery+="&shop_passenger2=0-CNN";
			}

			if (affType==2 || affType==3) {
				telescopeQuery+="&languageRedisplayPage=%2Fjsp%2Fshop%2FAward.jsp";

				if (getEl('Saver').checked==true) {
					var awardAffVal='Saver';
				} else {
					var awardAffVal='Standard';
				}
				telescopeQuery+="&award_type="+awardAffVal;
			} else { // revenue
				if(getEl("SearchBySCHEDULE")) {
					if(getEl("SearchBySCHEDULE").checked==true) {telescopeQuery+="&shop_viewresults=SCHEDULE";}
				}

				if(getEl("SearchByPRICE")) {
					if(getEl("SearchByPRICE").checked==true) {telescopeQuery+="&shop_viewresults=PRICE";}
				}

				if(getEl("SearchByFLEXDATE")) {
					if(getEl("SearchByFLEXDATE").checked==true) {telescopeQuery+="&shop_viewresults=FLEXDATE";}
				}

				telescopeQuery+="&languageRedisplayPage=%2Fjsp%2Fshop%2FShop.jsp";
				telescopeQuery+="&shop_promotioncode="+getEl("flightPromocode").value;
			}
			//Code added for FSNE Part 2 - ends

			if(isMpLogin){
				document.shopInputForm.action = telescopeQuery;
				return true;
			} else {
				window.location = telescopeQuery;
				return false;
			}
		}
	}

	/* United Vacations */
	if (ff29tsMode == 4){
		var i = 0, 
			result = {}, 
			thisElem = '', 
			thisDate = '', 
			_thisDate = '', /* Used as a backup of original value */ 
			thisResult = '', 
			thisValue = '',
			fieldType = '', 
			dateMask = 'mm/dd/yy',
			formContent = '',
			vsTempTags = [];
		
		/* This is the master form where the user input occurs */
		var fareFinderForm = document.getElementById('sideform');
		
		/* 
		 * This is a form created on the fly. We use this to translate our
		 * master form fields into the parameters required for the submission
		 * to UnitedVacations.com.
		 */
		$('<form id="UAVacations" style="display: none;"></form>').appendTo('body');
		var unitedVacationsForm = document.getElementById('UAVacations');
		unitedVacationsForm.method = 'get';
		unitedVacationsForm.action = 'http://www.unitedvacations.com/sitenav?';
		
		/* Set up a data dictionary to translate from the Fare Finder form into the United Vacations form */
		var vac_dict = [	
		//  ['United Field ID',		'UA Vacations Form Name',	'Field Type',	'VS Tracking tag']
			['vacType', 			'package', 					'radio',		'shop_triptype'], 
			['vacationO', 			'origin', 					'text',			'shop_from0'],  // Also hard-coded in validation.
			['vacationD', 			'destination', 				'text',			'shop_to0'], 	// Also hard-coded in validation.
			['shop_depart0', 		'departureDate', 			'date',			'shop_departdate0'], 
			['shop_arrive0', 		'returnDate', 				'date',			'shop_arrivedate0'], 
			['vacationsAdults', 	'adultCount', 				'text',			'shop_passenger0']
		];
		
		/* Process all form fields */
		for (i = 0; i < vac_dict.length; i++) {
			// Ex: "result.package". Generates object of elements
			fieldType = vac_dict[i][2];
			thisResult = result[vac_dict[i][1]] = '';
			if (fieldType === 'radio') {
				thisResult = fareFinderForm.elements[vac_dict[i][0]];
				thisResult.value = ua.utils.getRadioValue(thisResult);
			}
			else {
				thisResult = document.getElementById(vac_dict[i][0]);
			}
			
			if (fieldType === 'date') {
				_thisDate = thisDate = thisResult.value;
				/* If the string date has only a 2 digit year, let's make it into a 4-digit year */
				thisDate = thisDate.replace(new RegExp("/(\\d{2})$", ""), function($0, $1){
					if ($1.match(new RegExp("^[01]{1}", ""))) {
						return "/20" + $1
					}
					else {
						return "/19" + $1
					}
				});
				thisDate = new Date(thisDate);
				
				/* If we've been successful in converting the string to a date object, lets party! */
				if (ua.utils.isDate(thisDate)) {
					thisResult.value = thisDate.dateFormat(dateMask);
				}
				else {
					/* Otherwise, let's sit in the corner, shamefully, and revert to the original value */
					thisResult.value = _thisDate;
				}
			}
			thisName = vac_dict[i][1];
			thisValue = thisResult.value;
			
			/* Custom VS Tagging */
			vsTempTags.push([vac_dict[i][3],thisValue]);
			
			/* Dynamically create our form in prep for submission to United Vacations */
			formContent += '<input name="' + thisName + '" value="' + thisValue + '" type="hidden">';
			result[vac_dict[i][1]] = thisResult;
		}
		
		$(unitedVacationsForm).append(formContent);
		
		/* Always add this param */
		$(unitedVacationsForm).append('<input name="rfr" value="UAHPFF" type="hidden">');
		$(unitedVacationsForm).append('<input name="tag" value="BOOK_COBRAND" type="hidden">');
		
		/* Perform validation on form values */
		if (typeOfsearch === 'normal') {
			if (result.origin.value === '') {
				alert("Departing location (From) is a required field.");
				$(unitedVacationsForm).remove();
				vsTempTags = [];
				return false;
			}
			
			if (result.destination.value === '') {
				alert("Destination location (To) is a required field");
				$(unitedVacationsForm).remove();
				vsTempTags = [];
				return false;
			}
		}
		
		/* TODO: Not sure how/when this is used */
		if (typeOfsearch === "options") {
			window.location = "http://www.unitedvacations.com/sitenav?tag=HOME&rfr=UAHPFF";
		}
		
		/* Merge vsTempTags into the main tracking array */
		ua.vsTracking.mergeTags(vsTempTags);
		
		/* Everything looks good, let's submit */
		unitedVacationsForm.submit();
		return false;
	}

}


/*Added for Book flight button change - FSN Part 2 - starts*/
function ff29tabhover(currTab,polarity){
	if (currTab==1 && currTab!=ff29modes) {
		if(polarity==="over") {
			document.images['ff29bttab1'].src=ff29hptabs[2].src;
		}
		if(polarity==="out") {
			document.images['ff29bttab1'].src=ff29hptabs[1].src;
		}
	}

	if(currTab==2 && currTab != ff29modes) {
		if(ff29modes==1) {
			if(polarity=="over") {document.images['ff29bttab2'].src=ff29hptabs[5].src;}
			if(polarity=="out") {document.images['ff29bttab2'].src=ff29hptabs[4].src;}
		}
	}
}

/* Added for Book flight button change - FSN Part 2 - ends */

function chgAff(fltT) {
	ff29modes=fltT; /* Added to change the mode of the tab from book flights to redeem miles - FSN Part 2 */
	vsAffSwitch='T';
	clrErrMsgs();

	if(fltT === 1){
		ffredeemlogintxt(fltT);
		dynamicOpenAirportLink="http://travel.united.com/ube/aiportcitylookup.do?";
		
		/* START: Added for tab image and radio button to be checked by default - FSN Part 2 */
		document.images['ff29bttab1'].src=ff29hptabs[0].src;
		document.images['ff29bttab2'].src=ff29hptabs[4].src;
		/* END: Added for tab image and radio button to be checked by default - FSN Part 2 */

		/* Search Flights */
		if(getEl('affserviceclass') && getEl('serviceclass')){
			getEl('serviceclass').selectedIndex=getEl('affserviceclass').selectedIndex;
		}
		if(getEl("shop_serviceclass_inbound").selectedIndex == getEl("shop_serviceclass_outbound").selectedIndex){
			getEl("serviceclass").selectedIndex = getEl("shop_serviceclass_inbound").selectedIndex;
		}
		affType=1;
		flightschildandseniorvisible = false;

		if (affTripType==1){
			ff29ToggleReturn('wayOne');
		} else {
			ff29ToggleReturn('wayRound');
		}

		if (!isFltTypesOn){
			getEl('fltTypes').style.display='block';
			getEl("ff29Rlabel").style.display="block";
			getEl("ff29Ritem").style.display="block";
		}
		getEl('fltTypes').style.display='block';

		/* START: Added new div in HTML for cabin and login - FSN Part 2 */
		getEl('lbl-pass-adlt').style.display='block';
		getEl('affAwdSrchOptsNew').style.display='none';
		if(getEl('milesloginblock'))getEl('milesloginblock').style.display='none';
		//getEl('mpLogin').style.display='none';
		getEl('advancedSearch').style.display='block';
		getEl('arrow_multicity').style.display='';
		getEl('newSubscript').style.display='none';
		getEl("cabinIB").style.display = "none";
		getEl("cabinOB").style.display = "none";
		getEl("flex").style.display = "none";
		/* END: Added new div in HTML for cabin and login - FSN Part 2 */

		getEl('affAwdSrch').style.display='none';
		getEl('affFltSrch').style.display='block';
		getEl('affChldSen').style.display='block';

		var check10Alert=0;

		if (getEl('flightSRC').selectedIndex > 0 || getEl('flightCNN').selectedIndex > 0 ){
			getEl('childseniorcompact').style.display='none';
			getEl('childseniorfull').style.display='block';
			if (getEl('flightADT').selectedIndex+getEl('flightSRC').selectedIndex+getEl('flightCNN').selectedIndex-1 >8 ){
				getEl('flightADTmain').selectedIndex=8;
				var check10Alert=1;
			} else {
				getEl('flightADTmain').selectedIndex=(getEl('flightADT').selectedIndex+getEl('flightSRC').selectedIndex+getEl('flightCNN').selectedIndex)-1;
			}
		} else {
			getEl('childseniorcompact').style.display='block';
			getEl('childseniorfull').style.display='none';
			if (getEl('childseniorfull').style.display=='block'){
				if (getEl('flightADTmain').selectedIndex > 0){ // 31
					getEl('flightADTmain').selectedIndex=getEl('flightADT').selectedIndex-1;
				}
			} else {
				if((getEl('flightSRC').selectedIndex==0 && getEl('flightCNN').selectedIndex==0) && getEl('flightADTmain').selectedIndex==0 && getEl('flightADT').selectedIndex!=0){
					getEl('flightADTmain').selectedIndex=getEl('flightADT').selectedIndex-1;
				}
			}
		}

		if (getEl('childseniorfull').style.display=='block'){
			flightschildandseniorvisible = true;
			if (getEl('flightSRC').selectedIndex>0 || getEl('flightCNN').selectedIndex >0 ){
				if(((getEl('flightADTmain').selectedIndex+1)-(getEl('flightSRC').selectedIndex+getEl('flightCNN').selectedIndex))>0){
					getEl('flightADT').selectedIndex=((getEl('flightADTmain').selectedIndex+1)-(getEl('flightSRC').selectedIndex+getEl('flightCNN').selectedIndex));
				} else {
					getEl('flightADT').selectedIndex=0;
					if (getEl('srvErr0')){
						getEl('srvErr0').style.display='block';
					}
					if (getEl('srvErr0')){
						errVal=getEl('srvErr0');
						errVal.style.display='block';
						errVal.innerHTML=affPass0Msg;
						errVal.className='err';
					}
					if (getEl('lbl-pass0'))	{
						getEl('lbl-pass0').className += ' err';
					}
				}
			} else {
				flightschildandseniorvisible = false;
				if (getEl('flightSRC').selectedIndex>0 || getEl('flightCNN').selectedIndex >0 ){
					getEl('flightADTmain').selectedIndex=getEl('flightADT').selectedIndex+1;
				}
			}
		}

		if (getEl('affMoreText')) {
			getEl('affMoreText').innerHTML = affMore1;
		}

		getEl('affFltSrchOpts').style.display='block';

		if(getEl('affAwdSrchOpts')){
			getEl('affAwdSrchOpts').style.display='none';
		}

		if(getEl('stops')){
			getEl('stops').selectedIndex=getEl('affstops').selectedIndex;
		}

		if (getEl('childseniorfull').style.display=='block'){
			if (getEl('flightADTmain').selectedIndex > 0){
				getEl('flightADTmain').selectedIndex=getEl('flightADT').selectedIndex-1;
			}
		}
		
		if(getEl('flightADTmain').selectedIndex==-1){
			getEl('flightADTmain').selectedIndex=0;
		}
		
		validateMPlogin(); 
	} else {
		//book miles		
		if (DASwitch) {
			dynamicOpenAirportLink="https://www.mileageplus.com/awardbooking/award/us/aiportcitylookup.do?DAmpPage&amp;";
		}		
		ffredeemlogintxt(fltT);
		
		/* Added for tab image, and radio button - Start - FSN Part 2 -*/
		if (isFltTypesOn){
			getEl('fltTypes').style.display='block';
			getEl("cabinOB").style.display="";

			if (getEl("wayOne")) {
				if (getEl("wayOne").checked == true ){
					getEl("ff29Rlabel").style.display="none";
					getEl("ff29Ritem").style.display="none";
					getEl("cabinIB").style.display="none";
				} else {
					getEl("ff29Ritem").style.display="block";
					getEl("ff29Rlabel").style.display="block";
					getEl("cabinIB").style.display="";
				}
			}
		} else {
			if(getEl("wayOne")){
				if (getEl("wayOne").checked == true ){
					getEl("wayRound").checked = true;
					getEl("ff29Rlabel").style.display="block";
					getEl("ff29Ritem").style.display="block";
					//getEl("cabinIB").style.display="none";
				}
			}
			getEl('fltTypes').style.display='none';
		}
		document.images['ff29bttab1'].src=ff29hptabs[1].src;
		document.images['ff29bttab2'].src=ff29hptabs[3].src;
		
		/* START: Added fix for 17676 */
		getEl("shop_serviceclass_outbound").value=getEl("serviceclass").value;
		getEl("shop_serviceclass_inbound").value=getEl("serviceclass").value;
		/* END: Added fix for 17676 */
		
		/* Added for tab image, and radio button - End - FSN Part 2 */
		affType=2;
		flightschildandseniorvisible = false;

		/* START: FSN Part 2 Added new div in HTML for cabin and login*/
		getEl("cabinOB").style.display = "";
		getEl("flex").style.display = "";
		getEl('affAwdSrchOptsNew').style.display='block';
		getEl('arrow_multicity').style.display='none';
		getEl('newSubscript').style.display='';
		getEl('advancedSearch').style.display='none';
		getEl('lbl-pass-adlt').style.display='block';

		if(ua.utils.getCookie("rememberProfile") === ""){
			if(getEl('milesloginblock'))getEl('milesloginblock').style.display='block';
			if(getEl('loginNowblock'))getEl('loginNowblock').style.display='block';
			if(getEl('bestPricing').style.display=='none'){
				getEl('mpLogin').style.display='block';
			}
		}
		/* END: FSN Part 2 Added new div in HTML for cabin and login*/

		getEl('affFltSrch').style.display='none';
		getEl('affAwdSrch').style.display='none';

		var check10Alert=0;

		if (getEl('flightSRC').selectedIndex>0 || getEl('flightCNN').selectedIndex >0 ){
			getEl('childseniorcompact').style.display='none';
			getEl('childseniorfull').style.display='block';

			if (getEl('flightADT').selectedIndex+getEl('flightSRC').selectedIndex+getEl('flightCNN').selectedIndex-1 >8 ){
				getEl('flightADTmain').selectedIndex=8;
				var check10Alert=1;
			} else {

				getEl('flightADTmain').selectedIndex=(getEl('flightADT').selectedIndex+getEl('flightSRC').selectedIndex+getEl('flightCNN').selectedIndex)-1;
			}
		} else {
			getEl('childseniorcompact').style.display='block';
			getEl('childseniorfull').style.display='none';

			if (getEl('childseniorfull').style.display=='block'){
					if (getEl('flightADTmain').selectedIndex > 0){ // 31
						getEl('flightADTmain').selectedIndex=getEl('flightADT').selectedIndex-1;
					} // 31
			} else {
				if((getEl('flightSRC').selectedIndex==0 && getEl('flightCNN').selectedIndex==0) && getEl('flightADTmain').selectedIndex==0 && getEl('flightADT').selectedIndex!=0){
					getEl('flightADTmain').selectedIndex=getEl('flightADT').selectedIndex-1;
				}
			}
		}

		if (getEl('childseniorfull').style.display=='block'){
			flightschildandseniorvisible = true;
			if (getEl('flightSRC').selectedIndex>0 || getEl('flightCNN').selectedIndex > 0 ){
				if (((getEl('flightADTmain').selectedIndex+1)-(getEl('flightSRC').selectedIndex+getEl('flightCNN').selectedIndex))>0){
					getEl('flightADT').selectedIndex=((getEl('flightADTmain').selectedIndex+1)-(getEl('flightSRC').selectedIndex+getEl('flightCNN').selectedIndex));
				} else {
					getEl('flightADT').selectedIndex=0;
					if (getEl('srvErr0')) {
						getEl('srvErr0').style.display='block';
					}
					if (getEl('srvErr0')){
						errVal=getEl('srvErr0');
						errVal.style.display='block';
						errVal.innerHTML=affPass0Msg;
						errVal.className='err';
					}
					if (getEl('lbl-pass0')){
						getEl('lbl-pass0').className += ' err';
					}
				}
			} else {
				flightschildandseniorvisible = false; // 229
				if (getEl('flightSRC').selectedIndex>0 || getEl('flightCNN').selectedIndex >0 ){
					getEl('flightADTmain').selectedIndex=getEl('flightADT').selectedIndex+1;
				}
			}
		}

		if (getEl('affMoreText')) {
			getEl('affMoreText').innerHTML = affMore2;
		}

		getEl('affFltSrchOpts').style.display='none';

		if(getEl('affAwdSrchOpts')){
			getEl('affAwdSrchOpts').style.display='block';
		}

		if(getEl('stops')){
			getEl('affstops').selectedIndex=getEl('stops').selectedIndex;
		}
		
		if (check10Alert==1) {
			if (getEl('lbl-pass-adlt')){
				getEl('lbl-pass-adlt').className += ' err';
			}
			if (getEl('srvErr0')){
				getEl('srvErr0').style.display='block';
			}
			if (getEl('srvErr0')){
				errVal=getEl('srvErr0');
				errVal.innerHTML=affPass10Msg;
				errVal.className='err';
				errVal.style.marginBottom='5px';
			}
		}
		if (getEl('childseniorfull').style.display=='block'){
			if (getEl('flightADTmain').selectedIndex > 0){
				getEl('flightADTmain').selectedIndex=getEl('flightADT').selectedIndex-1;
			}
		}
		if(getEl('flightADTmain').selectedIndex==-1){
			getEl('flightADTmain').selectedIndex=0;
		}

		if(getEl('affserviceclass') && getEl('serviceclass')){
			getEl('affserviceclass').selectedIndex=getEl('serviceclass').selectedIndex;
		}
		validateMPlogin(); 
	}

}

// ADDED FROM 52008_fsne2.js
var flightschildandseniorvisible = false;
function showChildandSenior(){
	flightschildandseniorvisible = true;
	getEl("childseniorcompact").style.display = "none";
	getEl("childseniorfull").style.display = "block";
	getEl("flightADT").selectedIndex = getEl("flightADTmain").selectedIndex+1;
}

function showMoreSearch(){
	if (getEl("ff29upprclnoarrowa").style.display != "none"){
		getEl("ff29upprclnoarrowa").style.display = "none";
		getEl("ff29upprclnoarrowb").style.display = "inline";
		getEl("ff29upprclnolink").style.display = "none";
		getEl("ff29upprclno").style.display = "block";
	} else {
		getEl("ff29upprclnoarrowa").style.display = "inline";
		getEl("ff29upprclnoarrowb").style.display = "none";
		getEl("ff29upprclnolink").style.display = "inline";
		getEl("ff29upprclno").style.display = "none";
	}
}

function openAiportLookupWin(url){
	// START -- FSNE Part 1 Changes for Autosuggest
	var shopFrom0Val = getEl("shop_from0").value;
	var shopTo0Val = getEl("shop_to0").value;
	shopFrom0Val = shopFrom0Val.replace("(","");
	shopTo0Val = shopTo0Val.replace("(","");
	getEl("shop_from0").value=shopFrom0Val;
	getEl("shop_to0").value=shopTo0Val;
	//END -- FSNE Part 1 Changes for Autosuggest

	var tempurl = document.location.href;
	if (tempurl.indexOf('www.united.com')!=-1){
		document.domain = "united.com";
	}
	popWin = window.open(url,'popDoc','width=539,height=500,scrollbars=yes,status=yes,resizable=yes,toolbar=no,dependent=yes','AirportLookup');
}

function ff29ToggleReturn(tempId){
	if (tempId == "wayOne")	{
		getEl("ff29Ritem").style.display="none";
		getEl("ff29Rlabel").style.display="none";
		if(getEl('SearchByFLEXDATE').checked==true) {
			getEl('SearchByPRICE').checked=true;
		}
		getEl("SearchByFLEXDATE").checked=false;
		getEl("SearchByFLEXDATE").disabled=true;
		getEl("SearchByFLEXDATE").style.display="none"; // from rel night
		getEl("SearchByFLEXDATElabel").style.display="none"; // from rel night

	} else {
		if(getEl("shop_serviceclass_outbound")){
			getEl("shop_serviceclass_inbound").selectedIndex = getEl("shop_serviceclass_outbound").selectedIndex;
		}
		
		if(getEl('shop_departtime')){
			getEl('shop_arrivetime').selectedIndex=getEl('shop_departtime').selectedIndex;
		}
		getEl("ff29Ritem").style.display="block";
		getEl("ff29Rlabel").style.display="block";//affFltSrchOpts

		if(getEl('affFltSrchOpts') && getEl('affFltSrchOpts').style.display == 'none') {
			getEl("cabinIB").style.display = ""; // To Hide cabinIB from One Way to Roundtrip
		}
		if(getEl("SearchByFLEXDATE").checked==true && getEl("SearchByFLEXDATE").disabled==true){
			getEl("SearchByPRICE").checked=true;
		}
		getEl("SearchByFLEXDATE").disabled=false;
		getEl("SearchByFLEXDATE").style.display="inline"; // from rel night
		getEl("SearchByFLEXDATElabel").style.display="inline"; // from rel night
	}
}

function ff29searchByUpdate(tempId){
	if (getEl("SearchByFLEXDATE").disabled==false){
		if (tempId == "SearchByFLEXDATE"){
			getEl("wayOne").disabled=true;
			ff29ToggleReturn('wayRound');
		} else {
			getEl("wayOne").disabled=false;
		}
	}
}

function ff29updateOthers(){
	currOrig = getEl("shop_from0").value;
	currDest = getEl("shop_to0").value;
	currOrig = currOrig.replace("(","");
	currDest = currDest.replace("(","");
	if(getEl("hotelD")){
		getEl("hotelD").value = currDest;
	}
	getEl("vacationO").value = currOrig;
	getEl("vacationD").value = currDest;
}


function ff29multiCity(){
	var telescopeQuery="";
	if(ff29modes == 2){
		telescopeQuery+="http://www.mileageplus.com/awardbooking/award/us/shopInput.do?shop_triptype=multicity&actionType=changeAwardTripType";
	} else {
		telescopeQuery+="http://travel.united.com/ube/core/us/shop.do?shop_triptype=multicity";
	}

	var shopFrom0Val = getEl("shop_from0").value;
	var shopTo0Val = getEl("shop_to0").value;
	shopFrom0Val = shopFrom0Val.replace("(","");
	shopTo0Val = shopTo0Val.replace("(","");
	telescopeQuery+="&shop_from0="+shopFrom0Val;
	telescopeQuery+="&shop_to0="+shopTo0Val;

	if(getEl("fromnearby1").checked==true) {telescopeQuery+="&shop_fromnearbyairport0=on";}
	if(getEl("tonearby1").checked==true) {telescopeQuery+="&shop_tonearbyairport0=on";}
	telescopeQuery+="&shop_departmonth0="+getEl("shop_departmonth").value;
	telescopeQuery+="&shop_departday0="+getEl("shop_departday").value;
	telescopeQuery+="&shop_departtime0="+getEl("shop_departtime").value;
	telescopeQuery+="&shop_departmonth1="+getEl("shop_arrivemonth").value;
	telescopeQuery+="&shop_departday1="+getEl("shop_arriveday").value;
	telescopeQuery+="&shop_departtime1="+getEl("shop_arrivetime").value;

	if(getEl("SearchBySCHEDULE") && getEl("SearchBySCHEDULE").checked==true) {
		telescopeQuery+="&shop_viewresults=SCHEDULE";
	}
	if(getEl("SearchByPRICE") && getEl("SearchByPRICE").checked==true) {
		telescopeQuery+="&shop_viewresults=PRICE";
	}
	if(getEl("SearchByFLEXDATE") && getEl("SearchByFLEXDATE").checked==true) {
		telescopeQuery+="&shop_viewresults=PRICE";
	}
	if(getEl("flex_date_check") && getEl("flex_date_check").checked==true) {
		telescopeQuery+="&flex_date_check=true";
	}
	else{
		telescopeQuery+="&flex_date_check=false";
	}
	
	if(getEl("affstops")){
		telescopeQuery+="&shop_stops="+getEl("affstops").value;
	}

	if (flightschildandseniorvisible!=true){
		telescopeQuery+="&shop_passenger0="+getEl("flightADTmain").value;
		telescopeQuery+="&shop_passenger1=0-SRC";
		telescopeQuery+="&shop_passenger2=0-CNN";
	} else {
		telescopeQuery+="&shop_passenger0="+getEl("flightADT").value;
		telescopeQuery+="&shop_passenger1="+getEl("flightSRC").value;
		telescopeQuery+="&shop_passenger2="+getEl("flightCNN").value;
	}
	if(ff29modes == 2){//miles search
		telescopeQuery+="&shop_serviceclass="+getEl("shop_serviceclass_outbound").value;
		if(getEl('wayOne').checked){//oneway - set the inbound value = to outbound per business
			telescopeQuery+="&shop_serviceclass_inbound="+getEl("shop_serviceclass_outbound").value;
		} else {
			telescopeQuery+="&shop_serviceclass_inbound="+getEl("shop_serviceclass_inbound").value;
		}
	} else {

		var isRefundable="off";
		var tempServiceVal = getEl("serviceclass").value;
		if(getEl("refundable").checked){
			isRefundable="on";
			var tempServiceVal = getEl("serviceclass").value +"-REFUNDABLE";
			//getEl("serviceclass").value = tempServiceVal;
		} else {
			isRefundable="off";
			var tempServiceVal = getEl("serviceclass").value +"-NON-REFUNDABLE";
			//getEl("serviceclass").value = tempServiceVal;
		}

		telescopeQuery+="&shop_serviceclass="+tempServiceVal;
		telescopeQuery+="&shop_cabinrefundable="+isRefundable;
		telescopeQuery+="&shop_cabinclass="+ getEl("serviceclass").value;
		telescopeQuery+="&shop_promotioncode="+getEl("flightPromocode").value;
	}

	window.location=telescopeQuery;
}

function ff29popup(wURL){
	window.open(wURL,"ff29","width=550,height=400,top=20,left=20,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes")
}

function ff29DatesFlexible() {
	ua.vsTracking.addTag("v_ln","flex_dates")
	ua.vsTracking.addTag("v_pc","Fare_Finder")

	var telescopeQuery="";
	telescopeQuery+="http://travel.united.com/ube/core/us/shop.do?shop_viewresults=FLEXDATE&shop_triptype=roundtrip";
	var shopFrom0Val = getEl("shop_from0").value;
	var shopTo0Val = getEl("shop_to0").value;
	shopFrom0Val = shopFrom0Val.replace("(","");
	shopTo0Val = shopTo0Val.replace("(","");
	getEl("shop_from0").value=shopFrom0Val;
	getEl("shop_to0").value=shopTo0Val;
	telescopeQuery+="&shop_from0="+getEl("shop_from0").value;
	telescopeQuery+="&shop_to0="+getEl("shop_to0").value;
	if (getEl("fromnearby1").checked==true) {telescopeQuery+="&shop_fromnearbyairport0=on";}
	if (getEl("tonearby1").checked==true) {telescopeQuery+="&shop_tonearbyairport0=on";}
	telescopeQuery+="&shop_departmonth0="+getEl("shop_departmonth").value;
	telescopeQuery+="&shop_departday0="+getEl("shop_departday").value;
	telescopeQuery+="&shop_departtime0="+getEl("shop_departtime").value;
	telescopeQuery+="&shop_arrivemonth0="+getEl("shop_arrivemonth").value;
	telescopeQuery+="&shop_arriveday0="+getEl("shop_arriveday").value;
	telescopeQuery+="&shop_arrivetime0="+getEl("shop_arrivetime").value;

	if (flightschildandseniorvisible!=true) {
		telescopeQuery+="&shop_passenger0="+getEl("flightADTmain").value;
		telescopeQuery+="&shop_passenger1=0-SRC";
		telescopeQuery+="&shop_passenger2=0-CNN";
	} else {
		telescopeQuery+="&shop_passenger0="+getEl("flightADT").value;
		telescopeQuery+="&shop_passenger1="+getEl("flightSRC").value;
		telescopeQuery+="&shop_passenger2="+getEl("flightCNN").value;
	}
	var isRefundable="off";
	var tempServiceVal = getEl("serviceclass").value;
	if(getEl("refundable").checked){
		isRefundable="on";
		var tempServiceVal = getEl("serviceclass").value +"-REFUNDABLE";
	} else {
		isRefundable="off";
		var tempServiceVal = getEl("serviceclass").value +"-NON-REFUNDABLE";
	}

	telescopeQuery+="&shop_serviceclass="+tempServiceVal;
	telescopeQuery+="&shop_cabinrefundable="+isRefundable;
	telescopeQuery+="&shop_cabinclass="+ getEl("serviceclass").value;
	telescopeQuery+="&shop_promotioncode="+getEl("flightPromocode").value;
	window.location=telescopeQuery;
}


function clrErrMsgs() {
	var adultLabel = getEl('lbl-pass-adlt');
	if (adultLabel) {
		adultLabel.className = adultLabel.className.replace('err','');
	}

	if (getEl('srvErr0')) {
		getEl('srvErr0').innerHTML='';
		getEl('srvErr0').style.display='none';
	}

	var adultLabel2 = getEl('lbl-pass0') ;
	if (adultLabel2) {
		adultLabel2.className = adultLabel2.className.replace('err','');
	}
}

/* START: Code added for MP remember me option - FSNE Part 2 */
function rememberMEC(mpEmail) {
	var today = new Date();
	var expires = new Date();
	expires.setTime(today.getTime() + 1000*60*60*24*365*2)
	ua.utils.setCookie("rememberME", mpEmail, expires);
}
/* END: Code added for MP remember me option - FSNE Part 2 */

