function showMenu(num){
	if (!window.menu_start) return;
	hideMenus();
	if (window.menu_close == undefined){
		window.menu_close = [];
	}
	window.cur_menu_num = num;
	$('menu_hover_top'+num).show();
	$('menu_hover_top'+num).onmouseover = function(e){
		unBuble(e);
		window.menu_close[num] = 0;
	};
	$('menu_hover'+num).show();
	$('menu_hover'+num).onmouseover = function(e){
		unBuble(e);
		window.menu_close[num] = 0;
	};
	$('menu'+num).style.visibility = 'hidden';
	//$('menu'+num).hide();
	setTimeout('document.body.onmouseover=preHideMenu', 200);
}

function preHideMenu(){
	if (window.cur_menu_num && window.cur_menu_num > 0){
		var num = window.cur_menu_num;
	} else {
		return false;
	}
	setTimeout('hideMenu();', 500);
	window.menu_close[num] = 1;
}

function hideMenu(){
	if (window.cur_menu_num && window.cur_menu_num > 0){
		var num = window.cur_menu_num;
	} else {
		return false;
	}
	if (window.menu_close[num] != 1){
		return false;
	}
	$('menu_hover_top'+num).hide();
	$('menu_hover'+num).hide();
	$('menu'+num).style.visibility = 'visible';
	//$('menu'+num).show();
	document.body.onmouseover = function(e){};
	window.cur_menu_num = 0;
	hideSubMenu();
}

function showSubMenu(num){
	hideSubMenu();
	if (window.menu_close == undefined){
		window.menu_close = [];
	}
	var parent_num = window.cur_menu_num;
	$('menu_hover'+num).show();
	$('menu_hover'+num).onmouseover = function(e){
		unBuble(e);
		window.menu_close[parent_num] = 0;
	};
}

function hideSubMenu(){
	$$('.submenu_item').each(function(obj){obj.hide();});
}

function hideMenus(){
	$$('.menu_hover_top').each(function(obj){obj.hide();});
	$$('.menu_hover_item').each(function(obj){obj.hide();});
	$$('.menu_item').each(function(obj){obj.style.visibility = 'visible';});
}

function holdParentClass(parent_id){
	if (!window.hold_elem || window.hold_elem == 0){
		window.hold_elem = parent_id;
		$('menu_hold'+parent_id).removeClassName('menu_a');
		$('menu_hold'+parent_id).removeClassName('menu_arr');
		var class_color = $('menu_hold'+parent_id).className.toString();
		$('menu_hold'+parent_id).removeClassName(class_color);

		$('menu_hold'+parent_id).addClassName('menu_a_hover');
		$('menu_hold'+parent_id).addClassName('menu_arr_hover');
		$('menu_hold'+parent_id).addClassName(class_color+'_hover');
	}
}

function backParentClass(parent_id){
	if (window.hold_elem !== undefined && window.hold_elem > 0){
		window.hold_elem = 0;
		$('menu_hold'+parent_id).removeClassName('menu_a_hover');
		$('menu_hold'+parent_id).removeClassName('menu_arr_hover');
		var class_color = $('menu_hold'+parent_id).className.toString();
		$('menu_hold'+parent_id).removeClassName(class_color);
		class_color = class_color.substr(0, class_color.indexOf('_hover'));
		$('menu_hold'+parent_id).addClassName('menu_a');
		$('menu_hold'+parent_id).addClassName('menu_arr');
		$('menu_hold'+parent_id).addClassName(class_color);
	}
}

function showLeftMenu(parent_id, obj_ul){
	if ($('submenu_left'+parent_id) == null){
		return false;
	}
	if ( $('left_menu') !== null ){
		$('left_menu').select('li').each(function(obj_parent_li){
			if(obj_parent_li.id != '' && obj_parent_li.id != obj_ul.id){
				var target_a = obj_parent_li.select('a')[0];
				if (target_a.style.fontWeight == 'bold' || target_a.style.fontWeight == 700){
					var need_id = obj_parent_li.id.toString().substr(12);
					target_a.style.fontWeight = 'normal';
					$('submenu_left'+need_id).style.padding = '0 0 0 0';
					hideScroll('submenu_left'+need_id, 8, 20);
					target_a.removeClassName('no_decor');
				}
			}
		});
	}

	var obj = $(obj_ul.id).select('a')[0];
	var target_ul = $('submenu_left'+parent_id);
	if (obj.style.fontWeight == 'normal' || obj.style.fontWeight == '' || obj.style.fontWeight <700){
		obj.addClassName('no_decor');
		obj.style.fontWeight = 'bold';
		target_ul.onclick = unBuble;
		target_ul.style.padding = '5px 0 2px 0';
		target_ul.style.height = 'auto';
		target_height = target_ul.getHeight();
		target_ul.style.height = '1px';
		showScroll('submenu_left'+parent_id, 4, 20, target_height);
	} else {
		obj.style.fontWeight = 'normal';
		target_ul.style.padding = '0 0 0 0';
		hideScroll('submenu_left'+parent_id, 8, 20);
		obj.removeClassName('no_decor');
	}
}

function showScroll(obj_id, step, period, max_height){
	var obj = $(obj_id);
	var current_height = obj.getHeight();

	if (current_height < max_height){
		obj.style.height = ((current_height+step<max_height)?(current_height+step):max_height) + 'px';
		setTimeout("showScroll('"+obj_id+"', "+step+", "+period+", "+max_height+")", period);
	}
}

function hideScroll(obj_id, step, period){
	var obj = $(obj_id);
	var current_height = obj.getHeight();
	if (current_height > 1){
		obj.style.height = ((current_height-step>1)?current_height-step:1) + 'px';
		setTimeout("hideScroll('"+obj_id+"', "+step+", "+period+")", period);
	}
}


function makeMenuIeFix(){
	var ie = (document.body.runtimeStyle == undefined)?false:true;
	var opera = (navigator.userAgent.toString().toLowerCase().indexOf('opera') > -1)?true:false;

	$$('.menu_span_check1').each(function(obj){
		var cur_width = obj.getWidth();
		//alert(cur_width);
		if (cur_width > 0){
			obj.style.width = (cur_width+1)+'px';
			obj.parentNode.style.visibility = 'visible';
			obj.parentNode.style.display = 'none';
		} else {
			//setTimeout("makeMenuIeFix()", 200);
		}
	});
	$$('.menu_span_check').each(function(obj){
		var cur_width = obj.getWidth();
		//alert(cur_width);
		if (cur_width > 0){
			obj.parentNode.style.width = (cur_width+1)+'px';
			obj.parentNode.style.visibility = 'visible';
			obj.parentNode.style.display = 'none';
		} else {
			//setTimeout("makeMenuIeFix()", 200);
		}
	});
	window.menu_start = true;
}
setTimeout("makeMenuIeFix()", 300);
