// TOSHIBA :: Slide Menu (v.1.1, 17.09.2002)
// copyright (c) 2002 by taker (artstyle group), http://taker.artstyle.ru

var show_style = (nn4) ? 'show' : 'visible';
var hide_style = (nn4) ? 'hide' : 'hidden';

var active_menu = null;
var active_menu_layer = null;
var menu_click = false;

var active_width = 0;
var active_height = 0;
var active_step = 0;

var steps = (document.all || nn4) ? 15 : 12;

var menu_list = new Array();

function SubMenu(id, width, height) {
	this.id = id;
	this.width = width;
	this.height = height;
}

function get_layer(id) {
	return (dom) ? document.getElementById(id).style : ((ie4) ? document.all[id].style : ((nn4) ? document.layers[id] : null));
}

function NN4_MouseUp(e) {
	if (e.layerX == e.pageX && e.layerY == e.pageY && !e.target.href && !e.target.onclick) deactivate();
}

function deactivate() {
	if (active_menu && !menu_click) hide(active_menu);
	menu_click = false;
}

function resize_layer(leer, width, height) {
	if (nn4) {
		leer.resizeTo(width, height);
	} else {
		leer.width = width;
		leer.height = height;
	}
}

function slide_move() {
	if (active_menu) {
		if (active_step < steps) {
			active_step++;
			if (active_step >= steps) {
				var width = active_width;
				var height = active_height;
			} else {
				var width = parseInt(active_width * active_step / steps);
				var height = parseInt(active_height * active_step / steps);
			}
			resize_layer(active_menu_layer, width, height)
			if (active_step <= steps) setTimeout("slide_move()", 10);
		} else {
			show_layer(active_menu + 'Menu');
			if (nn4) document.onmouseup = NN4_MouseUp; else document.onclick = deactivate;
		}
	}
}

function show(item) {
	deactivate();
	resize_layer(get_layer(item + 'BG'), 0, 0);
	show_layer(item + 'BG');
	active_menu = item;
	active_menu_layer = get_layer(active_menu + 'BG');
	active_width = menu_list[item].width;
	active_height = menu_list[item].height;
	active_step = 0;
	slide_move();
}

function alrt() { alert() }

function hide(item) {
	if (nn4) document.onmouseup = null; else document.onclick = null;
	active_menu = null;
	hide_layer(item + 'Menu');
	hide_layer(item + 'BG');
}

function switch_item(item) {
	if (active_menu == item) deactivate(); else show(item);
}

function hide_layer(id) {
	var layer = get_layer(id);
	layer.visibility = hide_style;
}

function show_layer(id) {
	var layer = get_layer(id);
	layer.visibility = show_style;
}

if (ie4 || dom) {
	if (document.all.item)
	{
		document.writeln(
		'<' + 'style>' +
			'.submenuBG { background-color:white; filter:alpha(opacity=80); -moz-opacity:80%; }' +
		'<' + '/' + 'style>'
		);
	}
}


if (nn4) document.captureEvents(Event.MOUSEUP);
document.onmouseup = null;

