﻿function HilightTab(iTab, iTotal)
{
    for(var i = 1; i <= iTotal; i++)
    {
        $('#tabimageleft' + i).get(0).src = '/assets/images/tabinactiveleft.gif';
        $('#tabimageright' + i).get(0).src = '/assets/images/tabinactiveright.gif';
        $('#divtab' + i).get(0).className = 'tab_inactive';
        $('#tab' + i).get(0).style.display = 'none';
    }
    
    document.getElementById('tabimageleft' + iTab).src = '/assets/images/tabactiveleft.gif';
    document.getElementById('tabimageright' + iTab).src = '/assets/images/tabactiveright.gif';
    document.getElementById('divtab' + iTab).className = 'tab_active';
    document.getElementById('tab' + iTab).style.display = 'block';
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function getFileExtension(inputId) 
{ 
     var field = "#"+inputId;  
     var fileinput = $(field); 
     if(fileinput==null ) return ""; 
     var filename = fileinput.val(); 
     if( filename.length == 0 ) return ""; 
     var dot = filename.lastIndexOf("."); 
     if( dot == -1 ) return ""; 
     var extension = filename.substr(dot,filename.length); 
     return extension; 
} 

function Trim(str)
{
	return TrimLeft(TrimRight(str));
}

function TrimLeft(sText)
{
	sText = ('' + sText == 'undefined') ? '' : '' + sText;

	while (sText.charAt(0) == ' ')
	{
		sText = sText.substr(1);
	}

	return sText;
}

function TrimRight(sText)
{
	sText = ('' + sText == 'undefined') ? '' : '' + sText;

	while (sText.charAt(sText.length - 1) == ' ')
	{
		sText = sText.substr(0, sText.length - 1);
	}

	return sText;
}
/*
function $()
{
	var elements = new Array();

	for (var i = 0; i < arguments.length; i++)
	{
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);

		if (arguments.length == 1)
			return element;

		elements.push(element);
	}
	return elements;
}

function getElement(id) {
var elem;
if (document.getElementById) { // standard browsers
elem = document.getElementById(id);
} else if (document.all) { // IE 4
elem = document.all[id];
}
return elem;
}
*/
//SELECT ALL CHECKBOXES IN GROUP
function determineCheckedState(sender, target)
{
	var checked = 0;
	if(!sender.length)
	{
	
		
		for (i = 0; i < target.length; i++)
		{
			if(target[i].checked == true)
			{
				checked++;
			}
		}
		if(checked == target.length)
		{
			deselectGroup(target);
			sender.checked = false;
		}
		else
		{
			selectGroup(target);
			sender.checked = true;
		}
	}
	else
	{
		for (i = 0; i < sender.length; i++)
		{
			if(sender[i].checked == true)
			{
				checked++;
			}
		}
		if(checked == sender.length)
		{
			target.checked = true;
		}
		else
		{
			target.checked = false;
		}
	}
}

function selectGroup(group)
{
	for (i = 0; i < group.length; i++)
	{
		group[i].checked = true;
	}
}

function deselectGroup(group)
{
	for (i = 0; i < group.length; i++)
	{
		group[i].checked = false;
	}
}


function ShowFilterTip(id,event) {
	var elem = getElement(id);
	var elemStyle = elem.style || elem; // for NS4, not used here
	
	elemStyle.display = "block";
	
	var width = 123; // default to 100
	var height = 52;
	
	var posX,posY;
	if (event.pageX) { // NS 4, Mozilla
		posX = event.pageX;
		posY = event.pageY;
	} else { // IE, Opera
		var root = document.documentElement || document.body;
		posX = event.clientX + root.scrollLeft;
		posY = event.clientY + root.scrollTop;
	}
	
	elemStyle.top = posY - height  + "px";
	elemStyle.left = posX - width + 15 + "px";
}

function hideFilterTip(id) {
	var elem=document.getElementById(id);
	elem.style.display = "none";
}

function switchTable(currentTab,newTab,currentTable,newTable)	{
	document.getElementById(currentTab).style.display = "none";
	document.getElementById(newTab).style.display = "inline";
	document.getElementById(currentTable).style.display = "none";
	document.getElementById(newTable).style.display = "inline";
}


function toggleComparisonSections(tbody,arrow)
{
	//alert(window.location.protocol + "//" + window.location.host + "/Acquity/ivy_funds/html_templates/");
	if(document.getElementById(tbody).style.display == "none")
	{
		if(navigator.appName == "Microsoft Internet Explorer")
		{
			document.getElementById(tbody).style.display = "inline";
		    document.getElementById(arrow).src = "/assets/images/comparison_section_open.gif";
		}
		else
		{
			document.getElementById(tbody).style.display = "table-row-group";
		    document.getElementById(arrow).src = "/assets/images/comparison_section_open.gif";
		}
	}
	else
	{
		document.getElementById(tbody).style.display = "none";
		document.getElementById(arrow).src = "/assets/images/comparison_section_closed.gif";
	}
}
function showAllComparisonSections()
{
	var tbodyArray = ["comparison_overview_data","comparison_description_data",
	                  "comparison_returns_data_monthly",
	                  "comparison_returns_data_quarterly",
	                  "comparison_risk_data",
	                  "comparison_asset_data",
	                  "comparison_holdings_data",
	                  "comparison_sectors_data",
	                  "comparison_country_data",
	                  "comparison_expense_data",
	                  "comparison_growth_data",
	                  "comparison_morningstar_data",
	                  "comparison_lipper_data",
	                  "comparison_quality_data",
	                  "comparison_maturity_data",
	                  "comparison_market_data",
	                  "comparison_portfolio_data",
	                  "comparison_privatefootnotes_data"];
	                  
	var imageArray = ["comparison_overview_section",
	                  "comparison_description_section",
	                  "comparison_returns_section_monthly",
	                  "comparison_returns_section_quarterly",
	                  "comparison_risk_section",
	                  "comparison_asset_section",
	                  "comparison_holdings_section",
	                  "comparison_sectors_section",
	                  "comparison_country_section",
	                  "comparison_expense_section",
	                  "comparison_growth_section",
	                  "comparison_morningstar_section",
	                  "comparison_lipper_section",
	                  "comparison_quality_section",
	                  "comparison_maturity_section",
	                  "comparison_market_section",
	                  "comparison_portfolio_section",
	                  "comparison_privatefootnotes_section"];
	                  
	for(var x = 0; x < tbodyArray.length; x++)
	{
	
		if(navigator.appName == "Microsoft Internet Explorer")
		{
			document.getElementById(tbodyArray[x]).style.display = "inline";
		}
		else
		{
			document.getElementById(tbodyArray[x]).style.display = "table-row-group";
        }
	    
		document.getElementById(imageArray[x]).src = "/assets/images/comparison_section_open.gif";
	}
}
function hideAllComparisonSections()
{
	var tbodyArray = ["comparison_overview_data","comparison_description_data",
	                  "comparison_returns_data_monthly",
	                  "comparison_returns_data_quarterly",
	                  "comparison_risk_data",
	                  "comparison_asset_data",
	                  "comparison_holdings_data",
	                  "comparison_sectors_data",
	                  "comparison_country_data",
	                  "comparison_expense_data",
	                  "comparison_growth_data",
	                  "comparison_morningstar_data",
	                  "comparison_lipper_data",
	                  "comparison_quality_data",
	                  "comparison_maturity_data",
	                  "comparison_market_data",
	                  "comparison_portfolio_data",
	                  "comparison_privatefootnotes_data"];
	                  
	var imageArray = ["comparison_overview_section",
	                  "comparison_description_section",
	                  "comparison_returns_section_monthly",
	                  "comparison_returns_section_quarterly",
	                  "comparison_risk_section",
	                  "comparison_asset_section",
	                  "comparison_holdings_section",
	                  "comparison_sectors_section",
	                  "comparison_country_section",
	                  "comparison_expense_section",
	                  "comparison_growth_section",
	                  "comparison_morningstar_section",
	                  "comparison_lipper_section",
	                  "comparison_quality_section",
	                  "comparison_maturity_section",
	                  "comparison_market_section",
	                  "comparison_portfolio_section",
	                  "comparison_privatefootnotes_section"];
	for(var x = 0; x < tbodyArray.length; x++)
	{
		document.getElementById(tbodyArray[x]).style.display = "none";
		document.getElementById(imageArray[x]).src = "/assets/images/comparison_section_closed.gif";
	}
}



var menuwidth='225px' //default menu width
var menubgcolor='#a0681a' //menu bgcolor
var disappeardelay=250 //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
//if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
var iframeElement = document.getElementById('selectblocker')
if(iframeElement != null)
{
	iframeElement.style.visibility = "hidden";
}
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)
if(navigator.appName == "Microsoft Internet Explorer")
{

    var iSlash = window.location.pathname.lastIndexOf('/');
    var iLen = window.location.pathname.length;
    var iRemove = 0;
    if(iSlash > 0)
    {
        if(iSlash + 1 != iLen)
        {
            iRemove = iSlash;
        }
    }
    
    var sURLToUse = window.location.protocol + '//' + window.location.hostname + window.location.pathname.substring(0, iSlash + 1);
    
    //alert(window.location.pathname.substring(0, iSlash + 1));
	dropmenuobj.insertAdjacentHTML("afterEnd", '<IFRAME style="position: absolute;z-index:4; visibility:hidden;" src="' + sURLToUse + 'blank.html" frameBorder="0" scrolling="no" id="selectblocker" />');
	iframeShim = document.getElementById? document.getElementById("selectblocker") : selectblocker;
}

//if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)

dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
if(navigator.appName == "Microsoft Internet Explorer")
{
	iframeShim.style.visibility = "visible";
	iframeShim.style.top = dropmenuobj.style.top; 
	iframeShim.style.left = dropmenuobj.style.left;
	iframeShim.style.width = dropmenuobj.offsetWidth; 
	iframeShim.style.height = dropmenuobj.offsetHeight; 
}
//}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function DoSearch()
{
   window.location.href='searchFrame.aspx?search=' + escape(document.getElementById('txtSearch').value);
   return false;
}

function DoKeyDown(e)
{
    var keynum;

    if(window.event) // IE
    {
        keynum = e.keyCode;
    }
    else if(e.which) // Netscape/Firefox/Opera
    {
        keynum = e.which;
    }
    
    if(keynum == 13)
    {
        return DoSearch();
    }
    else
    {
        return true;
    }
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
    if (typeof dropmenuobj!="undefined"){
        if (ie4||ns6){
            if(navigator.appName == "Microsoft Internet Explorer"){iframeShim.style.visibility = "hidden";}
            dropmenuobj.style.visibility="hidden";
        }
    }
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
    if (typeof delayhide!="undefined")
    clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu



