
/********************************************************

Copyright© 2007 JT Avery & Associates, Inc.

This script was written from scratch. For those who care,
if you want to use it for any purpose please feel free to
do so.

Of course, it requires menu styles defined in (one of)
the accompanying style sheet(s) linked from the parent
document. The menus themselves are in the parent body - no
document.write calls, just style.visibility and style.clip
settings.

*********************************************************/

var total_menus = 3 // how many menus defined to show
var item_selected = false // whether an item within a menu is being moused-over 
var menu_selected = 0 // which menu is selected
var scroll_height = 0 // style.clip.bottom variable at start - incremented to create the scroll-height effect
var scroll_width = 0 // style.clip.right variable at start - incremented to create the scroll-width effect
var scroll_limit = 250 // total clipping height for menus - needs to cover total height in pixels of any menu with all of it's listed items
var scroll_interval = 3 // speed/time interval of scroll call in milliseconds - higher for slower, lower for faster
var height_increment = 20 // how many pixels in height to add to clip per scroll call - lower for slower, higher for faster
var width_increment = 20 // how many pixels in width to add to clip per scroll call - must complete before scroll-height does
var close_time = 0 // setTimeout variable that calls close_all()
var hide_wait = 50 // how long to wait before executing close_all() menus in milliseconds
var bgcolor_mouse_over = "#99cc99"
var bgcolor_mouse_out = "#006633"
var txtcolor_mouse_over = "#000000"
var txtcolor_mouse_out = "#ffffff"


function show(the_menu){
	clearTimeout(close_time);
	menu_selected = the_menu
	for(i=1; i<(total_menus + 1); i++){
		document.getElementById("menu" + i).style.visibility = "hidden";
	}
	document.getElementById("menu" + the_menu).style.clip = "rect(0,0,0,0)";
	document.getElementById("menu" + the_menu).style.visibility = "visible";
	scroll_height = 0;
  scroll_width = 0;
	call_scroll = setInterval('scroll(' + the_menu + ')', scroll_interval);
}

function scroll(the_menu){
	if(scroll_height < scroll_limit){
		clip = 'rect(auto, '+ scroll_width + 'px,' + scroll_height + 'px, auto)';
		document.getElementById('menu' + the_menu).style.clip = clip;
		scroll_height = scroll_height + height_increment;
		scroll_width = scroll_width + width_increment;
	}else{
		stop_scroll();
	}
}

function stop_scroll(){
	clearInterval(call_scroll);
	if(scroll_height < scroll_limit){
		close_all();
	}
}

function close_all(){
	if(item_selected == false){
		for(i=1; i<(total_menus + 1); i++){
		document.getElementById("menu" + i).style.visibility = "hidden";
		}
	}else if(item_selected == true){
		clearTimeout(close_time);
	}
}

function hide_menus(){
	close_time = setTimeout("close_all()", hide_wait);
}

function menu_item_mouseover(menu_item){
	clearTimeout(close_time);
	item_selected = true;
	document.getElementById(menu_item).style.backgroundColor = bgcolor_mouse_over;
	document.getElementById(menu_item).style.color = txtcolor_mouse_over;
	stop_scroll();
	document.getElementById("menu" + menu_selected).style.clip = "rect(auto,auto,auto,auto)";
}

function menu_item_mouseout(menu_item){
	item_selected = false;
	document.getElementById(menu_item).style.backgroundColor = bgcolor_mouse_out;
	document.getElementById(menu_item).style.color = txtcolor_mouse_out;
	hide_menus();
}