?
Solved

Why doesn't this JavaScript work?

Posted on 2003-03-13
2
Medium Priority
?
378 Views
Last Modified: 2007-12-19
I have 2 purposes for the javascript on this page (neither of which I wrote), one is to display my dropdown menu bar at the top of the page and the other is to autofill a list of home types depending on which Province you select.

Everything works except the home type dropdown is supposed to autofill with default values when the page loads and it doesn't.  If I delete the script for any part of the dropdown menu then it works fine. Is there a reason for this?

Here's the code...

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Calculator</title>


<script language="javascript">
var agt=navigator.userAgent.toLowerCase();
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);
    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1));
    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && (is_major >= 4));
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    var is_nav5 = (is_nav && (is_major == 5));
    var is_nav5up = (is_nav && (is_major >= 5));
    var is_moz7 = (is_nav && (agt.indexOf('netscape6')==-1));
    var is_ie   = (agt.indexOf("msie") != -1);
    var is_ie3  = (is_ie && (is_major < 4));
    var is_ie4  = (is_ie && (agt.indexOf("msie 4")!=-1));
    var is_ie5  = (is_ie && (agt.indexOf("msie 5")!=-1));
    var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);
    var is_opera = (agt.indexOf("opera") != -1);
    var is_opera4 = (is_opera && (agt.indexOf("opera 4")!=-1));
    var is_opera5up = ((is_opera && ((agt.indexOf("opera 5.11")!=-1) || (agt.indexOf("opera 5.02")!=-1) || (agt.indexOf("opera 5.01")!=-1))) || (is_opera && (is_major > 4)));
    var is_icab    = (agt.indexOf("icab")!=-1);
    var is_webtv = (agt.indexOf("webtv") != -1);
   
    var is_linux = (agt.indexOf("inux")!=-1);
    var is_mac    = (agt.indexOf("mac")!=-1);
    var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
//********************************************************************************


// if client settings are not specific, treat as old browser (no script) on windows

var bType = "old";
var osType = "win";


// find browser

if (is_ie3 == true) { bType = "ie3"; }
if (is_ie4 == true && is_opera == false && is_webtv == false) { bType = "ie4"; }
if (is_ie5up == true && is_opera == false && is_webtv == false) { bType = "ie5"; }
if (is_nav3 == true) { bType = "ns3"; }
if (is_nav4up == true && is_nav5up == false) { bType = "ns4"; }
if (is_nav5up == true && is_moz7 == false) { bType = "ns6"; }
if (is_nav5up == true && is_moz7 == true) { bType = "mz7"; }
if (is_opera == true) {  bType = "op3"; }
if (is_opera4 == true) {  bType = "op4"; }
if (is_opera5up == true) {  bType = "op5"; }
if (is_webtv == true) {  bType = "tv"; }
if (is_icab == true) { bType = "ic"; }


// find os

if (is_linux==true) { osType = "lnx"; }
if (is_mac==true) { osType = "mac"; }
if (is_win==true) { osType = "win"; }


//create a set of handy variables

var ie3=false;var ie4=false;var ie5=false; var ie=false;
var ns3=false;var ns4=false;var ns6=false; var mz7=false;
var op3=false;var op4=false;var op5=false; var op=false;
var ic=false;
var tv=false;var old=false;var exclude=false;

var lnx=false; var mac=false; var win=false;

if (bType == "ie3") ie3 = true;if (bType == "ie4") ie4 = true; if (bType == "ie5") ie5 = true;
if (bType == "ns3") ns3 = true;if (bType == "ns4") ns4 = true; if (bType == "ns6") ns6 = true;
if (bType == "mz7") mz7 = true;
if (bType == "op3") op3 = true;if (bType == "op4") op4 = true; if (bType == "op5") op5 = true;
if (bType == "ic") { ic = true; }
if (bType == "tv") tv = true; if (bType == "old") old = true;

if (osType=="win") { win = true; }
if (osType=="mac") { mac = true; }
if (osType=="lnx") { lnx = true; }


// create some browser groups

if (ie4 || ie5) { ie = true; }
if (op3 || op4 || op5) { op = true; }
if ((ie3==true) || (mac&&op) || (ns3==true) || op3 || op4 || ic || tv || old) { exclude = true; }







// array building functions for custom.js

var m=0;
var sm=0;
var cm=0;
var mainItem = new Array;

function addMainItem(ma,mb,mc,md,me) {
sm=0;
mainItem[m] = new Array(ma,mb,mc,md,me);
if (mainItem[m][4]=="") { mainItem[m][4]="_self"; }
m++;
}

var sp=0;
var subProps = new Array;

function defineSubmenuProperties(spa,spb,spc) {
subProps[(m-1)] = new Array(spa,spb,spc);
}

var subItem = new Array;

function addSubmenuItem(sma,smb,smc) {
if (sm==0) { subItem[(m-1)] = new Array; }
subItem[(m-1)][sm] = new Array(sma,smb,smc);
if (subItem[(m-1)][sm][0]=="") { subItem[(m-1)][sm][0]="#"; }
if (subItem[(m-1)][sm][1]=="") { subItem[(m-1)][sm][1]="&nbsp;"; }
if (subItem[(m-1)][sm][2]=="") { subItem[(m-1)][sm][2]="_self"; }
sm++;
}
</script>
<script language="javascript1.2" >
//UDMv2.1.1
//**DO NOT EDIT THIS *****
if (!exclude) { //********
//************************

// *** for more information about the script ******************************
// *** see http://www.brothercake.com/dropdown/ ***************************
// *** or http://www.dynamicdrive.com/dynamicindex1/topmen3/index.htm ****


// *** POSITIONING AND STYLES *********************************************


var menuALIGN = "left";            // alignment
var absLEFT =       17;            // absolute left or right position (if not center)
var absTOP =       21;             // absolute top position

var staticMENU = false;            // static positioning mode (not Opera 5)

var stretchMENU = false;            // show empty cells
var showBORDERS = false;            // show empty cell borders

var baseHREF =      "";              // base path to .js and image files
var zORDER =       100;            // base z-order of nav structure (not ns4)

var mCOLOR =       "";      // main nav cell color
var rCOLOR =       "";      // main nav cell rollover color
var keepLIT =      true;            // keep rollover color when browsing menu
var bSIZE =       1;            // main nav border size
var bCOLOR =       "";      // main nav border color
var aLINK =       "";      // main nav link color
var aHOVER =       "";            // main nav link hover-color (not ns4)
var aDEC =       "none";            // main nav link decoration
var fFONT =       "arial";      // main nav font face            
var fSIZE =       14;            // main nav font size (pixels)      
var fWEIGHT =       "bold"            // main nav font weight
var tINDENT =       7;            // main nav text indent (if text is left or right aligned)
var vPADDING =       5;            // main nav vertical cell padding
var vtOFFSET =       0;            // main nav vertical text offset (+/- pixels from middle)

var vOFFSET =       0;            // shift the submenus vertically
var hOFFSET =       0;            // shift the submenus horizontally

var smCOLOR =       "#ffcc00";      // submenu cell color
var srCOLOR =       "#ffcc00";      // submenu cell rollover color
var sbSIZE =       1;            // submenu border size
var sbCOLOR =       "black"            // submenu border color
var saLINK =       "#000066";      // submenu link color
var saHOVER =       "";            // submenu link hover-color (not ns4)
var saDEC =       "none";            // submenu link decoration
var sfFONT =       "arial";      // submenu font face            
var sfSIZE =       11;            // submenu font size (pixels)      
var sfWEIGHT =       "normal"      // submenu font weight
var stINDENT =       5;            // submenu text indent (if text is left or right aligned)
var svPADDING = 2;            // submenu vertical cell padding
var svtOFFSET = 0;            // submenu vertical text offset (+/- pixels from middle)

var shSIZE =      2;            // submenu drop shadow size
var shCOLOR =      "#000066";      // submenu drop shadow color
var shOPACITY = 45;            // submenu drop shadow opacity (not ns4 or Opera 5)

var cellCLICK = true;            // links activate on TD click
var aCURSOR = "hand";            // cursor for active links (not ns4 or op5)

var altDISPLAY = "status";            // where to display alt text
var allowRESIZE=true;            // allow resize/reload



//** LINKS ***********************************************************

// add main link item ("url","Link name",width,"text-alignment","_target","alt text",top position,left position)

// add main link item ("url","Link name",width,"text-alignment","target")



      






addMainItem("http://www.whereever.com","",130,"center","");

      
//********************************************************************

//**DO NOT EDIT THIS *****
}//***********************
//************************

</script>
<script language="javascript1.2">
//UDMv2.1.1
//**DO NOT EDIT THIS ******************************************
if (!exclude) { //*********************************************
// document object variable
var d = document;
// adjust font size discrepancy
if (ns4) { fSIZE+=1; sfSIZE+=1; }
// filter for bad definitions
if(bSIZE<0)bSIZE=0;if(fSIZE<5) fSIZE=5;if(tINDENT<0)tINDENT=0;if(vPADDING<0)vPADDING=0;
if(sbSIZE<0)sbSIZE=0;if(sfSIZE<5) sfSIZE=5;if(stINDENT<0)stINDENT=0;if(svPADDING<0)svPADDING=0;
// link style definitions
var stySTR='';
stySTR+='<style>';
stySTR+='.menubarTD A  \{ color: ' + aLINK + '\; font-weight:' + fWEIGHT + '\; \}';
stySTR+='.menubarTD A:Link  \{ color: ' + aLINK + ' \}';
stySTR+='.menubarTD A:Visited  \{ color: ' + aLINK + ' \}';
if (op5&&(aHOVER!="")) { stySTR+='.menubarTD A:Hover  \{ color: ' + aHOVER + ' \}'; }
stySTR+='.menubarTD A:Active,.menubarTD A:Link,.menubarTD A:Visited,.menubarTD A:Hover \{ font-weight:' + fWEIGHT + '\; font-size:' + fSIZE + 'px\; font-family:' + fFONT + '\; text-decoration:' + aDEC + '; position:relative\; \}';
stySTR+='.SUBmenubarTD A  \{  color: ' + saLINK + '\; font-weight:' + sfWEIGHT + '\; \}';
stySTR+='.SUBmenubarTD A:Link  \{ color: ' + saLINK + ' \}';
stySTR+='.SUBmenubarTD A:Visited  \{ color: ' + saLINK + ' \}';
if (op5&&(saHOVER!="")) { stySTR+='.SUBmenubarTD A:Hover  \{ color: ' + saHOVER + ' \}'; }
stySTR+='.SUBmenubarTD A:Active,.SUBmenubarTD A:Link,.SUBmenubarTD A:Visited,.SUBmenubarTD A:Hover \{ font-weight:' + sfWEIGHT + '\; font-size:' + sfSIZE + 'px\; font-family:' + sfFONT + '\; text-decoration:' + saDEC + '\; \}';
//*************************************************************
//*************************************************************


//** USE THIS SPACE FOR NEW STYLE DEFINITIONS *****************


var cl = '#000000'; var fs = 14;
if (ns4) { cl = '#000096'; fs = 15; }
stySTR+='.roman \{ font-size:' + fs + 'px\; color:' + cl + '\; background-color:white\; font-family:times new roman\; \}';

//**DO NOT EDIT THIS ******************************************
stySTR+='</style>';
d.write(stySTR);
}//************************************************************
//*************************************************************

</script>


<script language="JavaScript1.2">
<!--

function sendalert(messagetext) {
      alert(messagetext);
}

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.0
  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 && document.getElementById) x=document.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];}
}
//-->
</script>
<SCRIPT LANGUAGE="javascript">
<!--
arrQuebecList = new Array(14)  
arrQuebecList [0] = "Please Select"
arrQuebecList [1] = "Single Family Dwelling"
arrQuebecList [2] = "Link Home"
arrQuebecList [3] = "Semi-Detached"
arrQuebecList [4] = "Semi-Detached Duplex"
arrQuebecList [5] = "Detached Duplex"
arrQuebecList [6] = "Townhouse / Rowhouse"
arrQuebecList [7] = "Duplex"
arrQuebecList [8] = "Condo - Townhouse"
arrQuebecList [9] = "Condo - Stacked Townhouse"
arrQuebecList [10] = "Condo - Apartment Style"
arrQuebecList [11] = "Triplex"
arrQuebecList [12] = "Mobile Home"
arrQuebecList [13] = "Modular Home"


arrBCList = new Array(14)
arrBCList [0] = "Please Select"
arrBCList [1] = "Single Family Dwelling"
arrBCList [2] = "Single Family Dwelling - Land Strata"
arrBCList [3] = "Link Home"
arrBCList [4] = "Semi-Detached"
arrBCList [5] = "Semi-Detached Strata Condo"
arrBCList [6] = "Townhouse / Rowhouse"
arrBCList [7] = "Duplex"
arrBCList [8] = "Condo - Townhouse"
arrBCList [9] = "Condo - Stacked Townhouse"
arrBCList [10] = "Condo - Apartment Style"
arrBCList [11] = "Triplex"
arrBCList [12] = "Mobile Home"
arrBCList [13] = "Modular Home"

arrAllList = new Array(12)
arrAllList [0] = "Please Select"
arrAllList [1] = "Single Family Dwelling"
arrAllList [2] = "Link Home"
arrAllList [3] = "Semi-Detached"
arrAllList [4] = "Townhouse / Rowhouse"
arrAllList [5] = "Duplex"
arrAllList [6] = "Condo - Townhouse"
arrAllList [7] = "Condo - Stacked Townhouse"
arrAllList [8] = "Condo - Apartment Style"
arrAllList [9] = "Triplex"
arrAllList [10] = "Mobile Home"
arrAllList [11] = "Modular Home"




function halfCode(intSelected){
    strValue=eval('document.form1.Prov[' + intSelected + '].value')
   strFirst = strValue.substring(0,1);
//   var strFirst = document.form1.Prov.value;

   
  if(strFirst.toUpperCase()=="Q"){
       makeList(arrQuebecList);

  }
  if(strFirst.toUpperCase()=="B"){
       makeList(arrBCList);

  }    
 
  if(strFirst.toUpperCase()!="B" && strFirst.toUpperCase()!="Q"){
       makeList(arrAllList);

  }    

       
}

function makeList(arrName){
   for(i=0;i<arrName.length;i++){
       document.form1.Home.options[i] = new Option(arrName[i]);
   }
   document.form1.Home.length = arrName.length
}

//-->
</SCRIPT>

<style type="text/css">  
.calcSelect {width:250px}
</style>

</head>


<body onLoad="javascript:halfCode(0)" topmargin="0" leftmargin="0" rightmargin="0" marginheight="0" marginwidth="0" bgcolor="#ffffff">
 
        
         <form method="post" action="whereever.asp" id="form1" name="form1">
         Province:
<Select id="text1" name="Prov" onChange="javascript:halfCode(this.selectedIndex)">
   
            <option value="Please Select" selected>Please Select</option>
            <option value="Alberta">Alberta</option>
            <option value="British Columbia">British Columbia</option>
       <option value="Manitoba">Manitoba</option>
       <option value="New Brunswick">New Brunswick</option>
       <option value="Newfoundland">Newfoundland</option>
       <option value="Nova Scotia">Nova Scotia</option>
            <option value="Ontario">Ontario</option>
       <option value="P.E.I.">P.E.I.</option>
       <option value="Quebec">Quebec</option>
       <option value="Saskatchewan">Saskatchewan</option>
   
   </select>
   Home Type:
    <SELECT name="Home" class="calcSelect" id="Home">
  <OPTION></OPTION>
</SELECT>

   
    <input type="submit" value="Submit" class="submit_location">
   
  </form>

<script language="javascript1.2">
//UDMv2.1.1


// filter for undefined arrays

for (f=0;f<mainItem.length;f++) {
      if (!subProps[f]) { subProps[f] = new Array(mainItem[f][2],mainItem[f][3],mainItem[f][3]); }
      if (!subItem[f]) { subItem[f] = new Array; }
      }


if (absTOP<0) { absTOP = 0; }
if (absLEFT<0) { absLEFT = 0; }
if (svPADDING<=0) { svPADDING=1; }

// appreviated base image path
var bh = baseHREF;


// find the inner height of the browser window

var bHeight = document.body.clientHeight;


// find background colors or images

var back_defs = new Array(mCOLOR,bCOLOR,rCOLOR,smCOLOR,sbCOLOR,srCOLOR,shCOLOR);
var useIMG = new Array(false,false,false,false,false,false)
var backers = new Array;
var mbackers = new Array;

for (b=0;b<back_defs.length;b++) {
      backers[b] = 'bgcolor=' + back_defs[b];
      if ((back_defs[b].indexOf('.gif') != -1) || (back_defs[b].indexOf('.jpg') != -1) || back_defs[b]=='') { useIMG[b] = true; }
      if (useIMG[b]) {
            backers[b] = 'background="' + bh + back_defs[b] + '"';
            }
      if (back_defs[b]=='') { backers[b] = ''; }
      }




// find the inner width of the browser window

var nWid = document.body.clientWidth;
var bWid = nWid;



// find the nav width and horizontal space

var endSpace = 0;
var navSpace = 0;
for (j=0;j<mainItem.length;j++) {
      if (mainItem[j][2]=="") { mainItem[j][2]=10; }
      if (mainItem[j][1]=="") { mainItem[j][1]='&nbsp;';
            }
      navSpace+=mainItem[j][2]+bSIZE;
      }
endSpace = bWid-navSpace-bSIZE;

if (bWid<navSpace) { menuALIGN="left"; absLEFT=0; stretchMENU=false; showBORDERS=false; }


// find the nav height

var navHeight = fSIZE+5+vPADDING;
var actualHeight = navHeight+(bSIZE*2);


// find the subnav item height

var subnavHeight = sfSIZE+5+svPADDING;
var actualsubHeight = subnavHeight+(sbSIZE*2);



// set values for different alignments

var stA=0; var absR; var relLEFT;

var ra=false;
if (menuALIGN=="right") {
      ra=true;
      absR = absLEFT;
      absLEFT = endSpace-absR;
      relLEFT = absLEFT;
      if (relLEFT<0) { relLEFT=0; }
      absLEFT=0;
      }

var ca=false;
if (menuALIGN=="center") {
      ca=true;
      absLEFT = endSpace / 2;
      relLEFT = absLEFT;
      if (relLEFT<0) { relLEFT=0; }
      absLEFT=0;
      }

var la=false;
if (menuALIGN=="left") {
      la = true;
      absR = absLEFT;
      relLEFT = absLEFT;
      if (stretchMENU&&absR>0) { stA = absR+(2*bSIZE); }
      if (relLEFT<0) { relLEFT=0; }
      if (stretchMENU) { absLEFT=0; }
      }

var subLEFT = relLEFT;
if (ra) { subLEFT-=absR; }
if (la) { subLEFT+=absR; }
      
// how many main nav items
var ntl = 0;
for (intl=0;intl<mainItem.length;intl++) { if (mainItem[intl][1]!="") { ntl++; }}

var cSt = 'cursor:hand';


// do nothing
function doNothing() { }


// clear submenus

var previousId = 0;

function clearMenus(num) {
d.all["grid"].style.visibility = 'hidden';
if (vOFFSET>0) { d.all['gridblocker' + previousId].style.visibility = 'hidden'; }
if (shCOLOR!="") { d.all['shadow' + previousId].style.visibility = 'hidden'; }
d.all['subnav' + previousId].style.visibility = 'hidden';
d.all['sublinks' + previousId].style.visibility = 'hidden';
if (num!=previousId) { d.all['roll' + previousId].style.visibility = 'hidden'; }
previousId=0;
}



// open selected submenu

var rObj; var num;
var gridOkay = false;
function openMenu(num) {
//alert(num);
d.all["grid"].style.visibility = 'visible';
if (subItem[num]!="") {
      if (vOFFSET>0) { d.all['gridblocker' + num].style.visibility = 'visible'; }
      d.all['roll' + num].style.visibility = 'visible';
      d.all['subnav' + num].style.visibility = 'visible';
      d.all['sublinks' + num].style.visibility = 'visible';
      if (shCOLOR!=""&&subItem[num]!='') { d.all['shadow' + num].style.visibility = 'visible'; }
      }
previousId = num;
}



//alert("assemble main nav");

var tSTR='';

// event capturing layer
tSTR+='<span id="grid" style="visibility:hidden\; position:absolute\; top:0\; left:0\; width:' + bWid + '\; height:' + bHeight + '\; z-index:' + zORDER + '" onmouseover="clearMenus()">&nbsp;</span>';


// nav stretching and event capturing layer
var stbSize = bSIZE;
tSTR+='<table cellpadding=0 cellspacing=' + stbSize + ' border=0 width=' + bWid + '  height=' + actualHeight + ' id="stretchnav" ';
if (showBORDERS) {
      if (useIMG[1]) { tSTR+='style="background-image:url(' + bh + bCOLOR + ')\; z-index:' + (zORDER+1) + '\; position:absolute\; top:' + absTOP + '\; left:0\;">'; }
      else { tSTR+='style="background:' + bCOLOR + '\; z-index:' + (zORDER+1) + '\; position:absolute\; top:' + absTOP + '\; left:0\;">'; }
      } else {
      tSTR+='style="z-index:' + (zORDER+1) + '\; position:absolute\; top:' + absTOP + '\; left:0\;">';
      stbSize = 0;
      }

tSTR+='<tr><td onmouseover="clearMenus()"></td></tr></table>';

if (stretchMENU&&showBORDERS) {
      tSTR+='<table  id="stretchnav-sm-sb" cellpadding=0 cellspacing=' + stbSize + ' border=0 width=' + bWid + '  height=' + actualHeight + ' style="z-index:' + (zORDER+2) + '\; position:absolute\; top:' + absTOP + '\; left:0\;"><tr><td ' + backers[0] + ' onmouseover="clearMenus()"></td></tr></table>';
      }

if (stretchMENU&&!showBORDERS) {
      tSTR+='<table  id="stretchnav-sm"cellpadding=0 cellspacing=' + stbSize + ' border=0 ' + backers[0] + ' width=' + bWid + '  height=' + actualHeight + ' style="z-index:' + (zORDER+2) + '\; position:absolute\; top:' + absTOP + '\; left:0\;"><tr><td onmouseover="clearMenus()"></td></tr></table>';
      }


// open frame

tSTR+='<table cellpadding=0 cellspacing=' + bSIZE + ' border=0 width=' + navSpace + ' height=' + actualHeight + ' id="mainnav"  ' + backers[1] + ' style="z-index:' + (zORDER+4) + '\; position:absolute\; top:' + absTOP + 'px\; left:' + relLEFT + 'px\;"><tr>';


// links
var cSt = new Array;
var linkHover = ' onmouseover="this.style.color=\''+aHOVER+'\'" onmouseout="this.style.color=\''+aLINK+'\'"';
if (aHOVER=='') { linkHover=''; }
for (i=0;i<mainItem.length;i++) {
      var space = ' left:0px\;';
      if (mainItem[i][3]=="left") { space = ' left:' + tINDENT + 'px\;'; }
      if (mainItem[i][3]=="right") { space = ' left:-' + tINDENT + 'px\;'; }
      if(mainItem[i][1]!="") {
            if (mainItem[i][0]=="") {  mainItem[i][0] = "javascript:doNothing()"; cSt[i] = 'cursor:default'; } else { cSt[i] = 'cursor:hand'; }
            tSTR+='<td onmouseover="d.all[\'roll' + i + '\'].style.visibility=\'visible\'\; clearMenus(' + i + ')\; openMenu(' + i + ')" class=menubarTD style="height:' + navHeight + 'px\;" ' + backers[0] + '><table cellpadding=0 cellspacing=0 border=0 width=' + mainItem[i][2] + ' style="z-index:' + (zORDER+4) + '\; height:' + navHeight + '\;"><tr><td align="' + mainItem[i][3] + '"><a href="' + mainItem[i][0] + '" target="' + mainItem[i][4] + '" style="' + cSt + '\; position:relative\; top:' + (vtOFFSET) + '\; ' + space + '" ' + linkHover + '>' + mainItem[i][1] + '</a></td></tr></table></td>';
            }
      }

// close frame
tSTR+='</tr></table>';



// rollover cells
var rollLeft = relLEFT+bSIZE;

for (i=0;i<mainItem.length;i++) {
      var space = ' left:0px\;';
      if (mainItem[i][3]=="left") { space = ' left:' + tINDENT + 'px\;'; }
      if (mainItem[i][3]=="right") { space = ' left:-' + tINDENT + 'px\;'; }
      if (mainItem[i][1]!="") {
            tSTR+='<table id="roll' + i + '" cellpadding=0 cellspacing=0 border=0 style="visibility:hidden\; z-index:' + (zORDER+5) + '\; height:' + navHeight + '\; position:absolute\; top:' + (absTOP+bSIZE) + 'px\; left:' + rollLeft + 'px\;" onmouseout="if(!keepLIT){this.style.visibility=\'hidden\'}"><tr><td class=menubarTD ' + backers[2] + '><table cellpadding=0 cellspacing=0 border=0 width=' + mainItem[i][2] + ' style="height:' + navHeight + '\;"><tr><td align="' + mainItem[i][3] + '"><a href="' + mainItem[i][0] + '" target="' + mainItem[i][4] + '" style="' + cSt[i] + '\; position:relative\; top:' + (vtOFFSET) + '\; ' + space + '" ' + linkHover + '>' + mainItem[i][1] + '</a></td></tr></table></td></tr></table>';
            }            
      rollLeft+=(mainItem[i][2]+bSIZE);
      }



//alert("assemble submenus");

var mSTR='';

var SUBabsLEFT=0;

for (count=0;count<mainItem.length;count++) {

      // text alignment and indentation
      var stAlign = subProps[count][2];
      var space = ' left:0px\;';
      if (stAlign=="left") { space = ' left:' + stINDENT + 'px\;'; }
      if (stAlign=="right") { space = ' left:-' + stINDENT + 'px\;'; }
      
      // find next submenu position
      if (count==0) {
            SUBabsLEFT=relLEFT+bSIZE;
            }
      else { SUBabsLEFT+=mainItem[(count-1)][2]+bSIZE; }
      
      // specify edge alignemnt
      var actualLEFT = SUBabsLEFT+hOFFSET;
      //if ((SUBabsLEFT+subProps[count][0]+shSIZE)>bWid) { SUBabsLEFT-=shSIZE; }
      if (subProps[count][1]=="right") {
            actualLEFT = SUBabsLEFT-(subProps[count][0]-mainItem[count][2])-hOFFSET;
            }
            
      // grid blocking image for vertical offset
      if (vOFFSET>0) { mSTR+='<span id="gridblocker' + count + '" style="width:' + subProps[count][0] + 'px\; height:' + vOFFSET + 'px\; visibility:hidden\; z-index:' + (zORDER+1) + '\;position:absolute\; top:' + (absTOP+actualHeight) + 'px\; left:' + actualLEFT + 'px\;"></span>'; }
            
      // container cells
      mSTR+='<table id="subnav' + count + '" cellpadding=0 cellspacing=' + sbSIZE + ' width="' + subProps[count][0] + '" border=0 ' + backers[4] + ' style="visibility:hidden\; z-index:' + (zORDER+7) + '\; position:absolute\; top:' + (absTOP+actualHeight+vOFFSET) + 'px\; left:' + actualLEFT + 'px\;">';
      var SUBabsTOP = absTOP+actualHeight+vOFFSET;
      for (i=0;i<subItem[count].length;i++) {
            if (subItem[count][i][0]!=''&&subItem[count][i][1]!='') {
                  mSTR+='<tr><td class=SUBmenubarTD ' + backers[3] + ' align="' + stAlign + '" width="' + (subProps[count][0]-(sbSIZE*2)) + '" style="height:' + subnavHeight + 'px\;"></td></tr>';
                  }
            }
      mSTR+='</table>';

      // links
      var sublinkHover = ' onmouseover="this.style.color=\''+saHOVER+'\'" onmouseout="this.style.color=\''+saLINK+'\'"';
      if (saHOVER=='') { sublinkHover=''; }
      mSTR+='<table cellpadding=0 cellspacing=' + sbSIZE + ' width="' + subProps[count][0] + '" border=0 id="sublinks' + count + '" style="visibility:hidden\; z-index:' + (zORDER+9) + '\; position:absolute\; top:' + (absTOP+actualHeight+vOFFSET) + 'px\; left:' + actualLEFT + 'px\;">';
      var SUBabsTOP = absTOP+actualHeight+vOFFSET;
      for (i=0;i<subItem[count].length;i++) {
            if (subItem[count][i][0]!=''&&subItem[count][i][1]!='') {
                  mSTR+='<tr><td class=SUBmenubarTD height=' + subnavHeight + ' onmouseover="d.all[\'subroll' + count + i + '\'].style.visibility=\'visible\'" onmouseout="d.all[\'subroll' + count + i + '\'].style.visibility=\'hidden\'"><table cellpadding=0 cellspacing=0 border=0 id="sublink' + count + i + '" width=' + (subProps[count][0]-(sbSIZE*2)) + ' style="height:' + subnavHeight + '"><tr><td align="' + stAlign + '"><a href="' + subItem[count][i][0] + '" target="' + subItem[count][i][2] + '" style="position:relative\;top:' + (svtOFFSET) + '\; ' + space + '" ' + sublinkHover + '>' +  subItem[count][i][1] + '</a></td></tr></table></td></tr>';
                  }
            }
      mSTR+='</table>';
      
      // subrollover cells
      var subrollTop = absTOP+actualHeight+vOFFSET+sbSIZE;
      for (i=0;i<subItem[count].length;i++) {
      if (subItem[count][i][0]!=''&&subItem[count][i][1]!='') {
            tSTR+='<table id="subroll' + count + i + '" cellpadding=0 cellspacing=0 border=0 width=' + (subProps[count][0]-(sbSIZE*2)) + ' ' + backers[5] + ' style="visibility:hidden\; z-index:' + (zORDER+8) + '\; height:' + subnavHeight + '\; position:absolute\; top:' + subrollTop + 'px\; left:' + (actualLEFT+sbSIZE) + 'px\;"><tr><td align="' + stAlign + '" class=SUBmenubarTD onmouseout="this.style.visibility=\'hidden\'"><a href="' + subItem[count][i][0] + '" target="' + subItem[count][i][2] + '" style="position:relative\; top:' + (svtOFFSET) + '\; ' + space + '" ' + sublinkHover + '>' +  subItem[count][i][1] + '</a></td></tr></table>';
            }            
      subrollTop+=subnavHeight+sbSIZE;
      }



//alert("drop shadow");
if (shCOLOR!="") { mSTR+='<table cellpadding=0 cellspacing=0 border=0 ' + backers[6] + ' id="shadow' + count + '" style="visibility:hidden\; filter:alpha(opacity=' + shOPACITY + ')\; z-index:' + (zORDER+6) + '\; position:absolute\; top:' + (absTOP+actualHeight+vOFFSET+shSIZE) + 'px\; left:' + (actualLEFT+shSIZE) + 'px\; width:' + subProps[count][0] + '\; height:1\;"><tr><td></td></tr></table>'; }

}


// resize / reload trap

window.onresize=new Function("window.location.reload()");




// static positioning properties from Dynamic Drive
// http://www.dynamicdrive.com/dynamicindex1/staticmenu2.htm

var staticObj;
function makendSpacetatic() {
d.all["grid"].style.pixelTop=d.body.scrollTop;
d.all["stretchnav"].style.pixelTop=d.body.scrollTop+absTOP;
if (stretchMENU&&showBORDERS) { d.all["stretchnav-sm-sb"].style.pixelTop=d.body.scrollTop+absTOP; }
if (stretchMENU&&!showBORDERS) { d.all["stretchnav-sm"].style.pixelTop=d.body.scrollTop+absTOP; }
d.all["mainnav"].style.pixelTop=d.body.scrollTop+absTOP;
for (s=0;s<mainItem.length;s++) {
      d.all['subnav' + s].style.pixelTop=d.body.scrollTop+(absTOP+actualHeight+vOFFSET);
      d.all['sublinks' + s].style.pixelTop=d.body.scrollTop+(absTOP+actualHeight+vOFFSET);
      d.all['roll' + s].style.pixelTop=d.body.scrollTop+(absTOP+bSIZE);
      subrollTop = absTOP+actualHeight+vOFFSET+sbSIZE;
      for (sr=0;sr<subItem[s].length;sr++) {
            d.all['subroll' + s + sr].style.pixelTop=d.body.scrollTop+subrollTop;
            subrollTop+=subnavHeight+sbSIZE;
            }
      if (subItem[num]!=""&&shCOLOR!="") { d.all['shadow' + s].style.pixelTop=d.body.scrollTop+(absTOP+actualHeight+vOFFSET+shSIZE); }
      if (vOFFSET>0) { d.all['gridblocker' + s].style.pixelTop=d.body.scrollTop+(absTOP+actualHeight); }
      }
setTimeout("makendSpacetatic()",0);
}


// draw main nav

d.write(tSTR);


// draw submenus

d.write(mSTR);



// find shadow heights

function findHeights() {
      if (shCOLOR!="") {
            for(h=0;h<mainItem.length;h++) {
                  d.all['shadow' + h].style.height = d.all['subnav' + h].clientHeight;
                  }
            }
      // static mode trigger
      if (staticMENU==true||staticMENU=="safe") { makendSpacetatic(); }
      }

window.onload=findHeights;



</script>
</body>
</html>









0
Comment
Question by:dgwest
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
cubrovic earned 500 total points
ID: 8130119
You have two conflicting onload events

remove line

window.onload=findHeights;

near the end of the document
and change

onload="javascript:halfCode(0)"
to
onload="javascript:halfCode(0);findHeights()"

and now both work fine.
0
 

Author Comment

by:dgwest
ID: 8130951
Works great, thank you very much.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question