

var home = false;
var activeMenuID = "";
var browser = new Browser();
window.onresize = windowResized;

function Browser(){
	var agt = navigator.userAgent.toLowerCase();
	this.isIE = false;
	this.isFirefox = false;
    	
    	if((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)) {
        	this.isIE = true;
    	} else if((agt.indexOf("firefox") != -1) && (agt.indexOf("opera") == -1)) {
         	this.isFirefox = true;
    	}
    	return;
}

function showMenu(menuID, level) {
	menu = document.getElementById(menuID);
	menuItem = document.getElementById('item ' + menuID);

	if(level > 0) {
		menuItem.parentNode.style.backgroundColor = "#FFF";
	}
            
	if(menu) {
		var curleft = curtop = 0;
		var obj = menuItem;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft;
			curtop = obj.offsetTop;
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			}
		}

		if(level == 0) {
			menuItem.className = "navigationSectionSelected";
			menuItem.getElementsByTagName("a")[0].className = "navigationSelectedSectionLink";
			menu.style.visibility = "visible";
			menu.style.position = "absolute";
			menu.style.top =  (curtop + menuItem.offsetHeight) + "px";
			menu.style.left = curleft  + "px";
			menu.style.width = (menuItem.offsetWidth - 2)+ "px";
		} else {
			menu.style.visibility = "visible";
			menu.style.position = "absolute";
			menu.style.top =  curtop + "px";
			menu.style.left = (curleft + menuItem.offsetWidth + 7) + "px";
			menu.style.width = (menuItem.offsetWidth + 14 ) + "px";
		}
                
		//iframe properties for IE
		if(browser.isIE) {
			setIframeProperties(menuID, "");
		}
	}
}

function hideMenu(menuID, level) {
	menu = document.getElementById(menuID);
	menuItem = document.getElementById('item ' + menuID);

        if(level > 0) {
                menuItem.parentNode.style.backgroundColor = "#e8ECE9";
	}
	if(menu) {
		menu.style.visibility = "hidden";
		var nav = menuID.split('.');
		if(nav.length == 2) {
			document.getElementById('item ' + menuID).className = "navigationSection";
			document.getElementById('item ' + menuID).getElementsByTagName("a")[0].className = "navigationSectionLink";
		}
	}
	setTopMenuColors();
            
	//iframe properties for IE
	if(browser.isIE) {
		setIframeProperties(menuID, "none");
	}
}

function menuMouseOver(menuID) {
	var nav = menuID.split('.');
	menu = document.getElementById(menuID);
	menu.style.visibility = "visible";
	if(nav.length > 2) {
		document.getElementById(nav[0] + '.' + nav[1]).style.visibility = "visible";
	}
	document.getElementById('item ' + nav[0] + '.' + nav[1]).className = "navigationSectionSelected";
	document.getElementById('item ' + nav[0] + '.' + nav[1]).getElementsByTagName("a")[0].className = "navigationSelectedSectionLink";
            
	//iframe properties for IE
	if(browser.isIE) {
		setIframeProperties(menuID, "");
        	if(nav.length > 2) {
            		setIframeProperties(nav[0] + '.' + nav[1], "");   
        	}
    	}
}

function menuMouseOut(menuID) {
	var nav = menuID.split('.');
	menu = document.getElementById(menuID);
	menu.style.visibility = "hidden";
	if(nav.length > 2) {
		document.getElementById(nav[0] + '.' + nav[1]).style.visibility = "hidden";
	}
	document.getElementById('item ' + nav[0] + '.' + nav[1]).className = "navigationSection";
	document.getElementById('item ' + nav[0] + '.' + nav[1]).getElementsByTagName("a")[0].className = "navigationSectionLink";
	setTopMenuColors();
            
	//iframe properties for IE
	if(browser.isIE) {
		setIframeProperties(menuID, "none");
         	if(nav.length > 2) {
            		setIframeProperties(nav[0] + '.' + nav[1], "none");
        	}
    	}
}
        
function homeMenuMouseOver(menuID) {
	showMenu(menuID, 0);
}

function homeMenuMouseOut(menuID) {
	hideMenu(menuID, 0);
}
        
//set client login color on home page
function setTopMenuColors() {
	if(home){
		document.getElementById("item 0.1").className = "navigationSectionWeird";
		document.getElementById("item 0.1").getElementsByTagName("a")[0].className = "navigationSelectedSectionLink";
	} else {
		if(document.getElementById("item " + activeMenuID)) {
			document.getElementById("item " + activeMenuID).className = "navigationSectionSelected";
			document.getElementById('item ' + activeMenuID).getElementsByTagName("a")[0].className = "navigationSelectedSectionLink";
		}
	}
}

function setIframeProperties(menuID, displayStyle) {
	menuIframe = document.getElementById("topnav iframe " + menuID);
	if(menuIframe){
		if(menuIframe.isInitialized == null){
			menu = document.getElementById(menuID);
			menuIframe.style.left    = menu.style.left;
			menuIframe.style.top     = menu.style.top;
			menuIframe.style.width   = menu.offsetWidth + "px";
			menuIframe.style.height  = menu.offsetHeight + "px";
			menuIframe.isInitialized = true;
		}
		menuIframe.style.display = displayStyle;
	}
}

function windowResized() {
	var iframes = document.getElementsByTagName("iframe");
	for (var i = 0; i < iframes.length; i += 1) {
		if( iframes[i].getAttribute('id').indexOf("topnav iframe") != -1) {
			iframes[i].isInitialized = null;
			iframes[i].className = "menuBoxIframe";
		}
	}
}

function openLinkInNewWindow(hlink) 
{
	window.open(hlink, 'twpopup', 'width=, height=600, location=no , resizable=yes, scrollbars=yes, status=yes, titlebar=yes, toolbar=no');
}       

function openDiscoveryResearch () {
	window.open('http://www.westwindpartners.ca/new/clientlogin.aspx', 'blank', 'width=, height= , location=no , resizable=yes, scrollbars=yes, status=yes, titlebar=yes, toolbar=yes');
}

function openAssetManagement() {
	window.open('http://www.intralinks.com', 'blank', 'width=, height= , location=no , resizable=yes, scrollbars=yes, status=yes, titlebar=yes, toolbar=yes');
}
        
function renderNavigation(isHome, sectionToHighlight) {
	home = isHome;
	
		//display the top menu line only if its an internal page.
		if(!isHome) {
			document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%">');
			document.write('	<tr>'); 
				document.write('<td width="25%" onmouseover="showMenu(\'0.1\', 0)" onmouseout="hideMenu(\'0.1\', 0)">');				
				document.write('	<div id="item 0.1" class="navigationSection"><a href="#" class="navigationSectionLink">Client Login</a></div>');
				document.write('</td>'); 
				if(sectionToHighlight == "Client Login") { activeMenuID = "0.1"; } 
					document.write('<td width="1"><img src="/img/blank.gif" width="1"></td>'); 
				document.write('<td width="25%" onmouseover="showMenu(\'0.2\', 0)" onmouseout="hideMenu(\'0.2\', 0)">');				
				document.write('	<div id="item 0.2" class="navigationSection"><a href="#" class="navigationSectionLink">About Us</a></div>');
				document.write('</td>'); 
				if(sectionToHighlight == "About Us") { activeMenuID = "0.2"; } 
					document.write('<td width="1"><img src="/img/blank.gif" width="1"></td>'); 
				document.write('<td width="25%" onmouseover="showMenu(\'0.3\', 0)" onmouseout="hideMenu(\'0.3\', 0)">');				
				document.write('	<div id="item 0.3" class="navigationSection"><a href="#" class="navigationSectionLink">Products & Services</a></div>');
				document.write('</td>'); 
				if(sectionToHighlight == "Products & Services") { activeMenuID = "0.3"; } 
					document.write('<td width="1"><img src="/img/blank.gif" width="1"></td>'); 
				document.write('<td width="25%" onmouseover="showMenu(\'0.4\', 0)" onmouseout="hideMenu(\'0.4\', 0)">');				
				document.write('	<div id="item 0.4" class="navigationSection"><a href="#" class="navigationSectionLink">Additional Resources</a></div>');
				document.write('</td>'); 
				if(sectionToHighlight == "Additional Resources") { activeMenuID = "0.4"; } 
			document.write('	</tr>');
			document.write('</table>');
		}
		if(isHome){
			document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%">');
	              	document.write('	<tr valign="top">');	
		} 				
					if(isHome) {
				        	document.write('<td width="25%">');	
						document.write('	<div id="0.1" class="homeMenuBox" onmouseover="homeMenuMouseOver(\'0.1\')" onmouseout="homeMenuMouseOut(\'0.1\')">'); 
					} else {
				 		document.write('	<div id="0.1" class="menuBox" onmouseover="menuMouseOver(\'0.1\')" onmouseout="menuMouseOut(\'0.1\')">'); 
					} 
				document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%">'); 
					document.write('<tr>');
					if(isHome){
						document.write('	<td>');
					}else{
						document.write('	<td onmouseover="showMenu(\'0.1.1\', 1)" onmouseout="hideMenu(\'0.1.1\', 1)">');
					}
					document.write('		<div id="item 0.1.1" class="menuItemBox">');
					document.write('			<table border="0" cellpadding="0" cellspacing="0" width="100%">');
					document.write('				<tr>');

 
						document.write('				<td valign="center"><a href="/ClientLogin/International" class="navigationLink">Accounts Clearing through Stifel Nicolaus (12/4/2010 and after)</a></td>'); 

					
					document.write('				</tr>');
					document.write('			</table>');
					document.write('		</div>');
					document.write('	</td>');
					document.write('</tr>'); 
					document.write('<tr>');
					if(isHome){
						document.write('	<td>');
					}else{
						document.write('	<td onmouseover="showMenu(\'0.1.2\', 1)" onmouseout="hideMenu(\'0.1.2\', 1)">');
					}
					document.write('		<div id="item 0.1.2" class="menuItemBox">');
					document.write('			<table border="0" cellpadding="0" cellspacing="0" width="100%">');
					document.write('				<tr>');

 
						document.write('				<td valign="center"><a href="/ClientLogin/DomesticAccounts" class="navigationLink">Accounts Clearing through National Financial (activity before 12/04/2010)</a></td>'); 

					
					document.write('				</tr>');
					document.write('			</table>');
					document.write('		</div>');
					document.write('	</td>');
					document.write('</tr>'); 
					document.write('<tr>');
					if(isHome){
						document.write('	<td>');
					}else{
						document.write('	<td onmouseover="showMenu(\'0.1.3\', 1)" onmouseout="hideMenu(\'0.1.3\', 1)">');
					}
					document.write('		<div id="item 0.1.3" class="menuItemBox">');
					document.write('			<table border="0" cellpadding="0" cellspacing="0" width="100%">');
					document.write('				<tr>');

 
						document.write('				<td valign="center"><a href="/ClientLogin/PortfolioAnalytics" class="navigationLink">Portfolio Analytics</a></td>'); 

					
					document.write('				</tr>');
					document.write('			</table>');
					document.write('		</div>');
					document.write('	</td>');
					document.write('</tr>'); 
				document.write('	</table>');
				document.write('</div>'); 
				//add an iframe -  This is a fix for IE where menu drop downs show behind other controls 
				if(browser.isIE) {
					document.write('<iframe id="topnav iframe 0.1" class="menuBoxIframe" src="javascript:false;" scrolling="no" frameborder="0"></iframe>');				
				}
		if(isHome) {
                        document.write('</td>'); 
                        document.write('<td width="1"><img src="/img/blank.gif" width="1"></td>'); 
		} 				
					if(isHome) {
				        	document.write('<td width="25%">');	
						document.write('	<div id="0.2" class="homeMenuBox" onmouseover="homeMenuMouseOver(\'0.2\')" onmouseout="homeMenuMouseOut(\'0.2\')">'); 
					} else {
				 		document.write('	<div id="0.2" class="menuBox" onmouseover="menuMouseOver(\'0.2\')" onmouseout="menuMouseOut(\'0.2\')">'); 
					} 
				document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%">'); 
					document.write('<tr>');
					if(isHome){
						document.write('	<td>');
					}else{
						document.write('	<td onmouseover="showMenu(\'0.2.1\', 1)" onmouseout="hideMenu(\'0.2.1\', 1)">');
					}
					document.write('		<div id="item 0.2.1" class="menuItemBox">');
					document.write('			<table border="0" cellpadding="0" cellspacing="0" width="100%">');
					document.write('				<tr>');

 
						document.write('				<td valign="center"><a href="/AboutUs/PrivateClientServices" class="navigationLink">Private Client Services</a></td>'); 

					
					document.write('				</tr>');
					document.write('			</table>');
					document.write('		</div>');
					document.write('	</td>');
					document.write('</tr>'); 
					document.write('<tr>');
					if(isHome){
						document.write('	<td>');
					}else{
						document.write('	<td onmouseover="showMenu(\'0.2.2\', 1)" onmouseout="hideMenu(\'0.2.2\', 1)">');
					}
					document.write('		<div id="item 0.2.2" class="menuItemBox">');
					document.write('			<table border="0" cellpadding="0" cellspacing="0" width="100%">');
					document.write('				<tr>');

 
						document.write('				<td valign="center"><a href="/AboutUs/Leadership" class="navigationLink">Leadership</a></td>'); 

					
					document.write('				</tr>');
					document.write('			</table>');
					document.write('		</div>');
					document.write('	</td>');
					document.write('</tr>'); 
					document.write('<tr>');
					if(isHome){
						document.write('	<td>');
					}else{
						document.write('	<td onmouseover="showMenu(\'0.2.3\', 1)" onmouseout="hideMenu(\'0.2.3\', 1)">');
					}
					document.write('		<div id="item 0.2.3" class="menuItemBox">');
					document.write('			<table border="0" cellpadding="0" cellspacing="0" width="100%">');
					document.write('				<tr>');

 
						document.write('				<td valign="center"><a href="/AboutUs/Locations" class="navigationLink">Locations</a></td>'); 

					
					document.write('				</tr>');
					document.write('			</table>');
					document.write('		</div>');
					document.write('	</td>');
					document.write('</tr>'); 
				document.write('	</table>');
				document.write('</div>'); 
				//add an iframe -  This is a fix for IE where menu drop downs show behind other controls 
				if(browser.isIE) {
					document.write('<iframe id="topnav iframe 0.2" class="menuBoxIframe" src="javascript:false;" scrolling="no" frameborder="0"></iframe>');				
				}
		if(isHome) {
                        document.write('</td>'); 
                        document.write('<td width="1"><img src="/img/blank.gif" width="1"></td>'); 
		} 				
					if(isHome) {
				        	document.write('<td width="25%">');	
						document.write('	<div id="0.3" class="homeMenuBox" onmouseover="homeMenuMouseOver(\'0.3\')" onmouseout="homeMenuMouseOut(\'0.3\')">'); 
					} else {
				 		document.write('	<div id="0.3" class="menuBox" onmouseover="menuMouseOver(\'0.3\')" onmouseout="menuMouseOut(\'0.3\')">'); 
					} 
				document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%">'); 
					document.write('<tr>');
					if(isHome){
						document.write('	<td>');
					}else{
						document.write('	<td onmouseover="showMenu(\'0.3.1\', 1)" onmouseout="hideMenu(\'0.3.1\', 1)">');
					}
					document.write('		<div id="item 0.3.1" class="menuItemBox">');
					document.write('			<table border="0" cellpadding="0" cellspacing="0" width="100%">');
					document.write('				<tr>');

 
						document.write('				<td valign="center"><a href="/ProductsAndServices/comprehensiveWealthMgmtServices" class="navigationLink">Comprehensive Wealth Management Services</a></td>'); 

					
					document.write('				</tr>');
					document.write('			</table>');
					document.write('		</div>');
					document.write('	</td>');
					document.write('</tr>'); 
					document.write('<tr>');
					if(isHome){
						document.write('	<td>');
					}else{
						document.write('	<td onmouseover="showMenu(\'0.3.2\', 1)" onmouseout="hideMenu(\'0.3.2\', 1)">');
					}
					document.write('		<div id="item 0.3.2" class="menuItemBox">');
					document.write('			<table border="0" cellpadding="0" cellspacing="0" width="100%">');
					document.write('				<tr>');

 
						document.write('				<td valign="center"><a href="/ProductsAndServices/investMgmtConsulting" class="navigationLink">Investment Management Consulting</a></td>'); 

					
					document.write('				</tr>');
					document.write('			</table>');
					document.write('		</div>');
					document.write('	</td>');
					document.write('</tr>'); 
				document.write('	</table>');
				document.write('</div>'); 
				//add an iframe -  This is a fix for IE where menu drop downs show behind other controls 
				if(browser.isIE) {
					document.write('<iframe id="topnav iframe 0.3" class="menuBoxIframe" src="javascript:false;" scrolling="no" frameborder="0"></iframe>');				
				}
		if(isHome) {
                        document.write('</td>'); 
                        document.write('<td width="1"><img src="/img/blank.gif" width="1"></td>'); 
		} 				
					if(isHome) {
				        	document.write('<td width="25%">');	
						document.write('	<div id="0.4" class="homeMenuBox" onmouseover="homeMenuMouseOver(\'0.4\')" onmouseout="homeMenuMouseOut(\'0.4\')">'); 
					} else {
				 		document.write('	<div id="0.4" class="menuBox" onmouseover="menuMouseOver(\'0.4\')" onmouseout="menuMouseOut(\'0.4\')">'); 
					} 
				document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%">'); 
					document.write('<tr>');
					if(isHome){
						document.write('	<td>');
					}else{
						document.write('	<td onmouseover="showMenu(\'0.4.1\', 1)" onmouseout="hideMenu(\'0.4.1\', 1)">');
					}
					document.write('		<div id="item 0.4.1" class="menuItemBox">');
					document.write('			<table border="0" cellpadding="0" cellspacing="0" width="100%">');
					document.write('				<tr>');

 
							document.write('			<td valign="center"><a href="http://www.nasd.com/Investor/Alerts/alert_breakpoint.htm" class="navigationLink" onClick="openLinkInNewWindow(this.href);return false;">Breakpoint Calculation</a></td>'); 

					
					document.write('				</tr>');
					document.write('			</table>');
					document.write('		</div>');
					document.write('	</td>');
					document.write('</tr>'); 
					document.write('<tr>');
					if(isHome){
						document.write('	<td>');
					}else{
						document.write('	<td onmouseover="showMenu(\'0.4.2\', 1)" onmouseout="hideMenu(\'0.4.2\', 1)">');
					}
					document.write('		<div id="item 0.4.2" class="menuItemBox">');
					document.write('			<table border="0" cellpadding="0" cellspacing="0" width="100%">');
					document.write('				<tr>');

 
							document.write('			<td valign="center"><a href="http://www.finra.org/web/groups/corp_comm/documents/rules_regs/p011398.pdf" class="navigationLink" onClick="openLinkInNewWindow(this.href);return false;">Customer Identification Program Notice</a></td>'); 

					
					document.write('				</tr>');
					document.write('			</table>');
					document.write('		</div>');
					document.write('	</td>');
					document.write('</tr>'); 
					document.write('<tr>');
					if(isHome){
						document.write('	<td>');
					}else{
						document.write('	<td onmouseover="showMenu(\'0.4.3\', 1)" onmouseout="hideMenu(\'0.4.3\', 1)">');
					}
					document.write('		<div id="item 0.4.3" class="menuItemBox">');
					document.write('			<table border="0" cellpadding="0" cellspacing="0" width="100%">');
					document.write('				<tr>');

 
							document.write('			<td valign="center"><a href="http://www.finra.org/web/groups/inv_info/documents/investor_information/p037918.pdf" class="navigationLink" onClick="openLinkInNewWindow(this.href);return false;">Customer Account Protection</a></td>'); 

					
					document.write('				</tr>');
					document.write('			</table>');
					document.write('		</div>');
					document.write('	</td>');
					document.write('</tr>'); 
					document.write('<tr>');
					if(isHome){
						document.write('	<td>');
					}else{
						document.write('	<td onmouseover="showMenu(\'0.4.4\', 1)" onmouseout="hideMenu(\'0.4.4\', 1)">');
					}
					document.write('		<div id="item 0.4.4" class="menuItemBox">');
					document.write('			<table border="0" cellpadding="0" cellspacing="0" width="100%">');
					document.write('				<tr>');

 
							document.write('			<td valign="center"><a href="/additionalResources/orderRoutingDisclosure" class="navigationLink">Order Routing Disclosure Info</a></td>'); 

					
					document.write('				</tr>');
					document.write('			</table>');
					document.write('		</div>');
					document.write('	</td>');
					document.write('</tr>'); 
				document.write('	</table>');
				document.write('</div>'); 
				//add an iframe -  This is a fix for IE where menu drop downs show behind other controls 
				if(browser.isIE) {
					document.write('<iframe id="topnav iframe 0.4" class="menuBoxIframe" src="javascript:false;" scrolling="no" frameborder="0"></iframe>');				
				}
		if(isHome) {
                        document.write('</td>'); 
		} 	
		if(isHome) {
                    document.write('	</tr>');
                    document.write('</table>');
                } 
		//top menu colors
	        setTopMenuColors(); 
}
