var TAB_NAMES_ARRAY = new Array("performance", "fundmanagement", "fundholdings", "howtoinvest");

function doTabRollover(id, mode) {
	var tabImgId = id + "tabimg";
	var tabImgObj;
	if (document.getElementById && document.getElementById(tabImgId)) {
		tabImgObj = document.getElementById(tabImgId);
	} else if (document.all && document.all.item && document.all.item(tabImgId)) {
		tabImgObj = document.all.item(tabImgId);
	} else {
		return;
	}
	if (!tabImgObj || !tabImgObj.src) { return; }
	if (tabImgObj.src.indexOf("/images/dtf/profiles/tabs/" + id + "_on.gif") == -1) {
		if (mode == "over") {
			tabImgObj.src = "/images/dtf/profiles/tabs/" + id + "_over.gif";
		} else if (mode == "out") {
			tabImgObj.src = "/images/dtf/profiles/tabs/" + id + "_off.gif";
		}
	}
}

function doTabSelect(id) {
	var tabImgId;
	var tabImgObj;
	var divId;
	var divObjStyle;
	for (var i = 0; i < TAB_NAMES_ARRAY.length; i++) {
		tabImgId = TAB_NAMES_ARRAY[i] + "tabimg";
		divId = "profiletab" + TAB_NAMES_ARRAY[i];
		if (document.getElementById && document.getElementById(tabImgId)) {
			tabImgObj = document.getElementById(tabImgId);
			divObjStyle = document.getElementById(divId).style;
		} else if (document.all && document.all.item && document.all.item(tabImgId)) {
			tabImgObj = document.all.item(tabImgId);
			divObjStyle = document.all.item(divId).style;
		} else {
			return;
		}
		if (!tabImgObj || !divObjStyle) { continue; }
		if (TAB_NAMES_ARRAY[i] == id) {
			tabImgObj.src = "/images/dtf/profiles/tabs/" + TAB_NAMES_ARRAY[i] + "_on.gif";
			divObjStyle.visibility = "visible";
		} else {
			tabImgObj.src = "/images/dtf/profiles/tabs/" + TAB_NAMES_ARRAY[i] + "_off.gif";
			divObjStyle.visibility = "hidden";
		}
	}
}

function adjustContainerDiv() {
	var tabDivObjArray = new Array();
	var tabContainerObj;
	var maxDivHeight = 0;
	var tabCounter;
	if (document.getElementById && document.getElementById("profiletabcontainer")) {

		for (tabCounter = 0; tabCounter < TAB_NAMES_ARRAY.length; tabCounter++) {
			tabDivObjArray[tabCounter] = document.getElementById("profiletab" + TAB_NAMES_ARRAY[tabCounter]);
		}
		tabContainerObj = document.getElementById("profiletabcontainer");

	} else if (document.all && document.all.item && document.all.item("profiletabcontainer")) {

		for (tabCounter = 0; tabCounter < TAB_NAMES_ARRAY.length; tabCounter++) {
			tabDivObjArray[tabCounter] = document.all.item("profiletab" + TAB_NAMES_ARRAY[tabCounter]);
		}
		tabContainerObj = document.all.item("profiletabcontainer");

    } else {

        return;

    }

	for (tabCounter = 0; tabCounter < tabDivObjArray.length; tabCounter++) {
		if (tabDivObjArray[tabCounter].offsetHeight && tabDivObjArray[tabCounter].offsetHeight > maxDivHeight) {
			maxDivHeight = tabDivObjArray[tabCounter].offsetHeight;
		}
	}

	if (tabContainerObj.style) {
		tabContainerObj.style.height = (maxDivHeight + 30) + "px";
	}
}

function swapImage(imgId, newSrc) {
	if (imgId == null || imgId == "" || newSrc == null || newSrc == "") {
		return;
	}
	if (document.getElementById && document.getElementById(imgId)) {
		var Img = document.getElementById(imgId);
		Img.setAttribute("src", newSrc);
	} else if (document.all && document.all.item && document.all.item(imgId)) {
		document.all.item(imgId).src = newSrc;
	} else if (document.images && document.images[imgId]) {
		document.images[imgId].src = newSrc;
	} else {
		return;
	}
}

function popProfileWindow(width, height, url) {
	if (width <= 0 || width % 1 > 0 || height <= 0 || height % 1 > 0 || url == null || url == "") {
		return;
	}
	var left = (screen.availWidth - width) / 2;
	var top = (screen.availHeight - height) / 2;
	var newWindow = window.open(url, "popwindow", "height=" + height + ",left=" + left + ",screenX=" + left + ",screenY=" + top + ",scrollbars,top=" + top + ",width=" + width);
	newWindow.focus();
}