// to be used by the content frame to set the left nav bar
// when a click causes a jump to a new main section
// xiHowDeepCurrentPage is 1 if the calling page is a main subsection (i.e. - guide/chat/index.html
// and 2 if a subsection of that like guide/chat/bbs.html. 
function setLeftNav(xsWhich, xiHowDeepCurrentPage) {
	// check to see if there is a navbar
	if(parent.navbar == null) {
		vsFunctionCall = "setLeftNav(" + "\"" + xsWhich + "\"" + "," + xiHowDeepCurrentPage + ")";
		// if there isn't, set a timer and recursively call this function
		setTimeout(vsFunctionCall, 500);
	} else {
		// top replaced by parent for ea.com
		//vsLeftNavSelection = top.navbar.selectedItem;
		vsLeftNavSelection = parent.navbar.selectedItem;

		// check to see if the xsWhich is already selected
		if(vsLeftNavSelection != xsWhich) {
			vsImagesPath = buildImagesPath(xiHowDeepCurrentPage);	
					
			// turn off currently selected one
			if(vsLeftNavSelection != "none")
				parent.navbar.document.images[vsLeftNavSelection].src = vsImagesPath + vsLeftNavSelection + "off.gif";
									
			// turn on new one
			parent.navbar.document.images[xsWhich].src = vsImagesPath + xsWhich + "roll.gif";
		
			// set the variable
			parent.navbar.selectedItem = xsWhich;
		}	
	}
}


// build the images path - see comment above setLeftNav
function buildImagesPath(xiHowDeepCurrentPage) {
	if(ieWinP() == true) {
		vsPath = "images/local/";
	} else {
		vsPath = "../";
		for(i=0; i<xiHowDeepCurrentPage; i++) 
			vsPath = vsPath + "../";
		
		vsPath = vsPath + "navbars/images/local/";
	}
	
	return vsPath;
}

// not used anymore since top nav bar is not sticky
function setTopNav(xsWhich, xiHowDeepCurrentPage) {
	vsTopNavSelection = parent.eabar.eaSelectedItem;

	// check to see if the xsWhich is already selected
	if(vsTopNavSelection != xsWhich) {
		vsImagesPath = buildImagesPath(xiHowDeepCurrentPage);		
		
		// turn off currently selected one
		if(vsTopNavSelection != "none")
			parent.eabar.document.images[vsTopNavSelection].src = vsImagesPath + vsTopNavSelection + "off.gif";
	
		// turn on new one
		parent.eabar.document.images[xsWhich].src = vsImagesPath + xsWhich + "roll.gif";
	
		// set the variable
		parent.eabar.eaSelectedItem = xsWhich;
	}
	// need to turn off left nav bar
}

function ieWinP() {
    // convert all characters to lowercase to simplify testing 
    var agt=navigator.userAgent.toLowerCase(); 

    var is_ie   = agt.indexOf("msie") != -1; 
    var is_mac  = agt.indexOf("mac")  != -1;
       
    if(is_ie  && !is_mac)
    	return true;
    else
    	return false;
}

