// JavaScript Document
var select_sub_link     = '';
var select_parent_link = '';
    
 
//--- browser tests --------------------------------------
//--------------------------------------------------------
var agt=navigator.userAgent.toLowerCase();

var is_ie5=( document.all && document.getElementById ) ? true : false;
var is_ns6=( !document.all && document.getElementById ) ? true : false;
var is_ns4=( document.layers ) ? true : false;
var is_ns=( is_ns4 || is_ns6 ) ? true : false;
var is_ie=(is_ie4 || is_ie5 ) ? true : false;
var is_ie4=(document.all && !document.getElementById )?true : false;
var is_mac=(navigator.appVersion.indexOf("Mac")!=-1 )?true : false;
var is_win=((navigator.userAgent.indexOf("Win")!=-1))?true : false;
var is_dhtml= (is_ns || is_ie)?true:false;
var is_opera=((navigator.userAgent.indexOf("Opera")!=-1)) ? true : false;
var is_moz = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1)  && (agt.indexOf('compatible') == -1)));

//--------------------------------------------------------

//---- adjust layer heights for different browsers -------
//--------------------------------------------------------
function update_divs(){
var tdd = document.getElementsByTagName('div');	
if( is_moz && is_mac ){ tdd['nav_trans'].style.height = 86; tdd['nav_block'].style.height = 86; }}
//--------------------------------------------------------


//--------------------------------------------------------
//--------------------------------------------------------
function toggle_layers( td, tn, cdh ) 
{	   
         var dn = '';
	   var sdn = '';
         var hadj = 0;
         if( td.length == 6 ){  var ctdn = td.substr(0,6); }else{  var ctdn = td.substr(0,7);  }
	  //alert( " **select_parent_link: " + select_parent_link );
	   //var DHTML = (document.getElementById || document.all || document.layers); alert( "DHTML: " + DHTML );
	   //------- check for pDOM layers  ----------------------
	   //-----------------------------------------------------
         //doc = document.getElementsByTagName('div');		
	   if(navigator.appName == 'Netscape')
         {
               if(parseInt(navigator.appVersion) == 5){doc = document.getElementsByTagName('div'); }// alert( "netscape version 5" ); 
               else{  }// alert( "netscape version not 5" );
         }
         else
	   {
	         //alert( "Not netscape" );  
		   eval('doc = document.all');
         }
	   
	   
	   /*
	   if(navigator.appName == 'Netscape')
           {
           if(parseInt(navigator.appVersion) == 5)
              ReturnLayer = document.getElementById(layer);
           else
              eval('ReturnLayer = document.' + layer + ';');
           }
         else
           {
           eval('ReturnLayer = document.all.' + layer + ';');
           }*/
	        
	    /***** browser detect ******
	    if(document.getElementById)
	    {
                //This works in DOM compliant browsers (including later versions of IE)
               doc = document.getElementById('div'); alert( " dom" );
          }
          else if(document.all) 
	    {
   	      	 //This will work in older IE  
			 alert( "not  dom" );
			document.all['div'];
          }
	    ********/


         for( var i = 0; i < doc.length; i ++ ) //in doc )
         {		   
	    	    dn = doc[i].id.substr(0,5);
		    sdn = doc[i].id.split('_');		    
		    
	          if( tn != '' && dn == tn && doc[i].id != '')
		    {
		            var test_name = 'parent_' + td;
				
                		if( td == doc[i].id )
				{  
				     doc[i].style.display = 'block';  doc[ctdn + '_back'].style.display = 'block';  //original 
				     //doc[i].style.visibility = 'visible';  doc[ctdn + '_back'].visibility = 'visible'; 
				     
				     //doc[i].style.visibility = 'visible';  doc[ctdn + '_back'].style.visibility = 'visible';  
				     //document.all[doc[i].id].style.visibility = 'visible'; document.all[ctdn + '_back'].style.visibility = 'visible';
				  
				     //alert( "*("+sdn[sdn.length-1]+")("+ td +") doc[i].id: " + doc[i].id + " test_name: " + test_name); 
				}
		            else
				{  
				      if( ( 'parent_' + doc[i].id != test_name )  )
					{  
						if( sdn[0] + '_' + sdn[1] != td )//call row function to deselect all parent links except the selected one 
						{
					            roll( 'parent_' + sdn[0] + '_' + sdn[1], '', '' );   //alert( "***???: " + sdn[0] + '*_*' + strip_dn[1] + " select_sub_link: " + select_sub_link );   
						}
						doc[i].style.display = 'none';  //if( td == 'link_3' ){ alert( "***???" ); roll(  'parent_link_2', 'red' );  }
			            }
					//if( doc[i].id != td + '_back' && ( 'parent_' + doc[i].id != test_name ) ){ alert( "***dn: "+ doc[i].id + " test_name: " + test_name ); roll(  'parent_link_2', 'red' ); }
				 }							
		    }
	    }//___endFor___
	    
	    
	    change_layer_height( cdh );
	    
}//___endFunc___
//--------------------------------------------------------



//--------------------------------------------------------
//--------------------------------------------------------
function change_layer_height(tdh){doc['nav_trans'].style.height=tdh;doc['nav_block'].style.height=tdh;}
//--------------------------------------------------------


//--------------------------------------------------------
//--------------------------------------------------------
function roll( on, hc, actn, url)
{
      if( actn == 'click_sub_link'    ){ select_sub_link    = on; /*alert( "actn: " + actn + " select_sub_link: " + select_sub_link );*/  }
	if( actn == 'click_parent_link' ){ select_parent_link = on; /*alert( "actn: " + actn + " select_parent_link: " + select_parent_link );*/  }
	if( is_opera == true && is_mac == true && hc == '' ){ hc = '#5B5851';  } 
	
	//if( actn == 'click_parent_link' ){ alert( "**actn: " + actn + " on: " + on ); }
	
	var test_strip_string = '';	//if( actn == 'click_parent_link' ){  }
	
	var doc = document.getElementsByTagName('tr');	// doc['test_id'].style.backgroundColor = 'red';
	//alert( "**Roll called " ); 
	
      for( var i = 0; i < doc.length; i++ ) 
      {	     
	     if( doc[i].id != '' )
	     {      
	            test_strip_string = doc[i].id.split('_');
			
			if( test_strip_string[test_strip_string.length-1] != 'over' && test_strip_string[0] != 'parent' )
			{
	     			if( doc[i].id == on && actn == 'click_sub_link' && test_strip_string[test_strip_string.length-1] != 'over' )
	            	{   // alert( "**(sub)**doc: " + on );  
				      //if( actn == 'click_parent_link' ){ alert( "-actn: " + actn + " on: " + on ); }
	                   	doc[on + '_over'].style.backgroundColor = hc; //highlight the selected sublink  
	            	}	
				else if( ( doc[i].id != select_sub_link ) && actn == 'click_sub_link' )//unhighlight all other sublinks other than the selected one
				{
				     //if( actn == 'click_parent_link' ){ alert( "*actn: " + actn + " on: " + on ); }
					doc[doc[i].id + '_over'].style.backgroundColor= hc;     //alert( "**(sub)(" + doc[i].id + ")("+ on+")("+select_sub_link+") || test_strip_string: " + test_strip_string[test_strip_string.length-1]  ); 
                        }
			}
			
			//if( i < 10 && actn == 'click_parent_link' ){ alert( " doc[i].id: " + doc[i].id + " on: " + on + "  test_strip_string[0]: " +  test_strip_string[0]  + " select_sub_link: " + select_sub_link );  }
			//----un highlight sub link when new parent link is clicked  ----------
			if( doc[i].id != on && actn == 'click_parent_link' && test_strip_string[0] != 'parent' && select_sub_link != '' )
	            {   
			     // alert( " doc[i].id: " + doc[i].id + " on: " + on + "  test_strip_string[0]: " +  test_strip_string[0] );  
                        //if( actn == 'click_parent_link' ){ alert( "**actn: " + actn + " on: " + on ); }
				//if( actn == 'click_parent_link' ){ alert( "**(parent)(" + doc[i].id + ")("+ on+")("+select_sub_link+") " );  }
		            if( doc[select_sub_link + '_over'] != undefined ){ doc[select_sub_link + '_over'].style.backgroundColor = hc;  }
	            }	
	            
			//if( actn == 'click_parent_link' ){ alert( "***actn: " + actn + " on: " + on ); }
			//----highlight all links except selected links on roll over ----------
	            /*** hold, this all works *******************/
			if( doc[i].id == on && on != select_parent_link && on != select_sub_link )
			{ 
			     
			     doc[on+'_over'].style.backgroundColor=hc;   //alert( " on: " + on + " || select_sub_link: " + select_sub_link + " select_parent_link: " + select_parent_link + " hc: " + hc );
		      }	
			
	     }
	     
	}	   
	//if( actn == 'click_sub_link' && url != undefined ){ window.location = url; }
}

function load_selected_links( parent_link_to_load, sub_link_to_load, hc_1, hc_2 )
{
      //alert( ">>>>>(load_selected_links)**parent_link_to_load: " + parent_link_to_load ); 
	update_divs(); //adjust layer heights for specific browsers
	
	var doc_tr  = document.getElementsByTagName('tr');
	var doc_div = document.getElementsByTagName('div');
	
      for( var i = 0; i < doc_tr.length; i++ ) 
      {
	     if( doc_tr[i].id != '' )
	     {			
			if( doc_tr[i].id == 'parent_' + parent_link_to_load )
	            {  
			      // alert( "**>>>>id: *(" + doc_div[parent_link_to_load] + ")* " + doc_tr[i].id + " parent_link_to_load: " + parent_link_to_load  ); 
			       select_sub_link    = sub_link_to_load;
				 select_parent_link = 'parent_' + parent_link_to_load;
			       if( doc_div[parent_link_to_load] != undefined )
				 { 
				      doc_div[parent_link_to_load].style.display = 'block'; 
			            doc_div[parent_link_to_load  +'_back'].style.display = 'block'; 
				 }
	                   if( doc_tr[sub_link_to_load+ '_over'] != undefined ){ doc_tr[sub_link_to_load + '_over'].style.backgroundColor = hc_2; }    //!!!This all works! 
			       doc_tr['parent_' + parent_link_to_load+'_over'].style.backgroundColor = hc_1;   //!!!This all works!                
	            }	
	     }
	}//___endFor___	
	
}//___endFunc___
//--------------------------------------------------------
