// 03/01 BRANDING SSM


var displaySearch = true;
var defaultSearchBoxText = 'Type your question...'; 
//var defaultSearchBoxText = 'Search for . . .';

function checkForDefault() {
	var SearchValue = document.getElementById('overlayQuery').value;
	if (SearchValue == defaultSearchBoxText || SearchValue == '') return false;
	HPSearch(this);
	return true;
}

/* Self-Executing Function. This allows us to encapsulate the local variables for better minification */
(function() { 
	var assetPath = '//www.united.com/ual/asset/';
	var aMenuLinksLength = aMenuLinks.length;
	var HeaderContent = [];
	var tabIndex = 0;
	var tabName = '';
	var i = 0;
	var aMenuItem = '';
	
	//old header
	
	//HeaderContent.push('<div id="ualbranded">' );
	//HeaderContent.push('	<div id="ualbrandedlogo"><a href="'+ homepage_link +'"><img src="' + assetPath + logoImgName +'" height="15" width="144" alt="United" border="0" /></a></div>');
	//HeaderContent.push('	<div id="ualbrandedlinks"><a href="'+ myProfile_link +'">'+ myProfile_label +'</a> <span class="headerpipe">|</span> <a href="'+ worldwide_link +'">'+ worldwide_label +'</a> <span class="headerpipe">|</span> <a href="'+customerSerice_link+'">'+customerSerice_label+'</a></div>');
	//HeaderContent.push('</div>');
	
	
	//new branding header 02/07/11 11:20AM WHQEO 
	
		HeaderContent.push('<div id="bhHeader">');
		HeaderContent.push('<div id="bhTop">');
		HeaderContent.push('<div id="bhTopLeft">');
		HeaderContent.push('<p><a href="' + continental_link + '">continental.com</a>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;<span class="untxt">united.com</span></p>');
		HeaderContent.push('</div>');
		HeaderContent.push('<div id="bhTopRight">');
		HeaderContent.push('<p><a href="' + merger_link + '">About our new logo</a></p>');
		HeaderContent.push('</div>');
		HeaderContent.push('</div>');
		HeaderContent.push('<div id="bhMiddleArrow">');
		HeaderContent.push('<img src="' + assetPath + 'global-nav-pointer.gif" height="9" width="18" alt="Pointer" />');
		HeaderContent.push('</div>');
		HeaderContent.push('<div id="bhBottom">');
		HeaderContent.push('<div id="bhBottomLeft">');
		HeaderContent.push('<a href="' + homepage_link + '"><img class="newUnitedLogo" src="' + assetPath + logoImgName + '" height="30" width="173" alt="United" /></a>');
		HeaderContent.push('</div>');
		HeaderContent.push('<div id="bhBottomLeftSA">');
		HeaderContent.push('<a href="' + starAlliance_link + '"><img class="newSALogo" src="' + assetPath + staralliance_logo + '" height="14" width="160" alt="Star Alliance" /></a>');
		HeaderContent.push('</div>');
		HeaderContent.push('<div id="bhBottomRight">');
		HeaderContent.push('<p><span id="ualbrandedlinks"></span><a href="' + myProfile_link + '">' + myProfile_label + '</a>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;<a href="' + worldwide_link + '">' + worldwide_label + '</a>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;<a href="' + customerSerice_link + '">' + customerSerice_label + '</a></p>');
		HeaderContent.push('</div>');
		HeaderContent.push('</div>');
		HeaderContent.push('</div>');
	
	HeaderContent.push('<div id="ualswnarea">');
	//HeaderContent.push('	<form id="Homepagesearch" onsubmit="return checkForDefault();" action="/cgi-bin/texis/webinator/search/" name="Homepagesearch" method="get" style="margin: 0px;">');
	HeaderContent.push('		<div style="float:left; height:32px;width:10px; background-color:#FFF;"></div>');
	HeaderContent.push('		<ul class="jd_menu" style="float:left;">');
	
	//build the li's
	for (tabIndex=1; tabIndex< 5; tabIndex++) {
		//extract the url for the tab image
		tabName = "tab"+tabIndex;
		for(i=0; i<aMenuLinksLength; i++) {
			aMenuItem = aMenuLinks[i];
			if (aMenuItem[0] == tabName) {
				break; 
			}
		}
		// aMenuItem is the element in the array we are looking for to build the tab image
		HeaderContent.push('			<li id="'+tabName+'" onClick="window.location.assign(\''+aMenuItem[2]+aMenuItem[3]+'\');"><a id="'+ tabName +'Button" class="navButton" href="'+aMenuItem[2]+aMenuItem[3]+'"></a>');
		HeaderContent.push('				<ul class="newSubMenu" style="width:'+ulWidth[tabIndex]+'px !important"></ul>');
		HeaderContent.push('			</li>');
	}

	HeaderContent.push('		</ul>');
	HeaderContent.push('		<form id="searchFormWithOverlay" name="searchFormWithOverlay" autocomplete="off"><div class="swnquerytextContainer">');
	
	if (displaySearch) {
		HeaderContent.push('		<input type="text" value="' + defaultSearchBoxText + '" name="query" id="overlayQuery">');
	}
		
	HeaderContent.push('		</div>');
	HeaderContent.push('		<div class="swnquerybuttonContainer">');
	
	if (displaySearch) {
		HeaderContent.push('		<input id="submitlink" type="image" src="//www.united.com/ual/asset/btn_ask.gif" value="submit" name="submit"><input type="hidden" value="siteprofile" name="pr">');
	}
	
	HeaderContent.push('		</div></form>');
	//HeaderContent.push('	</form>');
	HeaderContent.push('</div>');
	HeaderContent.push('		<div id="ualbonusbar"></div>');

	
	document.write(HeaderContent.join(''));
})();

if (displaySearch) {
	var ualEvent = {
		add: function(obj, type, fn){
			if (obj.attachEvent) {
				obj['e' + type + fn] = fn;
				obj[type + fn] = function(){
					obj['e' + type + fn](window.event);
				};
				obj.attachEvent('on' + type, obj[type + fn]);
			}
			else 
				obj.addEventListener(type, fn, false);
		},
		remove: function(obj, type, fn){
			if (obj.detachEvent) {
				obj.detachEvent('on' + type, obj[type + fn]);
				obj[type + fn] = null;
			}
			else 
				obj.removeEventListener(type, fn, false);
		}
	};
	
	var SearchBoxObj = document.getElementById('overlayQuery');
	ualEvent.add(SearchBoxObj, 'focus', function(){
		if (SearchBoxObj.value == defaultSearchBoxText) {
			SearchBoxObj.value = '';
			SearchBoxObj.style.textAlign = 'left';
			SearchBoxObj.style.color = '#1B3D6B';
		}
	});
	
	ualEvent.add(SearchBoxObj, 'blur', function(){
		if (SearchBoxObj.value == '') {
			SearchBoxObj.value = defaultSearchBoxText;
			SearchBoxObj.style.textAlign = 'left';
			SearchBoxObj.style.color = '#666666';
		}
	});
	
	ualEvent.add(SearchBoxObj, 'keydown', function(e){
		if (window.quickUASearch) {
			quickUASearch(event);
		}
	});
	
	ualEvent.add(SearchBoxObj, 'keypress', function(e){
		if (window.quickUASearch) {
			quickUASearch(event);
		}
	});
}



