// JavaScript Document
//
var parentMenu = null;
var childMenu = null;
var sideMenu = null;
var parentOn = false;
var childOn = false;
var sideOn = false;
//
var agt=navigator.userAgent.toLowerCase();
//
function rollOffs() {
    if (agt.indexOf('msie 5.23; mac_powerpc') == -1) {
        hideMenus();
    } else {
        // nothing yet.
    }
}
//
function arrowPos(xPos) {
    var n = xPos + 'px';
    document.getElementById('navArrow').style.left = n;
    document.getElementById('navArrow').style.visibility = 'visible';
}
//
function arrowOff() {
    if (parentOn == false) {
    document.getElementById('navArrow').style.visibility = 'hidden';
    }
}
//
function showMenu(n,xPos) {
    hideMenus();
    arrowPos(xPos);
    document.getElementById(n).style.visibility = 'visible';
    parentMenu = n;
    parentOn = true;
};
//
function showChild(n) {
    hideChild();
    document.getElementById(n).style.visibility = 'visible';
    childMenu = n;
    childOn = true;
};
//
function showSideChild(n) {
    hideSide();
    document.getElementById(n).style.visibility = 'visible';
    sideMenu = n;
    sideOn = true;
}
//
function hideMenus() {
    if (childOn) {
        document.getElementById(childMenu).style.visibility = 'hidden';
        childMenu = null;
        childOn = false;
    }
    if (parentOn) {
        document.getElementById(parentMenu).style.visibility = 'hidden';
        parentMenu = null;
        parentOn = false;
    }
    if (sideOn) {
        document.getElementById(sideMenu).style.visibility = 'hidden';
        sideMenu = null;
        sideOn = false;
    }
    arrowOff();
};
//
function hideChild() {
    if (childOn) {
        document.getElementById(childMenu).style.visibility = 'hidden';
        childMenu = null;
        childOn = false;
    }
}

//
function hideSide() {
    hideMenus();
    if (sideOn) {
        document.getElementById(sideMenu).style.visibility = 'hidden';
        sideMenu = null;
        sideOn = false;
    }
}
//

// Flash heading tool
function flashHeading (word) {
    // Embed title flash using Javascript to Pretty up the page.
    //
    var flStr = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
    flStr += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ';
    flStr += ' WIDTH="486" HEIGHT="17" id="heading" ALIGN="">';
    flStr += '<PARAM NAME=movie VALUE="flash/heading.swf">';
    flStr += '<PARAM NAME=quality VALUE=high>';
    flStr += '<PARAM NAME=bgcolor VALUE=#FFFFFF>';
    flStr += '<PARAM NAME=FlashVars VALUE="heading='+word+'">';
    flStr += '<EMBED src="flash/heading.swf" quality=high bgcolor=#FFFFFF  WIDTH="375" HEIGHT="35"';
    flStr += ' NAME="heading" ALIGN="" TYPE="application/x-shockwave-flash"';
    flStr += ' FLASHVARS="heading='+word+'"';
    flStr += ' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
    document.write(flStr);
}


// Functions to build navigation
function buildSidemenu(arr) {
    // arr format: name, link
    var sb = '<table class="sidePopMenu" border="0" cellpadding="0" cellspacing="0" width="142">';
    sb += '<tr><td width="11"><img src="images/nodot.gif" width="11" height="6" /></td>';
    sb += '<td width="118"><img src="images/nodot.gif" width="118" height="6" /></td>';
    sb += '<td width="13"><img src="images/nodot.gif" width="13" height="6" /></td></tr>';
    var len = arr.length;
    for (i = 0; i < len; i ++) {
        //if (arr[i][0].indexOf('|') != -1) {
        //  var ts = arr[i][0].substring(0,arr[i][0].indexOf('|')) + '<br />' + arr[i][0].substring((arr[i][0].indexOf('|')+1),arr[i][0].length);
        //  arr[i][0] = ts;
        //}
        sb += '<tr><td width="11"><img src="images/nodot.gif" width="11" height="1" /></td>';
        sb += '<td class="sidePopMenuTD"><a href="'+arr[i][1]+'"  target="_parent">'+arr[i][0]+'</a></td>';
        sb += '<td width="13"><img src="images/nodot.gif" width="13" height="1" /></td></tr>';
    }
    sb += '<tr><td width="11"><img src="images/nodot.gif" width="11" height="6" /></td>';
    sb += '<td width="118"><img src="images/nodot.gif" width="118" height="6" /></td>';
    sb += '<td width="13"><img src="images/nodot.gif" width="13" height="6" /></td></tr>';
    sb += '</table>';
    document.write(sb);
}
//
function buildSubmenu(arr) {
    // arr format: name, link
    var sb = '<table class="homeMenu" border="0" cellpadding="0" cellspacing="0" width="142">';
    sb += '<tr><td width="11"><img src="images/nodot.gif" width="11" height="6" /></td>';
    sb += '<td width="118"><img src="images/nodot.gif" width="118" height="6" /></td>';
    sb += '<td width="13"><img src="images/nodot.gif" width="13" height="6" /></td></tr>';
    var len = arr.length;
    for (i = 0; i < len; i ++) {

        sb += '<tr><td width="11"><img src="images/nodot.gif" width="11" height="20" /></td>';
        sb += '<td class="homeMenuTDout" onmouseover="this.className=\'homeMenuTDover\'" onmouseout="this.className=\'homeMenuTDout\'">';
        sb += '<a href="'+arr[i][1]+'" target="_parent">'+arr[i][0]+'</a></td>';
        sb += '<td width="13"><img src="images/nodot.gif" width="13" height="20" /></td></tr>';
        if ((i+1)<len) {
            sb += '<tr><td><img src="images/nodot.gif" width="11" height="1" /></td>';
            sb += '<td bgcolor="#e1e1e1" height="1"><img src="images/nodot.gif" width="118" height="1" /></td>';
            sb += '<td><img src="images/nodot.gif" width="13" height="1" /></td></tr>';
        }
    }
    sb += '<tr><td width="11"><img src="images/nodot.gif" width="11" height="6" /></td>';
    sb += '<td width="118"><img src="images/nodot.gif" width="118" height="6" /></td>';
    sb += '<td width="13"><img src="images/nodot.gif" width="13" height="6" /></td></tr>';
    sb += '</table>';
    document.write(sb);
}
//
function buildMenu (arr) {
    // arr format: name, link, submenu
    var tb = '<table class="homeMenu" border="0" cellpadding="0" cellspacing="0" width="152">';
    tb += '<tr><td width="11"><img src="images/nodot.gif" width="11" height="6" /></td>';
    tb += '<td width="128"><img src="images/nodot.gif" width="128" height="6" /></td>';
    tb += '<td width="13"><img src="images/nodot.gif" width="13" height="6" /></td></tr>';
    var len = arr.length;
    for (i = 0; i < len; i ++) {
        tb += '<tr><td width="11" height="20"><img src="images/nodot.gif" width="11" height="20" /></td>';
        if (arr[i][2] == false) {
            tb += '<td class="homeMenuTDout" height="20" onmouseover="this.className=\'homeMenuTDover\';hideChild();"'
            tb += ' onmouseout="this.className=\'homeMenuTDout\'">';
        } else {
            tb += '<td class="homeMenuTDoutEX" height="20" onmouseover="this.className=\'homeMenuTDoverEX\';showChild(\''+arr[i][2]+'\');"'
            tb += ' onmouseout="this.className=\'homeMenuTDoutEX\'">';
        }
        //tb += '<a href="'+arr[i][1]+'" target="_parent">'+arr[i][0]+'</a></td>';
        	if ((arr[i][1].indexOf('hesreport.sunocoinc') != -1)||(arr[i][1].indexOf('www.sunocofoundation.com') != -1)) {
                    tb += '<a href="'+arr[i][1]+'" target="_blank">'+arr[i][0]+'</a></td>';
                }
                else {
                    tb += '<a href="'+arr[i][1]+'" target="_parent">'+arr[i][0]+'</a></td>';
        	}
        tb += '<td width="13" height="20"><img src="images/nodot.gif" width="13" height="20" /></td></tr>';
        if ((i+1)<len) {
            tb += '<tr><td><img src="images/nodot.gif" width="11" height="1" /></td>';
            tb += '<td bgcolor="#e1e1e1" height="1"><img src="images/nodot.gif" width="128" height="1" /></td>';
            tb += '<td><img src="images/nodot.gif" width="13" height="1" /></td></tr>';
        }
    }
    tb += '<tr><td width="11"><img src="images/nodot.gif" width="11" height="6" /></td>';
    tb += '<td width="118"><img src="images/nodot.gif" width="128" height="6" /></td>';
    tb += '<td width="13"><img src="images/nodot.gif" width="13" height="6" /></td></tr>';
    tb += '</table>';
    document.write(tb);
}
//

function buildLeftNavMenu(arr) {
    // arr format: name, link, submenu
    var tb = '<table class="sideMenu" border="0" cellpadding="0" cellspacing="0" width="226">';
    tb += '<tr><td bgcolor="#cccccc"><img src="images/nodot.gif" width="226" height="1" /></td></tr>';
    var len = arr.length;
    for (i = 0; i < len; i ++) {
        if (arr[i][2] == false) {
            tb += '<tr><td class="sideMenuTDout" height="24" onmouseover="this.className=\'sideMenuTDover\';hideMenus();" ';
            tb += 'onmouseout="this.className=\'sideMenuTDout\'"><a href="'+arr[i][1]+'" target="_parent">'+arr[i][0]+'</a></td></tr>';
        } else {
            var idName = 'side' + arr[i][2].substr(3);
            tb += '<tr><td class="sideMenuTDoutEX" height="24" onmouseover="this.className=\'sideMenuTDoverEX\';showSideChild(\''+idName+'\');" ';
            tb += 'onmouseout="this.className=\'sideMenuTDoutEX\'"><a href="'+arr[i][1]+'" target="_parent">'+arr[i][0]+'</a></td></tr>';
        }
    }
    tb += '<tr><td bgcolor="#cccccc"><img src="images/nodot.gif" width="226" height="1" /></td></tr>';
    tb += '</table>';
    document.write(tb);
}
//