/* header javascript for bigpond external 3rd party hostings */

function rollover(pos, name) {
	document.images[pos].src = eval(name + ".src"); 
}

function rollOn(oImg) {
	oImg.src = oImg.src.substring(0, oImg.src.length - 4) + "_on" + oImg.src.substring(oImg.src.length - 4, oImg.src.length);
}

function rollOff(oImg) {
	oImg.src = oImg.src.substring(0, oImg.src.length - 7) + oImg.src.substring(oImg.src.length - 4, oImg.src.length);
}

//Menu Functions
var timeOut = null;
var isOn = false;
var oCurrentlyHighlighted = null;
var sCurrentlyHighlightedCSS = "";

function showHeaderMenu(divID) {
	if (timeOut) clearTimeout(timeOut);
	if (isOn) killAll();
	if (document.getElementById(divID) != null) document.getElementById(divID).style.visibility = 'visible';
	isOn = true;
	
	if(document.getElementById("selectbox") && document.getElementById("selectempty") && (window.location.href.indexOf("/email") == -1) )
	{
		document.getElementById("selectbox").style.display = "none";
		document.getElementById("selectempty").style.display = "block";
	}
			
	if (document.getElementById("helpProductsSelect") != null) {
		document.getElementById("helpProductsSelect").style.display = "none";
		document.getElementById("helpProductsDummyDiv").style.display = "block"
	}
	
	oCurrentlyHighlighted = document.getElementById("n" + divID.charAt(divID.length-1));
	sCurrentlyHighlightedCSS = oCurrentlyHighlighted.className;
	oCurrentlyHighlighted.className = "globalTabOver";
	showTabBorder(divID);
}

function showTabBorder(divID)
{
	if (document.getElementById("imgTabRight" + divID) != null) {
		oItem = document.getElementById("imgTabRight" + divID);
		oItem.src = '/res/images/header/corner_top_right.gif';
	}	
	if (document.getElementById("imgTabLeft" + divID) != null) {
		oItem = document.getElementById("imgTabLeft" + divID);
		oItem.src = '/res/images/header/corner_top_left.gif';
	}	
}

function hideTabBorder(divID)
{
	if (document.getElementById("imgTabRight" + divID) != null) {
		oItem = document.getElementById("imgTabRight" + divID);
		oItem.src = '/res/images/header/global_right_tab.gif';
	}	
	if (document.getElementById("imgTabLeft" + divID) != null) {
		oItem = document.getElementById("imgTabLeft" + divID);
		oItem.src = '/res/images/header/global_left_tab.gif';
	}	
}

function hideHeaderMenu(divID) {
	if (document.getElementById(divID) != null) document.getElementById(divID).style.visibility = 'hidden';
	timeOut = 0;
	isOn = false;
	if(document.getElementById("selectbox") && document.getElementById("selectempty") && (window.location.href.indexOf("/email") == -1))
	{
		document.getElementById("selectbox").style.display = "block";
		document.getElementById("selectempty").style.display = "none";
	}
		
	if (document.getElementById("helpProductsSelect") != null) {
		document.getElementById("helpProductsSelect").style.display = "block";
		document.getElementById("helpProductsDummyDiv").style.display = "none"
	}
	if (oCurrentlyHighlighted != null) 
	{
		oCurrentlyHighlighted.className = sCurrentlyHighlightedCSS;					
	}
}

function killAll(){
	for(var i=1; i<7; i++) hideHeaderMenu("info_" + i);
}

function sleephide(divID) {
    if (navigator.appVersion.indexOf("Mac") > - 1 && navigator.appVersion.indexOf("Safari") > -1) hideHeaderMenu(divID);
	else timeOut = setTimeout('hideHeaderMenu(\'' + divID + '\')',400);
	hideTabBorder(divID);
}

function getObjPosition(obj,mode){// mode : top of left
	iPos = (mode) ? obj.offsetLeft : obj.offsetTop;
	while(obj.offsetParent != null){
		iPos += (mode) ? obj.offsetParent.offsetLeft : obj.offsetParent.offsetTop; 
		obj = obj.offsetParent;
	}
	return iPos;
}


function centreHeaderMenus()
{
	for (i=1;i<=6;i++) {
	    if (document.getElementById("n" + i) != null && document.getElementById("info_" + i) != null) 
	    {
            iLeft = getObjPosition(document.getElementById("n" + i),true);
            if (iLeft < 0) iOffset = 0;
            document.getElementById("info_" + i).style.left = iLeft + 'px';
	    
            iTop = getObjPosition(document.getElementById("n" + i),false);
            if (iTop > 0) document.getElementById("info_" + i).style.top = iTop + 22 + 'px';
        }
	}
	
	var sHeaderAdRight;
	if(navigator.appName.indexOf("Internet Explorer") > -1 ) sHeaderAdRight = ((document.body.clientWidth - 770) / 2) + 18 + "px";
	else sHeaderAdRight = ((document.documentElement.clientWidth - 770) / 2) + 9 + "px";
	document.getElementById("universalHeaderAd").style.textAlign = "right";
	document.getElementById("universalHeaderAd").style.right = sHeaderAdRight;
	if (!(navigator.appName.indexOf("Internet Explorer") > -1 && navigator.platform.indexOf("Mac") > -1))
	    document.getElementById("universalHeaderAd").style.display = "block";

}

// left nav
function writeNav() {
	if( (typeof aV7Nav) == "object") {
		sSubsection = '';
		for (i=0;i<aV7Nav.length;i++) {
			// level 1
			if(aV7Nav[i][0].length > 0) {
			    sSubsection += '<div class="';
			    if (aV7Nav[i][3].length) {

			    	if (aV7Nav[i][2]) {
			    		if (aV7Nav[i][0].length < 16) sSubsection += 'ntc';
			    		else if (aV7Nav[i][0].length > 26) sSubsection += 'ntcTall3Line';
			    		else sSubsection += 'ntcTall';
			    	}
			    	else {
			    		if (aV7Nav[i][0].length < 16) sSubsection += 'navcell';
			    		else if (aV7Nav[i][0].length > 26) sSubsection += 'navcellTall3Line';
			    		else sSubsection += 'navcellTall';
			    	}	
			    }
			    else sSubsection += (aV7Nav[i][0].length < 16 ? 'navcell' : 'navcellTall');
			    if (aV7Nav[i][0].length >= 16 && aV7Nav[i][0].length < 22) {
			    	// add line break so mouse over bolding doesnt break
			    	sTmp = aV7Nav[i][0].substr(0,aV7Nav[i][0].lastIndexOf(' ')) + "<br />" + aV7Nav[i][0].substr(aV7Nav[i][0].lastIndexOf(' '), aV7Nav[i][0].length);
			    	aV7Nav[i][0] = sTmp;
			    }
			    if (aV7Nav[i][0] == "HELP CENTRE") aV7Nav[i][0] = "<b>" + aV7Nav[i][0] + "</b>";
			    sSubsection += '" onMouseOver="this.style.fontWeight=\'bold\';" onMouseOut="this.style.fontWeight=\'normal\';" onClick="location.href=\''+aV7Nav[i][1]+'\'">'+aV7Nav[i][0]+'</div>';
			    // level 2
			    if (aV7Nav[i][3].length && aV7Nav[i][2]) {
			    	for(j=0;j<aV7Nav[i][3].length;j++) {
			    	    if (aV7Nav[i][3][j][0].length > 13 && aV7Nav[i][3][j][0].length < 24) {// add line break so mouse over bolding doesnt break
							sTmp = aV7Nav[i][3][j][0].substr(0,aV7Nav[i][3][j][0].lastIndexOf(' ')) + "<br />" + aV7Nav[i][3][j][0].substr(aV7Nav[i][3][j][0].lastIndexOf(' '), aV7Nav[i][3][j][0].length);
							aV7Nav[i][3][j][0] = sTmp;
						}
			    	    if(aV7Nav[i][3][j][0].length > 0) {
			    			sSubsection += '<div class="spacer"></div>';
			    			sSubsection += '<div class="';
			    			// either normal, current, normal last item, current last item 
			    			if (j == (aV7Nav[i][3].length-1)) {
			    				// last item
			    				if (aV7Nav[i][3][j][2]) {
			    					if (aV7Nav[i][3][j][3].length) {
			    						// current last with 3rd levels behaves as normal current 2nd
			    						sSubsection += "nlc";
			    						sSubsection += '" onMouseOver="this.style.fontWeight=\'normal\';" onMouseOut="this.style.fontWeight=\'bold\'" ';
			    					}
			    					else {
			    					    aV7Nav[i][3][j][0] = aV7Nav[i][3][j][0].replace("<br />","");
			    					    sSubsection += (aV7Nav[i][3][j][0].length < 15 ? 'nbco' : 'nbcoTall');
			    					}
			    				}
			    				else { //last l2 item, no 3rds > padding means 15 charcters wrap
			    					sSubsection += (aV7Nav[i][3][j][0].length < 15 ? 'nbc' : 'nbcTall');
			    					sSubsection += '" onMouseOver="this.className=\'' + (aV7Nav[i][3][j][0].length < 15 ? 'nbco' : 'nbcoTall') + '\';" onMouseOut="this.className=\'' + (aV7Nav[i][3][j][0].length < 15 ? 'nbc' : 'nbcTall') + '\'" ';
			    				}
			    			}
			    			else {
			    				// normal
			    				if (aV7Nav[i][3][j][2]) {
			    					sSubsection += "nlc";
			    					sSubsection += '" onMouseOver="this.style.fontWeight=\'normal\';" onMouseOut="this.style.fontWeight=\'bold\'" ';
			    				}
			    				else {
			    					sSubsection += "ndc";
			    					sSubsection += '" onMouseOver="clearFirefox(this);this.className=\'nlc\';" onMouseOut="this.className=\'ndc\'" ';
			    				}
			    			}
			    			sSubsection += ' onClick="location.href=\''+aV7Nav[i][3][j][1]+'\'">';
			    			sSubsection += (aV7Nav[i][3][j][2] ? '<img src="/res/images/bullseye/leftnav/arrow4.gif" width="4" height="7" alt="" />&nbsp;' : '')+aV7Nav[i][3][j][0]+'</div>';
			    			// 3rd level
			    			if (aV7Nav[i][3][j][2] && aV7Nav[i][3][j][3] ) {
			    				for(k=0;k<aV7Nav[i][3][j][3].length;k++){
			    				    if(aV7Nav[i][3][j][3][k][0].length > 0) {
			    					    if ( (k == aV7Nav[i][3][j][3].length - 1) && (j == aV7Nav[i][3].length - 1)) {
			    					    	//last 3rd level on last 2nd level, so base of a menu
			    					    	sCss = "nwcLast"; sCssOn = "nwcoLast";
			    					    	if (aV7Nav[i][3][j][3][k][0].length >= 15) {sCss = "nwcLastTall"; sCssOn = "nwcoLastTall";}
			    					    	if (aV7Nav[i][3][j][3][k][0].length > 35 || (aV7Nav[i][3][j][3][k][0].length > 25 && aV7Nav[i][3][j][3][k][2]) || navigator.appVersion.indexOf("Mac") > -1 && aV7Nav[i][3][j][3][k][0].length > 30) {sCss = "nwcLastTall3Line"; sCssOn = "nwcoLastTall3Line";}
			    					    	sSubsection += '<div class="' + sCss + '" '+(aV7Nav[i][3][j][3][k][2] ? ' style="font-weight:bold;text-decoration:none;"' : '' )+' onMouseOver="this.className=\'' + sCssOn + '\'" onMouseOut="this.className=\'' + sCss + '\'" onClick="location.href=\''+aV7Nav[i][3][j][3][k][1]+'\'">'+aV7Nav[i][3][j][3][k][0]+'</div>';
			    					    } else sSubsection += '<div class="nwc" '+(aV7Nav[i][3][j][3][k][2] ? ' style="font-weight:bold;text-decoration:none;"' : '' )+' onMouseOver="this.className=\'nwco\'" onMouseOut="this.className=\'nwc\'" onClick="location.href=\''+aV7Nav[i][3][j][3][k][1]+'\'">'+aV7Nav[i][3][j][3][k][0]+'</div>';
			    					}
			    			    }
			    		    }
			    		}
			    	}
			    }
			}
		}
		document.getElementById("nav").innerHTML = sSubsection;
	}
}

//firefox problems mouseOut
var oLastDiv = null;
function clearFirefox(div) {
	if (oLastDiv == null) {
		oLastDiv = div;
		oLastDivCss = div.className;
	}
	else {
		// reset last div
		oLastDiv.className = oLastDivCss;
		// set current div to be reset next
		oLastDiv = div;
		oLastDivCss = div.className;
	}
}


// head_array.js
var hd1='<div style="padding:4px;padding-left:10px;border-top:1px solid #0276B1;border-right:1px solid #0276B1;border-left:1px solid #0276B1;font-family:verdana,sans-serif;font-size:11px">';
var hd2='<div style="padding:4px;padding-left:10px;border-bottom:1px solid #0276B1;border-right:1px solid #0276B1;border-left:1px solid #0276B1;font-family:verdana,sans-serif;font-size:11px">';
var hdrNorm='<div style="padding:4px;padding-left:10px;border-right:1px solid #0276B1;border-left:1px solid #0276B1;font-family:verdana,sans-serif;font-size:11px">';
var hdrOver='<div style="background:#D9ECFF;padding:4px;padding-left:10px;border-right:1px solid #0276B1;border-left:1px solid #0276B1;font-family:verdana,sans-serif;font-size:11px">';
var hdrEnd="</div>";
var hd4='<div style="padding:4px;padding-left:10px;border:1px solid #0276B1;font-family:verdana,sans-serif;font-size:11px">';

sHost = "www.bigpond.com";
if (location.host.indexOf("dev") > -1) sHost = "iadev.bigpond.com";
if (location.host.indexOf("iate1") > -1 || location.host.indexOf("ia1") > -1) sHost = "www.iate1.bigpond.com";
if (location.host.indexOf("iate2") > -1 || location.host.indexOf("ia2") > -1) sHost = "www.iate2.bigpond.com";
if (location.host.indexOf("staging") > -1) sHost = "www.staging.bigpond.com";
document.write ('<scri' + 'pt type="text/javascript" src="' + location.protocol + '//' + sHost + '/res/javascript/head_array.js"><\/scri'+'pt>');


