/**------------ FILE NavTextGen.js  ------------------- 
------------ THE NAVIGATION BAR  ----------------**/

// Create global mxd_bars to store  bar instances , of TextBarClass /collapse bars 
// NavTextClass  access this bar-array as an array and TextBarClass methods as single bar in the array
//        - bar Array  is used and  is initialized for VERTICAL mixed type  bars: 
//			Text Menubars with link   CollapsedMenuBarwich opens to mixed menu bars 

  mxd_bars = new Array(50);  // create global mxd_bars to store pointers to SimpBar and/or CollapsBar

// this general functiion gets anum to approach instance of barClass by  barArray   and set /modify its value
/* -----------------------------------------------------------------
	  collapsMenu 
 for the displayed bar-instance do for the according collaps id the switch in innerHtml val
 Act Open/close   
 bar_num- gets you to the rigt bar-instance which is instance of CollapsBarClass within mxd_bars array 
 menu_id- is the css - id defined with <span we use to set its .innerHtml value which goes shrink and expand.
---------------------------------------------------------------------*/
function collapsMenu( menu_id,link_id ,bar_num){
	
  if ( mxd_bars[bar_num].open_flag == 1){			// if was not-open (closed) therefor do now -  open 
	 	  link_id.innerHTML =  plus_image +   mxd_bars[bar_num].the_name ;			   	   		  
  	  menu_id.innerHTML=  mxd_bars[bar_num].shrink_val;
			mxd_bars[bar_num].open_flag = 0;   
  }
  else{				//  was open ->close 
	 	  link_id.innerHTML = minus_image +   mxd_bars[bar_num].the_name ;		;			   	   		  
	 	  menu_id.innerHTML = mxd_bars[bar_num].expand_val;			  	   		  
			mxd_bars[bar_num].open_flag = 1;   
  }
}

//-----------------------------------------------------------------
//---------------- CollapsBarClass -------------------------------------	
//-----------------------------------------------------------------
function CollapsBarClass( bar_num, nic_name, bar_type, the_name,  num_incolp_bars ) {
  // parameters:
  // following lines are of use - if we would want to build ourselves  x3 image source file names 
  this.bar_num = bar_num; 
  this.nic_name = nic_name;
  this.bar_type = bar_type;
  this.the_name = the_name;	
  this.num_incolp_bars = num_incolp_bars ;		  	   	   		  
  this.open_flag = 0;  		  	   	   		  
  this.incolp_bars = new Array(num_incolp_bars);    // in future for more levels replace to mxd_txt_bars
  this.expand_val = "";			  	   	   		  
  this.shrink_val = "";	
  //this.barnum_str = bar_num.toString();		  	   	   		  
  this.lnk = 'link'+ bar_num;		// 	  'link'+ this.barnum_str;	 	   		  
  this.menu = 'menu'+ bar_num ; 		// 'menu'+ this.barnum_str 			  	   	   		  
 //methods:
  this.setIncolapVal = setIncolapVal;						  
  this.colapDisplay = colapDisplay;  // var menu_id = "menu"+ num;  //this.menu_id = "menu"+ this.id; 
}
//----------------------------------------------------------------
//-------- setIncolapVal  method of CollapsBarClass				--------
//-------- set val of expand_val used for expand innerHTML 	--------
//-------- is whole-expantion value  						--------
//----------------------------------------------------------------
function setIncolapVal(barname)  { 
	var menu =  '<table cellpadding="0" cellspacing="0" border="0" >' ;
	var the_css = menu_css;
  for (k=0 ; k < this.num_incolp_bars  ; k++){
      	 // if 	(   this.incolp_bars[k].bar_type == "text" ){			     	  }	
				if (this.incolp_bars[k].nic_name == current_collapse_barname){
					the_css = colap_cur_css;
			  }	
			  else{
			  	the_css = menu_css;
			  }	
				menu += '<tr><td height="21" valign="top">' + vertline_image + item_ptr_image + '</td><td height="21" valign="top" ><a href='; //vertline_image
				menu += this.incolp_bars[k].ref + ' class="' + the_css + '" >' +  this.incolp_bars[k].the_name+ '</a></td></tr>';			
	}
	menu += '</table>';
  this.expand_val =  menu ;	
  this.shrink_val = '';				 //		  	   	   		  	
}


/* -----------------------------------------------------------------
                colapDisplay  method
 method of CollapsBarClass - display the bar with all its features  
 the bar-instance  is displayed with it's according collaps id and call to 
 global func : collapseMenu that accesses this bar andd its-span-id and switches its innerHtml val
---------------------------------------------------------------------*/
function colapDisplay(main_barname) { 			// add using txt_bar_css   <... class="txt_bar_css" ...
/* 
  display method for the collaps bar (its ineer txtbars are defined and structred for display in att: 
	expand_val and shrink_val	, and open_flag for keeping track of last status of the menu
	while using collapseMenu as global func  which access the glob ary mxd_bars[bar_num of this bar] of type collaps
	and dispalys it with span id : menu+bar_num
  to get e.g.:	<a href="#" onclick="collapse_menu(menu1, 0); return false">Menu 1</a><br>
                  <span id="menu1"></span>
*/ 
   var clp_css = colap_css ; 	 	// set for reg css colap if this is current set the cur-collapse-css
	 var the_menu ="";	
	 var the_img = plus_image;
   if (this.nic_name == main_barname ){
   	clp_css = colap_thecur_css ;
   	the_menu= this.expand_val;
   	the_img = minus_image;
   	this.open_flag = 1;
   }
   document.write('<a href="#" onclick="collapsMenu(' + this.menu + ', ' + this.lnk + ', ' +this.bar_num+ '); return false"  class="'+ clp_css + '" >' );  
   // document.write('<a href="#" onclick="collapsMenu(menu' + this.bar_num + ', link' +this.bar_num+ ', ' +this.bar_num+ '); return false"  class="'+ clp_css + '" >' );  
   document.write('<span id="link' + this.bar_num + '" class="'+ clp_css + '" >' ); 
	 document.write(the_img);//'<img src="/images/nav/plus.gif" border=0> '
   document.write(this.the_name); 
   document.write('</span>'); 
   document.write('</a><span id="menu' + this.bar_num + '">' + the_menu + '</span>'); 

}

//---------- -------------------------------------------------------
//----------------  Text Bar Class -------------------------------------	
//-----------------------------------------------------------------
function TextBarClass(  bar_num, nic_name, bar_type, the_name, ref_file, on_flag ) {
  // parameters:
  this.bar_num = bar_num; 
  this.nic_name = nic_name;
  this.bar_type = bar_type;
  this.the_name = the_name;	
  this.ref = ref_file; 
 //methods:
  this.txtBarDisplay= txtBarDisplay;  
}

/* -----------------------------------------------------------------
---------------   display  method
 method of TextBarClass - display the bar with all its features  
 the bar-instance  is displayed with it's according link and according 
 ActOn/Off function (e.g. mouse on/out) in the future may extend 
 to support alt-status. assumes being displayed within table-td already
---------------------------------------------------------------------*/
function txtBarDisplay(barname) { 			// add using txt_bar_css   <... class="txt_bar_css" ...
	  document.write(item_ptr_image); //valign="bottom"  '<img src="/images/nav/item.gif" border=0> '  document.write('<img src="/images/nav/item.gif" border="0"> ');
	  document.write('<a class="menuLink" href='); // should add here css-id for color of mouse over, and link color when got in etc. 		
	  document.write(this.ref);
	  if (this.nic_name == barname){ 
	  		document.write(' id="' + menu_cur_css + '" >');					
	  }
	  else{
	  		document.write(' id="' + menu_css + '" >');					
	  }			
	  document.write(this.the_name); 	
	  document.write("</a>");
}

//-----------------------------------------------------------------
//--------------- Nav Class ----------------------------------
//-----------------------------------------------------------------
function NavTextClass(len, visualtop, visualbot) { // NavTextClass Class declaration
	 this.navLen=len;
   this.topVisual = visualtop;
   this.botVisual = visualbot;
	 //methods:
   this.displayNavTextVert =displayNavTextVert;   //puts the mixed-bar (uses css)navagation table frame 
   //this.setCollapseItemOpen = setCollapseItemOpen ; 	// setCollapseItemOpen: do the specific sets of the navigation for the page we entered (e.g. have the col laps item menu open when entering page-of-col laps menu item
}
//-----------------------------------------------------------------
// NavTextClass  displayNavTextVert Method 
//  display Vertical navigator in a table 
// activate display method for each bar
//-----------------------------------------------------------------
function displayNavTextVert(barname) {   //**replaced categoryNum with barname, here no use of barname  nor bar_numfor now
   document.write(this.topVisual);  // does all <table stuff
    var k;
	  for (k=1 ; k <= this.navLen  ; k++)
	  {
					// may use  class="vertRnav"
      	  document.write('<tr>');
      	  document.write('<td height="21" valign="top">');
      	  if 	(   mxd_bars[k].bar_type == "text" ){
			   	  	mxd_bars[k].txtBarDisplay(barname);   	   
      	  }
      	  if 	(   mxd_bars[k].bar_type == "collapse" ){
              mxd_bars[k].colapDisplay(barname);
          }
      	  document.write('</td></tr>');
	 }
   document.write(this.botVisual);
 	 
}


