	// Global Variables

var hasTopBar = false;
var hasTabBar = false;
var hasSubNavBar = false;
var hasFooter = false;
var hTabId = 0;
var sNavId = -1;
var headImgBase = "/assets/images/common/header/";
var footImgBase = "/assets/images/common/footer/";
var secureRoot = "https://nextelonline.nextel.com/";

var headerBaseUrl = "";
var storeBaseUrl = "";
var myBaseUrl = "";

var doOmniture = true;
var secureServer = (location.href.toString().indexOf("https:") == 0)?true:false;

var thirdPartyData = new Array();
var is3rdParty = false;

thirdPartyData.push(['www.nexteljobs.com',true]);
thirdPartyData.push(['www.corporate-ir.net/ireye/ir_site.zhtml?ticker=NXTL&script=300',true]);
thirdPartyData.push(['myaccount.nextel.com',true]);
thirdPartyData.push(['www.egolfscore.com/nextel/nextel.asp',true]);
thirdPartyData.push(['www.pktbo.com/nextel/sport_home.cfm',true]);
thirdPartyData.push(['www.xsvoice.com/deal',true]);
thirdPartyData.push(['messaging.nextel.com',false]);
thirdPartyData.push(['nextel.wirelessinbox.com',false]);
thirdPartyData.push(['nextel-mam.motorola.com/eaa/website/Login.do',false]);
thirdPartyData.push(['developer.nextel.com',false]);
thirdPartyData.push(['indirect.nextel.com',false]);
thirdPartyData.push(['www.nextelbuyback.com',false]);
thirdPartyData.push(['nextel.archway.com',false]);
thirdPartyData.push(['www.nextmail.com',false]);
thirdPartyData.push(['nextelesp.letstalk.com/promo/newlanding.htm?brandId=186&cmpId=209&langId=3&to=3450',false]);
thirdPartyData.push(['led.nextel.com',false]);
thirdPartyData.push(['www.nextel.com/NASApp/care/Action/LBSConsentAction',false]);
thirdPartyData.push(['www.referral.nextel.com',false]);
thirdPartyData.push(['www.ecardprogram.com/nextelrewards',false]);
thirdPartyData.push(['nextel.zingy.com',true]);
thirdPartyData.push(['nextelstore.cellmania.com/web/home.jsp?H=Applications',true]);
thirdPartyData.push(['hosting.mqube.us/nextel/',false]);
thirdPartyData.push(['webclient.blackberry.net/WebMail/Window.jsp?site=nextel',false]);
thirdPartyData.push(['mms.nextel.com/',false]);
thirdPartyData.push(['nextelphotoshare.com',false]);
thirdPartyData.push(['enet.nextel.com',false]);
//thirdPartyData.push(['localhost:8080',true]);

for(q=0;q<thirdPartyData.length;q++){
	if(location.href.toString().indexOf(thirdPartyData[q][0])>-1){
		doOmniture = thirdPartyData[q][1];
		is3rdParty = true;
	}
}

if(((location.hostname.toString().indexOf('nextel.com') == -1)&&(location.hostname.toString().indexOf('localhost') == -1)&&(location.hostname.toString().indexOf('10.153') != 0))||(location.hostname.toString().indexOf('myaccount.nextel.com') != -1)||(is3rdParty == true)){
	headerBaseUrl = "http://www.nextel.com";
	storeBaseUrl = "http://nextelonline.nextel.com";
	myBaseUrl = "http://my.nextel.com";
	headImgBase = ((secureServer)?secureRoot:headerBaseUrl)+"/assets/images/common/header/";
	footImgBase = ((secureServer)?secureRoot:headerBaseUrl)+"/assets/images/common/footer/";
}

//AMDOCS URL corrections
if((location.hostname.toString().indexOf('ecuat.nextel.com') != -1)||(location.hostname.toString().indexOf('snv887:8217') != -1)||(location.hostname.toString().indexOf('cmis072:8080') != -1)||(location.hostname.toString().indexOf('localhost:8051')!=-1)){
	myBaseUrl = "http://myndt2.nextel.com";
	headerBaseUrl = "http://myndt2.nextel.com";
	storeBaseUrl = "http://myndt2.nextel.com";
	headImgBase = headerBaseUrl+"/assets/images/common/header/";
	footImgBase = headerBaseUrl+"/assets/images/common/footer/";
}







// custom aisles settings
var isCA = ((typeof nxCookie["nolcustomaisletoken"] != "undefined")&&(nxCookie[" nolcustomaisletoken"] != ""))?true:false;
var gSup = ((typeof nxCookie["globalsuppressedaisle"] != "undefined")&&(nxCookie["globalsuppressedaisle"] == "true")) ? true : false;

// set Language
var lang = ((typeof nxCookie["nxcommon"] != "undefined")&&(nxCookie["nxcommon"]["language"] != "")) ? nxCookie["nxcommon"]["language"].toLowerCase():"en";
var loc = location.pathname;
if(loc.indexOf("/en/") > -1){
	lang = "en";
}

if(loc.indexOf("/es/") > -1){
	lang = "es";
}

if(isCA == true){
	lang="en";
}

// user state settings
var aud = ((typeof nxCookie["nxcommon"] != "undefined")&&(nxCookie["nxcommon"]["audience"]!="")) ? nxCookie["nxcommon"]["audience"]:"INDIVIDUAL";
var zipCode = ((nxCookie["nxcommon"] != null)&&(nxCookie["nxcommon"]["zipcode"] != "")) ? nxCookie["nxcommon"]["zipcode"]:"";
var uRegion = ((nxCookie["nxcommon"]!= null)&&(nxCookie["nxcommon"]["location"]!=""))? nxCookie["nxcommon"]["location"]:"";
var isLoggedIn = ((nxCookie["smsession"] != null)&&(nxCookie["smsession"] != "LOGGEDOFF"))? true:false;


// parse audience from url
var tAud = null;
if(location.search.length >0){
	loc = location.search;
	loc = loc.toString().substring(1);
	if(loc.indexOf("audience=") > -1){
		sLoc = loc.split("&");
		for(x=0; x<sLoc.length; x++){
			if(sLoc[x].indexOf("audience=")>-1){
				tAud = sLoc[x].substring(9);
				switch(tAud){
					case "INDIVIDUAL": aud = tAud; break;
					case "FAMILY_FRIENDS": aud = tAud; break;
					case "PUBLIC_SECTOR": aud = tAud; break;
					case "ENTERPRISE": aud = tAud; break;
					case "GENERAL_BUSINESS": aud = tAud; break;
					default: aud = "INDIVIDUAL"; break;
				}
			}
		}
	}
}
var audHomeUrls = new Array('/landings/individual.shtml','/landings/family.shtml','/landings/business.shtml','/landings/enterprise.shtml','/landings/public.shtml');
for(x=0;x<audHomeUrls.length;x++){
	if(location.href.indexOf(audHomeUrls[x]) >-1){
		switch(x){
			case 0: tAud = "INDIVIDUAL"; aud=tAud; break;
			case 1: tAud = "FAMILY_FRIENDS"; aud=tAud; break;
			case 2: tAud = "GENERAL_BUSINESS"; aud=tAud; break;
			case 3: tAud = "ENTERPRISE"; aud=tAud; break;
			case 4: tAud = "PUBLIC_SECTOR"; aud=tAud; break;
		}
	}
}
if(tAud != null){
	var cStr = "";
	if(nxCookie["nxcommon"]){
		for(x in nxCookie["nxcommon"]){
			if(cStr.length >0){
				cStr += "||";
			}
			if(x == "audience"){
				cStr += x+"^^"+aud;
			}
			else{
				cStr += x+"^^"+nxCookie["nxcommon"][x];
			}
		}
	}
	else{
		cStr = "language^^EN||zipcode^^||audience^^"+aud+"||location^^";
	}
	setNxCookie("nxcommon",cStr);
}
delete tAud;
delete audHomeUrls;

// link settings
var homeLink = ((isCA == true)&&(typeof nxCookie["customaislefilecookie"]!= "undefined")&&(nxCookie["customaislefilecookie"]["aislelandingfilename"] != "")) ? nxCookie["customaislefilecookie"]["aislelandingfilename"]:headerBaseUrl+"/index.shtml";
var contactLink = ((isCA == true)&&(typeof nxCookie["customaislefilecookie"]!= "undefined")&&(nxCookie["customaislefilecookie"]["aislecontactinfofilename"] != "")) ? nxCookie["customaislefilecookie"]["aislecontactinfofilename"]:headerBaseUrl+"/"+lang+"/contact/index.shtml";

var shopUrl = (isCA == true)? homeLink : "";
if(shopUrl == ""){
	switch (aud){
		case "INDIVIDUAL": shopUrl = headerBaseUrl+"/"+lang+"/landings/individual.shtml"; break;
		case "FAMILY_FRIENDS": shopUrl = headerBaseUrl+"/"+lang+"/landings/family.shtml"; break;
		case "PUBLIC_SECTOR": shopUrl = headerBaseUrl+"/"+lang+"/landings/business.shtml"; break;
		case "ENTERPRISE": shopUrl = headerBaseUrl+"/"+lang+"/landings/enterprise.shtml"; break;
		case "GENERAL_BUSINESS": shopUrl = headerBaseUrl+"/"+lang+"/landings/public.shtml"; break;
		default: shopUrl = headerBaseUrl+"/"+lang+"/landings/individual.shtml"; break;
	}
}
var supportUrl = (isCA == true)? contactLink : headerBaseUrl+"/"+lang+"/support/";
var myUrl = myBaseUrl+"/wps/myportal/mynextel/LandingPage";
	
	

function setSubNavItem(idnum,title,url,showCA,showAriba,aisleLink,audience){
	var nums = idnum.split(".");
	this.groupNum = parseInt(nums[0]);
	this.orderNum = parseInt(nums[1]);
	this.title = title;
	this.url = url;
	this.caUrlCookie = aisleLink;
	this.showCA = showCA;
	this.showAriba = showAriba; // global suppressed aisle
	this.audience = new Array();
	this.audience["INDIVIDUAL"] = false;
	this.audience["FAMILY_FRIENDS"] = false;
	this.audience["GENERAL_BUSINESS"] = false;
	this.audience["ENTERPRISE"] = false;
	this.audience["PUBLIC_SECTOR"] = false;
	if(audience == "*"){
		for(x in this.audience){
			this.audience[x] = true;
		}
	}
	else{
		var aud = audience.split(":");
		for(x=0; x<aud.length; x++){
			this.audience[aud[x]] = true;
		}
	}
}


// Sub Nav Link Sets (all parameters required)
// 
// subNavSet["uniqueLinkID"] = new setSubNavItem(params);
//
// Params:
// setID: sets which sub-nav group the link belongs in and the position of the link in the group
//		format: groupID.positionID
//		ex: 1.2 is group 1, second link
//
// linkText: An array of the text for the link, by language
//		format: ["english Title","spanish Title"]
//				Additional languages can be added by adding field to array and adding definition in setSubNavItem function above
//
// URL:  The url the link normally points to
//		ex: "/shop/"
//
// showCA:  true/false, should this link appear when in a custom aisle (true = show)
//
// showAriba:  true/false, should this link appear if the globalSuppressedAisle cookie is set (true = show)
//
// aisleCookieLink:  the name of the aisle cookie item which contains the value of the link to overide the normal link.  Null if no cookie
//		ex: "aisleFaqsFilename"
//		ex for none: null
//	
// audience:  a colon delimited list of audiences which this link appears (ignored in custom aisles or audiences not in list).  * if all audiences
//		ex: "GENERAL_BUSINESS:ENTERPRISE:PUBLIC_SECTOR"
// 		ex for all: "*"
//
//

var subNavSet = new Array();
var langItems = new Array();

switch(lang){
	case "en":
	subNavSet["f1"] = new setSubNavItem("1.1","Home",headerBaseUrl+"/index.shtml", true, true,"aislelandingfilename","*");
	subNavSet["f2"] = new setSubNavItem("1.2","About Nextel",headerBaseUrl+"/en/about/index.shtml",true, false,null,"*");
	subNavSet["f3"] = new setSubNavItem("1.3","Careers","http://www.nexteljobs.com/",false,false,null,"*");
	subNavSet["f4"] = new setSubNavItem("1.4","News","http://www.corporate-ir.net/ireye/ir_site.zhtml?ticker=NXTL&script=400",true,false,null,"*");
	subNavSet["f5"] = new setSubNavItem("1.5","Investor Relations","http://www.corporate-ir.net/ireye/ir_site.zhtml?ticker=NXTL&script=2300",true,false,null,"*");
	subNavSet["f6"] = new setSubNavItem("1.6","Corporate Governance",headerBaseUrl+"/en/about/governance/index.shtml",true,false,null,"*");
	subNavSet["f7"] = new setSubNavItem("1.7","Developer Program","http://developer.nextel.com/",true,false,null,"*");
	subNavSet["f8"] = new setSubNavItem("1.8","En Espa&ntilde;ol",headerBaseUrl+"/espanol/index.shtml",false,false,null,"*");
	subNavSet["f9"] = new setSubNavItem("1.9","Contact Us",headerBaseUrl+"/en/contact/index.shtml",true,true,"aislecontactinfofilename","*");
	
	subNavSet["pho"] = new setSubNavItem("2.1","Phones",storeBaseUrl+"/NASApp/onlinestore/Action/DisplayPhones",true,true,null,"*");
	subNavSet["pla"] = new setSubNavItem("2.2","Plans",storeBaseUrl+"/NASApp/onlinestore/Action/DisplayPlans",true,true,null,"*");
	subNavSet["ser"] = new setSubNavItem("2.3","Services",headerBaseUrl+"/en/services/index.shtml",true,false,null,"*");
	subNavSet["sol"] = new setSubNavItem("2.4","Solutions",headerBaseUrl+"/en/solutions/",true,false,null,"GENERAL_BUSINESS:ENTERPRISE:PUBLIC_SECTOR");
	subNavSet["acc"] = new setSubNavItem("2.5","Accessories",storeBaseUrl+"/NASApp/onlinestore/Action/OSBrowseAccessoriesOnly",true,false,null,"*");
	subNavSet["rtm"] = new setSubNavItem("2.6","Ring Tones &amp; More",headerBaseUrl+"/en/services/personalize/index.shtml",true,true,null,"INDIVIDUAL:FAMILY_FRIENDS");
	subNavSet["pad"] = new setSubNavItem("2.7","Package Deals",storeBaseUrl+"/NASApp/onlinestore/Action/OSPackageCollectionAction?rootCollection=true",false,false,null,"*");
	subNavSet["pro"] = new setSubNavItem("2.8","Promotions",headerBaseUrl+"/en/promotions/",true,false,"aislePromoFilename","*");
	
	subNavSet["bil"] = new setSubNavItem("3.1","Billing","https://myaccount.nextel.com/servlet/ecare?inf_action=login&action=accountBill",true,true,null,"*");
	subNavSet["faq"] = new setSubNavItem("3.2","FAQs",headerBaseUrl+"/en/support/faq/",true,true,"aisleFaqsFilename","*");
	subNavSet["gat"] = new setSubNavItem("3.3","Guides &amp; Tutorials",headerBaseUrl+"/en/support/guides/",true,true,null,"*");
	subNavSet["net"] = new setSubNavItem("3.4","Network Trouble",headerBaseUrl+"/en/support/network/",true,true,null,"*");
	subNavSet["sar"] = new setSubNavItem("3.5","Service &amp; Repair",headerBaseUrl+"/en/support/servicerepair/",true,true,null,"*");
	subNavSet["upg"] = new setSubNavItem("3.6","Upgrades",headerBaseUrl+"/en/support/upgrades.shtml",true,true,null,"*");
	
	langItems[0] = "Personal"; // individual alt text
	langItems[1] = "Family and Friends"; // family and friends alt text
	langItems[2] = "General Business"; // general business alt text
	langItems[3] = "Enterprise"; // enterprise alt text
	langItems[4] = "Public Sector"; // Public Sector alt text
	langItems[5] = "Change ZIP Code"; // Change ZIP alt Text
	langItems[6] = "View Coverage"; // View Coverage alt Text
	langItems[7] = "Home"; // home alt text
	langItems[8] = "Search"; // search alt text
	langItems[9] = "About Nextel"; // about Nextel alt text
	langItems[10] = "Contact Us"; // contact us alt text
	langItems[11] = "Shop"; // Shop alt text
	langItems[12] = "Support"; // support alt text
	langItems[13] = "My Nextel"; // my nextel alt text
	langItems[14] = "View Cart"; 
	langItems[15] = "Find a Store"; 
	langItems[16] = "Bring Your Number";
	langItems[17] = "Check Status";
	langItems[18] = "Orders, Rebates, and More";
	break;
	
	case "es":
	subNavSet["f1"] = new setSubNavItem("1.1","Inicio",headerBaseUrl+"/es/index.shtml", true, true,"aislelandingfilename","*");
	subNavSet["f2"] = new setSubNavItem("1.2","Sobre Nextel",headerBaseUrl+"/es/about/index.shtml",true, false,null,"*");
	subNavSet["f3"] = new setSubNavItem("1.3","Empleo","http://www.nexteljobs.com/",false,false,null,"*");
	subNavSet["f4"] = new setSubNavItem("1.4","Noticias","http://www.corporate-ir.net/ireye/ir_site.zhtml?ticker=NXTL&script=400",true,false,null,"*");
	subNavSet["f5"] = new setSubNavItem("1.5","Relaciones con Inversores","http://www.corporate-ir.net/ireye/ir_site.zhtml?ticker=NXTL&script=2300",true,false,null,"*");
	subNavSet["f6"] = new setSubNavItem("1.6","Corporate Governance",headerBaseUrl+"/en/about/governance/index.shtml",true,false,null,"*");
	subNavSet["f7"] = new setSubNavItem("1.7","Developer Program","http://developer.nextel.com/",true,false,null,"*");
	subNavSet["f8"] = new setSubNavItem("1.8","In English",headerBaseUrl+"/index.shtml",false,false,null,"*");
	subNavSet["f9"] = new setSubNavItem("1.9","Contacto",headerBaseUrl+"/es/contact/index.shtml",true,true,"aislecontactinfofilename","*");
	
	subNavSet["pho"] = new setSubNavItem("2.1","Tel&eacute;fonos",storeBaseUrl+"/NASApp/onlinestore/Action/DisplayPhones",true,true,null,"*");
	subNavSet["pla"] = new setSubNavItem("2.2","Planes",storeBaseUrl+"/NASApp/onlinestore/Action/DisplayPlans",true,true,null,"*");
	subNavSet["ser"] = new setSubNavItem("2.3","Servicios",headerBaseUrl+"/es/services/index.shtml",true,false,null,"*");
	subNavSet["sol"] = new setSubNavItem("2.4","Soluciones",headerBaseUrl+"/es/solutions/",true,false,null,"GENERAL_BUSINESS:ENTERPRISE:PUBLIC_SECTOR");
	subNavSet["acc"] = new setSubNavItem("2.5","Accesorios",storeBaseUrl+"/NASApp/onlinestore/Action/OSBrowseAccessoriesOnly",true,false,null,"*");
	subNavSet["rtm"] = new setSubNavItem("2.6","Ring Tones &amp; More",headerBaseUrl+"/es/services/personalize/index.shtml",true,true,null,"INDIVIDUAL:FAMILY_FRIENDS");
	subNavSet["pad"] = new setSubNavItem("2.7","Paquetes",storeBaseUrl+"/NASApp/onlinestore/Action/OSPackageCollectionAction?rootCollection=true",false,false,null,"*");
	subNavSet["pro"] = new setSubNavItem("2.8","Promociones",headerBaseUrl+"/es/promotions/",true,false,"aislePromoFilename","*");
	
	subNavSet["bil"] = new setSubNavItem("3.1","Facturaci&oacute;n","https://myaccount.nextel.com/servlet/ecare?inf_action=login&action=accountBill",true,true,null,"*");
	subNavSet["faq"] = new setSubNavItem("3.2","Preguntas Frecuentes",headerBaseUrl+"/es/support/faq/",true,true,"aisleFaqsFilename","*");
	subNavSet["gat"] = new setSubNavItem("3.3","Gu&iacute;as y Tutoriales",headerBaseUrl+"/es/support/guides/",true,true,null,"*");
	subNavSet["net"] = new setSubNavItem("3.4","Problemass de Conexi&oacute;n",headerBaseUrl+"/es/support/network/",true,true,null,"*");
	subNavSet["sar"] = new setSubNavItem("3.5","Service y Reparaci&oacute;n",headerBaseUrl+"/es/support/servicerepair/",true,true,null,"*");
	subNavSet["upg"] = new setSubNavItem("3.6","Actualizaci&oacute;nes",headerBaseUrl+"/es/support/upgrades.shtml",true,true,null,"*");
	
	langItems[0] = "Personal";
	langItems[1] = "Familia y Amigos";
	langItems[2] = "Negocios";
	langItems[3] = "Empresas";
	langItems[4] = "Sector P&uacute;blico";
	langItems[5] = "Cambiar C&oacute;digo ZIP";
	langItems[6] = "Ver Cobertura";
	langItems[7] = "Inicio";
	langItems[8] = "B&uacute;squar";
	langItems[9] = "Sobre Nextel";
	langItems[10] = "Contacto";
	langItems[11] = "Comprar";
	langItems[12] = "Soporte";
	langItems[13] = "Mi Nextel";
	langItems[14] = "Carrito"; 
	langItems[15] = "Tienda M&aacute;s Cercana"; 
	langItems[16] = "Trae Tu N&uacute;mero";
	langItems[17] = "Check Status[es]";
	langItems[18] = "Orders, Rebates, and More[es]";
	break;
}

function setUrlMatch(urlBit, tabId, subNavId, subUrlMatch){
	this.urlBit = urlBit;
	this.tabId = tabId;
	this.subNavId = subNavId;
	this.subUrls = new Array();
	if(subUrlMatch != null){
		if(typeof subUrlMatch[0] == "object"){
			var tmp;
			while(tmp = subUrlMatch.pop()){
				var subs = ((typeof tmp[3] != "undefined")?tmp[3]:null);
				this.subUrls.push(new setUrlMatch(tmp[0],tmp[1],tmp[2],subs));
			}
		}
		else{
			var subs = ((typeof subUrlMatch[3] != "undefined")?subUrlMatch[3]:null);
			this.subUrls.push(new setUrlMatch(subUrlMatch[0],subUrlMatch[1],subUrlMatch[2],subs));
		}
	}
		
}

var calcTabId = null;
var calcSubNav = null;

function findUrlLocation(){
	var urlList = new Array();
/*	urlList.push(new setUrlMatch('my.nextel.com',3,0));
	urlList.push(new setUrlMatch('nextelonline.nextel.com',1,'shop',[
		['/NASApp/onlinestore/Action/',1,0,
			[
				['DisplayPhones',1,'pho'],
				['DisplayPlans',1,'pla'],
				['OSBrowseAccessoriesOnly',1,'acc'],
				['OSPackageCollectionAction?rootCollection=true',1,'pad'],
				['DefineRegionAction',1,'shop']
			]
		],
		['/NASApp/search/NxtSearchServlet',0,0]
	]));*/
	
//test URLs	
	urlList.push(new setUrlMatch('http://localhost:8080/',0,0,[
		['dynamic/',1,'shop',
			[
				['phones/',1,'pho'],
				['plans/',1,'pla'],
				['accessories/',1,'acc',['accessories_inflow',1,0]],
				['registration/',3,0],
				['my_nextel/',3,0],
				['cart/',1,0]
			]
		],
		['static/',2,'support',
			[
				['solutions_',2,'sol'],
				['package_applications',2,'pad'],
			]
		]
	]));
	
	var loc = (location.search.length >0)?location.href.substring(0,location.href.indexOf(location.search)):location.href;
	var listPointer = urlList;
	var matchFound = false;
	var count = 0;
	while(matchFound == false){
		if(listPointer.length > 1){
			locPl = loc.indexOf(listPointer[count].urlBit);
			if(locPl > -1){
				if(listPointer[count].subUrls.length >0){
					// alert('test1');
					loc = loc.substring(locPl+listPointer[count].urlBit.length);
					calcTabId = listPointer[count].tabId;
					calcSubNav = listPointer[count].subNavId;
					listPointer = listPointer[count].subUrls;
					count = 0;
				}
				else{
					calcTabId = listPointer[count].tabId;
					calcSubNav = listPointer[count].subNavId;
					matchFound = true;
				}
			}
			else{
				count++;
				if(count >= listPointer.length){
					if(calcTabId == null){
						calcTabId = 0;
					}
					if(calcSubNav == null){
						calcSubNav = 0;
					}
					matchFound = true;
				}
			}
		}
		else{
			locPl = loc.indexOf(listPointer[count].urlBit);
			if(locPl > -1){
				if(listPointer[count].subUrls.length >0){
					loc = loc.substring(locPl+listPointer[count].urlBit.length);
					calcTabId = listPointer[count].tabId;
					calcSubNav = listPointer[count].subNavId;
					listPointer = listPointer[count].subUrls;
					count = 0;
				}
				else{
					calcTabId = listPointer[count].tabId;
					calcSubNav = listPointer[count].subNavId;
					matchFound = true;
				}
			}
			else{
				if(calcTabId == null){
					calcTabId = 0;
				}
				if(calcSubNav == null){
					calcSubNav = 0;
				}
				matchFound = true;
			}
		}
	}	
	return;
}




// Utility Bar Functions

// parameter (optional)
// supLinks: 1 = 3rd party app, suppress search
// 			 -1 = suppress all
//
function renderUtilityBar(supLinks){
	var barStr = "";
	if(parseInt(supLinks) == -1){
		barStr += '<div style="height:16px;" class="blackBG">&nbsp;</div>';
	}
	else{
		barStr += '<table cellpadding="0" cellspacing="0" width="100%" class="blackBG"><tr>';
		var audImg;
		var regionText = "";
		var regionLinkText = "";
		var utilityText = "";
		if((typeof nxCookie["nxcommon"] != "undefined")&&(nxCookie["nxcommon"]["zipcode"]!= "")&&((supLinks == null)||(supLinks != 1))){
			regionText = '<span class="lightGreySmBText">'+nxCookie["nxcommon"]["location"]+' '+nxCookie["nxcommon"]["zipcode"]+'</span>';
			regionLinkText = '<a href="/NASApp/onlinestore/Action/DefineRegionAction"><img src="'+headImgBase+'buk_change_zip_code_'+lang+'.gif" alt="'+langItems[5]+'" style="vertical-align:middle;"></a>';
			regionLinkText += '<span class="greyBText" style="margin:0 5px;">|</span>';
			regionLinkText += '<a href="'+headerBaseUrl+'/cgi-bin/localMarketMap.cgi?zip='+zipCode+'"><img src="'+headImgBase+'buk_view_coverage_'+lang+'.gif" alt="'+langItems[6]+'" style="vertical-align:middle;"></a>';
		}
		switch(aud){
			case "INDIVIDUAL": audImg = headImgBase+"buk_personal_v1_"+lang+".gif"; audImgAlt=0; break;
			case "FAMILY_FRIENDS": audImg = headImgBase+"buk_personal_v1_"+lang+".gif"; audImgAlt=1; break;
			case "PUBLIC_SECTOR": audImg = headImgBase+"buk_public_sector_v1_"+lang+".gif"; audImgAlt=2; break;
			case "ENTERPRISE": audImg = headImgBase+"buk_enterprise_v1_"+lang+".gif"; audImgAlt=3; break;
			case "GENERAL_BUSINESS": audImg = headImgBase+"buk_general_business_v1_"+lang+".gif"; audImgAlt=4; break;
			default: audImg = headImgBase+"buk_personal_v1_"+lang+".gif"; audImgAlt=0; break;
		}
		utilityText = '<a href="'+homeLink+'"><img src="'+headImgBase+'buk_home_'+lang+'.gif" alt="'+langItems[7]+'" style="vertical-align:middle;"></a>';
		utilityText += '<span class="greyBText" style="margin:0 5px;">|</span>';
		if((isCA == false)&&((supLinks == null)||(parseInt(supLinks) != 1))){
			utilityText += '<a href="'+storeBaseUrl+'/NASApp/search/NxtSearchServlet"><img src="'+headImgBase+'buk_search_'+lang+'.gif" alt="'+langItems[8]+'" style="vertical-align:middle;"></a>';
			utilityText += '<span class="greyBText" style="margin:0 5px;">|</span>';
		}
		if(gSup != true){
			utilityText += '<a href="'+headerBaseUrl+'/'+lang+'/about/index.shtml"><img src="'+headImgBase+'buk_about_nextel_'+lang+'.gif" alt="'+langItems[9]+'" style="vertical-align:middle;"></a>';
			utilityText += '<span class="greyBText" style="margin:0 5px;">|</span>';
		}
		utilityText += '<a href="'+contactLink+'"><img src="'+headImgBase+'buk_contact_us_'+lang+'.gif" alt="'+langItems[10]+'" style="vertical-align:middle;"></a>';
	
		if((isCA == false)&&((typeof supLinks == "undefined")||(parseInt(supLinks) != 1))){
			barStr += '<td width="190" style="background-color:#6A9913;"><img src='+audImg+' alt="'+langItems[audImgAlt]+'"></td>';
		}
		barStr += '<td align="left"><div style="margin-left:10px;">'+regionText+'</div></td>';
		barStr += '<td align="left"><div style="margin-left:15px;">'+regionLinkText+'</div></td>';
		barStr += '<td align="right"><div style="margin:0 10px 0 50px;">'+utilityText+'</div></td></tr></table>';
	}	
	hasTopBar = true;
	return barStr;
	
}



// Tab Bar Functions
// htab:  -1 to 3, determines which tab to highlight (-1 = hide tabs, 0 = none, 1=shop, 2=support, 3=mynextel)
//
function renderTabBar(hTab){
	var shopTab = false;
	var supportTab = false;
	var myTab = false;
	var shopImg, supportImg, myImg;
	var caExt = (isCA == true)? "_ca":"";
	
	
	if(typeof hTab == "undefined"){
		findUrlLocation();
		hTabId = calcTabId;
		switch(hTabId){
			case 1: shopTab = true; break;
			case 2: supportTab = true; break;
			case 3: myTab = true; break;
		}
	}
	else{
		switch(parseInt(hTab)){
			case -1: hTabId = -1; break;
			case 1: shopTab = true; hTabId = 1; break;	
			case 2: supportTab = true; hTabId = 2; break;
			case 3: myTab = true; hTabId = 3; break;
			default: hTabId = 0;
		}
	}
	
	if(isCA){
		shopImg = (shopTab == true)? nxCookie["customaislefilecookie"]["aislelogofilename"].replace(/_off./,"_on."):nxCookie["customaislefilecookie"]["aislelogofilename"];
	}
	else{
		shopImg = (shopTab == true)? headImgBase+"tab_shop_on_v1_"+lang+".gif":headImgBase+"tab_shop_off_v1_"+lang+".gif";
	}
	supportImg = (supportTab == true)? headImgBase+"tab_support"+caExt+"_on_v1_"+lang+".gif":	headImgBase+"tab_support"+caExt+"_off_v1_"+lang+".gif";
	myImg = (myTab == true)? headImgBase+"tab_my_nextel"+caExt+"_on_v1_"+lang+".gif":	headImgBase+"tab_my_nextel"+caExt+"_off_v1_"+lang+".gif";
		
	var barStr = '<table cellpadding="0" cellspacing="0" class="yellowBarBG" width="775" height="65"></tr>';
	if(hTabId > -1){
		barStr += '<td valign="bottom"><a href="'+shopUrl+'"><img src="'+shopImg+'" alt="'+langItems[11]+'" style="margin-left:8px;"></a></td>';
		barStr += '<td valign="bottom"><a href="'+supportUrl+'"><img src="'+supportImg+'" alt="'+langItems[12]+'"></a></td>';
		if(gSup == false){
			barStr += '<td valign="bottom"><a href="'+myUrl+'"><img src="'+myImg+'" alt="'+langItems[13]+'"></a></td>'
		}
		barStr += '<td width="100%" align="right"><div style="margin:15px 11px 15px 0;"><a href="'+homeLink+'"><img src="'+headImgBase+'logo_nextel_header.gif"></a></div></td>';
	}
	else{
		barStr += '<td width="100%" align="right"><div style="margin:15px 11px 15px 0;"><img src="'+headImgBase+'logo_nextel_header.gif"></div></td>';
	}
	barStr += '</tr></table>';
	hasTabBar = true;
	return barStr;
}



// sub nav bar functions
//
// navID: the unique Identifier for which sub-nav Item to highlight, see subNavSet for IDs
//        0 = suppress all, render empty space
//		  shop = show shop sub-nav with nothing highlighted
//        support = show support sub-nav with nothing highlighted
// 

function renderSubNavBar(navID){
	var links;
	var lnkId;
	var barStr = "";
	var defStr = '<div style="height:35px;">&nbsp;</div>';
	if(typeof navID != "undefined"){
		lnkId = navID;
	}
	else{
		if(calcSubNav == null){
			findUrlLocation();
		}
		lnkId = calcSubNav;
	}
	links = returnLinkList(lnkId);
	if(links == 0){
		hasSubNavBar = true;
		return defStr;
	}
	else{
		barStr += '<table cellpadding="0" cellspacing="0" width="775" height="35"><tr><td>';
		barStr += '<div style="margin:12px 0 12px 8px;">';
		for(x=0; x<links.length; x++){
			if(x>0){
				barStr += '<span class="subNavDivider lightGreyText">|</span>';
			}
			var lnkCls = (links[x] == lnkId)? "blackBText":"darkGreyText";
			barStr += '<a href="'+getRealLink(links[x])+'" class="'+lnkCls+'">'+subNavSet[links[x]].title+'</a>';
		}
		barStr += '</div></td><td align="right"><div style="margin:12px 10px 12px 50px;">';
		switch(hTabId){
			case 1:
				barStr += '<a href="'+storeBaseUrl+'/NASApp/onlinestore/Action/CartLanding" class="linkSm">'+langItems[14]+'</a>';
				if(gSup == false){
					barStr += '<span class="subNavDivider lightGreyText">|</span><a href="'+headerBaseUrl+'/en/stores/index.shtml" class="linkSm">'+langItems[15]+'</a>';
				}
				barStr += '<span class="subNavDivider lightGreyText">|</span><a href="'+storeBaseUrl+'/NASApp/wnp/Action/PECLanding" class="linkSm">'+langItems[16]+'</a>';
				break;
			case 2:
//				barStr += '<div style="margin:12px 10px 12px 0;"><a href="'+headerBaseUrl+'/support/status/" class="linkSm">'+langItems[17]+'</a> <span class="blackSmText">('+langItems[18]+')</span></div>';
				break;
			default:
				barStr += '';
				break;
		}			
		barStr += '</div></td></tr></table>'			
	}
	hasSubNavBar = true;
	return barStr;
}


// renders the footer
// fOpt:  -1 = suppress nav links, otherwise it ignores all inputs
//
//
function renderFooter(fOpt){
	var ftlnk = '<div class="yellowBG"><div style="width:773;padding:1px;"><div style="margin:5px 9px 5px 9px;">';
	var lnkAr = returnLinkList("f1");
	if((typeof fOpt == "undefined")||(parseInt(fOpt) != -1)){
		for(x=0; x<lnkAr.length; x++){
			if(x>0){
				ftlnk += '<span class="subNavDivider darkOrangeText">|</span>';
			}
			var lnk = getRealLink(lnkAr[x]);
			ftlnk += '<a href="'+lnk+'" class="blackSmText">'+subNavSet[lnkAr[x]].title+'</a>';
		}
	}
	else{
		ftlnk += '&nbsp;';
	}
	ftlnk += '</div></div></div>';
	ftlnk += '<table cellpadding="0" cellspacing="0" style="margin:10px 10px 10px 10px; width:755;" class="blackBG"><tr>';
	switch(lang){
		case 'en': ftlnk +=	'<td valign="top"><div style="margin-top:5px; line-height:1.5em;" class="greySmText">By accessing this site you accept the terms of our ';
				   ftlnk += '<a href="'+headerBaseUrl+'/en/legal/visitor_agreement.shtml" class="cyanSmText">Acceptable Use Policy and Visitor Agreement</a> and <a href="'+headerBaseUrl+'/en/legal/privacy_prefs.shtml" class="cyanSmText">Privacy Policy</a><br>';
				   ftlnk += '&copy; 1995-'+(new Date().getFullYear()) +' Nextel Communications Inc. All rights reserved. <a href="'+headerBaseUrl+'/en/legal/legal.shtml" class="cyanSmText">Copyright and Disclaimer Notice</a></div>';
				   break;
		case 'es': ftlnk += '<td valign="top"><div style="margin-top:5px; line-height:1.5em;" class="greySmText">Al acceder a este sitio usted acepta los t&eacute;rminos y condiciones de nuestra  ';
				   ftlnk += '<a href="'+headerBaseUrl+'/es/legal/privacy_prefs.shtml" class="cyanSmText">Pol&iacute;tica de Privacidad</a>, como as&iacute; tambi&eacute;n nuestros <a href="'+headerBaseUrl+'/es/legal/visitor_agreement.shtml" class="cyanSmText">T&eacute;rminos y Condiciones de uso de la p&aacute;gina</a><br>';
				   ftlnk += '&copy; 1995-'+(new Date().getFullYear()) +' Nextel Communications Inc. All rights reserved. <a href="'+headerBaseUrl+'/es/legal/legal.shtml" class="cyanSmText">Copyright and Disclaimer Notice</a></div>';
					break;
	}
	if((isCA)&&(nxCookie["customaislefilecookie"]["aisledisclaimer"]!=null)){
		ftlnk += '<div style="margin-top:15px; line-height:1.5em;" class="greySmText">'+nxCookie["customaislefilecookie"]["aisledisclaimer"]+'</div>';
	}
	ftlnk += '</td><td><a href="'+headerBaseUrl+'/'+lang+'/legal/ctia_popup.shtml"><img src="'+footImgBase+'logo_cic.gif"></a></td>';
	ftlnk += '<td><a href="https://digitalid.verisign.com/as2/c22d4f6a7af1664f3349b07d53f0d2a1" target="_blank"><img src="'+footImgBase+'logo_verisign.gif"></a></td>';
	ftlnk += '<td><a href="'+headerBaseUrl+'/'+lang+'/legal/fact_driver.shtml"><img src="'+footImgBase+'logo_smart_drivers.gif"></a></td>';
	ftlnk += '</tr></table>';
	ftlnk += '<div id="omnitureDiv"></div>';
	if(doOmniture){
		var omniScript = document.createElement("script");
		omniScript.setAttribute("src",((secureServer)?secureRoot:headerBaseUrl)+"/assets/scripts/s_code_remote.js");
		omniScript.setAttribute("id","omnitureCodeInclude");
		document.getElementsByTagName("head")[0].appendChild(omniScript);
	}
	hasFooter = true;
	if((setobj('navUtilityBar') != null)&&(hasTopBar == false)){
		setInnerHTML('navUtilityBar',renderUtilityBar());
	}
	if((setobj('navTabBar') != null)&&(hasTabBar == false)){
		setInnerHTML('navTabBar',renderTabBar());
	}
	if((setobj('subNavBar') != null)&&(hasSubNavBar == false)){
		setInnerHTML('subNavBar',renderSubNavBar());
	}
	return ftlnk;
}


// sorts a list of sub-nav link IDs
//
function sortLinkList(a,b){
	return subNavSet[a].orderNum - subNavSet[b].orderNum;
}

// returns the correct link based on whether a link is supposed to be over-ridden by a custom aisle cookie
//
function getRealLink(id){
	if((subNavSet[id].caUrlCookie != null)&&(isCA == true)){
		return nxCookie["customaislefilecookie"][subNavSet[id].caUrlCookie];
	
	}
	else{
		return subNavSet[id].url;
	}
}
		
//  returns the appropriate set of sub-nav and footer links based on audience, custom aisle, and custom aisle suppression flag
//
function returnLinkList(linkId){
	if(parseInt(linkId) == 0){
		return 0;
	}
	var gNum;
	if(typeof linkId != "undefined"){
		switch(linkId){
			case "shop": gNum = 2; break;
			case "support": gNum = 3; break;
			case "mynextel": gNum = 0; break;
			default: if(subNavSet[linkId] == null){	return 0;}else{gNum = subNavSet[linkId].groupNum; break;}
		}
	}
	else{
		switch(hTabId){
			case -1: gnum = 0; break;
			case 0: gnum = 0; break;
			case 1: gnum = 2; break;
			case 2: gnum = 3; break;
			case 3: gnum = 0; break;
		}
	}
	var idList = new Array();
	if(gNum > 0){
		for(x in subNavSet){
			if(subNavSet[x].groupNum == gNum){
				if((isCA == true)&&(subNavSet[x].showCA == false)){
					continue;
				}
				if((gSup == true)&&(subNavSet[x].showAriba == false)){
					continue;
				}
				if((isCA == false)&&(subNavSet[x].audience[aud] == false)){
					continue;
				}
				idList.push(x);
			}
		}
		idList.sort(sortLinkList);
	}
	else{
		return 0;
	}
		
	return idList;
}


