window.cur_nav_obj = null;

function nav_initialize() {
	for (i=1; i<=nav_total; i++) {
		nav_obj = document.getElementById('nav' + i);
		nav_arr = eval('nav' + i + '_array');
		nav_link_arr = eval('nav' + i + '_link_array');
		if (nav_arr.length < 1) {
			nav_obj.style.display = "none";
		} else {
			//nav_obj.style.backgroundColor = nav_border_color;
			//nav_obj.style.padding = nav_border_size + "px";
			nav_obj.height_int = ((nav_item_height * nav_arr.length)+((nav_item_vertpadding*2) * nav_arr.length));
			//nav_obj.style.height = nav_obj.height_int + "px";
			nav_obj.top_int = 0;
			nav_obj.style.top = nav_obj.top_int + "px";
			nav_obj_html = "";
			
			nav_obj_html += "<div class=\"content\" style='width: " + nav_item_width + "px; padding-top: 6px;'>";

			for (x=0; x<nav_arr.length; x++) {
				nav_style = "height: " + nav_item_height + "px; padding-top: " + nav_item_vertpadding + "px; padding-bottom: " + nav_item_vertpadding + "px; padding-left: " + nav_item_horzpadding + "px; padding-right: " + nav_item_horzpadding + "px; ";
				nav_obj_html += "<div style='" + nav_style + "' onMouseOut='clearInterval(window.hide_nav_int);'><a href='" + nav_link_arr[x] + "' style='display: block'>" + nav_arr[x] + "</a></div>";
			}
			nav_obj_html += "</div>";			
			nav_obj.innerHTML = nav_obj_html;
			nav_obj.style.display = "none";
			
			container_obj = document.getElementById('container' + i);
			//container_obj.style.height = (nav_obj.height_int + (nav_item_vertpadding*2)) + "px";
		}
	}
}
function show_nav(obj) {
	clearInterval(window.hide_nav_int);
	nav_obj = document.getElementById(obj);

	if (window.cur_nav_obj != nav_obj) {
		for (i=1; i<=nav_total; i++) {
			inc_nav_obj = document.getElementById('nav' + i);
			nav_reset(inc_nav_obj);
		}
		nav_obj.top_int = -1 * nav_obj.height_int;
		nav_obj.style.top = nav_obj.top_int + "px";
		nav_obj.style.display = "block";

		container_obj = nav_obj.parentNode;
		container_obj.style.height = (nav_obj.height_int + (nav_item_vertpadding*2)) + "px";

		clearInterval(window.show_nav_int);
		window.show_nav_int = setInterval("nav_animate(nav_obj)", 25);
		window.cur_nav_obj = nav_obj;
	}
}
function nav_animate(obj) {
	if (in_range(obj.top_int, 0, 1)) {
		obj.top_int = 0;
		obj.style.top = obj.top_int + "px";
		clearInterval(window.show_nav_int);
	} else {
		obj.top_int = obj.top_int + ((0 - obj.top_int) / 4);
		obj.style.top = obj.top_int + "px";
	}
}
function hide_nav(obj) {
	nav_obj = document.getElementById(obj);
	clearInterval(window.hide_nav_int);
	window.hide_nav_int = setInterval("nav_reset(nav_obj)", 500);
}
function nav_reset(obj) {
	clearInterval(window.hide_nav_int);
	obj.top_int = -1 * obj.height_int;
	obj.style.display = "none";
	obj.parentNode.style.height = "0px";
	window.cur_nav_obj = null;
}
function in_range(input_num, base_num, range_int) {
	if (input_num+range_int>=base_num && input_num-range_int<=base_num) {
		return true;
	} else {
		return false;
	}
}