fknaut
11-16-2003, 05:32 PM
I have the following script that needs help to make compatible with Netscape and Safari for the MAC any help appreciated as I created it for my Church website:
The script is called here:
<body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0">
<script language="javascript" src="menu/nav_template.js"></script>
<script>
var nav_highlight="Locator Map"; //this tells it which nav item to highlight
nav_template.js:
document.write('<script language="javascript" src="menu/spillout_data_global.js"></script>');
document.write('<script language="javascript" src="menu/generateSpillouts.js"></script>');
document.write('<script language="javascript" src="menu/spillout_code.js"></script>');
document.write('<script language="javascript" src="menu/nav_data.js"></script>');
function write_nav(){
var nav_html ='<div id="sideMenu" style="position:absolute;top:220;left:0;z-index:10;">';
for (a=0; a<nav_array.length; a++){ //the nav categories
// nav_array[a][0][0] the name of the category;
if (nav_array[a][0].length==1){
//if only one elements in first item, is category item, and has sub items
nav_html += '<span id="' + nav_array[a][0][0] + '_title' +'""><table width=187 height=25 cellpadding=0 cellspacing=1 border=0><tr><td bgcolor="#339999"> <a href="#" class="arialnarrow" onclick="toggle(\'' + nav_array[a][0][0] + '\'); return false"><img src="images/arrow_right.gif" width=9 height=9 border=0 id="'+ nav_array[a][0][0] +'_arrow">' + nav_array[a][0][0] +'</a></td></tr></table></span>';
//The links in the category, which get hid or displayed
nav_html += '<span id="' + nav_array[a][0][0] +'" style="display: none"><table border=0 cellspacing=0 cellpadding=0 width=187 style="border:2px;border-style:solid;border-color:#339999;margin-top;">\n\n';
// nav_array[a][b][0] the link
//nav_array[a][0][1]+ b the link ID (for changing the formatting to make it black
//nav_array[a][b][1] the link name
for (b=1; b<nav_array[a].length; b++){
nav_html+= '<tr bgcolor="#CC9933"><td height="20" style="padding-left:16px;"><a href="'+ nav_array[a][b][0] +'" id="link'+ a+'_'+b +'" class="sidenav"><b>'+ nav_array[a][b][1] +'</b></a></td></tr>\n\n';
}
nav_html +='</table></span>\n\n';
//end category links
} else {
//MAIN LEVEL LINK OPTION
// has more than one item in first array of a category, therefore, should be a link and not a category
//disregard following arrays in this array, maybe for testing or something
//just display link
nav_html += '<span id="' + nav_array[a][0][1] + '_title' +'""><table width=187 height=25 cellpadding=0 cellspacing=0 border=0><tr><td bgcolor="#339999"> <a href="'+nav_array[a][0][0] +'" class="arialnarrow"><img src="images/spacer.gif" width=9 height=9 border=0 id="'+ nav_array[a][0][1] +'_arrow" style="display: none"><img src="images/spacer.gif" width=9 height=9 border=0 id="'+ nav_array[a][0][1] +'_blank">' + nav_array[a][0][1] +'</a></td></tr></table></span><span id="' + nav_array[a][0][1] +'" style="display: none"></span>';
}
}
nav_html +='</div>';
document.write(nav_html);
}
function write_after_content(){
document.write ('</td></tr></table>'); //main page table close --->
if ( typeof(no_write_side_nav)=='undefined') {//check to see if the variable is defined on the html page
write_nav();
} else {
nav_highlight='';
}
display_nav_of_page();
}
//displays the left hand nav category list of links
//cycles through the arrays for a match for the calue of the var nav_highlight
// stored on the page. then it highlights the match
//WARNING nav_highlight var string CASE SENSITIVE
function display_nav_of_page () {
if (( typeof(nav_highlight)!='undefined')&&(nav_highlight != '')) {//check to see if the variable is defined on the html page
for (a=0; a<nav_array.length; a++){
for (b=1; b<nav_array[a].length; b++){
if (nav_array[a][b][1]==nav_highlight){
eval('document.all["' +'link'+a+'_'+b+ '"].style.color="#000000";');
eval('document.all["' +'link'+a+'_'+b+ '"].style.textDecoration="none";');
toggle(nav_array[a][0][0]);
break;
break;
}
}
}
}
}
//displays and hides the links for each left hand nav category
function toggle(id){
if (document.all){
var state = document.all[id].style.display
//hide all lists of links, show or hide this one
for (a=0; a< nav_array.length; a++){
document.all[nav_array[a][0][0]].style.display='none';
document.all[nav_array[a][0][0] +'_arrow'].src='images/arrow_right.gif';
}
if(state == 'none'){
document.all[id +'_arrow'].src='images/arrow_down.gif';
document.all[id].style.display = '';
} else {
document.all[id +'_arrow'].src='images/arrow_right.gif';
document.all[id].style.display = 'none';
}
//return false;
}
}
generate_spillouts.js:
function createMenu(aryMenu, ID, buttonTxt, gutter, left, top, width, subWidth, buttonHeight, buttonWidth) {
var strHTML = "";
var count = 0;
var width = width - (gutter * 2);
var menuTop = top + buttonHeight + 1;
strHTML += "<div onmouseover='openMenu(\"" + ID + "Main\", this);' class='mnuBtn' style='left:" + left + "; top:" + top + "; height:" + buttonHeight + ";'>";
strHTML += " <div style='margin-left:" + gutter + "px; margin-right:" + gutter + "px; margin-top:7px; color:#ffffff; font:11px verdana; font-weight:bold;letter-spacing:-.04em;'>";
strHTML += buttonTxt;
strHTML += " </div>";
strHTML += "</div>";
strHTML += "<div id='" + ID + "Main' style='position:absolute; top:" + menuTop + "; left:" + left + "; font:11px verdana; z-index:400; visibility:hidden; width:" + (width + gutter * 2) + ";'>";
strHTML += "<table cellpadding='0' cellspacing='0' border='0' width='" + (width + gutter * 2) + "' style='background:#d6ce49;'>";
for (i in aryMenu) {
if (aryMenu[i].subMenu != null) {
strHTML += "<tr><td style='background:#d6ce49;'>";
strHTML += "<div style='margin-left:1px; margin-right:1px; width:" + (width - 2) + ";' onmouseover='openSubMenu(\"" + ID + "\", " + count + ", this);'>";
strHTML += "<div class='menuItemText' style='margin-left:" + gutter + "px; margin-right:" + gutter + "px;'><a href='" + aryMenu[i].path + "' onmouseover='this.style.textDecoration=\"underline\";' onmouseout='this.style.textDecoration=\"underline\";'>" + aryMenu[i].title + "</a></div>";
strHTML += "</div>";
strHTML += "</td><td valign='top'><div class='bluArrow'><img src='images/arrow_blue.gif' width='4' height='9' border='0'></div></td></tr>";
count++;
} else {
strHTML += "<tr><td style='background:#d6ce49;'>";
strHTML += "<div style='margin-left:1px; margin-right:1px; width:" + (width - 2) + "; height:100%;' onmouseout='unhighlight(this);' onmouseover='highlight(this);'>";
strHTML += "<div class='menuItemText' style='margin-left:" + gutter + "px; margin-right:" + gutter + "px;'><a href='" + aryMenu[i].path + "'>" + aryMenu[i].title + "</a></div></div>";
strHTML += "</td><td></td><td></td></tr>";
}
}
strHTML += "<tr><td colspan='2'><img src='/images/pixel.gif' width='" + (width) + "' height='5'/></td></tr>";
strHTML += "</table>";
strHTML += "<div style='height:100; width:" + (width + gutter * 2) + ";' onmouseover='closeMenu();'> </div>";
strHTML += "</div>";
strHTML += "<div id='" + ID + "' style='position:absolute; top:" + menuTop + "; left:" + left + "; font:11px verdana; z-index:200;'>";
for (z = 0; z < aryMenu.length; z++) {
if (aryMenu[z].subMenu != null) {
var screenWidth = parseInt(document.body.clientWidth - 10);
if ((left + width + subWidth) > screenWidth) {
var leftSpillout_x = (subWidth + (gutter * 4) + width + 2) * -1 - 1;
strHTML += "<div style='position:absolute; top:0; left:" + leftSpillout_x + "; z-index:200; visibility:hidden;'>";
strHTML += "<table cellpadding='0' cellspacing='0' border='0'>";
for (j in aryMenu) {
strHTML += "<tr><td style='background:#d6ce49; visibility:hidden;'>";
strHTML += " <div style='margin-left:1px; margin-right:1px; width:" + (width - 2) + ";'>";
strHTML += " <div class='menuItemText' style='margin-left:" + gutter + "px; margin-right:" + gutter + "px;'><a href='#' style='color:345686;'>" + aryMenu[j].title + "</a></div>";
strHTML += " </div>";
strHTML += "</td>";
strHTML += "<td valign='top' style='visibility:hidden;'><div class='bluArrow'><img src='images/arrow_blue.gif' width='4' height='9' border='0'></div></td>";
// Generate sub menu
if (aryMenu[j] == aryMenu[z]) {
strHTML += "<td valign='top' width='" + subWidth + "'>";
for (k = 0; k < aryMenu[z].subMenu.length; k++) {
strHTML += "<div style='background:#d6ce49; width:" + subWidth + ";'>";
strHTML += "<div style='margin-left:1px; margin-right:1px; background:#d6ce49;' onmouseout='unhighlight(this);' onmouseover='highlightSub(this);'>";
strHTML += "<div class='menuItemText' style='margin-left:" + gutter + "; margin-right:" + gutter + "; width:" + (subWidth) + "'><a href='" + aryMenu[z].subMenu[k].path + "'>" + aryMenu[z].subMenu[k].title + "</a></div>";
strHTML += "</div></div>";
}
strHTML += "<div style='font:1px verdana; background:#d6ce49; height:5; width:" + (subWidth + gutter * 2 + 2) + ";'></div>";
} else {
strHTML += "<td valign='bottom' width='" + subWidth + "'>";
strHTML += "<div class='menuItemText' style='width:" + (subWidth) + ";' onmouseover='closeMenu();'> </div>";
}
}
strHTML += "<tr><td colspan='2'><img src='/images/pixel.gif' width='" + (width + gutter * 2) + "' height='1'/></td>";
strHTML += " <td><img src='/images/pixel.gif' width='" + subWidth + "' height='1'/></td><td></td>";
strHTML += "</tr>";
strHTML += "</table>";
strHTML += "</div>";
} else {
strHTML += "<div style='position:absolute; top:0; left:1; z-index:200; visibility:hidden;'>";
strHTML += "<table cellpadding='0' cellspacing='0' border='0'>";
for (j in aryMenu) {
strHTML += "<tr><td style='background:#d6ce49; visibility:hidden;'>";
strHTML += " <div style='margin-left:1px; margin-right:1px; width:" + (width - 2) + ";'>";
strHTML += " <div class='menuItemText' style='margin-left:" + gutter + "px; margin-right:" + gutter + "px;'><a href='#'>" + aryMenu[j].title + "</a></div>";
strHTML += " </div>";
strHTML += "</td>";
strHTML += "<td valign='top' style='visibility:hidden;'><div class='bluArrow'><img src='images/arrow_blue.gif' width='4' height='9' border='0'></div></td>";
// Generate sub menu
if (aryMenu[j] == aryMenu[z]) {
strHTML += "<td valign='top' width='" + subWidth + "'>";
for (k = 0; k < aryMenu[z].subMenu.length; k++) {
strHTML += "<div style='background:#d6ce49; width:" + subWidth + ";'>";
strHTML += "<div style='margin-left:1px; margin-right:1px; background:#d6ce49;' onmouseout='unhighlight(this);' onmouseover='highlightSub(this);'>";
strHTML += "<div class='menuItemText' style='margin-left:" + gutter + "; margin-right:" + gutter + "; width:" + (subWidth) + "'><a href='" + aryMenu[z].subMenu[k].path + "'>" + aryMenu[z].subMenu[k].title + "</a></div>";
strHTML += "</div></div>";
}
strHTML += "<div style='font:1px verdana; background:#d6ce49; height:5; width:" + (subWidth + gutter * 2 + 2) + ";'></div>";
strHTML += "<div style='height:100; width:" + (subWidth) + ";' onmouseover='closeMenu();'> </div>";
} else {
strHTML += "<td valign='bottom' width='" + subWidth + "'>";
strHTML += "<div class='menuItemText' style='width:" + (subWidth) + ";' onmouseover='closeMenu();'> </div>";
}
strHTML += "</td><td onmouseover='closeMenu();'><img src='images/pixel.gif' width='100' height='1' border='0'/></td></tr>";
}
strHTML += "<tr><td colspan='2'><img src='/images/pixel.gif' width='" + (width + gutter * 2) + "' height='1'/></td>";
strHTML += " <td><img src='/images/pixel.gif' width='" + subWidth + "' height='1'/></td><td></td>";
strHTML += "</tr>";
strHTML += "</table>";
strHTML += "</div>";
}
}
}
strHTML += "</div>";
return strHTML;
}
spiilout_code.js:
var gCurMenu = null;
var gMenuIsActive = false;
var gCurSubMenu = null;
function MenuObject(menuObj, buttonObj) {
this.menuObj = menuObj;
this.buttonObj = buttonObj;
this.width = parseInt(menuObj.style.width);
this.x = parseInt(buttonObj.style.left);
this.buttonX = parseInt(this.buttonObj.style.left);
this.y = parseInt(buttonObj.style.top);
this.isActive = true;
this.buttonObj.style.background = "#4899B7";
this.menuObj.style.visibility = "visible";
gMenuIsActive = true;
}
function openMenu(menuID, buttonObj) {
if (gCurMenu != null) closeMenu();
menuObj = (document.all) ? eval("document.all." + menuID) : document.getElementById(menuID);
gCurMenu = new MenuObject(menuObj, buttonObj); // create instance of MenuObject
}
function openSubMenu(ID, index, menuItemObj) {
if (gCurSubMenu != null) closeSubMenu();
var menuObj = eval("document.all." + ID);
gCurSubMenu = new SubMenu(menuObj, index, menuItemObj);
}
function SubMenu(menuObj, index, menuItemObj) {
this.subMenuObj = menuObj.children[index];
this.menuItemObj = menuItemObj;
this.x = parseInt(this.subMenuObj.style.left);
this.opensOnLeft = (this.x < -10) ? 1 : 0;
this.subMenuObj.style.visibility = "visible";
menuItemObj.children[0].children[0].style.textDecoration = "underline";
}
function closeSubMenu() {
gCurSubMenu.menuItemObj.children[0].children[0].style.textDecoration = "none";
gCurSubMenu.subMenuObj.style.visibility = "hidden";
unhighlight(gCurSubMenu.menuItemObj);
gCurSubMenu = null;
}
function closeMenu() {
if (gCurSubMenu != null) closeSubMenu();
gCurMenu.menuObj.style.visibility = "hidden";
gCurMenu.buttonObj.style.background = "#345686";
gMenuIsActive = false;
gCurMenu = null;
}
function highlight(obj) {
if (gCurSubMenu != null) {
closeSubMenu();
}
obj.children[0].children[0].style.textDecoration = "underline";
}
function highlightSub(obj) {
obj.children[0].children[0].style.textDecoration = "underline";
}
function unhighlight(obj) {
obj.children[0].children[0].style.textDecoration = "none";
}
function checkMenuBounds(e) {
if (gMenuIsActive) {
y = (document.all) ? window.event.clientY : e.clientY;
x = (document.all) ? window.event.clientX : e.clientX;
if ((gCurSubMenu != null) && (!gCurSubMenu.opensOnLeft)) { // subMenu open on right
if ((x < gCurMenu.x) || (y < gCurMenu.y)) {
closeMenu();
}
} else if ((gCurSubMenu != null) && (gCurSubMenu.opensOnLeft)) { // subMenu open on left
if (((x < (gCurMenu.width + gCurMenu.x + gCurSubMenu.x)) || (y < gCurMenu.y) || (x > gCurMenu.x + gCurMenu.width))) {
closeMenu();
}
} else { // no subMenu
if ((x < gCurMenu.x) || (x > gCurMenu.x + gCurMenu.width) || (y < gCurMenu.y)) {
closeMenu();
}
}
}
}
document.onmousemove = checkMenuBounds;
nav_data:
//this file is accessed by nav_template.js
//each array in the main array is a category title, then the subnav links
// a link is added after the category title in its array, makes that a link, with no sub nav items
//['',''],
var nav_array = new Array(
[
['Contact Us'],
['http://www.phumc.net/ContactUs/ChurchStaff.htm','Church Staff']
]
);
Then written to the page by:
<script>
write_after_content();
</script>
Thanks Ahead.:confused:
The script is called here:
<body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0">
<script language="javascript" src="menu/nav_template.js"></script>
<script>
var nav_highlight="Locator Map"; //this tells it which nav item to highlight
nav_template.js:
document.write('<script language="javascript" src="menu/spillout_data_global.js"></script>');
document.write('<script language="javascript" src="menu/generateSpillouts.js"></script>');
document.write('<script language="javascript" src="menu/spillout_code.js"></script>');
document.write('<script language="javascript" src="menu/nav_data.js"></script>');
function write_nav(){
var nav_html ='<div id="sideMenu" style="position:absolute;top:220;left:0;z-index:10;">';
for (a=0; a<nav_array.length; a++){ //the nav categories
// nav_array[a][0][0] the name of the category;
if (nav_array[a][0].length==1){
//if only one elements in first item, is category item, and has sub items
nav_html += '<span id="' + nav_array[a][0][0] + '_title' +'""><table width=187 height=25 cellpadding=0 cellspacing=1 border=0><tr><td bgcolor="#339999"> <a href="#" class="arialnarrow" onclick="toggle(\'' + nav_array[a][0][0] + '\'); return false"><img src="images/arrow_right.gif" width=9 height=9 border=0 id="'+ nav_array[a][0][0] +'_arrow">' + nav_array[a][0][0] +'</a></td></tr></table></span>';
//The links in the category, which get hid or displayed
nav_html += '<span id="' + nav_array[a][0][0] +'" style="display: none"><table border=0 cellspacing=0 cellpadding=0 width=187 style="border:2px;border-style:solid;border-color:#339999;margin-top;">\n\n';
// nav_array[a][b][0] the link
//nav_array[a][0][1]+ b the link ID (for changing the formatting to make it black
//nav_array[a][b][1] the link name
for (b=1; b<nav_array[a].length; b++){
nav_html+= '<tr bgcolor="#CC9933"><td height="20" style="padding-left:16px;"><a href="'+ nav_array[a][b][0] +'" id="link'+ a+'_'+b +'" class="sidenav"><b>'+ nav_array[a][b][1] +'</b></a></td></tr>\n\n';
}
nav_html +='</table></span>\n\n';
//end category links
} else {
//MAIN LEVEL LINK OPTION
// has more than one item in first array of a category, therefore, should be a link and not a category
//disregard following arrays in this array, maybe for testing or something
//just display link
nav_html += '<span id="' + nav_array[a][0][1] + '_title' +'""><table width=187 height=25 cellpadding=0 cellspacing=0 border=0><tr><td bgcolor="#339999"> <a href="'+nav_array[a][0][0] +'" class="arialnarrow"><img src="images/spacer.gif" width=9 height=9 border=0 id="'+ nav_array[a][0][1] +'_arrow" style="display: none"><img src="images/spacer.gif" width=9 height=9 border=0 id="'+ nav_array[a][0][1] +'_blank">' + nav_array[a][0][1] +'</a></td></tr></table></span><span id="' + nav_array[a][0][1] +'" style="display: none"></span>';
}
}
nav_html +='</div>';
document.write(nav_html);
}
function write_after_content(){
document.write ('</td></tr></table>'); //main page table close --->
if ( typeof(no_write_side_nav)=='undefined') {//check to see if the variable is defined on the html page
write_nav();
} else {
nav_highlight='';
}
display_nav_of_page();
}
//displays the left hand nav category list of links
//cycles through the arrays for a match for the calue of the var nav_highlight
// stored on the page. then it highlights the match
//WARNING nav_highlight var string CASE SENSITIVE
function display_nav_of_page () {
if (( typeof(nav_highlight)!='undefined')&&(nav_highlight != '')) {//check to see if the variable is defined on the html page
for (a=0; a<nav_array.length; a++){
for (b=1; b<nav_array[a].length; b++){
if (nav_array[a][b][1]==nav_highlight){
eval('document.all["' +'link'+a+'_'+b+ '"].style.color="#000000";');
eval('document.all["' +'link'+a+'_'+b+ '"].style.textDecoration="none";');
toggle(nav_array[a][0][0]);
break;
break;
}
}
}
}
}
//displays and hides the links for each left hand nav category
function toggle(id){
if (document.all){
var state = document.all[id].style.display
//hide all lists of links, show or hide this one
for (a=0; a< nav_array.length; a++){
document.all[nav_array[a][0][0]].style.display='none';
document.all[nav_array[a][0][0] +'_arrow'].src='images/arrow_right.gif';
}
if(state == 'none'){
document.all[id +'_arrow'].src='images/arrow_down.gif';
document.all[id].style.display = '';
} else {
document.all[id +'_arrow'].src='images/arrow_right.gif';
document.all[id].style.display = 'none';
}
//return false;
}
}
generate_spillouts.js:
function createMenu(aryMenu, ID, buttonTxt, gutter, left, top, width, subWidth, buttonHeight, buttonWidth) {
var strHTML = "";
var count = 0;
var width = width - (gutter * 2);
var menuTop = top + buttonHeight + 1;
strHTML += "<div onmouseover='openMenu(\"" + ID + "Main\", this);' class='mnuBtn' style='left:" + left + "; top:" + top + "; height:" + buttonHeight + ";'>";
strHTML += " <div style='margin-left:" + gutter + "px; margin-right:" + gutter + "px; margin-top:7px; color:#ffffff; font:11px verdana; font-weight:bold;letter-spacing:-.04em;'>";
strHTML += buttonTxt;
strHTML += " </div>";
strHTML += "</div>";
strHTML += "<div id='" + ID + "Main' style='position:absolute; top:" + menuTop + "; left:" + left + "; font:11px verdana; z-index:400; visibility:hidden; width:" + (width + gutter * 2) + ";'>";
strHTML += "<table cellpadding='0' cellspacing='0' border='0' width='" + (width + gutter * 2) + "' style='background:#d6ce49;'>";
for (i in aryMenu) {
if (aryMenu[i].subMenu != null) {
strHTML += "<tr><td style='background:#d6ce49;'>";
strHTML += "<div style='margin-left:1px; margin-right:1px; width:" + (width - 2) + ";' onmouseover='openSubMenu(\"" + ID + "\", " + count + ", this);'>";
strHTML += "<div class='menuItemText' style='margin-left:" + gutter + "px; margin-right:" + gutter + "px;'><a href='" + aryMenu[i].path + "' onmouseover='this.style.textDecoration=\"underline\";' onmouseout='this.style.textDecoration=\"underline\";'>" + aryMenu[i].title + "</a></div>";
strHTML += "</div>";
strHTML += "</td><td valign='top'><div class='bluArrow'><img src='images/arrow_blue.gif' width='4' height='9' border='0'></div></td></tr>";
count++;
} else {
strHTML += "<tr><td style='background:#d6ce49;'>";
strHTML += "<div style='margin-left:1px; margin-right:1px; width:" + (width - 2) + "; height:100%;' onmouseout='unhighlight(this);' onmouseover='highlight(this);'>";
strHTML += "<div class='menuItemText' style='margin-left:" + gutter + "px; margin-right:" + gutter + "px;'><a href='" + aryMenu[i].path + "'>" + aryMenu[i].title + "</a></div></div>";
strHTML += "</td><td></td><td></td></tr>";
}
}
strHTML += "<tr><td colspan='2'><img src='/images/pixel.gif' width='" + (width) + "' height='5'/></td></tr>";
strHTML += "</table>";
strHTML += "<div style='height:100; width:" + (width + gutter * 2) + ";' onmouseover='closeMenu();'> </div>";
strHTML += "</div>";
strHTML += "<div id='" + ID + "' style='position:absolute; top:" + menuTop + "; left:" + left + "; font:11px verdana; z-index:200;'>";
for (z = 0; z < aryMenu.length; z++) {
if (aryMenu[z].subMenu != null) {
var screenWidth = parseInt(document.body.clientWidth - 10);
if ((left + width + subWidth) > screenWidth) {
var leftSpillout_x = (subWidth + (gutter * 4) + width + 2) * -1 - 1;
strHTML += "<div style='position:absolute; top:0; left:" + leftSpillout_x + "; z-index:200; visibility:hidden;'>";
strHTML += "<table cellpadding='0' cellspacing='0' border='0'>";
for (j in aryMenu) {
strHTML += "<tr><td style='background:#d6ce49; visibility:hidden;'>";
strHTML += " <div style='margin-left:1px; margin-right:1px; width:" + (width - 2) + ";'>";
strHTML += " <div class='menuItemText' style='margin-left:" + gutter + "px; margin-right:" + gutter + "px;'><a href='#' style='color:345686;'>" + aryMenu[j].title + "</a></div>";
strHTML += " </div>";
strHTML += "</td>";
strHTML += "<td valign='top' style='visibility:hidden;'><div class='bluArrow'><img src='images/arrow_blue.gif' width='4' height='9' border='0'></div></td>";
// Generate sub menu
if (aryMenu[j] == aryMenu[z]) {
strHTML += "<td valign='top' width='" + subWidth + "'>";
for (k = 0; k < aryMenu[z].subMenu.length; k++) {
strHTML += "<div style='background:#d6ce49; width:" + subWidth + ";'>";
strHTML += "<div style='margin-left:1px; margin-right:1px; background:#d6ce49;' onmouseout='unhighlight(this);' onmouseover='highlightSub(this);'>";
strHTML += "<div class='menuItemText' style='margin-left:" + gutter + "; margin-right:" + gutter + "; width:" + (subWidth) + "'><a href='" + aryMenu[z].subMenu[k].path + "'>" + aryMenu[z].subMenu[k].title + "</a></div>";
strHTML += "</div></div>";
}
strHTML += "<div style='font:1px verdana; background:#d6ce49; height:5; width:" + (subWidth + gutter * 2 + 2) + ";'></div>";
} else {
strHTML += "<td valign='bottom' width='" + subWidth + "'>";
strHTML += "<div class='menuItemText' style='width:" + (subWidth) + ";' onmouseover='closeMenu();'> </div>";
}
}
strHTML += "<tr><td colspan='2'><img src='/images/pixel.gif' width='" + (width + gutter * 2) + "' height='1'/></td>";
strHTML += " <td><img src='/images/pixel.gif' width='" + subWidth + "' height='1'/></td><td></td>";
strHTML += "</tr>";
strHTML += "</table>";
strHTML += "</div>";
} else {
strHTML += "<div style='position:absolute; top:0; left:1; z-index:200; visibility:hidden;'>";
strHTML += "<table cellpadding='0' cellspacing='0' border='0'>";
for (j in aryMenu) {
strHTML += "<tr><td style='background:#d6ce49; visibility:hidden;'>";
strHTML += " <div style='margin-left:1px; margin-right:1px; width:" + (width - 2) + ";'>";
strHTML += " <div class='menuItemText' style='margin-left:" + gutter + "px; margin-right:" + gutter + "px;'><a href='#'>" + aryMenu[j].title + "</a></div>";
strHTML += " </div>";
strHTML += "</td>";
strHTML += "<td valign='top' style='visibility:hidden;'><div class='bluArrow'><img src='images/arrow_blue.gif' width='4' height='9' border='0'></div></td>";
// Generate sub menu
if (aryMenu[j] == aryMenu[z]) {
strHTML += "<td valign='top' width='" + subWidth + "'>";
for (k = 0; k < aryMenu[z].subMenu.length; k++) {
strHTML += "<div style='background:#d6ce49; width:" + subWidth + ";'>";
strHTML += "<div style='margin-left:1px; margin-right:1px; background:#d6ce49;' onmouseout='unhighlight(this);' onmouseover='highlightSub(this);'>";
strHTML += "<div class='menuItemText' style='margin-left:" + gutter + "; margin-right:" + gutter + "; width:" + (subWidth) + "'><a href='" + aryMenu[z].subMenu[k].path + "'>" + aryMenu[z].subMenu[k].title + "</a></div>";
strHTML += "</div></div>";
}
strHTML += "<div style='font:1px verdana; background:#d6ce49; height:5; width:" + (subWidth + gutter * 2 + 2) + ";'></div>";
strHTML += "<div style='height:100; width:" + (subWidth) + ";' onmouseover='closeMenu();'> </div>";
} else {
strHTML += "<td valign='bottom' width='" + subWidth + "'>";
strHTML += "<div class='menuItemText' style='width:" + (subWidth) + ";' onmouseover='closeMenu();'> </div>";
}
strHTML += "</td><td onmouseover='closeMenu();'><img src='images/pixel.gif' width='100' height='1' border='0'/></td></tr>";
}
strHTML += "<tr><td colspan='2'><img src='/images/pixel.gif' width='" + (width + gutter * 2) + "' height='1'/></td>";
strHTML += " <td><img src='/images/pixel.gif' width='" + subWidth + "' height='1'/></td><td></td>";
strHTML += "</tr>";
strHTML += "</table>";
strHTML += "</div>";
}
}
}
strHTML += "</div>";
return strHTML;
}
spiilout_code.js:
var gCurMenu = null;
var gMenuIsActive = false;
var gCurSubMenu = null;
function MenuObject(menuObj, buttonObj) {
this.menuObj = menuObj;
this.buttonObj = buttonObj;
this.width = parseInt(menuObj.style.width);
this.x = parseInt(buttonObj.style.left);
this.buttonX = parseInt(this.buttonObj.style.left);
this.y = parseInt(buttonObj.style.top);
this.isActive = true;
this.buttonObj.style.background = "#4899B7";
this.menuObj.style.visibility = "visible";
gMenuIsActive = true;
}
function openMenu(menuID, buttonObj) {
if (gCurMenu != null) closeMenu();
menuObj = (document.all) ? eval("document.all." + menuID) : document.getElementById(menuID);
gCurMenu = new MenuObject(menuObj, buttonObj); // create instance of MenuObject
}
function openSubMenu(ID, index, menuItemObj) {
if (gCurSubMenu != null) closeSubMenu();
var menuObj = eval("document.all." + ID);
gCurSubMenu = new SubMenu(menuObj, index, menuItemObj);
}
function SubMenu(menuObj, index, menuItemObj) {
this.subMenuObj = menuObj.children[index];
this.menuItemObj = menuItemObj;
this.x = parseInt(this.subMenuObj.style.left);
this.opensOnLeft = (this.x < -10) ? 1 : 0;
this.subMenuObj.style.visibility = "visible";
menuItemObj.children[0].children[0].style.textDecoration = "underline";
}
function closeSubMenu() {
gCurSubMenu.menuItemObj.children[0].children[0].style.textDecoration = "none";
gCurSubMenu.subMenuObj.style.visibility = "hidden";
unhighlight(gCurSubMenu.menuItemObj);
gCurSubMenu = null;
}
function closeMenu() {
if (gCurSubMenu != null) closeSubMenu();
gCurMenu.menuObj.style.visibility = "hidden";
gCurMenu.buttonObj.style.background = "#345686";
gMenuIsActive = false;
gCurMenu = null;
}
function highlight(obj) {
if (gCurSubMenu != null) {
closeSubMenu();
}
obj.children[0].children[0].style.textDecoration = "underline";
}
function highlightSub(obj) {
obj.children[0].children[0].style.textDecoration = "underline";
}
function unhighlight(obj) {
obj.children[0].children[0].style.textDecoration = "none";
}
function checkMenuBounds(e) {
if (gMenuIsActive) {
y = (document.all) ? window.event.clientY : e.clientY;
x = (document.all) ? window.event.clientX : e.clientX;
if ((gCurSubMenu != null) && (!gCurSubMenu.opensOnLeft)) { // subMenu open on right
if ((x < gCurMenu.x) || (y < gCurMenu.y)) {
closeMenu();
}
} else if ((gCurSubMenu != null) && (gCurSubMenu.opensOnLeft)) { // subMenu open on left
if (((x < (gCurMenu.width + gCurMenu.x + gCurSubMenu.x)) || (y < gCurMenu.y) || (x > gCurMenu.x + gCurMenu.width))) {
closeMenu();
}
} else { // no subMenu
if ((x < gCurMenu.x) || (x > gCurMenu.x + gCurMenu.width) || (y < gCurMenu.y)) {
closeMenu();
}
}
}
}
document.onmousemove = checkMenuBounds;
nav_data:
//this file is accessed by nav_template.js
//each array in the main array is a category title, then the subnav links
// a link is added after the category title in its array, makes that a link, with no sub nav items
//['',''],
var nav_array = new Array(
[
['Contact Us'],
['http://www.phumc.net/ContactUs/ChurchStaff.htm','Church Staff']
]
);
Then written to the page by:
<script>
write_after_content();
</script>
Thanks Ahead.:confused: