    $(document).ready(function() {

		var topNavList = {
			MarketMaking: { 
				description: "Market Making includes all global market making across regions and asset classes. In addition to the electronic market making in U.S. equities, the segment includes cash market making, designated market maker (DMM) services at the NYSE, market making in European equities and U.S. options, and non-client quantitative trading.", 
				links:[
					{ title: "CASH TRADING", link: "marketmaking/cashtrading.asp" },
					{ title: "DMM SERVICES", link: "marketmaking/DMMServices.asp",
						links: [
							{ title: "WHAT IS A DMM?", link: "marketmaking/DMMWhatIsDMM.asp" },
							{ title: "CAPITAL", link: "marketmaking/DMMCaptial.asp" },
							{ title: "EXPERIENCE", link: "marketmaking/DMMExperience.asp" },
							{ newColumAfter: true, title: "COMMUNICATIONS", link: "marketmaking/DMMCommunications.asp" },
							{ title: "NYSE AND NYSE AMEX LISTING INFORMATION", link: "marketmaking/DMMNYSE.asp" },
							{ title: "CONTACTS", link: "marketmaking/DMMContacts.asp" }
						]
					},
					{ title: "ELECTRONIC MARKET MAKING", link: "marketmaking/electronicMarketMaking.asp" },
					{ title: "KNIGHT LINK", link: "marketmaking/knightLink.asp", 
						links: [
							//{ title: "NORTH AMERICA", link: "marketmaking/klNorthAmerica.asp" },
							//{ title: "FEATURES & BENEFITS", link: "marketmaking/klFeaturesAndBenefits.asp" },
							//{ title: "FAQ", link: "marketmaking/klFAQ.asp" },
							{ title: "SALES & SUPPORT", link: "marketmaking/klSalesAndSupport.asp" }//,
							//{ title: "CONNECTIVITY", link: "marketmaking/klConnectivity.asp" },
							//{ title: "EUROPE", link: "marketmaking/klEurope.asp" }
						]
					},
					{ title: "RELATIONSHIP MANAGEMENT", link: "marketmaking/relationshipManagement.asp" }
				]
			},
			ElectronicExecution: { 
				description: "Electronic Execution Services consists of electronic trading products that provide clients with market access, speed and trading efficiencies. The offering includes Knight Direct, Hotspot FX and Knight BondPoint.", 
				links:[
					{ title: "HOTSPOT FX", link: "electronicExecutionServices/hotspotFX.asp", 
						links: [
							{ title: "SALES AND SUPPORT", link: "electronicExecutionServices/fxSalesAndSupport.asp" },
							{ title: "SOLUTIONS", link: "electronicExecutionServices/fxSolutions.asp" },
							{ title: "FAQ", link: "electronicExecutionServices/fxFaq.asp" },
							{ title: "BECOME A CLIENT", link: "electronicExecutionServices/fxBecomeAClient.asp" }
						]
					},
					{ title: "KNIGHT BONDPOINT", link: "electronicExecutionServices/knightBondpoint.asp", 
						links: [
							{ title: "SALES AND SUPPORT", link: "electronicExecutionServices/kbpSalesAndSupport.asp" }
						]
					},
					{ title: "KNIGHT DIRECT", link: "electronicExecutionServices/knightDirect.asp", 
						links: [
							{ title: "NORTH AMERICA", link: "electronicExecutionServices/knightDirect.asp" },
							{ title: "SOLUTIONS", link: "electronicExecutionServices/KDSolutions.asp" },
							{ title: "FEATURES & BENEFITS", link: "electronicExecutionServices/KDFeaturesAndBenefits.asp" },
							{ title: "REQUEST A DEMO", link: "electronicExecutionServices/KDRequestDemo.asp" },
							{ title: "FAQ", link: "electronicExecutionServices/KDFAQ.asp" },
							{ title: "SALES AND SUPPORT", link: "electronicExecutionServices/KDSalesAndSupport.asp" },
							{ title: "INSTALLATION", link: "electronicExecutionServices/KDInstallation.asp" },
							{ title: "DISCLOSURES", link: "electronicExecutionServices/KDDisclosures.asp" },
							{ title: "EUROPE", link: "electronicExecutionServices/KDEurope.asp" }
						]
					},
					{ title: "ALGORITHMIC SUITE", link: "electronicExecutionServices/algorithmicSuite.asp", 
						links: [
							{ title: "FEATURES & BENEFITS", link: "electronicExecutionServices/ETFeaturesAndBenefits.asp" },
							{ title: "SOLUTIONS", link: "electronicExecutionServices/ETSolutions.asp" },
							{ title: "REQUEST A DEMO", link: "electronicExecutionServices/ETRequestDemo.asp" },
							{ title: "REQUEST MORE INFORMATION", link: "electronicExecutionServices/ETRequestInfo.asp" },
							{ title: "SALES AND SUPPORT", link: "electronicExecutionServices/ETSalesAndSupport.asp" },
							{ title: "BECOME A CLIENT", link: "electronicExecutionServices/ETBecomeAClient.asp" }
						] 
					},
					{ title: "KNIGHT MATCH", link: "electronicExecutionServices/knightMatch.asp", 
						links: [
							{ title: "EXECUTION PROTOCOLS", link: "electronicExecutionServices/kmExecutionProtocols.asp" }
						] 
					}
				]
			},
			SalesAndTrading: { 
				description: "Institutional Sales and Trading covers a range of activities including full service sales and trading across global equities, fixed income, ETFs and options, research, equity and debt capital markets, reverse mortgage origination and HMBS securitization, and asset management.", 
				links:[
					{ 
						title: "EQUITIES", 
						link: "institutionalSalesAndTrading/equities.asp", 
						links: [
							{ customClass: "navNodeMulti", title: "INSTITUTIONAL EQUITIES<br/>SALES & TRADING", link: "institutionalSalesAndTrading/institutionalEquitiesSalesAndTrading.asp" },
							{ title: "COMMISSION RECAPTURE", link: "institutionalSalesAndTrading/commissionRecapture.asp" },
							{ title: "EQUITY FINANCE", link: "institutionalSalesAndTrading/equityFinance.asp" },
							{ newColumAfter: true, title: "ETF TRADING", link: "institutionalSalesAndTrading/ETFTrading.asp" },
							{ customClass: "navNodeMulti", title: "GLOBAL COMMISSION<br/>MANAGEMENT", link: "institutionalSalesAndTrading/globalCommissionManagement.asp" },
							{ title: "PROGRAM TRADING", link: "institutionalSalesAndTrading/programTrading.asp" },
							{ title: "RELATIONSHIP MANAGEMENT", link: "institutionalSalesAndTrading/brokerDealerRM.asp" },
							{ newColumAfter: true, title: "SPECIAL SITUATIONS", link: "institutionalSalesAndTrading/specialSituations.asp" },
							{ title: "STRATEGIC OPTIONS", link: "institutionalSalesAndTrading/strategicOptions.asp" }//,
						//	{ customClass: "navNodeMulti", title: "CENTRALIZED CASH FX<br />MARKETPLACE", link: "#cash7" },
						//	{ newColumAfter: true, customClass: "navNodeMulti", title: "CLIENT-OPTIMIZED BANK<br/>LIQUIDITY ALGORITHM", link: "#cash7" },
						//	{ title: "EXECUTABLE STREAMING PRICES", link: "#cash7" },
						//	{ title: "FX PRIME BROKER CREDIT MODEL", link: "#cash7" },
						//	{ title: "PIP PRECISION IMPROVED PRICING", link: "#cash7" },
						//	{ title: "TECHNOLOGY", link: "#cash7" },
						//	{ title: "TRADEVIEW FX", link: "#cash7" }
						]
					},
					{ 
						title: "FIXED INCOME", 
						link: "institutionalSalesAndTrading/fixedIncome.asp", 
						links: [
							{ title: "U.S. CREDIT", link: "institutionalSalesAndTrading/usCredit.asp" },
							{ title: "EUROPEAN CREDIT", link: "institutionalSalesAndTrading/europeanCredit.asp" },
							{ title: "ABS/MBS", link: "institutionalSalesAndTrading/ABSMBS.asp" },
							{ title: "EMERGING MARKETS", link: "institutionalSalesAndTrading/emergingMarkets.asp" },
							{ title: "KNIGHT ADVISOR SERVICES", link: "institutionalSalesAndTrading/knightAdvisorServices.asp" }//,
						]
					},
					{ title: "RESEARCH", link: "institutionalSalesAndTrading/research.asp" },
					{ 
						title: "CAPITAL MARKETS", 
						link: "institutionalSalesAndTrading/capitalMarkets.asp", 
						links: [
							{ title: "CORPORATE ACCESS", link: "institutionalSalesAndTrading/corporateAccess.asp" },
							{ title: "DEBT CAPITAL MARKETS", link: "institutionalSalesAndTrading/debtCapitalMarkets.asp" },
							{ title: "EQUITY CAPITAL MARKETS", link: "institutionalSalesAndTrading/equityCapitalMarkets.asp" },
							{ title: "KNIGHT CAPITAL PARTNERS", link: "institutionalSalesAndTrading/knightCapitalPartners.asp" },
							{ title: "PE SOURCE", link: "institutionalSalesAndTrading/peSource.asp" }
						] 
					},
					{ title: "ASTOR ASSET MANAGEMENT", link: "institutionalSalesAndTrading/assetManagement.asp" }
				]
			}
		};
		
		

		var sideNavList = {
			OurFirm: { 
				description: "", 
				links:[
					{ title: "ABOUT KNIGHT", link: "ourFirm/aboutKnight.asp" },
					{ title: "OUR CLIENTS", link: "ourFirm/ourClients.asp" },
					{ title: "LEADERSHIP", link: "ourFirm/leadership.asp" },
					{ title: "LIQUIDITY", link: "ourFirm/liquidity.asp" },
					{ title: "EXECUTION QUALITY", link: "ourFirm/executionQuality.asp" },
					{ title: "TRADING TECHNOLOGY", link: "ourFirm/tradingTechnology.asp" },
					{ title: "PHILANTHROPY", link: "ourFirm/philanthropy.asp" },
					{ title: "OUR LOCATIONS", link: "ourFirm/ourLocations.asp" },
					{ title: "OPERATING SUBSIDIARIES", link: "ourFirm/operatingSubsidiaries.asp" },
					{ title: "FAQ", link: "ourFirm/faq.asp" }
				]
			},
			InvestorRelations: { 
				description: "", 
				links:[
					{ title: "ANALYST COVERAGE", link: "investorRelations/analystCoverage.asp" },
					{ title: "ANALYST ESTIMATES", link: "investorRelations/analystEstimates.asp" },
					{ title: "ANALYST PRESENTATIONS", link: "investorRelations/analystPresentations.asp" },
					{ title: "ANNUAL REPORT", link: "investorRelations/annualReport.asp"},
					{ title: "CORPORATE GOVERNANCE", link: "investorRelations/corporateGovernance.asp" },
					{ title: "PRESS RELEASES", link: "investorRelations/pressReleases.asp"},
					{ title: "EDUCATION", link: "investorRelations/education.asp" },
					{ title: "REQUEST E-MAIL ALERTS", link: "investorRelations/emailAlerts.asp"},
					{ title: "PROXY/ANNUAL MEETING", link: "investorRelations/proxyAnnualMeeting.asp"},
					{ title: "SEC FILINGS", link: "investorRelations/secFiling.asp"},
					{ title: "SHAREHOLDER INFORMATION", link: "investorRelations/shareholderInfo.asp"},
					{ title: "STOCK INFORMATION", link: "investorRelations/stockInformation.asp"},
					{ title: "WEBCASTS", link: "investorRelations/webcasts.asp"}
				]
			},
			Newsroom: { 
				description: "", 
				links:[
					{ title: "PRESS RELEASES", link: "newsroom/pressReleases.asp" },
					{ customClass: "navNodeMulti", title: "RESEARCH AND<br />COMMENTARY", link: "newsroom/researchAndCommentary.asp" },
					{ title: "EVENT CALENDAR", link: "newsroom/eventCalendar.asp" }
				]
			},
			Careers: { 
				description: "", 
				links:[
					{ title: "OPPORTUNITIES", link: "http://tbe.taleo.net/NA5/ats/careers/jobSearch.jsp?org=KNIGHT&cws=7", target: "_blank" },
					{ title: "WORKING AT KNIGHT", link: "careers/workingAtKnight.asp" },
					{ title: "ETG CAREERS", link: "careers/etgCareers.asp" }
				]
			},
			Contact: { 
				description: "contact/index.asp", 
				links:[
					{ title: "OUR LOCATIONS", link: "ourFirm/ourLocations.asp"},
					{ title: "EMERGENCY INFORMATION", link: "contact/emergencyInfo.asp"}
				]
			}
		};

		
		
		
		
		
		
		var isDebug = true;
		var isTopMenuVisible = false;
		var activeTopMenu = '';
		var hoverTopMenu = '';
		
		var knightMenuConfig_top = {
			interval: 300,
			sensitivity: 7,
			over: showTopMenu,
			timeout: 300,
			out: hideTopMenu
		};
	  function setActiveNav() {
		var tempURL = window.document.location.pathname;
		var tempPath = unescape(tempURL.substring(0,(tempURL.lastIndexOf("/"))));
		var tempCurrentDir = '';
		if (tempPath.length > 0) {
			var tempPathList = tempPath.split('/');
			if (tempPathList.length > 1) {
				tempCurrentDir = tempPathList[tempPathList.length - 1];
			}
			else {
				tempCurrentDir = tempPathList;
			}
		}
		
		if (!tempCurrentDir.length) return;
		tempCurrentDir = tempCurrentDir.toLowerCase();
		
		var tempDiv = '';
		var tempNavLoc = 'top';
		switch(tempCurrentDir) {
			case 'marketmaking':
				tempDiv = 'MarketMaking';
				break;
			case 'electronicexecutionservices':
				tempDiv = 'ElectronicExecution';
				break;
			case 'institutionalsalesandtrading':
				tempDiv = 'SalesAndTrading';
				break;
			case 'ourfirm':
				tempDiv = 'OurFirm';
				tempNavLoc = 'side';
				break;
			case 'investorrelations':
				tempDiv = 'InvestorRelations';
				tempNavLoc = 'side';
				break;
			case 'newsroom':
				tempDiv = 'Newsroom';
				tempNavLoc = 'side';
				break;
			case 'careers':
				tempDiv = 'Careers';
				tempNavLoc = 'side';
				break;
			case 'contact':
				tempDiv = 'Contact';
				tempNavLoc = 'side';
				break;
		}
		if (tempDiv.length) {
			if (tempNavLoc == 'side') {
				$('div[name*="' + tempDiv + '"]').addClass("activeMenu");
			}
			else {
				$('div[name*="' + tempDiv + '"]').addClass("activeMenu");
			}
		}
	  }
	  setActiveNav();
	  
	  function getLinkPrefix(thePathPrefix) {
		return (thePathPrefix == '../') ? '../' : '';
	  }



	  function resetTopMenu() {
		isTopMenuVisible = false;
		activeTopMenu = '';
	  }

      function hideTopMenu(){
		$('div.topMenuItem').removeClass("hovering");
		$('#topSubMenuMaster').removeClass("hovering");
		
		resetTopMenu();
      }
     function showTopMenu(){
		if (hoverTopMenu.length <= 0) return;
		$('div[name*="' + hoverTopMenu + '"]').addClass("hovering");
		
		buildTopSubNav(hoverTopMenu);
		
		$("#topSubNav div.navNode").each( function() {
			$(this).hover( mouseOverSubMenu, mouseOutSubMenu );
		});
		$("#topSubNav div.navNodeMulti").each( function() {
			$(this).hover( mouseOverSubMenu, mouseOutSubMenu );
		});
		
		$('#topSubMenuMaster').addClass("hovering");
		isTopMenuVisible = true;
      }
	  function buildTopSubNav(theNav) {
		var tempNavList = topNavList[theNav];
		if (typeof(tempNavList) === 'undefined') return false;
		
		if (typeof(tempNavList.links) === 'undefined') return false;

		resetSubNavCategory('top', theNav);
		
		var tempLinkHtml = '';
		var tempNavItem = '';
		var tempLinks = tempNavList.links;
		for (var x = 0; x < tempLinks.length; x++) {
			
			tempNavItem = tempLinks[x].title;
			if (typeof(tempLinks[x].link) !== 'undefined') {
				var tempLinkURL = tempLinks[x].link;
				if (tempLinkURL.indexOf('http') < 0) {
					tempLinkURL = getLinkPrefix(navPrefix) + tempLinkURL;
				}
				var tempLinkTarget = '';
				if (typeof(tempLinks[x].target) !== 'undefined') {
					tempLinkTarget = ' target="' + tempLinks[x].target + '"';
				}

				tempNavItem = '<a href="' + tempLinkURL + '"' + tempLinkTarget + '>' + tempNavItem + '</a>';
			}
			var tempClass = 'navNode';
			if (typeof(tempLinks[x].customClass) !== 'undefined') {
				if (tempLinks[x].customClass.length) tempClass = tempLinks[x].customClass;
			}
			tempLinkHtml += '<div name="top_' + theNav + '_' + x + '" class="' + tempClass + '">' + tempNavItem + '</div>';
		}
		$('#topSubNav').html(tempLinkHtml);
	  }
	  
	  function buildSubNavItems(theSubNavName, isHideNavItems) {
		var hideNavItems = (typeof(isHideNavItems) === 'undefined') ? false : isHideNavItems;
		var tempNav, tempSubNav, tempSubIndex;
		var tempList = theSubNavName.split('_');
		tempNav = tempList[0];
		tempSubNav = tempList[1];
		tempSubIndex = tempList[2];

		if (hideNavItems) {
			hideSubNavItems();
			resetSubNavCategory(tempNav, tempSubNav);
			return;
		}

		var tempNavList;
		if (tempNav == 'side') {
			tempNavList = sideNavList[tempSubNav];
		}
		else {
			tempNavList = topNavList[tempSubNav];
		}

		if (typeof(tempNavList) === 'undefined') {
			buildSubNavItems(theSubNavName, true);
			return;
		}

		if (typeof(tempNavList.links) === 'undefined') {
			buildSubNavItems(theSubNavName, true);
			return;
		}

		if (tempNavList.links.length-1 < tempSubIndex) {
			buildSubNavItems(theSubNavName, true);
			return;
		}
		
		var tempLinkData = tempNavList.links[tempSubIndex];
		if (typeof(tempLinkData) === 'undefined') {
			buildSubNavItems(theSubNavName, true);
			return false;
		}

		resetSubNavItems(tempNav);
		
		var tempDivContainer = 0;
		var isNewColumn = false;

		var tempLinkHtml = '';
		var tempNavItem = '';
		var tempLinks = tempLinkData.links;
		
		var isDivideContainer = false;
		var tempItemsCount = 0;
		for (var x = 0; x < tempLinks.length; x++) {
			
			tempNavItem = tempLinks[x].title;
			if (typeof(tempLinks[x].link) !== 'undefined') {
				var tempLinkURL = tempLinks[x].link;
				if (tempLinkURL.indexOf('http') < 0) {
					tempLinkURL = getLinkPrefix(navPrefix) + tempLinkURL;
				}
				var tempLinkTarget = '';
				if (typeof(tempLinks[x].target) !== 'undefined') {
					tempLinkTarget = ' target="' + tempLinks[x].target + '"';
				}

				tempNavItem = '<a href="' + tempLinkURL + '"' + tempLinkTarget + '>' + tempNavItem + '</a>';
			}
			var tempClass = 'navNode';
			if (typeof(tempLinks[x].customClass) !== 'undefined') {
				if (tempLinks[x].customClass.length) tempClass = tempLinks[x].customClass;
			}
			
			tempLinkHtml += '<div class="' + tempClass + '">' + tempNavItem + '</div>';

			if (typeof(tempLinks[x].newColumAfter) !== 'undefined') {
				if (tempLinks[x].newColumAfter) {
					isNewColumn = true;
					tempItemsCount = 4;
				}
			}

			if (((tempItemsCount % 5) == 4) || isNewColumn) {
				$('#' + tempNav + 'SubNavItems' + tempDivContainer).html(tempLinkHtml);
				tempDivContainer++;
				tempLinkHtml = '';
				
				isDivideContainer = true;
				tempItemsCount = -1;
				isNewColumn = false;
			}
			tempItemsCount++;
		}
		if (!isDivideContainer) {
			$('#' + tempNav + 'SubNavItems0').html(tempLinkHtml);
		}
		else {
			$('#' + tempNav + 'SubNavItems' + tempDivContainer).html(tempLinkHtml);
		}

		$('.' + tempNav + 'SubNavItems .navNode').each( function() {
			$(this).hover( mouseOverSubNavItem, mouseOutSubNavItem );
		});
		$('.' + tempNav + 'SubNavItems .navNodeMulti').each( function() {
			$(this).hover( mouseOverSubNavItem, mouseOutSubNavItem );
		});
	  }
	  function resetSubNavCategory(theNav, theSubNav) {
		switch(theNav) {
			case 'top':
				$('#topSubDescription').removeClass("hideNavItems");
				$('div.topSubNavItems').addClass("hideNavItems");

				var tempDescription = '';
				var tempNavList = topNavList[theSubNav];

				if (typeof(tempNavList) !== 'undefined') {
					tempDescription = tempNavList.description;
				}
				$('#topSubDescription').html(tempDescription)
			break;
			case 'side':
				$('#sideSubNav0').html('');
				$('#sideSubNav1').html('');
				$('#sideSubNav2').html('');
			break;
		}
	  }
	  function hideSubNavItems() {
		cmDBug('wow is this working');
		$('div.topSubNavItems').addClass("hideNavItems");
		$('#topSubDescription').addClass("hideNavItems");

		$('div.sideSubNavItems').html('');
		$('#sideSubDescription').addClass("hideNavItems");
	  }
	  function resetSubNavItems(theNav) {
		switch(theNav) {
			case 'top':
				$('div.topSubNavItems').removeClass("hideNavItems");
				$('#topSubDescription').addClass("hideNavItems");
				$('#topSubNavItems0').html('');
				$('#topSubNavItems1').html('');
				$('#topSubNavItems2').html('');
				break;
			case 'side':
				$('div.sideSubNavItems').removeClass("hideNavItems");
				$('#sideSubNavItems0').html('');
				$('#sideSubNavItems1').html('');
				$('#sideSubNavItems2').html('');
				break;
			default:
				break;
		}
	  }
	
	function mouseOverSubNavItem() {
		$(this).addClass('hovering');
	}
	
	function mouseOutSubNavItem() {
		$(this).removeClass('hovering');
	}
	
	function mouseOverTopMenu() {
		var tempMenu = $(this).attr("name");
		hoverTopMenu = tempMenu;
		
		if (!isTopMenuVisible) {
			activeTopMenu = tempMenu;
			return;
		}

		if (tempMenu === activeTopMenu) { 
			// build this strange parameter to reuse another function
			buildSubNavItems('top_' + $(this).attr("name") + '_0', true);
			return; 
		}
		else {
			$('div.topMenuItem').removeClass("hovering");
			hoverTopMenu = tempMenu;
			activeTopMenu = tempMenu;
			showTopMenu();
		}
	}

	function mouseOutTopMenu() {
		hoverTopMenu = '';
	}


	function mouseOverSubMenu() {
		$("#topSubNav div.navNode").removeClass('hovering');
		$("#topSubNav div.navNodeMulti").removeClass('hovering');
		$(this).addClass("hovering");

		buildSubNavItems($(this).attr("name"));
	}
	function mouseOutSubMenu() {
//		$(this).removeClass("hovering");
	}
	
	$("#topMenuWrapper").hoverIntent(knightMenuConfig_top);
	$("div.topMenuItem").hover( mouseOverTopMenu, mouseOutTopMenu );
	
	
	
	
	
	var isSideMenuVisible = false;
	var activeSideMenu = '';
	var hoverSideMenu = '';
	
	var knightMenuConfig_side = {
		interval: 300,
		sensitivity: 7,
		over: showSideMenu,
		timeout: 300,
		out: hideSideMenu
	};




	function resetSideMenu() {
		isSideMenuVisible = false;
		activeSideMenu = '';
	  }

      function hideSideMenu(){
		$('div.sideMenuItem').removeClass("hovering");
		$('#sideSubMenuMaster').removeClass("hovering");

		resetSideMenu();
      }
     function showSideMenu(){
		if (hoverSideMenu.length <= 0) return;
		$('div[name*="' + hoverSideMenu + '"]').addClass("hovering");
		
		buildSideSubNav(hoverSideMenu);
		
		$("#sideSubNav div.navNode").each( function() {
			$(this).hover( mouseOverSubMenu_side, mouseOutSubMenu );
		});		
		$("#sideSubNav div.navNodeMulti").each( function() {
			$(this).hover( mouseOverSubMenu_side, mouseOutSubMenu );
		});
		$("#sideSubNav0 div.navNode").each( function() {
			$(this).hover( mouseOverSubMenu_side, mouseOutSubMenu );
		});		
		$("#sideSubNav0 div.navNodeMulti").each( function() {
			$(this).hover( mouseOverSubMenu_side, mouseOutSubMenu );
		});
		$("#sideSubNav1 div.navNode").each( function() {
			$(this).hover( mouseOverSubMenu_side, mouseOutSubMenu );
		});		
		$("#sideSubNav1 div.navNodeMulti").each( function() {
			$(this).hover( mouseOverSubMenu_side, mouseOutSubMenu );
		});
		$("#sideSubNav2 div.navNode").each( function() {
			$(this).hover( mouseOverSubMenu_side, mouseOutSubMenu );
		});		
		$("#sideSubNav2 div.navNodeMulti").each( function() {
			$(this).hover( mouseOverSubMenu_side, mouseOutSubMenu );
		});
		
		$('#sideSubMenuMaster').addClass("hovering");
		isSideMenuVisible = true;
      }
	  function buildSideSubNav(theNav) {
		var tempNavList = sideNavList[theNav];
		if (typeof(tempNavList) === 'undefined') return false;
		
		if (typeof(tempNavList.links) === 'undefined') return false;

		resetSubNavCategory('side', theNav);
		
		var tempDivContainer = 0;
		var isNewColumn = false;

		var tempLinkHtml = '';
		var tempNavItem = '';
		var tempLinks = tempNavList.links;

		var isDivideContainer = false;
		var tempItemsCount = 0;
		for (var x = 0; x < tempLinks.length; x++) {
			
			tempNavItem = tempLinks[x].title;
			if (typeof(tempLinks[x].link) !== 'undefined') {
				var tempLinkURL = tempLinks[x].link;
				if (tempLinkURL.indexOf('http') < 0) {
					tempLinkURL = getLinkPrefix(navPrefix) + tempLinkURL;
				}
				var tempLinkTarget = '';
				if (typeof(tempLinks[x].target) !== 'undefined') {
					tempLinkTarget = ' target="' + tempLinks[x].target + '"';
				}
				tempNavItem = '<a href="' + tempLinkURL + '"' + tempLinkTarget + '>' + tempNavItem + '</a>';
			}
			var tempClass = 'navNode';
			if (typeof(tempLinks[x].customClass) !== 'undefined') {
				if (tempLinks[x].customClass.length) tempClass = tempLinks[x].customClass;
			}

			if (typeof(tempLinks[x].newColumAfter) !== 'undefined') {
				if (tempLinks[x].newColumAfter) {
					isNewColumn = true;
					tempItemsCount = 4;
				}
			}

			tempLinkHtml += '<div name="side_' + theNav + '_' + x + '" class="' + tempClass + '">' + tempNavItem + '</div>';

			if (((tempItemsCount % 5) == 4) || isNewColumn) {
//				$('#sideSubNav0').html(tempLinkHtml);
				$('#sideSubNav' + tempDivContainer).html(tempLinkHtml);
				tempDivContainer++;
				tempLinkHtml = '';
				
				isDivideContainer = true;
				tempItemsCount = -1;
				isNewColumn = false;
			}
			tempItemsCount++;
		}
		if (!isDivideContainer) {
			$('#sideSubNav0').html(tempLinkHtml);
		}
		else {
			$('#sideSubNav' + tempDivContainer).html(tempLinkHtml);
		}
//		$('#sideSubNav0').html(tempLinkHtml);
	  }

	  
	function mouseOverSideMenu() {
		var tempMenu = $(this).attr("name");
		hoverSideMenu = tempMenu;
		
		if (!isSideMenuVisible) {
			activeSideMenu = tempMenu;
			return;
		}

		if (tempMenu === activeSideMenu) { 
			// build this strange parameter to reuse another function
			buildSubNavItems('side_' + $(this).attr("name") + '_0', true);
			return; 
		}
		else {
			$('div.sideMenuItem').removeClass("hovering");
			hoverSideMenu = tempMenu;
			activeSideMenu = tempMenu;
			showSideMenu();
		}
	}

	function mouseOutSideMenu() {
		hoverSideMenu = '';
	}
	function mouseOverSubMenu_side() {
		$("#sideSubNav div.navNode").removeClass('hovering');
		$("#sideSubNav div.navNodeMulti").removeClass('hovering');

		$("#sideSubNav0 div.navNode").removeClass('hovering');
		$("#sideSubNav0 div.navNodeMulti").removeClass('hovering');
		$("#sideSubNav1 div.navNode").removeClass('hovering');
		$("#sideSubNav1 div.navNodeMulti").removeClass('hovering');
		$("#sideSubNav2 div.navNode").removeClass('hovering');
		$("#sideSubNav2 div.navNodeMulti").removeClass('hovering');
		
		$(this).addClass("hovering");

		buildSubNavItems($(this).attr("name"));
	}


    $("#sideMenuWrapper").hoverIntent(knightMenuConfig_side);
	$("div.sideMenuItem").hover( mouseOverSideMenu, mouseOutSideMenu );

	function cmDBug(out) {
		if (isDebug) {
			if (navigator.userAgent.indexOf("Firefox")!=-1)	console.log(out);
		}
	}

      
    });


