
var itemIdMaster;
var bottomval=0;

function showMenu(itemId){
	itemIdMaster = itemId;
    if (document.getElementById) {
       var navLeft_id = document.getElementById(itemId+'Left');
	   var navCenter_id= document.getElementById(itemId+'Center');
	   var navRight_id= document.getElementById(itemId+'Right');
	   var menuFoot_id = document.getElementById(itemId+'_foot');
   
	   if (navLeft_id!=null){
			navLeft_id.className = 'menu1openLeft';
	   }
	   
	   if (navCenter_id!=null){
			navCenter_id.className = 'menu1open';
	   }
		   
	   if (navRight_id!=null){
			navRight_id.className = 'menu1openRight';
	   }
	   	   	   
	   if (menuFoot_id!=null){	
	     	menuFoot_id.className = 'footerOn';
	   }
	   
	}

}


// this function determines whether the event is the equivalent of the microsoft
// mouseleave or mouseenter events. (e)= event ;  (handler) = the event handler ; 
// this is a fix for nested div problem
function isMouseLeaveOrEnter(e, handler)
{		
	if (e.type != 'mouseout' && e.type != 'mouseover') return false;
	var reltg = e.relatedTarget ? e.relatedTarget :
	e.type == 'mouseout' ? e.toElement : e.fromElement;
	while (reltg && reltg != handler) reltg = reltg.parentNode;
	return (reltg != handler);
}


function showQuickSubMenu(itemId){
	if (document.getElementById) {
       var nav_id = document.getElementById(itemId);
	   var nav_subId = document.getElementById(itemId+'Contents');
	   		if (nav_id!=null){								
	   			nav_id.className = 'subContainer show';
				maxHeight=nav_subId.offsetHeight;
				bottomval=maxHeight;
				nav_subId.style.clip="rect(0px,155px,"+maxHeight+"px,0px)";	
	   		}
	  }
}

function showSubMenu(itemId){
	if(bottomval==1){
		bottomval = 0;
	}	
	 if (document.getElementById && bottomval==0) {
       var nav_id = document.getElementById(itemId);
	   var nav_subId = document.getElementById(itemId+'Contents');
	   		if (nav_id!=null){	
				nav_subId.style.clip="rect(0px,155px,0px,0px)";							
	   			nav_id.className = 'subContainer show';
				maxHeight=nav_subId.offsetHeight;
				openScrollMenu(""+itemId+'Contents'+"", maxHeight);	
	   		}
	  }
}

function openScrollMenu(subItem, maxHeight){
	var nav_subId = document.getElementById(subItem);
	if(bottomval<maxHeight && bottomval!=1){ 
		nav_subId.style.clip="rect(0px,155px,"+bottomval+"px,0px)";
		setTimeout("openScrollMenu('"+subItem+"',"+maxHeight+")",10);
		bottomval=bottomval+5;
	}
}

function hideSubMenu(itemId){
	bottomval = 1;	
	 if (document.getElementById) {
       var nav_id = document.getElementById(itemId);
	   var nav_subId = document.getElementById(itemId+'Contents');
	   		if (nav_id!=null){				
				nav_id.className = 'subContainer hide';
				nav_subId.style.clip="rect(0px,155px,0px,0px)";	   			
	   		}

	  }
}

function hideToggleInfo(){	
	 if (document.getElementById) {
       var nav_id = document.getElementById('toggleInfo');
	   		if (nav_id!=null){
	   			nav_id.className = 'toggleInfoContainer hide';
	   		}

	  }
}



function showToggleInfo(){	
	 if(document.getElementById) {
       var nav_id = document.getElementById('toggleInfo');
	   		if (nav_id!=null){
	   			nav_id.className = 'toggleInfoContainer show';
	   		}

	  }
}

function hoverMenu(itemId){
	   var navLeft_id = document.getElementById(itemId+'Left');
	   var navCenter_id= document.getElementById(itemId+'Center');
	   var navRight_id= document.getElementById(itemId+'Right');
	   
	   if(document.getElementById && itemIdMaster!=itemId){
		   if (navLeft_id!=null){
				navLeft_id.className = 'menu1openLeft';
		   }
		   
		   if (navCenter_id!=null){
				navCenter_id.className = 'menu1open';
		   }
		   
		   if (navRight_id!=null){
				navRight_id.className = 'menu1openRight';
		   }
		 }
}

function regularMenu(itemId){
	   var navLeft_id = document.getElementById(itemId+'Left');
	   var navCenter_id= document.getElementById(itemId+'Center');
	   var navRight_id= document.getElementById(itemId+'Right');
	   
	   if(document.getElementById && itemIdMaster!=itemId){   
		   if (navLeft_id!=null){
				navLeft_id.className = 'menu1Left';
		   }
		   
		   if (navCenter_id!=null){
				navCenter_id.className = 'menu1';
		   }
		   
		   if (navRight_id!=null){
				navRight_id.className = 'menu1Right';
		   }
		 }
}


function sideNavShow(){
	if(document.getElementById){
		document.getElementById('sideNav').src="images/etfs_over_alpha.gif";
	}
}

function sideNavHide(){
	if(document.getElementById){
		document.getElementById('sideNav').src="images/etfs_normal.gif";
	}
}

function checkHeight(){
	//The purpose of this function is to make sure the footer is at the bottom of the window if 
	// the content is shorter than the window height
	var windowHeight=pageHeight();
	var headerHeight=document.getElementById('headerContainer').offsetHeight;
	var menuHeight=document.getElementById('menuContainer').offsetHeight;
	var footerHeight=document.getElementById('footerContainer').offsetHeight;
	var contentHeight=document.getElementById('contentContainer').offsetHeight;
	var minContentHeight;
	//First, take the height of the window subtract the height of the other divs to figure out
	//  what the minimum contentContainer height should be.
	minContentHeight=windowHeight-headerHeight-menuHeight-footerHeight;
	if(contentHeight<minContentHeight){
		if (document.getElementById) {
			document.getElementById('contentContainer').style.height=minContentHeight+'px';
		}
	}
}

function pageHeight(){
	return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
} 


// This function is used to blank out the default contents of the text box. Called onFocus of text boxes.
// itemId = the id of the text box
function blankOut(itemId){
	if(document.getElementById){
		document.getElementById(itemId).value="";
	}
}

// This function is used to put back the default contents of the text box if the user has left it blank. Called onBlur of text boxes.
// itemId = the id of the text box; originalVal = the original 'value' contents
function checkBlank(itemId, originalVal){
	if(document.getElementById){
		textbox = document.getElementById(itemId);
		if(textbox.value==""){
			textbox.value=originalVal;
		}
	}
}

function showQuickLink(linkId){
	for(i=1; i<100; i++){ 
		if(document.getElementById("quickLink_M"+i)!=null){
			document.getElementById("quickLink_F"+i).className="quickLinkContainer hide";
			document.getElementById("quickLink_P"+i).className="quickLinkContainer hide";
			document.getElementById("quickLink_M"+i).className="quickLinkContainer hide";
			document.getElementById("quickLink_SI"+i).className="quickLinkContainer hide";
			document.getElementById("quickLink_PR"+i).className="quickLinkContainer hide";
		}else{
			break;
		}	
	}
	
	if(linkId!=""){
		document.getElementById(linkId).className="quickLinkContainer show";
	}
}

function showIndexQuickLink(linkId){
	for(i=0; i<100; i++){ 
		if(document.getElementById("quickLink_D"+i)!=null){
			document.getElementById("quickLink_D"+i).className="quickLinkContainer hide";		
		}else{
			i=200;
		}
	}
	for(i=0; i<100; i++){ 
		if(document.getElementById("quickLink_CW"+i)!=null){
			document.getElementById("quickLink_CW"+i).className="quickLinkContainer hide";	
		}else{
			i=200;
		}
	}
	
	
	if(document.getElementById(linkId)!=null){
		document.getElementById(linkId).className="quickLinkContainer show";
	}
}


function changeLanguage(val){
	if(val.value!='this'){
		var uri = new Object();
		getURL(uri);
		if(uri.ext==""){
				uri.ext='asp';
		}
		if(val.value=='fr'){
			if(uri.ext==""){
				window.location=uri.dir+'/fr/';
			}else{
				window.location=uri.dir+'/fr/'+uri.page+'.'+uri.ext;
			}
		}else{			
			if(uri.ext==""){
				window.location=uri.dir.substr(0,uri.dir.length-2);
			}else{
				window.location=uri.dir.substr(0,uri.dir.length-2)+uri.page+'.'+uri.ext;
			}			
		}	
	}
}


// Current Page Reference
// copyright Stephen Chapman, 1st Jan 2005
// you may copy this function but please keep the copyright notice with it
function getURL(uri) {
	uri.dir = location.href.substring(0, location.href.lastIndexOf('\/'));
	uri.dom = uri.dir; if (uri.dom.substr(0,7) == 'http:\/\/') uri.dom = uri.dom.substr(7);
	uri.path = ''; var pos = uri.dom.indexOf('\/'); if (pos > -1) {uri.path = uri.dom.substr(pos+1); uri.dom = uri.dom.substr(0,pos);}
	uri.page = location.href.substring(uri.dir.length+1, location.href.length+1);
	pos = uri.page.indexOf('?');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
	pos = uri.page.indexOf('#');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
	uri.ext = ''; pos = uri.page.indexOf('.');if (pos > -1) {uri.ext =uri.page.substring(pos+1); uri.page = uri.page.substr(0,pos);}
	uri.file = uri.page;
	if (uri.ext != '') uri.file += '.' + uri.ext;
	if (uri.file == '') uri.page = 'index';
	uri.args = location.search.substr(1).split("?");
	return uri;
}