//====================================================================================================
//This program is property of Hyteware Consulting - Steven D. Hyte and permission is hereby given
// to fireengineeringco.com to use this program on their site and their site only.
//Theft of this program will and can be detected and will be prosecuted to the full extend of the law.
//====================================================================================================
//mod history:
// 2-14-2006 each button can have individual back color 
// 2-14-2006 each button can have individual hover color
// 2-14-2006 gave up trying to set individual text color for hover
// Note: need to test with AOL and Mozila
// 2-14-2006 included text size into div section
// Added logic if opera browser then change iframe height to 1 then back to reg 
//  The var using_iframes should always be set to true incase someone decides to add an iframe on a page else be warned
//   With opera the buttons will go behind the iframe. Setting 'using_iframes' to false in a way to turn the feature off.
//   While using buttons: see new vars in menu def: iframe_size and using_iframes. if use iframe must call it 'iframe1'.
//    if you leave the 'using_frames' switch off, all will work ok except opera users may see buttons behind iframes.
// see site for diffs in box sizes in browsers: http://www.codeproject.com/useritems/css-internet-explorer.asp
// now must set var: abs_or_rel to equal relative or absolute here or menu def
// -----------------
// see divclick it seems to be calling resize_iframe very often 
// -----------------
// see:http://www.quirksmode.org/js/detect.html
// and:http://www.quirksmode.org/js/support.html 
// see buildstyles function where we get the browser and OS which are global vars. 'Internet Explorer' is IE returned
// 2-17-2006 place a [_blank] at beginning of the link address  to open a new window 
// 2-21-2006 variable 'top_adjuster' can be set plus or minus to fine tune the menu y position
//  optionally you can place the var 'top_adjuster' in your menu such as 'var top_adjuster = 10';
// 2-22-2006 added shadows so each button can have a few px of shadow See vars:
//  shadow_color, shadow_x, shadow_y  
var textsize_same;

function checkFontSizeInIE(){
	if(document.getElementById && document.getElementById("font-size-test")){
		// 4 - smallest, 5-smaller, 6 - medium, 7 - larger, 8 - largest
		var intOffsetHeight = document.getElementById("font-size-test").offsetHeight;		
		var strTextSizeSetting;
		if (intOffsetHeight == 4){
			strTextSizeSetting = "Smallest";
		}
		else if (intOffsetHeight == 5){
			strTextSizeSetting = "Smaller";
		}
		else if (intOffsetHeight == 6){
			strTextSizeSetting = "Medium";
		}
		else if (intOffsetHeight == 7){
			strTextSizeSetting = "Larger";
		}
		else if (intOffsetHeight == 8){
			strTextSizeSetting = "Largest";
		}
		
		var strAlertText = "Your text setting is " + strTextSizeSetting;
		//if(!document.all && navigator.userAgent.search(/MSIE/i) == -1){
		//	strAlertText = "You don't seem to be using IE. \n
		//			However, the current test element's offsetHeight is "+ intOffsetHeight;
		//}	
		//alert(strAlertText);
                //alert("my offset is: " + intOffsetHeight);
	}
        //alert("not");
        //if(document.getElementById) {
        //  alert("got id");
        //}
        //if(document.getElementById("font-size-test")){
        //  alert("got other");
        //}
        return intOffsetHeight;
}

    


  function checkIt(string) {
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
  }

  function mycheckIt(string,indetect) {
	place = indetect.indexOf(string) + 1;
	thestring = string;
	return place;
  }
  function user_detection() {
    //this will set globals browser and os, nice
    if (checkIt('konqueror')) {
	browser = "Konqueror";
	OS = "Linux";
    }
    else if (checkIt('safari')) browser = "Safari"
    else if (checkIt('omniweb')) browser = "OmniWeb"
    else if (checkIt('opera')) browser = "Opera"
    else if (checkIt('webtv')) browser = "WebTV";
    else if (checkIt('icab')) browser = "iCab"
    else if (checkIt('msie')) browser = "Internet Explorer"
    else if (!checkIt('compatible'))
    {
	browser = "Netscape Navigator"
	version = detect.charAt(8);
    }
    else browser = "An unknown browser";

    if (!version) version = detect.charAt(place + thestring.length);

    if (!OS)
    {
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
    }
    //return checkIt;
  }
  function resize_iframe(id, increment)  {
          if(using_iframes == false) {
            return;
          }
          //since menu buttons will go behind iframe , we need to resize the iframe
          var detect = navigator.userAgent.toLowerCase();
          //alert(detect);
          //var OS,browser,version,total,thestring;


          var browser = "na";
          if (mycheckIt('opera',detect)) browser = "Opera";

          //alert(browser);
          if(browser == "Opera") {
             var iframe = document.getElementById(id);
            //iframe.style.height = increment + 'px';
            //iframe.style.height = iframe_size;
            iframe.style.height = increment;
             //iframe.style.width = (parseInt(iframe.style.width) + increment) + 'px';
            
          }
          
  }
  function swap(){
    if (document.images){
      for (var x=0;
        x<swap.arguments.length;
        x+=2) {
        document[swap.arguments[x]].src = eval(swap.arguments[x+1] + ".src");
      }
    }
  }
  
  function steveshowdiv_old(thisdiv,mylevel) {

        //modified from orig so that does not do the hideDivsToLevel seen below

	//this function shows the div and sets the level that the div exists at to 'mylevel'
	//--steve--remove this---hideDivsToLevel(mylevel); //first, hide the last one
	olddiv[mylevel] = getRefToDivNest(thisdiv);
	//Make the object visible
	if( olddiv[mylevel].style ) {
		//DOM compliant
		olddiv[mylevel].style.visibility = 'visible';
	} else {
		if( olddiv[mylevel].visibility ) {
			//Netscape and old versions of Mozilla compliant
			olddiv[mylevel].visibility = 'show';
		} else {
			//Nothing found, no known way of changing the style
			olddiv[mylevel] = false;
			notifyFail();
			return;
		}
	}
  }
  function steveshowdiv(thisdiv,mylevel) {

        //modified from orig so that does not do the hideDivsToLevel seen below

	//this function shows the div and sets the level that the div exists at to 'mylevel'
	//--steve--remove this---hideDivsToLevel(mylevel); //first, hide the last one
	//olddiv[mylevel] = getRefToDivNest(thisdiv);
        var idid = getRefToDivNest(thisdiv);
	//Make the object visible
	if( idid.style ) {
		//DOM compliant
		idid.style.visibility = 'visible';
	} else {
		if( idid.visibility ) {
			//Netscape and old versions of Mozilla compliant
			idid.visibility = 'show';
		} else {
			//Nothing found, no known way of changing the style
			idid = false;
			notifyFail();
			return;
		}
	}
  }
  function notifyFail(){
    alert("Sorry, the javascript menu has failed with your browser");
  }
  function stevehover(thisdiv,invarnamelit){

  

    var hovbackclr = (window[ invarnamelit][12]);
    var hovtxtclr = (window[ invarnamelit][13]);

    var divid = getRefToDivNest(thisdiv);  
    if (divid.style) {
       //alert("style");
       if(divid.style.background) {
         //alert("style with backcolor");
         ////divid.style.background = 'black';
         divid.style.background = hovbackclr;
         //gaveup changine text color:divid.style.color = '#880000';
         //works but need to but back: divid.style.fontStyle = "italic";
         divid.style.foreground = hovtxtclr; 
       } else {
         //alert("style no backcolor");
         //divid.style.backgroundColor = 'black';
         divid.style.backgroundColor = hovbackclr;
       }
    } else {
      if (divid.backcolor) {
        alert("javascript error trying to change background hover color");
      } else {
        alert("javascript error trying to change background hover color non bc");
      }
    }
  }
  function stevehover_out(thisdiv,invarnamelit){


    var backcol = (window[ invarnamelit][7]);

    var divid = getRefToDivNest(thisdiv);  
    if (divid.style) {
       //alert("style");
       if(divid.style.background) {
         //alert("style with backcolor");
         divid.style.background = backcol;
       } else {
         //alert("style no backcolor");
         divid.style.backgroundColor = backcol;
       }
    } else {
      if (divid.backcolor) {
        alert("javascript error trying to change background hover color");
      } else {
        alert("javascript error trying to change background hover color non bc");
      }
    }
  }
  function hideDivSpecial(specialDiv) { //hide a div, bypassing levels

        //alert(specialDiv);
	specialDiv = getRefToDivNest(specialDiv);
	if( specialDiv.style ) {
		//DOM compliant
		specialDiv.style.visibility = 'hidden';
	} else {
		if( specialDiv.visibility ) {
			//Netscape and old versions of Mozilla compliant
			specialDiv.visibility = 'hide';
		} else {
			//Nothing found, no known way of changing the style
			notifyFail();
			return;
		}
	}
  }
  function getRefToDivNest( divID, oDoc ) {
	if( !oDoc ) { oDoc = document; }
	if( document.layers ) {
		if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
			for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
				y = getRefToDivNest(divID,oDoc.layers[x].document); }
			return y; } }
	if( document.getElementById ) { return document.getElementById(divID); }
	if( document.all ) { return document.all[divID]; }
	return document[divID];
  }
  function writestyle(text,fontsize,x,y,len,height,border,backcolor,textcolor,visible,level,link){
     //Styles belong in the head
     //visible not used here, nor level
     document.write('<style type="text/css">');
     document.write('#' + text + '{border: ' + border + ' solid black;width: ' + len + ';height: ' + height + ';background-color: '+ backcolor + ';}');
     document.write('#' + text + ' a{font: bold ' + fontsize + ' Verdana;padding: 2px;padding-left: 4px;display: block;width: 100%;color: ' + textcolor + ';text-decoration: none;border-bottom: 1px solid black;}');
     //document.write('html>body #' + text + ' a{width: auto;});
     //document.write('html>body #' + text + ' a{ /*Non IE rule*/width: auto;}
     document.write('#' + text + ' a:hover{background-color: black;color: white;}');
     document.write('</style>');
  }
  function write_one_style(text,fontsize,x,y,len,height,border,backcolor,textcolor,visible,level,link){
     //Styles belong in the head
     //visible not used here, nor level
     document.write('<style type="text/css">');
     document.write('#' + text + '{border: ' + border + ' solid black;width: ' + len + ';height: ' + height + ';background-color: '+ backcolor + ';}');
     document.write('#' + text + ' a{font: bold ' + fontsize + ' Verdana;padding: 2px;padding-left: 4px;display: block;width: 100%;color: ' + textcolor + ';text-decoration: none;border-bottom: 1px solid black;}');
     //document.write('html>body #' + text + ' a{width: auto;});
     //document.write('html>body #' + text + ' a{ /*Non IE rule*/width: auto;}
     document.write('#' + text + ' a:hover{background-color: black;color: white;}');
     document.write('</style>');
  }
  function getdata_write_styles(varnamelit){
     var text;
     var fontsize;
     var x;
     var y;
     var len;
     var height;
     var border; 
     var backcolor;
     var textcolor;
     var visible;
     var level;
     var link;

     text = (window[ varnamelit][0]);
     fontsize = (window[ varnamelit][1]);
     x = (window[ varnamelit][2]);
     y = (window[ varnamelit][3]);
     len = (window[ varnamelit][4]);
     height = (window[ varnamelit][5]);
     border = (window[ varnamelit][6]);
     backcolor = (window[ varnamelit][7]);
     textcolor = (window[ varnamelit][8]);
     visible = (window[ varnamelit][9]);
     level = (window[ varnamelit][10]);
     link = (window[ varnamelit][11]);

     //alert("text is: " + text);     

     writestyle(text,fontsize,x,y,len,height,border,backcolor,textcolor,visible,level,link);
    
  }
  function getdata_write_divs(varnamelit){
     var text;
     var fontsize;
     var x;
     var y;
     var len;
     var height;
     var border; 
     var backcolor;
     var textcolor;
     var visible;
     var level;
     var link;

     text = (window[ varnamelit][0]);

     
     fontsize = (window[ varnamelit][1]);
     x = (window[ varnamelit][2]);
     y = (window[ varnamelit][3]);
     len = (window[ varnamelit][4]);
     height = (window[ varnamelit][5]);
     border = (window[ varnamelit][6]);
     backcolor = (window[ varnamelit][7]);
     textcolor = (window[ varnamelit][8]);
     visible = (window[ varnamelit][9]);
     level = (window[ varnamelit][10]);
     link = (window[ varnamelit][11]);

     //alert("text is: " + text);     

    if (level == 1){
      var shadows = 'shadow_color';
      if ( typeof( window[ shadows ] ) != "undefined" ) {
        //alert("here y is: " + shadow_y);
        var x2 = parseInt(x) + shadow_x;
        var y2 = parseInt(y) + shadow_y;
        x2 = x2 + '';
        y2 = y2 + '';
        //builddivs(text+"x","1",x2,y2,len,height,"0",shadow_color,textcolor,visible,level,link,varnamelit);
        builddivs("xx","1",x2,y2,len,height,"0",shadow_color,textcolor,visible,level,link,varnamelit);
      }
    }
 builddivs(text,fontsize,x,y,len,height,border,backcolor,textcolor,visible,level,link,varnamelit);
  }
  function showmouseover(varnamelit){
     // the build divs routine sets this as the function called when the mouse is over the button
     //  it handles loading and clearing buttons
     var text;
     var fontsize;
     var x;
     var y;
     var len;
     var height;
     var border; 
     var backcolor;
     var textcolor;
     var visible;
     var level;
     var link;

     

     
     //TimerMouseOff=setTimeout("bodyclearmenu()",offbuttonstimer);
     outstatus = "in";

     text = (window[ varnamelit][0]);


     fontsize = (window[ varnamelit][1]);
     x = (window[ varnamelit][2]);
     y = (window[ varnamelit][3]);
     len = (window[ varnamelit][4]);
     height = (window[ varnamelit][5]);
     border = (window[ varnamelit][6]);
     backcolor = (window[ varnamelit][7]);
     textcolor = (window[ varnamelit][8]);
     visible = (window[ varnamelit][9]);
     level = (window[ varnamelit][10]);
     link = (window[ varnamelit][11]);
     //alert("wow text: " + text);
     //
     //====================================
     // --- do the hover ourselves here ---
     stevehover(text,varnamelit);
    
     //====================================
     //--return if level 3---
     if (level == 3) {
       //var showtext = ( window[ varnamelit ][0]);
       //var showlevel = ( window[ varnamelit ][10]);
       //steveshowdiv(showtext,showlevel);
       //stevehover(text,varnamelit);
       return;
     }
    
     //alert(text);
     //--if level 2 clear out all other level 3's then ...
     if (level == 2)  {
       var m;
       var n;
       var o;
       var tempm;
       var varnamelitx;

       for(var m=0;m<max_all_levels;m++) {
         varnamelitx = "Menu" + m;
         if ( typeof( window[ varnamelitx ] ) != "undefined" ) {
           //alert("here");
           tempm = ( window[ varnamelitx ][0]);
           //alert("tempm is: " + tempm);
           if(tempm == text) {
             //document.title = "continue: " + tempm + " " + text;
             //alert("here " + tempm + " " + text);
             continue;
           }
           for(var n =0;n < max_all_levels; n++) {
             varsubnamelit = varnamelitx + "_" + n;
             //alert("here now");
             if ( typeof( window[ varsubnamelit ] ) != "undefined" ) {
               hidetext = ( window[ varsubnamelit][0]);
               //only level 3 below
             }
             for(var o = 0;o < max_all_levels; o++) {
               varsubsubnamelit = varsubnamelit + "_" + o;
               if ( typeof( window[ varsubsubnamelit ] ) != "undefined" ) {
                 hidetext = ( window[ varsubsubnamelit][0]);
                 hideDivSpecial(hidetext);
               }
             }
           }
         }
       }
     }
     
     //--if level 2 show level 3's and maybe leave ---
     if (level == 2) {
       var varname = varnamelit;
       var showtext;
       var showlevel;

       //alert("varname is: " + varname);
       var testvar;
       for(var y=0;y<max_all_levels;y++) {
         testvar = varname + '_' + y;
         //alert("testing: " + testvar);
         if ( typeof( window[ testvar ] ) != "undefined" ) { 
           //alert("now: " + testvar);
           showtext = ( window[ testvar ][0]);
           showlevel = ( window[ testvar ][10]);
           steveshowdiv(showtext,showlevel);
         }
       }
       return;
     }
     
     // -- hide level 2's that are not under this one
     //document.write("working with: " + text);
    
     var hidetext;
     var varnamelitx;
     
     if(level == 1){
       for(var iii=0;iii<max_all_levels;iii++) {
         varnamelitx = "Menu" + iii;
         if ( typeof( window[ varnamelitx ] ) != "undefined" ) {
           //alert("here");
           var tempx = ( window[ varnamelitx ][0]);
           //alert("tempx is: " + tempx);
           if(tempx == text) {
             //window.status = text + " , " + tempx;
             continue;
           
           }
           for(var jjj =0;jjj < max_all_levels; jjj++) {
             varsubnamelit = varnamelitx + "_" + jjj;
             //alert("here now");
             if ( typeof( window[ varsubnamelit ] ) != "undefined" ) {
               hidetext = ( window[ varsubnamelit][0]);
               //TimerId = setTimeout("newhide('"+hidetext+"')",stall_factor);
               newhide(hidetext);
               //document.title = "cleared level 2 for level 1 name: " + text;
             }
             for(var qqq = 0;qqq < max_all_levels; qqq++) {
               varsubsubnamelit = varsubnamelit + "_" + qqq;
               if ( typeof( window[ varsubsubnamelit ] ) != "undefined" ) {
                 hidetext = ( window[ varsubsubnamelit][0]);
                 //TimerId = setTimeout("newhide('"+hidetext+"')",stall_factor);
                 newhide(hidetext);
                 //document.title = "cleared level 3 for level 1 name: " + text;
               }
             }
           }
         }
       }
     }
    
     // --test for higher subs and display if found--
     var sublit;
     var subtext;
     var sublevel;
     var foundone = 0;
     if(level == 1) {
       for (var jj = 0;jj<max_all_levels;jj++) {
         sublit = varnamelit + '_' + jj;
         //alert(sublit);
         if ( typeof( window[ sublit ] ) != "undefined" ) {
           //must be sub
           //alert("found sub: " + sublit);
           subtext = (window[ sublit][0]);
           sublevel = (window[ sublit][10]);
           //alert(subtext);
           steveshowdiv(subtext,sublevel);
           
         }
       }
       
     }
     
     
  }
    
  function newhide(text){
    //this is called after timer wait
    hideDivSpecial(text);
  }
  function nolink(){
    //do nothing
  }
  function mouseout(invarnamelit){
     var intext = (window[ invarnamelit][0]);
     outstatus = "out";
     stevehover_out(intext,invarnamelit);
  }
  function get_link_target(inlink){
    var linkwork;
    var linkposbstart;
    var linkposbend;
    var newlink;

    linkposbstart = inlink.indexOf("[");
    linkposbend = inlink.indexOf("]");
    if(linkposbend != 0) {
      linkwork = inlink.substring(linkposbstart+1,linkposbend);
      newlink = inlink.substring(linkposbend+1);
    }else{
      newlink = inlink;
      linkwork = "";
    }
    //alert("target: " + linkwork+" reg: " +newlink);
    return linkwork;
  }
  function get_link_non_target(inlink){
    var linkwork;
    var linkposbstart;
    var linkposbend;
    var newlink;

    linkposbstart = inlink.indexOf("[");
    linkposbend = inlink.indexOf("]");
    if(linkposbend != 0) {
      linkwork = inlink.substring(linkposbstart+1,linkposbend);
      newlink = inlink.substring(linkposbend+1);
    }else{
      newlink = inlink;
      linkwork = "";
    }
    //alert("target: " + linkwork+" reg: " +newlink);
    return newlink;
  }


  function builddivs(text,fontsize,x,y,len,height,border,backcolor,textcolor,visible,level,link,varnamelit) {
    //--divs are block level and therefor belong in the body

  //builddivs(text+"x","1",x2,y2,len,height,"0",shadow_color,textcolor,visible,level,link,varnamelit);  

var text_here_same = parseInt(textsize_same);

if(text_here_same > 19) {
//alert(text_here_same);
fontpercent=8;
}
if(text_here_same < 19) {
  fontpercent=8;
}
    var str;
    

    var adjvar = 'top_adjuster';
    if ( typeof( window[ adjvar ] ) != "undefined" ) {
      var tempy = parseInt(y) + top_adjuster;
      y = tempy;
      y = y + '';
    }
    var adjvarx = 'left_adjuster';
    if ( typeof( window[ adjvarx ] ) != "undefined" ) {
      var tempx = parseInt(x) + left_adjuster;
      x = tempx;
      x = x + '';
    }

 
    var linktarget = get_link_target(link);
    var templink = get_link_non_target(link);
    if(linktarget.length != 0) {
      //link = "javascript:history.go(0)";
      //link = templink;
      link = link;
    } else {
      //link = templink; 
      link = link;
    }

  
    if(browser == "Internet Explorer") {
      //var adj_len = len - (2 * border);
      var adj_len = parseInt(len) + (2 * parseInt(border));
      var adj_height = parseInt(height) + (2 * parseInt(border));
      adj_len = adj_len+'';
      adj_height = adj_height + '';
      //alert("height: " + height + "border: " + border + " adj: " + adj_height);
    } else {
      if(browser == "Opera") {
        adj_len = len;
        adj_height = height;
      } else {
        //figure netscape
        adj_len = parseInt(len) - (2 * parseInt(border));
        adj_height = parseInt(height) - (4 * parseInt(border));
        adj_len = len;
        adj_height = height;
      }
    }
    
    var padding = "0";

    //document.write("<font color = '#990000' size = '2' face='Arial, Helvetica, sans-serif'>"); 
    //str = '<div id="' + text + '" style = "';

    if(level == "2") {
      str = '<div id="' + text + '" align = "left" style = "';
     
    } else {
      str = '<div id="' + text + '" align = "center" style = "';
    }

    str = str + 'position:'+abs_or_rel+';';
    str = str + 'visibility: ' + visible + ';';
    str = str + 'top: ' + y + '; left: ' + x + ';';

    
    str = str + 'width:' + adj_len + 'px;';
    
    str = str + 'height:' + adj_height + 'px;';
    
    str = str + 'font:bold '+fontsize+' verdana;';
   
    str = str + 'border: ' + border + 'px solid ' + system_border_color + ';';
    str = str + 'background-color:' + backcolor + ';';
   
    str = str + 'text-decoration: none;border-bottom:'+border+'px solid black;';
    //see functions that deal with hovering
    
   

    str = str + '" onmouseover = "divmouseover('+"'" + varnamelit + "'" + ')" onmouseout = "mouseout(' + "'" + varnamelit + "'" + ')"';
    //str = str + ' onclick = "divclick(' + "'" + link + "'" + ')"';
    str = str + ' onclick = "divclick(' + "'" + link + "'" + ');return false;"';
    str = str + '>';


    //alert(str)

    document.write(str);
    
  
    if(link != "na") {
      if(linktarget.length == 0) {
       
        str = '<a class = "menu" href=' + '"' + link + '"' + ' style="text-decoration:none" onmouseover="showmouseover(' + "'" + varnamelit + "'" + ')" onmouseout="mouseout('+"'"+varnamelit+"'"+')">';

      } else {
      
        templink = templink + "zzzzzz";
        str = '<a class = "menu" href=' + '"' + templink + '"' + ' target = "_blank"'+' style="text-decoration:none" onmouseover="showmouseover(' + "'" + varnamelit + "'" + ')" onmouseout="mouseout('+"'"+varnamelit+"'"+')">';

      }

      //pp str = str + "<p class='menu'>"

      if (level=="3"){
        str = str + '&nbsp;&nbsp;' + text + '</a>';
      } else {
        //pp str = str + text + '</p></a>';
        str = str + text + "</a>";
      }
      
    } else {
      
      str = '<a class = "menu" href="javascript:nolink();" style="text-decoration:none" onmouseover="showmouseover(' + "'" + varnamelit + "'" + ')" onmouseout="mouseout('+"'"+varnamelit+"'"+')">';

      //pp str = str + "<p class='menu'>" + text + "</p></a>";
      str = str + text + "</a>";
      
    }
    
    //alert(str);
    document.write(str);

    //----IMAGE ARROWS HERE ---remember the text is centered--font 2 equals each char takes 6 of the len
    var arrow_type = get_arrow_type(varnamelit);
  
    if (arrow_type != 0){
      if(arrow_type == 1) {
        var arr_name = "images/down_arrow.gif";
      } else {
        var arr_name = "images/right_arrow.gif";
      }
      str = "";
      var rmn;
      var tlen = text.length * 6;
      rmn = len - tlen;
      rmn = rmn / 2;
      rmn = rmn - 10;
      rmn = rmn / 6;
      //document.write(text.length + " " + tlen + " " + rmn);
      for(var yyy =0;yyy<rmn;yyy++){
        str = str + "&nbsp;";
      }
      str = str + '<img src="' + arr_name + '" width = "10" height = "10"  />';
      document.write(str);
    }
    //document.write("</p>");


    str = '</div>';
    document.write(str);
    //document.write("</font>");
    
  }
   function get_arrow_type(varnamelit){
    //return 0=no arrow;1=down arrow;2=over arrow

    var templit;

    text = (window[ varnamelit][0]);
    fontsize = (window[ varnamelit][1]);
    x = (window[ varnamelit][2]);
    y = (window[ varnamelit][3]);
    len = (window[ varnamelit][4]);
    height = (window[ varnamelit][5]);
    border = (window[ varnamelit][6]);
    backcolor = (window[ varnamelit][7]);
    textcolor = (window[ varnamelit][8]);
    visible = (window[ varnamelit][9]);
    level = (window[ varnamelit][10]);
    link = (window[ varnamelit][11]);
    if (level == 3 ) {
      return 0;
    } else {
      if(level == 2) {
        templit = varnamelit + "_0";
        if ( typeof( window[ templit ] ) != "undefined" ) {
          return 2;
        } else {
          return 0;
        }
      } else {
        //level 1
        templit = varnamelit + "_0";
        if ( typeof( window[ templit ] ) != "undefined" ) {
          return 1;
        }else{
          return 0;
        }
      }
    }

  }
  function divclick(link) {
    

    var linktarget = get_link_target(link);
    var templink = get_link_non_target(link);

    var str = "divclick incomming link is: " + link + " target is: " + linktarget + " and newlink is: " + templink;
    //alert(str);

    //link = templink; 
  
    if(link != 'na'){
       
       if(linktarget.length == 0) {
         //alert("debug inside len = 0");
         window.location = templink;
         //below is for opera browser since buttons go behind iframes
         //resize_iframe("iframe1",iframe_size);
         //alert("resize back iframesize is: " + iframe_size);
         resize_iframe("iframe1",iframe_size);
       } else {
         //open new window
         //alert("debug len not 0 "+link);
         window.open(templink,"noname",'height=500,width=600,scrollbars=yes,toolbar=yes,status=yes,resizable=yes,menubar=yes,location=yes,directories=yes');
       }
    }
    
  }
  function divmouseover(varnamelit){
    //alert("div mouse over" + varnamelit);
    //document.write("<bgsound src=sounds/start.wav>");

    link = (window[ varnamelit][11]);
    window.status = link;
    showmouseover(varnamelit);
    resize_iframe("iframe1",0);
  }
  function clearupperlevels(){
    //alert("inside clear");

    var f;
    var g;
    var h;

    
    var noactivetext;

    
    //alert("time to clear");

    for(var f=0;f<max_all_levels;f++) {
      varnamelit = "Menu" + f;
      if ( typeof( window[ varnamelit ] ) != "undefined" ) {
        //alert('We have Menu: ' + varnamelit);
      
        for(var g =0;g < max_all_levels; g++) {
          varsubnamelit = varnamelit + "_" + g;
          if ( typeof( window[ varsubnamelit ] ) != "undefined" ) {
            noactivetext = ( window[ varsubnamelit ][0]);
            hideDivSpecial(noactivetext);
          }
          for(var h = 0;h < max_all_levels; h++) {
            varsubsubnamelit = varsubnamelit + "_" + h;
            if ( typeof( window[ varsubsubnamelit ] ) != "undefined" ) {
              noactivetext = ( window[ varsubsubnamelit ][0]);
              hideDivSpecial(noactivetext);
            }
          }
        }
      }
    }
    
    
  }
 


  function bodyclearmenu() {
    //--main program calls this with a settimer then this will call itself from then on
    var temptimer;

    clearTimeout(TimerMouseOff);
    if(outstatus == "out"){
      temptimer = setTimeout("clearupperlevels()",100);
      //window.status = "called clear";
    } else {
      //window.status = "outstatus not out";
    }
    TimerMouseOff=setTimeout("bodyclearmenu()",offbuttonstimer);
    resize_iframe("iframe1",iframe_size);
  }
  function BuildStyles(){  
    var varnamelit;
    
    //write_one_style(text,fontsize,x,y,len,height,border,backcolor,textcolor,visible,level,link);
    write_one_style("one","12px",10,10,120,"1px","#ffffff","#000000","visible","1","none");

    detect = navigator.userAgent.toLowerCase();
    user_detection();
    //alert("browser: " + browser + " and OS: " + OS);
    //document.write('<a name="NA"></a>');
    //====================================
    //  return now because we use in-line styles (not in head tag)
    //====================================
    return;    
    //====================================
   
    for(var i=0;i<max_all_levels;i++) {
      varnamelit = "Menu" + i;
      if ( typeof( window[ varnamelit ] ) != "undefined" ) {
        //alert('We have Menu: ' + varnamelit);
        //getdata_write_style_and_divs(varnamelit);
        getdata_write_styles(varnamelit);
        for(var j =0;j < max_all_levels; j++) {
          varsubnamelit = varnamelit + "_" + j;
          if ( typeof( window[ varsubnamelit ] ) != "undefined" ) {
            //alert('we have sub: ' + varsubnamelit);
            //getdata_write_style_and_divs(varsubnamelit);
            getdata_write_styles(varsubnamelit);
          }
          for(var q = 0;q < max_all_levels; q++) {
            varsubsubnamelit = varsubnamelit + "_" + q;
            if ( typeof( window[ varsubsubnamelit ] ) != "undefined" ) {
              //alert('we have sub sub: ' + varsubsubnamelit);
              //getdata_write_style_and_divs(varsubsubnamelit);
              getdata_write_styles(varsubsubnamelit);
            }
          }
        }
      }
    }
  }
  function BuildDivs(){  
    var varnamelit;

var offheight =  checkFontSizeInIE();
//alert(offheight);
textsize_same = offheight;

//document.write("<STYLE type='text/css'><!-- P.menu {font-family: Arial, Helvetica, sans-serif, Verdana;font-size: 13px;color:" +
//all_text_color + ";} --></STYLE>");

//var test_color = "#ffffff";

//document.write("<STYLE type='text/css'><!-- p.menu {font-family: Arial, Helvetica, sans-serif, Verdana;font-size: 13px;color: '" +
//test_color + "' ;} --></STYLE>");
document.write("<STYLE type='text/css'>a.menu {font-family: Arial, Helvetica, sans-serif, Verdana;font-size: 13px;color:" + all_text_color + " }</STYLE>");



    for(var i=0;i<max_all_levels;i++) {
      varnamelit = "Menu" + i;
      if ( typeof( window[ varnamelit ] ) != "undefined" ) {
        //alert('We have Menu: ' + varnamelit);d
        //getdata_write_style_and_divs(varnamelit);
        getdata_write_divs(varnamelit);
        for(var j =0;j < max_all_levels; j++) {
          varsubnamelit = varnamelit + "_" + j;
          if ( typeof( window[ varsubnamelit ] ) != "undefined" ) {
            //alert('we have sub: ' + varsubnamelit);
            //getdata_write_style_and_divs(varsubnamelit);
            getdata_write_divs(varsubnamelit);
          }
          for(var q = 0;q < max_all_levels; q++) {
            varsubsubnamelit = varsubnamelit + "_" + q;
            if ( typeof( window[ varsubsubnamelit ] ) != "undefined" ) {
              //alert('we have sub sub: ' + varsubsubnamelit);
              //getdata_write_style_and_divs(varsubsubnamelit);
              getdata_write_divs(varsubsubnamelit);
            }
          }
        }
      }
    }
  }