//+----------------------------------------------------------------------------+
//| Copyright 2005, Dipl. eng. Andri Ivin.                                     |
//| Unauthorized copying of this script or any part of this script prohibited. |
//| Contact: andri.ivin@mail.ee                                                |
//+----------------------------------------------------------------------------+

var menu_button_is_pressed = false;

var menu_button_width = 80;
var menu_button_height = 33;
var menu_button_hotarea_delta = 20;

//Preload Images ----------------------------------------
function loadMenuButtonImage() {
	var doc_mb = document;
	doc_mb.imageArray = new Array();
	doc_mb.imageArray[0] = new Image;
	doc_mb.imageArray[0].src = "buttons/button_menu_on.png";
	doc_mb.imageArray[1] = new Image;
	doc_mb.imageArray[1].src = "buttons/button_menu_up.png";
	doc_mb.imageArray[2] = new Image;
	doc_mb.imageArray[2].src = "buttons/button_menu_down.png";
}

function swapButtonImage(button,buttonImage) {
	document[button].src = buttonImage;
}

function changeMenuButton(elemName, action) {
	document.getElementById(elemName).style.visibility = action;
}

//------------------ Menu Button ----------------------
function create_Menu_Button() {
//------------------ Menu Button On ------------------- 
	document.write('<DIV ID="MenuButtonOn" STYLE="visibility:visible;position:absolute;top:'+(menu_button_y)+'px;left:'+(menu_button_x)+'px;height:'+(menu_button_height)+'px;width:'+(menu_button_width)+'px;z-index:5;cursor:hand;" ONMOUSEOVER="swapButtonImage(\'menu_button_on\',\'buttons/button_menu_up.png\');" ONMOUSEUP="swapButtonImage(\'menu_button_on\',\'buttons/button_menu_down.png\');changeMenuButton(\'MenuButtonOn\', \'hidden\');menuStatus(\'visible\');">');
	document.write('<IMG SRC="buttons/button_menu_on.png" BORDER="0" NAME="menu_button_on">');
	document.write('</DIV>');
	
//------------------ Menu Button Down ------------------- 
	document.write('<DIV ID="MenuButtonDown" STYLE="visibility:visible;position:absolute;top:'+(menu_button_y)+'px;left:'+(menu_button_x)+'px;height:'+(menu_button_height)+'px;width:'+(menu_button_width)+'px;z-index:4;cursor:hand;"  ONMOUSEUP="swapButtonImage(\'menu_button_on\',\'buttons/button_menu_up.png\');changeMenuButton(\'MenuButtonOn\', \'visible\');menuStatus(\'hidden\');">');
	document.write('<IMG SRC="buttons/button_menu_down.png" BORDER="0" NAME="menu_button_down">');
	document.write('</DIV>');
	
//######################## HOT AREA #########################

	document.write('<DIV ID="MenuButtonMenuHotArea" STYLE="visibility:visible;position:absolute;left:' + (menu_button_x-menuhotarea_delta/2) + 'px;top:' + (menu_button_y-menu_button_hotarea_delta/2) + 'px;width:' + (menu_button_width+menu_button_hotarea_delta) + 'px;height:' + (menu_button_height+menu_button_hotarea_delta) + 'px;z-index:1;" ONMOUSEOVER="menuStatus(\'hidden\');swapButtonImage(\'menu_button_on\',\'buttons/button_menu_on.png\');changeMenuButton(\'MenuButtonOn\', \'visible\');">');
	document.write('<TABLE WIDTH="'+(menu_button_width+menu_button_hotarea_delta)+'px" HEIGHT="'+(menu_button_height+menu_button_hotarea_delta)+'px" CELLPADDING="0" CELLSPACING="0" BORDER="0">');
	document.write('<TR>');
	document.write('<TD BACKGROUND="menuimages/spacer_1px.gif">');
	document.write('<IMG SRC="menuimages/spacer_1px.gif" BORDER="0">');
	document.write('</TD>');
	document.write('</TR>');
	document.write('</TABLE>');
	document.write('</DIV>');
}

//-------------------------------------------------------
function set_Menu_Button() {
	setRootMenuPosition();
	
	document.getElementById('MenuButtonOn').style.left = menu_button_x;
	document.getElementById('MenuButtonDown').style.left = menu_button_x;
	document.getElementById('MenuButtonMenuHotArea').style.left = menu_button_x-menuhotarea_delta/2;
	
	document.getElementById('RootMenu').style.left = root_menu_x;
	document.getElementById('RootMenuHotArea').style.left = root_menu_x-menuhotarea_delta/2;
	
	document.getElementById('Submenu_level_1_4_Menu').style.left = submenu_level_1_4_menu_x;
	document.getElementById('Submenu_level_1_4_HotArea').style.left = submenu_level_1_4_menu_x-menuhotarea_delta/2;
	
	document.getElementById('Submenu_level_1_8_Menu').style.left = submenu_level_1_8_menu_x;
	document.getElementById('Submenu_level_1_8_HotArea').style.left = submenu_level_1_8_menu_x-menuhotarea_delta/2;
}
