// file global.js

function get_window_size() {
	var windowWidth, windowHeight;

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	arrayWindowSize = new Array(windowWidth, windowHeight);
	return(arrayWindowSize);
}

function hide_all_submenu() {
	for(var i = 1; i <= num_link; i++) {
		if ($('submenu_' + i)) Element.hide('submenu_' + i);
	}

	if ($('link_id_' + active_submenu)) {
		if (Element.hasClassName('link_id_' + active_submenu, 'over')) {
			Element.removeClassName('link_id_' + active_submenu, 'over');
		}
	}
}

function show_submenu(number) {
	if ($('submenu_' + number)) {
		Element.show('submenu_' + number);
		active_submenu = number;

		if ($('link_id_' + active_submenu)) {
			if (Element.hasClassName('link_id_' + active_submenu, 'over')) {
				Element.removeClassName('link_id_' + active_submenu, 'over');
			}
		}

		if ($('link_id_' + number)) {
			if (!Element.hasClassName('link_id_' + number, 'over')) {
				Element.addClassName('link_id_' + number, 'over');
			}
		}
	}
}

function hide_submenu(number) {
	if ($('submenu_' + number)) {
		Element.hide('submenu_' + number);
	}
}

var active_submenu = 0;
var revert_delay = 1000;
var revert_timeout = 500;
var revert_time = 0;
var timeout_id;

function start_revert() {
	revert_time = revert_delay;
	timeout_id = window.setTimeout('do_revert()', revert_timeout);
}

function do_revert() {
	revert_time = revert_time - revert_timeout;

	if (revert_time < 0) {
		hide_submenu(active_submenu);
		if ($('link_id_' + active_submenu)) {
			if (Element.hasClassName('link_id_' + active_submenu, 'over')) {
				Element.removeClassName('link_id_' + active_submenu, 'over');
			}
		}
		active_submenu = 0;
	}
	else {
		timeout_id = window.setTimeout('do_revert()', revert_timeout);
	}
}

function stop_revert() {
	if (timeout_id) window.clearTimeout(timeout_id);
}