// JavaScript Document


//easier floaty table of contents ************************
//  http://www.csscreator.com/menu/multimenu.php

activateMenu = function(nav)
{

  /* currentStyle restricts the Javascript to IE only */
  if (document.all && document.getElementById(nav).currentStyle)
  {
    var navroot = document.getElementById(nav);
    
    /* Get all the list items within the menu */
    var lis=navroot.getElementsByTagName("LI");  
    for (i=0; i<lis.length; i++)
    {
      
      /* If the LI has another menu level */
      if (lis[i].lastChild.tagName=="UL")
      {
        
        /* assign the function to the LI */
        lis[i].onmouseover=function()
        {
          
          /* display the inner menu */
          this.lastChild.style.display="block";
        }
        lis[i].onmouseout=function()
        {
          this.lastChild.style.display="none";
        }
      }
    }
  }
}

//populates floaty table of contents 

function stuff_list(topic_name, topic_array, link_array)
{

  var topics  = new Array();
  var links  = new Array();
  var topics=topic_array.split(";");
  var links=link_array.split(";");

  document.writeln('<li><a href="#"> ' + topic_name + '</a> <ul>');
  for (i = 0; i < topics.length; i++)
  {
    
    
    document.write('<li><a href=' + links[i] + '>'  + topics[i] + ' </a> </li>');
    
  }
  
  document.writeln('</ul></li> ');

}



var recent = new Array(

                      "http://www.drin.org/jason/genevieve/birth.asp\" target=\"_blank\";New Kid!;3.31",  
                      "http://www.drin.org/jason/Adventures/brycezion/1_1.htm;Bryce & Zion;3.32",  
                      "http://members.cox.net/casa_victoria/index.htm\" target=\"_blank\";Casa Victoria;3.33",  
                      "http://www.drin.org/jason/Adventures/Moab_2005/\" target=\"_blank\";Moab 2005;3.34",  
                      "http://www.drin.org/jason/foundcat/cat.htm\" target=\"_blank\";Found Cat;3.35",
                      "http://members.cox.net/chollaball/wedding/index.htm\" target=\"_blank\";Wedding;3.36",
                      "http://www.drin.org/jason/Adventures/Grand_Canyon/index.htm\" target=\"_blank\";Grand Canyon;3.37" 
                      );


var bryce_array = new Array(
                          "Bryce",
                          "1_1.htm;Queen's Garden;1.1",
                          "1_2.htm;Fairyland;1.2",
                          "1_3.htm;Peekaboo Loop;1.3"
                          );

var zion_array = new Array(
                         "Zion",
                         "2_1.htm;Angel's Landing;2.1",
                         "2_2.htm;The Narrows;2.2",
                         "2_3.htm;Emerald Pools;2.3",
                         "2_4.htm;East Rim;2.4"
                         );


var nav_array = new Array(
                         "Nav & Contact",
                         "mailto:chollaball@cox.net;Jason;3.1",
                         "mailto:beckieholmes@cox.net;Beckie;3.2",
                          "#;recent",
                          recent,
                         "http://members.cox.net/kila/Adventures/adventures2.html\" target=\"_blank\";Adventures Home;3.4",
                         "http://members.cox.net/chollaball\" target=\"_blank\";Homepage;3.5;new"
                          );   

var toplev = new Array(
                      bryce_array,
                      zion_array,
                      nav_array
                      );



function writeTab(label,title_link,link_array)
{

  //top used to set menu position
  document.write('<div id=menuTitle' + tab_index +' class=menuTitle style="position: absolute; left: '+ tab_left + 'px; top: ' + tab_top + 'px; width: '+ tab_width + 'px; height: 20px; z-index: ' + tab_index +'; line-height: 15px; text-align: center">');
  
  if (link_array.length == 0)
  {
    
    document.write('<a href="' + title_link + '" target="main" class=menuBarLink onMouseOver="return !showMenu(\'' + tab_index +'\', event)" onClick="show_toptext3(\'' + label + '\'); return !showMenu(\'' + tab_index +'\', event)"><b>' + label +' </b></a></div>');
    
    // onMouseOver="show_toptext2(20)"
    //   document.write(' onMouseOver="show_toptext2('+label+')"');
    //       document.write(' onMouseOver="show_toptext2');
    //document.write('('+label+')"');
    
  } else
  {
    document.write('<a href="' + title_link + '" target="main" class=menuBarLink onMouseOver="return !showMenu(\'' + tab_index +'\', event)" onClick="return !showMenu(\'' + tab_index +'\', event)"><b>' + label +'</b></a></div>');
    document.write('<div id=menu' + tab_index +' class=menu style="left: ' + tab_left +'px; top: ' + tab_sub_top + 'px; width: 50px; height: 21px" onClick="event.cancelBubble = true"><nobr>');
    
    var link_info_array = new Array();
    for (var i = 0; i < link_array.length;i++)
    {
      link_info_array = link_array[i].split(";");
      document.write('<a href="' + link_info_array[0] + '"'); 
      if (link_info_array.length > 2)
      {
        document.write(' target="' + link_info_array[2] + '" ');
      } else
      {
        
        document.write(' target="main" ');
        
        
        //to hide new targets      }
        //var thetext =link_info_array[2];
        if (link_info_array[1].indexOf("'") >= 0)
        {
          var thetext =  link_info_array[1];
          var p = link_info_array[1].indexOf("'")
          //alert(' onClick="show_toptext3(\'' +thetext.substring(0,p) + '\')" class=menuLink>' + thetext.substring(p+1,thetext.length) + ' </a>');
          document.write(' onClick="show_toptext4(');
          document.write('\'' + thetext.substring(0,p) + '\',\'' + thetext.substring(p+1,thetext.length)  + '\')" ');
        } else
        {
          document.write(' onClick="show_toptext3(');
          document.write('\'' + link_info_array[1] + '\')" ');
        }
      }
      document.write('class=menuLink>' + link_info_array[1] + ' </a>');
      

      if (i + 1 < link_array.length)
      {
        document.write('&nbsp;|&nbsp;');
      }

    }
    document.write('</div>');
  }

  
  tab_left = tab_left + tab_width - 6;  
  //  tab_left = tab_left + tab_width + 2;
  tab_index++;
  tab_top = tab_top - 8;
}




function stuff_list2(arrays)
{
  for (var i = 0; i < arrays.length;i++)
  {
    //get first item in each subarray to label the section
    document.writeln('<li><a href="#"> ' + arrays[i][0] + '</a><ul id="nav"> ');
    var lev2 = new Array();
    
    for (var j = 1; j < arrays[i].length;j++)
    {
//figures out 2nd level array headers vs. 2nd level items - 2nd level headers are less than 10
      if (arrays[i][j].length > 7)
      {
        if (arrays[i][j].length > 10)
        {
          lev2 = arrays[i][j].split(";");
//adding ids so the background can be changed onload
          //this line extract the id from the data array (statically)  
          document.write('<li id="'+lev2[2]+'"> <a href="' + lev2[0] + '" >'+ lev2[1] + '</a>');

//this line generates the id dynamically from how the array is ordered
          //  document.write('<li id="'+(1+i)+j+'"> <a href="' + lev2[0] + '" >'+ lev2[1] + (1+i)+j + '</a>');


//  use this line to fade navbar text in on top of page
//   document.write('<li id="'+(1+i)+j+'"> <a href="' + lev2[0] + '" onMouseOver="fade_text(\' ' + lev2[1] + '\');"  >'+ lev2[1] +  (1+i)+j+'</a>');

        }

        else
        {
          lev2 = arrays[i][j].split(";");
          document.write('<li><a href="' + lev2[0] + '" >'+ lev2[1] + '</a>');
        }
      } else
      {
        //writes 3rd level items
        document.write('<ul>');
        for (var k = 0; k < arrays[i][j].length; k++)
        {
          lev3 = arrays[i][j][k].split(";");
          
          
          //this line extract the id from the data array (statically)  
          document.write('<li id="'+lev3[2]+'"><a href="' + lev3[0] + '">'+ lev3[1] + '</a></li>');

//this line generates the id dynamically from how the array is ordered
//		document.write('<li id="'+(1+i)+j+k+'"><a href="' + lev3[0] + '">'+ lev3[1] + (1+i)+j+k+'</a></li>');
          
          //  use this line to fade navbar text in on top of page
//		document.write('<li id="'+(1+i)+j+k+'"><a href="' + lev3[0] + '" onMouseOver="fade_text(\' ' + lev3[1] + '\');">'+ lev3[1] + (1+i)+j+k+'</a></li>');
          
        }
        document.write('</ul>');
      }
    }
    document.writeln('</ul></li> ');
  }
}

function pagenum_launch(arrays, pagenum)
{
      
//arrays=toplev;
  for (var i = 0; i < arrays.length;i++)
  {
    var lev2 = new Array();
    for (var j = 1; j < arrays[i].length;j++)
    {
      if (arrays[i][j].length > 7)
      {
        if (arrays[i][j].length > 10)
        {
          lev2 = arrays[i][j].split(";");

          if (lev2[2]==pagenum)
          {
   
        highlight_img(lev2[2],1);
            fade_text(lev2[1]);
          }


		  
        }
		else
		{
		 lev2 = arrays[i][j].split(";");
	       
          if (lev2[2]==pagenum)
          {
   
        highlight_img(lev2[2],1);
            fade_text(lev2[1]);
          }


        }
	  }
	  else
      {
        //writes 3rd level items
          for (var k = 0; k < arrays[i][j].length; k++)
          {
          lev3 = arrays[i][j][k].split(";");
	 
	 
	          if (lev3[2]==pagenum)
    	      {

			      	   highlight_img(lev3[2],1);
          	  fade_text(lev3[1]);
              }


          }
      }
    }
  }
  
}


