//free JavaScripts on http://www.ScriptBreaker.com


  var UP = 0;
	var DOWN = 1;

  var height = 23; // height of the menu headers
  var iheight = 18; // height of the menu_items
  
  var bgc1 = "#FFFFFF" // background color of the item
  var tc1 = "#1e5382" // text color of the item
  
  var over_bgc1 = "#B7E8FF";
  var over_tc1 = "#1e5382";
  
  var bgc2 = "#ECF9FF" // background color of the item
  var tc2 = "#1e5382" // text color of the item
  
  var over_bgc2 = "#B7E8FF";
  var over_tc2 = "#1e5382";
  
  var movement_rate = iheight/6;  
  var speed = 0;
  var timerID = "";
  var N = (document.all) ? 0 : 1;
  var width = 152

  var element_array = new Array();

/*============================================================  
  write menu - writes html for menu
  ============================================================  */
function write_menu()
{
  header_index = 0; // count the position of the element_array
  document.write("<div style='position:absolute'>");
  minimum_v_position = 0;
  minimum_item_position = 1;
  start = -1;
  
  for(i=0;i<Link.length;i++)
  {
   link_array = Link[i].split("|");

   if (link_array[0] == "0") //menu header
   {
    if(start == 0) // setup the end of a menu block
    {
      document.write("</div>");
      height_of_block =  csmc * iheight;
      top_of_header = minimum_v_position; //-height_of_block
				// sets the top and bottom of the list of links
      element_array[header_index] = new Array(top_of_header,height_of_block,0,-2);
      header_index++;
      minimum_v_position--;
    } // if start = 0

   csmc = 0;
/*    document.write("<div class='menu' style='top:"+minimum_v_position+";height:"+height+"' id='down"+header_index+"' onclick='pull_down("+header_index+","+minimum_item_position+")'>&nbsp;"+ link_array[1] + "</div>");*/
   document.write("<div class='menu' style='top:"+minimum_v_position+";height:"+height+"' id='down"+header_index+"' onclick='pull_down("+header_index+","+minimum_item_position+")' onmouseover='color1(this.id)' onmouseout='uncolor1(this.id)'>&nbsp;"+ link_array[1] + "</div>"); 
   element_array[header_index] = new Array(minimum_v_position, height, 0, minimum_item_position);
   header_index++;
   minimum_item_position++;
   minimum_v_position+=height;
   start = 1;
  } // end of menu header
   else 
   {  
    if(start == 1)  // top menu item in a list
    {
      if(N)minimum_v_position+=2;
       document.write("<div class='item_panel' id='down"+header_index+"' style='top:"+minimum_v_position+"' >");
       start = 0;
    } // end top menu item section
    document.write("<a href='"+link_array[2]+"'");
    if (link_array[3] != "") document.write(" target='" + link_array[3] + "' ");
    document.write("><div class='item' id='d"+i+"' style='height:"+iheight);
    if (N) document.write(";width:150");
    document.write("' onmouseover='color2(this.id)' onmouseout='uncolor2(this.id)'>&nbsp;"+ link_array[1] + "</div></a>");
    csmc++;
   } //else
  } //for
  if (start == 0) // finish menu details
   {
     document.write("</div>");
     height_of_block =  csmc * iheight;
     top_of_header = minimum_v_position + 5; //-height_of_block
			 // sets the top and bottom of the header
     element_array[header_index] = new Array(top_of_header,height_of_block,0);
     name = "down" + (element_array.length-1);
     obj = document.getElementById(name);
     obj.style.borderBottomColor = "white";
     obj.style.borderBottomWidth = 0;
     obj.style.borderBottomStyle = "solid";
   }
  document.write("</div>"); // end of menu
} //end write menu
  

function color1(obj)
{
 document.getElementById(obj).style.backgroundColor = over_bgc1;
 document.getElementById(obj).style.color = over_tc1
}

function uncolor1(obj)
{
 document.getElementById(obj).style.backgroundColor = bgc1;
 document.getElementById(obj).style.color = tc1
}

function color2(obj)
{
 document.getElementById(obj).style.backgroundColor = over_bgc2;
 document.getElementById(obj).style.color = over_tc2
}

function uncolor2(obj)
{
 document.getElementById(obj).style.backgroundColor = bgc2;
 document.getElementById(obj).style.color = tc2
}

function hide_others(item_id) {
	// bail if there is only one element
  if (element_array.length <= 2) return;
	var offset = 0; // amount to move items up
	var obj;
	// search the list for open items
  for(i = 1; i < element_array.length; i += 2) {
		if(i != item_id){
			if(element_array[i][2] == DOWN){
				element_array[i][2] = UP;
				document.getElementById("down"+i).style.clip = "rect(0,"+width+", 0, 0)";
				offset += element_array[i][1];
			} //if 
		} //if 

		for (j=i+1;j<element_array.length;j++)
    {
     name = "down" + j;
     obj = document.getElementById(name);
		 obj.style.top = parseInt(obj.style.top) - offset;

    }
		offset=0;
	} // for 
} //hide_others

/*========================================================================
  pull_down - moves menu down or up
  ======================================================================== */
function pull_down(item_id, header_counter)
{

 //alert("item_id = " + item_id + " header_counter = " + header_counter);
 if (timerID == "") // pull down
 { 
    destination_position = element_array[item_id+1][1];
    begin = item_id + 2;
    if (timerID != "") clearTimeout(timerID);
		//alert("0 " + element_array[item_id+1][0]+ " 1 " + element_array[item_id+1][1] + " 2 " + element_array[item_id+1][2]);
    if (element_array[item_id+1][2] == UP) // pull down
    {
		 // hides other menus 
 		 hide_others(item_id);
     element_array[item_id+1][2] = DOWN;
     if(item_id == element_array.length-2) {destination_position++;}
     epull_down(begin,destination_position,0); 
    } 
    else // pull up
    { 
        destination_position = 0;
        element_array[item_id+1][2] = UP;
        name = "down"+(item_id+2);
        open_item = 0;
        for(i=0;i<item_id;i++)
        {
         if(element_array[i][2] == DOWN) 
          {
      	    open_item += element_array[i][1];
          }
        } // for
        if (N == false) {open_item -= (header_counter)};
        if (item_id == element_array.length-2) 
        {
      	  val = element_array[element_array.length-1][1];
      	  destination_position=-1;
        }
        else  val = parseInt(document.getElementById(name).style.top) -(open_item)-(header_counter*height);
        epull_up(begin,destination_position,val); 
    } //else
  } //if
} // end pull_down

/*=============================================================
  epull_down - slides menus down
  =============================================================*/
function epull_down(item_id, destination_position, current_position)
{
   name = "down" + (item_id-1);
   obj = document.getElementById(name).style.clip = "rect(0,"+width+","+(current_position+1)+",0)";
   for (i=item_id;i<element_array.length;i++)
   {
    name = "down" + i;
    obj = document.getElementById(name);
    obj.style.top = parseInt(obj.style.top)+movement_rate;
   }
   current_position += movement_rate;
   if(current_position < destination_position) timerID = setTimeout("epull_down("+item_id+","+destination_position+","+current_position+")",speed);
   else timerID = "";
}
/*=============================================================
  epull_up - slides menus up
  =============================================================*/
function epull_up(item_id, destination_position, current_position)
{
    name = "down" + (item_id-1);
    obj = document.getElementById(name).style.clip = "rect(0,"+width+","+current_position+",0)";
    for (i=item_id;i<element_array.length;i++)
    {
     name = "down" + i;
     obj = document.getElementById(name);
     obj.style.top = parseInt(obj.style.top)- movement_rate;
    }
    current_position -= movement_rate;
    if(current_position > destination_position) timerID = setTimeout("epull_up("+item_id+","+destination_position+","+current_position+")",speed);
    else timerID = "";
}

/*================================================================
  startup - called after menus are created
  ================================================================*/
function startup(item_id)
{
 write_menu();
 
 if (item_id != 0)
 {
 for(i=0;i<element_array.length;i++)
 {
  if(element_array[i][3] == item_id) pull_down(i,item_id)
  i==element_array.length;
 }
 }
}  