var g_element = '';

window.onload = function() {
	if (location.hash.substring(1) == '') {
		activate('item_1');
	} else {
		activate(location.hash.substring(1))
	}
	onclick_activate();
}

function activate(a_item)
{
	var l_element = document.getElementById(a_item + '_block');
	if (g_element.length > 0 && document.getElementById(g_element)) {
		document.getElementById(g_element).className = 'hidden';
	}
	if (a_item.length > 0 && l_element) {
		g_element = a_item + '_block';
		l_element.className = 'table';
	}
	if (document.getElementsByTagName) {
		var alinks = document.getElementById('sub_menu').getElementsByTagName('a');
		for (i = 0; i < alinks.length; i++) {
			if (alinks[i].getAttribute('href').indexOf('#') >= 0) {
				var l_element = alinks[i].getAttribute('href').substring(alinks[i].getAttribute('href').indexOf('#') + 1);
				if (a_item == l_element) {
					alinks[i].parentNode.className = 'active';
				} else {
					alinks[i].parentNode.className = '';
				}
			}
		}
	}
	if (document.getElementById('sub_menu').clientHeight > document.getElementById(g_element).clientHeight) {
		if (document.getElementById(g_element).tagName == 'TABLE') {
			var l_height = document.getElementById('sub_menu').clientHeight - 32 + 'px';
		} else {
			var l_height = document.getElementById('sub_menu').clientHeight - 44 + 'px';
		}
		document.getElementById(g_element).style.height = l_height;
	}
}

function onclick_activate()
{
	if (document.getElementsByTagName) {
		var alinks = document.getElementById('sub_menu').getElementsByTagName('a');
		for (i = 0; i < alinks.length; i++) {
			if (alinks[i].getAttribute('href').indexOf('#') >= 0) {
				var l_element = alinks[i].getAttribute('href').substring(alinks[i].getAttribute('href').indexOf('#') + 1);
				var l_onclick_function = "activate('" + l_element + "')";
				var new_function = new Function('e', l_onclick_function);
				alinks[i].onclick = new_function;
			}
		}
	}
}
