var $j = jQuery.noConflict();

/* setting values for sprop11 */

function checkTxtBoxValue(objId){
	if(document.getElementById(objId).value == '' || document.getElementById(objId).value == null) {
		return false;	
	}
}

	/*** JS required for Smart Box : Starts ***/

	/**
	 *  author:		Timothy Groves - http://www.brandspankingnew.net
	 *	version:	1.2 - 2006-11-17
	 *              1.3 - 2006-12-04
	 *              2.0 - 2007-02-07
	 *              2.1.1 - 2007-04-13
	 *              2.1.2 - 2007-07-07
	 *              2.1.3 - 2007-07-19
	 *
	 */

if (typeof(bsn) == "undefined")
	_b = bsn = {};


if (typeof(_b.Autosuggest) == "undefined")
	_b.Autosuggest = {};
//else
	//alert("Autosuggest is already set!");


_b.AutoSuggest = function (id, param)
{
	// no DOM - give up!
	//
	if (!document.getElementById)
		return 0;
	
	
	// get field via DOM
	//
	this.fld = _b.DOM.gE(id);

	if (!this.fld)
		return 0;
	
	
	// init variables
	//
	this.sInp 	= "";
	this.nInpC 	= 0;
	this.aSug 	= [];
	this.iHigh 	= 0;
	
	// parameters object
	//
	this.oP = param ? param : {};
	
	// defaults	
	//
	var k, def = {minchars:1, meth:"get", varname:"input", className:"autosuggest", timeout:2500, delay:10, offsety:-5, shownoresults: true, noresults: "No results!", maxheight: 250, cache: true, maxentries: 25};
	for (k in def)
	{
		if (typeof(this.oP[k]) != typeof(def[k]))
			this.oP[k] = def[k];
	}
	
	
	// set keyup handler for field
	// and prevent autocomplete from client
	//
	var p = this;
	
	// NOTE: not using addEventListener because UpArrow fired twice in Safari
	//_b.DOM.addEvent( this.fld, 'keyup', function(ev){ return pointer.onKeyPress(ev); } );
	
	this.fld.onkeypress 	= function(ev){ return p.onKeyPress(ev); };
	this.fld.onkeyup 		= function(ev){ return p.onKeyUp(ev); };
	this.fld.onkeydown 		= function(ev){ return p.onKeyDown(ev); };
	
	this.fld.setAttribute("autocomplete","off");
};

_b.AutoSuggest.prototype.onKeyPress = function(ev)
{
	
	var key = (window.event) ? window.event.keyCode : ev.keyCode;

	// set responses to keydown events in the field
	// this allows the user to use the arrow keys to scroll through the results
	// ESCAPE clears the list
	// TAB sets the current highlighted value
	//
	var RETURN = 13;
	var TAB = 9;
	var ESC = 27;
	
	var bubble = 1;

	switch(key)
	{
		case RETURN:
			this.setHighlightedValue("enter");
            return this.iHigh == false;

		case ESC:
			this.clearSuggestions();
			break;
		
		case TAB:
			this.setHighlightedValue();
			break;
	}

	return bubble;
};

_b.AutoSuggest.prototype.onKeyDown = function(ev)
{
	
	var key = (window.event) ? window.event.keyCode : ev.keyCode;

	// set responses to keydown events in the field
	// this allows the user to use the arrow keys to scroll through the results
	// ESCAPE clears the list
	// TAB sets the current highlighted value
	//
	var RETURN = 13;
	var TAB = 9;
	var ESC = 27;
	
	var bubble = 1;
	
	switch(key)
	{
		case TAB:
			this.setHighlightedValue();
			break;
	}

	return bubble;
};

_b.AutoSuggest.prototype.onKeyUp = function(ev)
{
	var key = (window.event) ? window.event.keyCode : ev.keyCode;
	
	// set responses to keydown events in the field
	// this allows the user to use the arrow keys to scroll through the results
	// ESCAPE clears the list
	// TAB sets the current highlighted value
	//

	var ARRUP = 38;
	var ARRDN = 40;
	
	var bubble = 1;

	switch(key)
	{
		case ARRUP:
			this.changeHighlight(key);
			bubble = 0;
			break;


		case ARRDN:
			this.changeHighlight(key);
			bubble = 0;
			break;
		
		default:
			this.getSuggestions(this.fld.value);
	}

	return bubble;
};

_b.AutoSuggest.prototype.getSuggestions = function (val)
{
	
	// if input stays the same, do nothing
	//
	if (val == this.sInp)
		return 0;
	
	// kill list
	//
	_b.DOM.remE(this.idAs);
	
	this.sInp = val;
	
	// input length is less than the min required to trigger a request
	// do nothing
	//
	if (val.length < this.oP.minchars)
	{
		this.aSug = [];
		this.nInpC = val.length;
		return 0;
	}
	
	var ol = this.nInpC; // old length
	this.nInpC = val.length ? val.length : 0;
	
	// if caching enabled, and user is typing (ie. length of input is increasing)
	// filter results out of aSuggestions from last request
	//
	var l = this.aSug.length;
	
	var pointer = this;
	var input = this.sInp;
	clearTimeout(this.ajID);
	this.ajID = setTimeout( function() { pointer.doAjaxRequest(input) }, this.oP.delay );

	return false;
};


_b.AutoSuggest.prototype.doAjaxRequest = function (input)
{
	// check that saved input is still the value of the field
	//
	if (input != this.fld.value)
		return false;
	
	var pointer = this;
	
	// create ajax request
	//
	if (typeof(this.oP.script) == "function") {
		var url = this.oP.script(encodeURIComponent(this.sInp));
	} else {
		var url = this.oP.script+"/"+encodeURIComponent(this.sInp);
	}
	
	if (!url)
		return false;
	
	var meth = this.oP.meth;
	var input = this.sInp;
	
	var onSuccessFunc = function (req) { pointer.setSuggestions(req, input) };
	var onErrorFunc = function (status) { /*alert("AJAX error: "+status);*/ };

	var myAjax = new _b.Ajax();
	myAjax.makeRequest( url, meth, onSuccessFunc, onErrorFunc );
};

_b.AutoSuggest.prototype.setSuggestions = function (req, input)
{
	// if field input no longer matches what was passed to the request
	// don't show the suggestions
	//
	if (input != this.fld.value)
		return false;
	
	this.aSug = [];
	
	if (this.oP.json)
	{
		var jsondata = eval('(' + req.responseText + ')');

		if(navigator.appVersion.indexOf('MSIE') != -1){
			jsonDateLen = jsondata.results.length - 1;
		} else {
			jsonDateLen = jsondata.results.length;
		}

		for (var i=0;i<jsonDateLen;i++)
		{
			this.aSug.push(  { 'id':jsondata.results[i].id, 'value':jsondata.results[i].value, 'info':jsondata.results[i].info }  );
		}
	}
	
	this.idAs = "as_"+this.fld.id;

	this.createList(this.aSug);
	
	if(navigator.appVersion.indexOf('MSIE 6') != -1) {
		var widthval;
		if(this.fld.id == 'GH_search_field'){
			widthval = $j("#GH_search_field").width();
		}else if(this.fld.id == 'GH_footer_search_field'){
			widthval = $j("#GH_footer_search_field").width() + 5;
		}else{
			widthval = $j("#as_ul").width();
		}
		$j("#as_ul").width(widthval+3);
		var ulWidth  = $j("#as_ul").width();
		var ulHeight = $j("#as_ul").height();
		$j("#as_ifrm").width(ulWidth+3);
		$j("#as_ifrm").height(ulHeight+3);
		if(widthval != null)
			document.getElementById("as_ifrm").style.border = "none";
	}
};


_b.AutoSuggest.prototype.createList = function(arr)
{
	var pointer = this;
	
	// get rid of old list
	// and clear the list removal timeout
	//
	_b.DOM.remE(this.idAs);
	this.killTimeout();
	
	// if no results, and shownoresults is false, do nothing
	//
	if (arr.length == 0 && !this.oP.shownoresults)
		return false;
	
	// create holding div
	//
	var div = _b.DOM.cE("div", {id:this.idAs, className:this.oP.className});	

	try {
		document.execCommand('BackgroundImageCache', false, true);
	} catch(e) {}
	
	//Fix for IE6 selectbox Issue
	if(navigator.appVersion.indexOf('MSIE 6') != -1) {
		var iframe = _b.DOM.cE("iframe", {id:"as_ifrm",className:"ifram"});

		div.appendChild(iframe);
	}

	// create and populate ul
	//
	var ul = _b.DOM.cE("ul", {id:"as_ul"});
	
	// loop throught arr of suggestions
	// creating an LI element for each suggestion
	//
	for (var i=0;i<arr.length;i++)
	{
		// format output with the input enclosed in a EM element
		// (as HTML, not DOM)
		//
		var srchUrl = arr[i].info;
		var val = arr[i].value;
		var st = val.toLowerCase().indexOf( this.sInp.toLowerCase() );
		var output = val.substring(0,st) + val.substring(st, st+this.sInp.length) + val.substring(st+this.sInp.length);
		
		var span 		= _b.DOM.cE("span", {}, output, true);
	
		var a 			= _b.DOM.cE("a", { href:"#" });
		
		a.appendChild(span);
		
		a.name = i+1;
		a.onclick = function () { pointer.setHighlightedValue("click"); return false; };
		a.onmouseover = function () { pointer.setHighlight(this.name); };
		
		if(srchUrl.indexOf("hotel-detail") != -1){
			var li = _b.DOM.cE(  "li", {className:"hotelsIcon"}, a  );
		}else if(srchUrl.indexOf("/hotels/") != -1){
			var li = _b.DOM.cE(  "li", {className:"hotelBrandIcon"}, a  );
		} else {
			var li = _b.DOM.cE(  "li", {className:"cityIcon"}, a  );
		}
		
		ul.appendChild( li );

	}
	
	
	// no results
	//
	if (arr.length == 0 && this.oP.shownoresults)
	{
		var li = _b.DOM.cE(  "li", {className:"as_warning"}, this.oP.noresults  );
		ul.appendChild( li );
	}
	
	div.appendChild( ul );

	// get position of target textfield
	// position holding div below it
	// set width of holding div to width of field
	//
	var pos = _b.DOM.getPos(this.fld);
	
	if(navigator.appVersion.indexOf('MSIE') != -1) {
		div.style.left 		= (pos.x)+ "px";
	} else {
		div.style.left 		= (pos.x - 1)+ "px";
	}
	if(this.fld.id != "dest_interest" && this.fld.id != "destInterest" && this.fld.id != "destination" && this.fld.id != "leavingFrom1" && this.fld.id != "goingTo1" && this.fld.id != "leavingFrom2" && this.fld.id != "goingTo2" && this.fld.id != "leavingFrom3" && this.fld.id != "goingTo3" && this.fld.id != "leavingFrom4" && this.fld.id != "goingTo4"&& this.fld.id != "leavingFromFL" && this.fld.id != "goingToFL" && this.fld.id != "valeavingFrom" && this.fld.id != "vagoingTo" && this.fld.id != "trvCity" && this.fld.id != "pickupCity" && this.fld.id != "dropoffCity")
	{
		div.style.width 	= this.fld.offsetWidth + "px";
	}
	
	// set mouseover functions for div
	// when mouse pointer leaves div, set a timeout to remove the list after an interval
	// when mouse enters div, kill the timeout so the list won't be removed
	//
	div.onmouseover 	  = function(){ pointer.killTimeout() };
	div.onmouseout 		  = function(){ pointer.resetTimeout() };
	document.body.onclick = function(){ pointer.resetTimeout() };
	// add DIV to document
	//
	document.getElementsByTagName("body")[0].appendChild(div);

	if(this.fld.id == "GH_footer_search_field"){
		if(navigator.appVersion.indexOf('MSIE') != -1) {
			div.style.top 		= ((pos.y + this.oP.offsety - $j("#as_ul").height()) + 6) + "px";
		} else {
			div.style.top 		= ((pos.y + this.oP.offsety - $j("#as_ul").height()) + 3) + "px";
		}
	} else {
		div.style.top 		= ( pos.y + this.fld.offsetHeight + this.oP.offsety + 2 ) + "px";
	}
	
	// currently no item is highlighted
	//
	this.iHigh = 0;
	
	// remove list after an interval
	//
	var pointer = this;
	this.toID = setTimeout(function () { pointer.clearSuggestions() }, this.oP.timeout);
};

_b.AutoSuggest.prototype.changeHighlight = function(key)
{	
	var list = _b.DOM.gE("as_ul");
	if (!list)
		return false;
	
	var n;

	if (key == 40)
		n = this.iHigh + 1;
	else if (key == 38)
		n = this.iHigh - 1;
	
	
	if (n > list.childNodes.length)
		n = list.childNodes.length;
	if (n < 1)
		n = 1;
	
	
	this.setHighlight(n);
};

_b.AutoSuggest.prototype.setHighlight = function(n)
{
	var list = _b.DOM.gE("as_ul");
	if (!list)
		return false;
	
	if (this.iHigh > 0)
		this.clearHighlight();
	
	this.iHigh = Number(n);
	
	$j(list.childNodes[this.iHigh-1]).addClass("as_highlight")

	this.killTimeout();
};


_b.AutoSuggest.prototype.clearHighlight = function()
{
	var list = _b.DOM.gE("as_ul");
	if (!list)
		return false;
	
	if (this.iHigh > 0)
	{
		$j(list.childNodes[this.iHigh-1]).removeClass("as_highlight")
		this.iHigh = 0;
	}
};


_b.AutoSuggest.prototype.setHighlightedValue = function (eventFired)
{
	if (this.iHigh)
	{
		this.sInp = this.fld.value = this.aSug[ this.iHigh-1 ].value;
		
		// move cursor to end of input (safari)
		//
		this.fld.focus();
		if (this.fld.selectionStart)
			this.fld.setSelectionRange(this.sInp.length, this.sInp.length);
		

		this.clearSuggestions();

		var srchUrl = this.aSug[ this.iHigh-1 ].info;
		if(srchUrl.indexOf("hotel-detail") != -1){
			var hotelFlag = true;
			createCookieObj("HotelDetailDirect", "1");
		} else {
			var hotelFlag = false;
		}
		
		if(this.fld.id == "dealCity"){
			createCookieObj("dealsOnMapTerm", this.sInp, 1);
		}else if(this.fld.id == "destination" || this.fld.id == "destInterest" || this.fld.id == "dest_interest"){
			createCookieObj("dealsAdvSrchTerm", this.sInp, 1);
		} else {
			createCookieObj("searchTerm", this.sInp, 1);
			createCookieObj('curSearchTerm', 1);
		}
		// pass selected object to callback function, if exists
		//
		if (typeof(this.oP.callback) == "function")
			this.oP.callback( this.aSug[this.iHigh-1], eventFired, hotelFlag);
	}
};


_b.AutoSuggest.prototype.killTimeout = function()
{
	clearTimeout(this.toID);
};

_b.AutoSuggest.prototype.resetTimeout = function()
{
	clearTimeout(this.toID);
	var pointer = this;
	this.toID = setTimeout(function () { pointer.clearSuggestions() }, 1000);
};


_b.AutoSuggest.prototype.clearSuggestions = function ()
{
	
	this.killTimeout();
	
	var ele = _b.DOM.gE(this.idAs);
	var pointer = this;
	if (ele)
	{
		var fade = new _b.Fader(ele,1,0,250,function () { _b.DOM.remE(pointer.idAs) });
	}
};


// AJAX PROTOTYPE _____________________________________________

if (typeof(_b.Ajax) == "undefined")
	_b.Ajax = {};

_b.Ajax = function ()
{
	this.req = {};
	this.isIE = false;
};

_b.Ajax.prototype.makeRequest = function (url, meth, onComp, onErr)
{
	
	if (meth != "POST")
		meth = "GET";
	
	this.onComplete = onComp;
	this.onError = onErr;
	
	var pointer = this;
	
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest)
	{
		this.req = new XMLHttpRequest();
		this.req.onreadystatechange = function () { pointer.processReqChange() };
		this.req.open("GET", url, true); //
		this.req.send(null);
	// branch for IE/Windows ActiveX version
	}
	else if (window.ActiveXObject)
	{
		this.req = new ActiveXObject("Microsoft.XMLHTTP");
		if (this.req)
		{
			this.req.onreadystatechange = function () { pointer.processReqChange() };
			this.req.open(meth, url, true);
			this.req.send();
		}
	}
};

_b.Ajax.prototype.processReqChange = function()
{
	
	// only if req shows "loaded"
	if (this.req.readyState == 4) {
		// only if "OK"
		if (this.req.status == 200)
		{
			this.onComplete( this.req );
		} else {
			this.onError( this.req.status );
		}
	}
};


// DOM PROTOTYPE _____________________________________________

if (typeof(_b.DOM) == "undefined")
	_b.DOM = {};

/* create element */
_b.DOM.cE = function ( type, attr, cont, html )
{
	var ne = document.createElement( type );
	if (!ne)
		return 0;
		
	for (var a in attr)
		ne[a] = attr[a];
	
	var t = typeof(cont);
	
	if (t == "string" && !html)
		ne.appendChild( document.createTextNode(cont) );
	else if (t == "string" && html)
		ne.innerHTML = cont;
	else if (t == "object")
		ne.appendChild( cont );

	return ne;
};

/* get element */
_b.DOM.gE = function ( e )
{
	var t=typeof(e);
	if (t == "undefined")
		return 0;
	else if (t == "string")
	{
		var re = document.getElementById( e );
		if (!re)
			return 0;
		else if (typeof(re.appendChild) != "undefined" )
			return re;
		else
			return 0;
	}
	else if (typeof(e.appendChild) != "undefined")
		return e;
	else
		return 0;
};

/* remove element */
_b.DOM.remE = function ( ele )
{
	var e = this.gE(ele);
	
	if (!e)
		return 0;
	else if (e.parentNode.removeChild(e))
		return true;
	else
		return 0;
};

/* get position */
_b.DOM.getPos = function ( e )
{
	var e = this.gE(e);

	var obj = e;

	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	
	var obj = e;
	
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;

	return {x:curleft, y:curtop};
};

// FADER PROTOTYPE _____________________________________________

if (typeof(_b.Fader) == "undefined")
	_b.Fader = {};

_b.Fader = function (ele, from, to, fadetime, callback)
{	
	if (!ele)
		return 0;
	
	this.e = ele;
	
	this.from = from;
	this.to = to;
	
	this.cb = callback;
	
	this.nDur = fadetime;
		
	this.nInt = 50;
	this.nTime = 0;
	
	var p = this;
	this.nID = setInterval(function() { p._fade() }, this.nInt);
};


_b.Fader.prototype._fade = function()
{
	this.nTime += this.nInt;
	
	var ieop = Math.round( this._tween(this.nTime, this.from, this.to, this.nDur) * 100 );
	var op = ieop / 100;
	
	if (this.e.filters) // internet explorer
	{
		try
		{
			this.e.filters.item("DXImageTransform.Microsoft.Alpha").opacity = ieop;
		} catch (e) { 
			// If it is not set initially, the browser will throw an error.  This will set it if it is not set yet.
			this.e.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity='+ieop+')';
		}
	}
	else // other browsers
	{
		this.e.style.opacity = op;
	}
	
	
	if (this.nTime == this.nDur)
	{
		clearInterval( this.nID );
		if (this.cb != undefined)
			this.cb();
	}
};

_b.Fader.prototype._tween = function(t,b,c,d)
{
	return b + ( (c-b) * (t/d) );
};
	/*** JS required for Smart Box : Ends ***/
/*** Travel - Channel Header & Footer JS : Ends ***/

/*** Travel - Auth Code JS : Starts ***/ 

var rsp_cookie=getCk("RSP_COOKIE");var loginId=null;if(rsp_cookie){b64loginId=getValue(rsp_cookie,"name");if(b64loginId){loginId=base64Decode(b64loginId);}}function getCk(M){var c=document.cookie.indexOf(M+"=");if(c==-1){return null;}c=document.cookie.indexOf("=",c)+1;var p=document.cookie.indexOf(";",c);if(p==-1){p=document.cookie.length;}return unescape(document.cookie.substring(c,p));}function getValue(t,p){var M=t.split("&");nmvalpos=0;while(nmvalpos<M.length){if(M[nmvalpos].indexOf(p+"=")>=0){var m=M[nmvalpos].indexOf("=")+1;var c=M[nmvalpos].substring(m,M[nmvalpos].length);return c;}nmvalpos++;}return null;}function base64Decode(u){var E=new Array();var T=0,m=0,G,k=0,M=-1,p=0;var t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];var X;for(T=0;T<u.length;T++){X=u.charAt(T);if("A"<=X&&X<="Z"){G=u.charCodeAt(T)-65;}else{if("a"<=X&&X<="z"){G=u.charCodeAt(T)-97+26;}else{if("0"<=X&&X<="9"){G=u.charCodeAt(T)-48+52;}else{if(X=="+"){G=62;}else{if(X=="/"){G=63;}else{continue;}}}}}M++;switch(M%4){case 0:k=G;continue;case 1:p=(k<<2)|(G>>4);k=G&15;break;case 2:p=(k<<4)|(G>>2);k=G&3;break;case 3:p=(k<<6)|(G>>0);k=G&0;break;}var L=p;if((L<32||L>126)&&(L!=13)&&(L!=10)){E[m++]="<";E[m++]=t[((L/16)&15)];E[m++]=t[((L/1)&15)];E[m++]=">";}else{E[m++]=String.fromCharCode(L);}}return E.join("");}

function checkAuth(id){
	var loginStr = null;
	var aolBrowser = (navigator.userAgent.toLowerCase().indexOf("aol") != -1)?1:0;
	
	if(typeof _sns_isLoggedIn != "undefined"){
		if(_sns_isLoggedIn == 1){	
			if(loginId != null){
				if(aolBrowser){		
					loginStr = "";	
					loginStr += "<span id='userName'>Hi "
					+loginId
					+"</span>";
				}else{
					loginStr = "";	
					loginStr += "<span id='userName'>Hi "
					+loginId
					+"</span>"
					+"<br />"
					+"<span id='sns_logout'><a href='#' onclick='javascript:userLogout();return false;'>Log out</a></span>"
				}
				createCookieObj("travelupstate", "1", "");
			}else{
				loginStr = "";
				loginStr += "<a id='sns_login' href='javascript:userLogin();'>Log In</a>";	
			}
		} else {
			loginStr = "";
			loginStr += "<a id='sns_login' href='javascript:userLogin();'>Log In</a>";	
		}
	} else {
		loginStr = "";
		loginStr += "<a id='sns_login' href='javascript:userLogin();'>Log In</a>";	
	}
	
	document.getElementById(id).innerHTML = loginStr;
}

function userLogin(){
	var url = window.location.toString();
	var list =  escape(url);
	var startUrl = "/_cqr/login/login.psp?mcState=initialized&sitedomain=travel.aol.com&authLev=1&seamless=y&lang=en&locale=us&siteState=OrigUrl%3d";
	var finalUrl = snsURL+ startUrl +list;
	window.location.href = finalUrl;
}

function userLogout(){
	var url = window.location.toString();
	var list =  escape(url);
	var startUrl = "/_cqr/logout/mcLogout.psp?mcState=initialized&sitedomain=travel.aol.com&authLev=1&seamless=y&lang=en&locale=us&siteState=OrigUrl%3d";
	var finalUrl = snsURL+ startUrl +list;
	eraseCookieObj("travelupstate");
	window.location.href = finalUrl;
}

/*** Travel - Auth Code JS : Ends ***/

/*** Travel - ClaraBridge - Feedback JS : Starts ***/

/* fbLink v1.0b
/*  */
var _fBsp='%3A\\/\\/',_fBrp='%3A//',_fBd=document,_fBw=window,_fBr=escape(_fBw.location.href),_sW=screen.width,_sH=screen.height,_fBtm=(new Date()).getTime(),_fBpv=escape(_fBd.referrer);
function _fBe(_fBarg){_fBs=_fBsp+',\\/,\\.,-,_,'+_fBrp+',%2F,%2E,%2D,%5F';_fBa=_fBs.split(',');for(i=0;i<5;i++){eval('_fBarg=_fBarg.replace(/'+_fBa[i]+'/g,_fBa[i+5])')}return _fBarg;}
function _fBsG () {var _chG = typeof 's_channel' == 'undefined'? s_channel : "";return _chG;}
function _fBsH () {var _chH = 'channel' in s_265? s_265.channel : "";_chH = _chH=='undefined'?'':_chH;return _chH;}
function fBch() {var _ch = typeof s_265 == 'undefined'?_fBsG():_fBsH();return _ch;}
var _fBr=encodeURIComponent(window.location.href);
var _fBh=362;
var _fBw=452;
var _fByt=(((screen.height-_fBh)/2)-100);
var _fBxl=((screen.width-_fBw)/2);
function fBo(_sid){var _fBhref = 'http://feedback.aol.com/rs/rs.php?sid='+_sid;window.open(_fBhref+'&referer='+_fBr+'&ch='+fBch(),'feedback','width='+_fBw+',height='+_fBh+',screenX='+_fBxl+',screenY='+_fByt+',top='+_fByt+',left='+_fBxl+',resizable=yes,copyhistory=yes,scrollbars=no');return false;}
function fBo2(_sid){_fBhref = 'http://feedback.aol.com/rs/rs.php?sid='+_sid;_fBw.open(_fBhref+'&time1='+_fBtm+'&time2='+(new Date()).getTime()+'&referer='+_fBe(_fBr)+'&prev='+_fBe(_fBpv)+'&width='+_sW+'&height='+_sH+'&ch='+fBch(),'feedback','width=535,height=425,screenX='+((_sW-535)/2)+',screenY='+((_sH-425)/2)+',top='+((_sH-425)/2)+',left='+((_sW-535)/2)+',resizable=yes,copyhistory=yes,scrollbars=no');}

/*** Travel - claraBridge - Feedback JS : Ends ***/


/*** Travel - Common JS Functions : Starts ***/

/* Function to set a cookie */
function createCookieObj(name,value,days) {
        if (days) {
                var date = new Date();
                date.setTime(date.getTime()+(days*24*60*60*1000));
                var expires = "; expires="+date.toGMTString();
        } else {
			var expires = "";
		}
        document.cookie = name+"="+value+expires+"; path=/";
}

/* Function to read a cookie */
function readCookieVal(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for(var i=0;i < ca.length;i++) {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1,c.length);
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
        }
        return '';
}

/* Function to delete a cookie */
function eraseCookieObj(name) {
        createCookieObj(name,"",-1);
}


/* Function to find the X-Position of a object in the page*/
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

/* Function to find the Y-Position of a object in the page*/
function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}


function globalInit() {
	var options = {
		script:"/travel-guide/smartBox",
		minchars:3,
		varname:"query",
		json:true,
		shownoresults:false,
		maxresults:10,
		timeout:10000,
		delay:1,
		callback: function (obj, eventFired, hotelFlag){
			if(eventFired == "enter") {
				if (obj.info) {
					location.href = obj.info;
					return false;
				} else {
					$j('#GH_search_form').submit(function(){
						return false;
					});
				}
			} else {
				location.href = obj.info;
				return false;				
			}
		}
	};
	var as_json = new bsn.AutoSuggest("GH_search_field", options);
	
	var options = {
		script:"/travel-guide/smartBox",
		minchars:3,
		varname:"query",
		json:true,
		shownoresults:false,
		maxresults:10,
		timeout:10000,
		delay:1,
		callback: function (obj, eventFired, hotelFlag){
			if(eventFired == "enter") {
				if (obj.info) {
					location.href = obj.info;
					return false;
				} else {
					$j('#GH_footer_search_form').submit(function(){
						return false;
					});
				}
			} else {
				location.href = obj.info;
				return false;				
			}
		}
	};
	var as_json = new bsn.AutoSuggest("GH_footer_search_field", options);

	var savedGhostText = $j('#GH_search_field').val();
    $j('#GH_footer_search_field').val(savedGhostText).blur(function() {
    	if ($j.trim($j(this).val()) == '') $j(this).val(savedGhostText)
    }).focus(function() {
    	if ($j(this).val() == savedGhostText) $j(this).val('')
    });
	$j('#GH_footer_search_button').click(function() {
		var q = $j('#GH_footer_search_field').val()
		if ($j.trim(q) == savedGhostText || $j.trim(q) == '') return false; 
	})
    if (navigator.appVersion.indexOf('MSIE 6') != -1) {
        $j('#GH_nav').find('.GH_nav_list').each(function() {
            var myUL = $j(this).find('ul');
            $j(this).append('<iframe height="'+myUL.height()+'" width="'+myUL.width()+'" frameborder="0" class="menuIfrm" style="top:'+$j(this).height()+'"></iframe>')
        })
    }
}

$j(document).ready(function() {globalInit()});

/*
name : globalHeader
file : jquery.globalheader.js
	owner : Dave Artz
(c) Copyright 2009 AOL LLC
	$LastChangedDate: 2010-01-14 11:24:00 -0500 (Thu, 14 Jan 2010) $
$Rev: 134091 $
///////////////////////////		
dependencies : jQuery 1.3.2, jquery.globalsearchbox.js
///////////////////////////
description: 
Build global header.
*/

(function($) {
$.fn.globalHeader = function( customOptions ) {
/** 
*	default options 
*		These can be overridden by passing in an updates customOptions object
*		
*		==== Using options ====
*		Example to change the moreText below: 
*			jQuery('#myElemId').globalHeader( { moreText : "I can change this value:" } );
*		
*
*       ==== Override Functions (if needed) ====	
*		You can also override the functions in the core Object. 
*		To do this, just add your method to the fn Object. 
*		An example to change the buildAuth method:
*		
*		jQuery('#myElemId').globalHeader( { fn : { buildAuth : function(){ 
*					alert('I am changing the buildAuth!');
*					// ... do stuff
*				} 
*			} 
*		});
*		
*		
*		==== Showing user as logged in (auth) ====
*		To show the header in a signed in state, alter the value of the auth Object.
*		A simple example:
*		jQuery('#myElemId').globalHeader( { auth : { authenticated : true } } );
*	
*/
var defaultOptions = {
		activeTab : null,
		moreLinks : [],
		morePromoCount : 2,
		moreText: 'You might also like:',
		moreAnd: 'and',
		moreMore: 'More',
		moreTextHeadline: 'More Sites You Might Like', 
		uiHat : '#GH_hat',
		uiHatLinks : '#GH_hat_links',
		uiHatTools : '#GH_hat_tools',
		uiNavLi : 'li.GH_nav_LI',
		uiNavADd : '.GH_nav_dd_A',
		auth : {
			doAuth: false,
			authenticated: false,
			authState: null,
			unauthState: null
		}, // search params
		search : {
			uiSearch: '#GH_search',
			params : {}
		}, // options passed on to globalSearchBox
		fn : {} // functions to be overridden
	},

	/* merged options */
	options = {},
	
	/** 
	*	target jQuery collection 
	*		Cache 'this' into the variable $this for later reference.
	*/
	$this = this,

	/* ui model*/
	ui = {},

	/* local data store */
	local = {
		activeTab : null,
		moreLinksBuilt : false
	},

	/* private functions, can be overriden, cannot be called directly */
	core = {
		/** 
		*	This method is automatically fired as soon as the plugin is called 
		*		It *CAN* be overriden following the above steps.
		*/			
		init : function(container) {
			ui.$d = $(document);
			ui.$c = $(container);
			ui.hat = $(options.uiHat)[0];	
			ui.hatLinks = $(options.uiHatLinks)[0];
			ui.$hatTools = $(options.uiHatTools);
			ui.$search = $(options.search.uiSearch);
			ui.$searchInput = ui.$search.find('input:first');
			ui.$searchSubmit = ui.$search.find('input:last');
			ui.$navLi = ui.$c.find(options.uiNavLi);
			ui.$navADd = ui.$c.find(options.uiNavADd);
			
			core.setActiveTab(null, options.activeTab);
			if (options.auth.doAuth) { core.buildAuth(); }
			core.buildMoreLinks();
			core.buildDropDowns();

			ui.$c.bind('setActiveTab', function(e,data) { core.setActiveTab(e,data); });
			ui.$c.bind('setAuthState', function(e,data) { core.buildAuth(e,data); });
			
			// focus on input field on init
			if (options.search.params.initFocus !== undefined && options.search.params.initFocus) {
				/**
				 * This immediately builds the autocomplete box.
				 */
				ui.$search.globalSearchBox(options.search.params);
			}
			else {
				/**
				* This event offloads the element building of the autocomplete box to user action
				*  This technique helps speed up the render of the header. It doesn't penalize users who aren't searching.
				*/					
				ui.$searchInput.bind('focus.GH', function(e) { core.buildSearch(e); }).attr('autocomplete','off');
				ui.$searchSubmit.bind('mouseover.GH', function(e) { core.buildSearch(e); });
				
				// preset search text
				if (options.search.params.searchText !== undefined && options.search.params.searchText !== '') {
					ui.$searchInput.val(options.search.params.searchText);
				}
			}		
		},
		
		/** 
		*	helper function to return private variables to extended functions 
		*		This method let's the code be minified, but still work with function overrides.
		*/
		getVars : function() {
			return {
				options : options,
				ui : ui,
				local : local							
			};					
		},
		
		/** 
		*	initialize global search box 
		*		This function has a dependency on an external file. jquery.globalSearchBox.js
		*		The globalSearchBox is for autocomplete. The autocomplete is not auto-magic. You will need to set up a channel dictionary
		*/		
		buildSearch : function(e) {
			ui.$searchInput.unbind('focus.GH');
			ui.$searchSubmit.unbind('mouseover.GH');
			if (e.target === ui.$searchInput[0]) {
				ui.$searchInput.addClass('GH_search_active').attr('value','');	
			}								
			ui.$search.globalSearchBox(options.search.params);
		},				
		
		/* build auth and unauth states 
		 * user can sent auth params on globalheader init or trigger a 'setAuthState' event with necessary auth params
		 * 
		 * eg. $("#GH_").trigger('setAuthState',{authenticated:false})
		 */
		buildAuth : function(e, authObject) {
			if (authObject !== undefined) {
				$.extend(true, options.auth, authObject);
			} 

			ui.$hatTools.empty().append((options.auth.authenticated) ? options.auth.authState : options.auth.unauthState);
		},

		/** 
		*	build more links drop down 
		*		This is not the 'nav' items drop down, it's for the 'other sites' links in the top hat
		*/
		buildMoreLinks : function() {
				var ml = options.moreLinks, 
					i = 0, 
					l = ml.length;
			
			if (l >= options.morePromoCount) {
				// Build 'More' Line
					var $hatMore = $('#GH_hat_more'),
						hatMore, 
						hatLi;

					if (!$hatMore.length) {
					hatLi = $('<li />').addClass('GH_hat_LI').append(
							hatMore = $('<ul />').attr('id','GH_hat_more').addClass('GH_hat_UL').append(
									$('<li />').addClass('GH_hat_LI').text(options.moreText + '\xa0 ')));
				
				for (; i < options.morePromoCount; i++) { 
					hatMore.append(
						$('<li />').addClass('GH_hat_LI').append(
							$('<a />').attr({ href : ml[i][1], target : (ml[i][2] !== undefined) ? ml[i][2] : '_self' }).addClass('GH_hat_A GH_hat_more_A').text(ml[i][0])).append((i < options.morePromoCount-1) ? ',\xa0' : ''));
				}
				
				// Build 'More' Call To Action
				if (l > options.morePromoCount) {
					hatMore.append(
						ui.$hatLIMore = $('<li />').addClass('GH_hat_LI GH_hat_LI_more').append('\xa0'+options.moreAnd+'\xa0').append(
									ui.$hatMoreLink = $('<a />').attr({ id : 'GH_hat_more_link', href : '#' }).addClass('GH_hat_A GH_hat_more_A').text(options.moreMore)));
				}
				hatLi.appendTo(ui.hatLinks);
					} else {
						
						ui.$hatMoreLink = $('#GH_hat_more_link');
						ui.$hatLIMore = ui.$hatMoreLink.parent();
						
					}
					
					ui.$hatMoreLink.bind('mouseover.GH', function(e) { core.showMoreLinks(e); });
				}
		},			
		
		/* build 'More' box 
		 * fade in/out more links drop-down when clicked */
		showMoreLinks : function(e) {
			e.preventDefault();
							
			if (local.moreLinksBuilt === false) {
				var ml = options.moreLinks.slice(options.morePromoCount),
					i = 0, l = ml.length,
					bp = Math.ceil(l/3), bp2 = Math.ceil(l/3*2),
					hatMoreList_1, hatMoreList_2, hatMoreList_3,hatMoreListLi;
				
				ui.$hatMoreList = $('<div />').attr('id','GH_more_list').append(
					$('<b />').attr('id','GH_more_list_lab').text(options.moreTextHeadline)).append(
					hatMoreList_1 = $('<ul />').addClass('GH_more_list_UL')).append(
					hatMoreList_2 = $('<ul />').addClass('GH_more_list_UL')).append(
					hatMoreList_3 = $('<ul />').addClass('GH_more_list_UL'));

				for (; i < l; i++) {
					hatMoreListLi = $('<li />').append(
						$('<a />').attr({ href : ml[i][1], target : (ml[i][2] !== undefined) ? ml[i][2] : '_self' }).text(ml[i][0]));
					if (i < bp) { hatMoreListLi.appendTo(hatMoreList_1); }
					else if (i < bp2) { hatMoreListLi.appendTo(hatMoreList_2); }
					else { hatMoreListLi.appendTo(hatMoreList_3); }
				}
				
				ui.$hatMoreList.css('left',ui.$hatLIMore.offset().left-ui.$c.offset().left+14).appendTo(ui.hat);
				local.moreLinksBuilt = true;	
			}
			
			if (ui.$hatMoreList.css('display') === 'none') {
				ui.$d.bind('mousemove.GHTEMP', function(e) { core.kill(e); });
				ui.$hatMoreList.fadeIn('fast');
				
			}
		},
		
		kill : function(e) {
			var $target = $(e.target);
			
			if ($target.closest('#GH_hat_more_link').length === 0 && $target.closest('#GH_more_list').length === 0) {
				ui.$d.unbind('mousemove.GHTEMP');
				ui.$hatMoreList.fadeOut('fast');
			}
		},			
		
		/* set a navigation tab as active */
		setActiveTab : function(e, activeTab) {				
			if(activeTab !== undefined && activeTab !== null) {
				if (local.activeTab !== null) { 
					local.activeTab.removeAttr('id'); 
					// If menu item has dropdowns
					if(local.activeTab.hasClass('GH_nav_list')) { 
						$('#GH_nav_act_B').removeAttr('id'); 
					} 
				}
				local.activeTab = ui.$navLi.eq(activeTab).attr('id', 'GH_nav_act');
				local.activeTab.children().eq(0).css('clear','both');
				// If menu item has dropdowns
				if(local.activeTab.hasClass('GH_nav_list')) {  
					local.activeTab.children().eq(0).wrapInner('<b id="GH_nav_act_B"></b>'); 
				}
			}
		},
		
		/* attach drop down functionality to navigation tab */
		buildDropDowns : function() {
			ui.$navLi.each(function() {
				var li = $(this);
				if(li.hasClass('GH_nav_list')){
					li.mouseover(function(){
						if(li.showtimer){
							clearInterval(li.showtimer);
							li.showtimer = null;
						}
                        li.find('iframe').css('display','block');
							li.addClass('GH_nav_list_open').find('ul').fadeIn('fast');
					}).mouseout(function(){
						li.showtimer=setTimeout(function(){
							if(li.showtimer){
								clearInterval(li.showtimer);
								li.showtimer=null;
							}
								li.removeClass('GH_nav_list_open').find('ul').fadeOut('fast');
                            li.find('iframe').css('display','none');
							},250);
					});
				}
			});	
		}
	};//end core			

	/* extend default options to include user's custom options */
	$.extend( true, options, defaultOptions, customOptions );	
			
	/* apply any overrides to core */
	$.extend( true, core, options.fn );

	/* begin */
	core.init($this);
	
	/* jQuery default behavior, return jQuery object */
	return $this;
};
})(jQuery);
/*
name : globalSearchBox
file : jquery.globalsearchbox.js
author : Ali Hasan
(c) Copyright 2009 AOL LLC
$LastChangedDate: 2009-11-20 14:21:28 -0500 (Fri, 20 Nov 2009) $
$Rev: 133745 $
///////////////////////////		
dependencies : jQuery 1.3.2
///////////////////////////
description: 
Build global search box.
*/

(function($){
$.fn.globalSearchBox = function( customOptions ) {
	/* default options */
var defaultOptions = {
		apiUrl : 'http://autocomplete.search.aol.com/autocomplete/get', // api url
		apiIt : 'ops-test', // internal tracking channel id
		apiOutput : 'json',  // data format for api to return
		apiCount : 8, // # of results for api to return
		apiQueryParam : 'q',
		apiDictionary : '',
		ui_form : '#GH_search_form', // search form
		ui_input : '#GH_search_field', // ui input field
		ui_submit : '#GH_search_button', // ui submit button
		ui_output : '#GH_search_results', // ui output container
		initSmartSearch : false,
		searchText : '',
		preserveGhostText : false,
		initFocus : false,
		fn : { } // functions to be overridden
	},

	/* merged options */
	options = {},
	
	/* target jQuery collection */
	$this = this,

	/* ui model*/
	ui = {},

	/* local data store */
	local = {
		ghostText : '',
		query : '',
		results : [],
		highlight : -1,
		$highlight : null,
		timer : null
	},
		
	/* private functions */
	core = { 
		/* create ui model, attach events */
		init : function(container) {
			ui.$c = $(container);
			ui.$input = $(options.ui_input);
			ui.$output = $(options.ui_output);
			ui.form = $(options.ui_form)[0];
			ui.submit = $(options.ui_submit)[0];
			
			local.ghostText = ui.$input.attr('defaultValue'); // save initial ghost text value
			ui.$input.attr('autocomplete','off').bind('focus.GH', function(e) { core.processInputFocus(e); }).bind('blur.GH', function(e) { core.processInputBlur(e); });
			$(ui.form).bind('submit.GH', function(e) { core.selectSuggestion(e); });

			// initialize type ahead functionality
			if (options.initSmartSearch) {
				// create api url
				options.apiUrl = options.apiUrl + '?it=' + options.apiIt + '&count=' + options.apiCount + '&output=' + options.apiOutput;
				if (options.apiDictionary !== '') {
					options.apiUrl = options.apiUrl + '&dict='+ options.apiDictionary;
				}
				// attach events
				ui.$input.bind('keyup.GH', function(e) { core.processKeyPress(e); });
				ui.$output.bind('mouseover.GH', function(e) { core.moveHighlightMouse(e); }).bind('mouseover.GH', function(e) { core.suspendBlurDetection(e); }).bind('mouseleave.GH', function(e) { core.resumeBlurDetection(e); }).bind('click.GH', function(e) { core.selectSuggestion(e); });	
			}
			// initial focus
			if (options.initFocus) {
				ui.$input.focus();
			}
			// preserve ghost text
			if (options.preserveGhostText) {
				ui.$label = $('<label />').attr('id','GH_search_label').text(local.ghostText).appendTo(ui.form);
				ui.$label.bind('click.GH_SL', function(e) { core.preserveGhostText(true); } );
				ui.$input.bind('keyup.GH_SL', function(e) { core.preserveGhostText(e); }).bind('click.GH_SL', function(e) { core.preserveGhostText(e); }).bind('blur.GH_SL', function(e) { setTimeout(function() { core.preserveGhostText(e); },250); });
			}
			// preset search text
			if (options.searchText !== '') {
				ui.$input.val(options.searchText);
			}
		},

		/* helper function to return private variables to extended functions */
		getVars : function() {
			return {
				options : options,
				ui : ui,
				local : local							
			};					
		},
					
		/* clear out text, primed for user's input */
		processInputFocus : function(e) {				
			ui.$input.addClass('GH_search_active').val((ui.$input.val() === local.ghostText) ? '' : ui.$input.val());			
		},
		
		/* close out flyout, restore text */
		processInputBlur : function(e) {
			ui.$input.removeClass('GH_search_active').val((ui.$input.val() === '') ? local.ghostText : ui.$input.val());
			core.displaySuggestions();
		},
		
		preserveGhostText : function(labelClick) {
			if (typeof labelClick === 'boolean' && labelClick) {
				ui.$input.focus();
			}
			ui.$input.unbind('keyup.GH_SL').unbind('click.GH_SL').unbind('blur.GH_SL');
			ui.$label.remove();
		},
		
		/* capture key press and determine if it is a navigation action or a query action */
		processKeyPress : function(e) {
			var kc = e.keyCode;
			if (kc === 38) {
				core.moveHighlightKey(-1);
			}
			else if (kc === 40) {
				core.moveHighlightKey(1);
			}
			else {
				var input = e.target,
					query = $.trim(input.value);
				
				if (query !== '') {	
					/* create delay to reduce number of api calls */
					if (local.timer !== null) { clearTimeout(local.timer); }
					local.timer = setTimeout(function(){ core.getSuggestions(query); },200);
				}
				else {
					core.displaySuggestions();
				}
			}
		},
			
		/* handle keyboard actions */
		moveHighlightKey : function(i) {
			if (local.$highlight !== null ) { local.$highlight.removeClass('GH_highlight'); }
			local.highlight = local.highlight + i;
			if (local.highlight >= local.results.length || local.highlight === -1) {
				local.highlight = -1;
				ui.$input.val(local.query);
			}
			else if (local.highlight < -1) {
				local.highlight = local.results.length - 1;						
			}
			if (local.highlight > -1) {
				local.$highlight = $(local.results[local.highlight]);
				local.$highlight.addClass('GH_highlight');
				ui.$input.val(local.$highlight.text());
			}
		},
		
		/* handle mouse actions */
		moveHighlightMouse : function(e) {
			var target = e.target;
			if (target.nodeName === 'B') { target = target.parentNode; }
			if (local.$highlight !== null ) { local.$highlight.removeClass('GH_highlight'); }
			local.highlight = local.results.index(target);
			local.$highlight = $(target).addClass('GH_highlight');
		},	
		
		/* submit form on mouse click */
		selectSuggestion : function(e) {
			e.preventDefault();
			if (e !== undefined && e.type === 'click') {
				var target = e.target;
				if (target.nodeName === 'B') { target = target.parentNode; }
				ui.$input.val($(target).text());
			}
			
			ui.$input.val($.trim(ui.$input.val()));
			
			if (ui.$input.val() !== '' && ui.$input.val() !== local.ghostText) {
				ui.form.submit();
			}
		},
		
		/* make api call */
		getSuggestions : function(query) {
			var url = options.apiUrl + '&' + options.apiQueryParam + '=' + query;

			$.ajax({
				dataType : 'jsonp',
				url: url,
				jsonp : 'cb',
				success: function ( jsonp ) {
					core.displaySuggestions(jsonp);
				}, 
				error : function () {
					core.displaySuggestions();
				}
			});	
		},
		
		suspendBlurDetection : function() { ui.$input.unbind('blur.GH'); },
		
		resumeBlurDetection : function() { ui.$input.bind('blur.GH', function(e) { core.processInputBlur(e); }); },
		
		/* render search results drop down */
		displaySuggestions : function(data) {
			// Clear out old data
			local.highlight = -1;
			local.$highlight = null;
			
			// Populate new data 
			if (data !== undefined && data[1].length > 0) {
				local.query = data[0];
				var s = data[1],
					suggestions = $('<ul />'),
					i, l = s.length,
					re = new RegExp(local.query,'i'),
					rex = "<b>"+local.query+"</b>";
				
				for (i = 0; i < l; i++) {
					$('<li />').html(s[i].replace(re,rex)).appendTo(suggestions);
				}
				local.results = suggestions.find('li');
				ui.$output.empty().append(suggestions).fadeIn('fast');
			}
			else {
				local.query = '';
				local.results = [];
				ui.$output.fadeOut('fast').empty();
			}
		}
	};//end core

	/* extend default options to include user's custom options */
	$.extend( true, options, defaultOptions, customOptions );	
	
	/* apply any overrides to core */
	$.extend( true, core, options.fn );
		
	/* begin */
	core.init($this);
	
	/* jQuery default behavior, return container */
	return $this;
};
})(jQuery);

//switch search forms
function changeTab(element) {
	var tab1 = document.getElementById('channeltab');
	var tab2 = document.getElementById('webtab');
	if(element == "webtab")
	{
		tab1.className = "tab_selected";
		tab2.className = "";
		document.getElementById('GH_search').className = "hide";
		document.getElementById('GH_searchT1').className ="";	
        if(document.getElementById('GH_search_field').value != ' '  &&  document.getElementById('GH_search_field').value != 'What can we help you find?')
		{
        	document.getElementById('top_search_input').value = document.getElementById('GH_search_field').value;
		}
        else {
        	document.getElementById('top_search_input').value = 'Search the Web';
        }
	}
	if (element == "channeltab")
	{
		tab1.className = "";
		tab2.className = "tab_selected";
        document.getElementById('GH_search').className = "";
		document.getElementById('GH_searchT1').className = "hide";	
		if(document.getElementById('top_search_input').value != ' '  &&  document.getElementById('top_search_input').value !='Search the Web')
		{
			document.getElementById('GH_search_field').value = document.getElementById('top_search_input').value;
		}
		else
		{
			document.getElementById('GH_search_field').value = 'What can we help you find?';
		}
 	}
}
function changecolor()
{
	document.getElementById("top_search_input").className="GH_search_active";
}
function removecolor()
{
	document.getElementById("top_search_input").className="";
}
function submitWebSearch(event) {
    if (event == "onclick" || eventIsEnterKey(event)) {
        return srchSub2();        
    } else {
        return true;
    }
}
function p_o(o){return document.getElementById(o);}
function eventIsEnterKey(event) {
    if (event && event.which == 13 || window.event && window.event.keyCode == 13 || event && event.which == 3 || window.event && window.event.keyCode == 3) {
        return true;
    }
    return false;
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
function srchSub2() {
    var frm=p_o("top_search_form");
    var queryval = frm.top_search_input.value.trim();
    if(queryval == '' || queryval == 'Search the Web')
    {
    	var newurl='http://search.aol.com/aol/webhome?'+'s_it=hdt-travel';
    }
    else{
    	queryval = queryval.replace( /\+/, " ");
    	var newurl = frm.action + queryval+'&s_it=hdt-travel'; }
    	if (frm.target == '_blank') {
    		window.open(newurl, '_self', '');
    	} else {
    		window.location = newurl;
    	}
    return false;
}
//This is a common calendar related function. The requirement is to blur the depart date if return date selected is before it.
function checkDepartReturnDate(lDate, rDate, elementToClear, ghostText) {
	var returnDate = $j('#'+rDate).val();
	var leavingDate =  $j('#'+lDate).val();
	
	var dateInvalid = false;	
	if(isValidDate(leavingDate)==false) {
		dateInvalid = true;
	} else {
		var lMonth = parseInt(leavingDate.split('/')[0], 10), lDay = parseInt(leavingDate.split('/')[1], 10), lYear = parseInt(leavingDate.split('/')[2], 10);
		if(leavingDate.split('/')[2].length == 2) { 
			lYear = lYear + 2000;
			$j('#'+lDate).val(leavingDate.split('/')[0]+'/'+leavingDate.split('/')[1]+'/'+lYear);
		}
	}
	if(isValidDate(returnDate)==false) {
		dateInvalid = true;
	} else {
		var rMonth = parseInt(returnDate.split('/')[0], 10), rDay = parseInt(returnDate.split('/')[1], 10), rYear = parseInt(returnDate.split('/')[2], 10);
		if(returnDate.split('/')[2].length == 2) { 
			rYear = rYear + 2000;
			$j('#'+rDate).val(returnDate.split('/')[0]+'/'+returnDate.split('/')[1]+'/'+rYear);
		}
	}
	if(dateInvalid)
		return;
	
	var invalid = false;
	if(lYear>=rYear) {
		if(lYear>rYear) {
			invalid = true;
		}
		else if(lMonth>=rMonth) {
			if(lMonth>rMonth) {
				invalid = true;
			}
			else if(lDay>rDay) {
				invalid = true;
			}
		}
	}
	if(invalid)
		$j('#'+elementToClear).val(ghostText);
}

var dtCh= "/";

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 daysInFebruary (year){
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

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 isValidDate(dtStr){
	var daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	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, 10)
	day=parseInt(strDay, 10)
	year=parseInt(strYr, 10)
	if (pos1==-1 || pos2==-1){
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month-1]){
		return false
	}
	if ((strYear.length != 4 && strYear.length != 2) || year==0){
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		return false
	}
	return true
}