
var navStyleExtension = (/Win32/.test(window.navigator.platform)) ? "" : "-MAC";
var isIE = (/MSIE/.test(navigator.userAgent));

var navDisabled = false;
var navigatingTo = "";

var parentWindow;
var rootWindow;

var windowPageMappings = new Array();
var topNavigationSection;




function loadNavigation(){		
	loadWindowMappingsAndNavigationSection();
	
	rootWindow = findRootWindow(window);

	loadNavigationModeFromCookies();
		
	syncWindowReferences();
	
	//Load the navigation section objects and show the icons if necessary
	//topNavigationSection.icon = document.getElementById(topNavigationSection.layerName + '_icon');	
	//topNavigationSection.layer = document.getElementById(topNavigationSection.layerName);			
	//topNavigationSection.selectionLayer = document.getElementById(topNavigationSection.popUpLayerName);	
	
	try{
		//if(window.top.document.location.search.indexOf('toMultipleWindow') > -1){
			//initializeNavigationStyleChangeMode();
		//}else 
		if(window.parent.document.location.href.indexOf('admin') > -1){initializeAdminMode();}
		//else{
			//showNavigationSectionIcons();				
		//}
	}catch(e){}	
		
	if(isIE){
		document.body.onmouseleave = hideEverything;
	}else{
		window.addEventListener('mouseout', hideEverything, true);
	}
}



function loadWindowMappingsAndNavigationSection(){
	windowPageMappings[0] = new WindowPageMapping("Home", "home.aspx", "single", true);
	windowPageMappings[1] = new WindowPageMapping("Maps", "interactiveMap.aspx", "perType", "800", false);
	windowPageMappings[2] = new WindowPageMapping("Business Directory", "businessDirectory.aspx", "single", "783", false);
	windowPageMappings[3] = new WindowPageMapping("Special Offers", "specialOffers.aspx", "single", "783", false);
	windowPageMappings[4] = new WindowPageMapping("Other", "", "single", "783", false);

	topNavigationSection = new NavigationSection(windowPageMappings[0], "topNavigationStyleSelector", "selectionLayer", "/top/images/nav_win_single.gif", "single");
}


function loadNavigationModeFromCookies(){
	try{
		var windowMode = fetchNamedCookie('preferredWindowMode');
		var permanentWindowMode = fetchNamedCookie('permanentPreferredWindowMode');
		
		if(windowMode != '' && windowMode != '_'){
			topNavigationSection.setting = windowMode;
			setNamedCookie('preferredWindowMode', '_');
		}else if(permanentWindowMode != ''){
			topNavigationSection.setting = permanentWindowMode;
		}
	}catch(e){}
}


function syncWindowReferences(){
	if(window == rootWindow){		
		topNavigationSection.windowPage.windowRef = parentWindow;		
	}else{
		for(var i = 0; i < windowPageMappings.length; i++){
			try{
				if(rootWindow.windowPageMappings[i].windowRef != undefined && rootWindow.windowPageMappings[i].windowRef.closed != true){
					windowPageMappings[i].windowRef = rootWindow.windowPageMappings[i].windowRef;
				}
			}catch(e){
				windowPageMappings[i].windowRef = undefined;
			}
		}
			
		topNavigationSection.windowPage.windowRef = rootWindow.topNavigationSection.windowPage.windowRef;
		topNavigationSection.setting = rootWindow.topNavigationSection.setting;
	}			
}


function initializeAdminMode(){
	document.getElementById('logoHomeLink').href = '';
	document.getElementById('logoHomeLink').onclick = function(){return false;};
	topNavigationSection.setting = 'single';
	document.getElementById('logoHomeLink').style.cursor = 'default';}


function initializeNavigationStyleChangeMode(){
	hideEverything();
	hideNavigationBar();			
	//topNavigationSection.icon.style.display = 'none';
	//topNavigationSection.layer.style.display = 'none';
	//topNavigationSection.selectionLayer.style.display = 'none';
	document.getElementById('logoHomeLink').onclick = '';
	document.getElementById('logoHomeLink').style.cursor = 'default';}



		

function hideEverything(e){
	if(!isIE){
		//window.status = e.target.nodeName;
		if(e.target.nodeName != 'BODY'){return;}
	}
	
	try{hideAllMenus();}catch(e){}
	
	//topNavigationSection.selectionLayer.style.display = 'none';
	}

