
isIE = false;

function browser_check()
	{
	if(navigator.userAgent.indexOf("MSIE")!=-1)
		isIE = true;
	}

browser_check();

function dropdown(relative_to_element,dropdown_element)
	{
	if(relative_to_element!=null&&dropdown_element!=null)
		{
		this.relative_to_element = relative_to_element;
		this.dropdown_element = dropdown_element;
		this.relative_to_element.onmouseover = this.show;
		this.relative_to_element.onmouseout = this.hide;
		this.left = getX(this.relative_to_element);
		
		//this.top = 82;
		this.dropdown_element.style.left = this.left + 'px';
		//this.dropdown_element.style.top = this.top + 'px';
		this.relative_to_element.submenu_id = dropdown_element.id;
		
		//var pos = this.relative_to_element.submenu_id.indexOf('_');
		//var id = this.relative_to_element.submenu_id.substring(pos+1);
		//this.relative_to_element.id = id;
		
		this.dropdown_element.onmouseover = function () {  if(timeout_id) clearTimeout(timeout_id); };
		this.dropdown_element.onmouseout = function () { if(timeout_id) clearTimeout(timeout_id); timeout_id = setTimeout(hide_all,'1000');};
		}
	}

dropdown.prototype.show = dropdown_show;
dropdown.prototype.hide = dropdown_hide;

var timeout_id = 0;

function dropdown_show()
	{
	if(timeout_id)
		clearTimeout(timeout_id);
	hide_all();
	//this.style.background = 'url(./images/bgr_menu2.gif)';
	//var li_el = document.getElementById(this.id);
	//li_el.firstChild.style.background = 'url(./images/bgr_menu2.gif)';
	//this.firstChild.style.background = 'url(./images/bgr_menu2.gif)';
	this.firstChild.style.backgroundPosition = 'right top';
	//alert(this.firstChild.style.background.url);
	document.getElementById(this.submenu_id).style.left = getX(this) + 'px';
	document.getElementById(this.submenu_id).style.visibility = 'visible';
	}
	
function dropdown_hide()
	{
	if(timeout_id) 
		clearTimeout(timeout_id);
	timeout_id = setTimeout(hide_all,'1000');
	}

function getX( element )
	{
	var ret = 0;
	while( element!=null)
		{
		ret += element.offsetLeft;
		element = element.offsetParent;
		//element = element.parent;
		}
	return ret;
	}


function getY( element )
	{
	var ret = 0;
	while( element!=null)
		{
		ret += element.offsetTop;
		element = element.offsetParent;
		}
	return ret;
	}


function hide_all()
	{
	for(aa=0;aa<dropdowns.length;aa++)
		{
		if(dropdowns[aa].dropdown_element!=null)
			{
			dropdowns[aa].dropdown_element.style.visibility = 'hidden';
			dropdowns[aa].relative_to_element.firstChild.style.backgroundPosition = 'left top';
			//alert(dropdowns[aa].relative_to_element.firstChild);
			}
		}
	}

dropdowns = new Array();

function apply_dropdowns()
	{
	var nav = document.getElementById('mainmenu');
	//alert(nav.childNodes.length);
	//for(aa=0;aa<nav.firstChild.childNodes.length;aa++)
	
	for(aa=0;aa<nav.childNodes.length;aa++)
		{
		//var rel_el = nav.firstChild.childNodes[aa];
		var rel_el = nav.childNodes[aa];
		var sub_el = document.getElementById('subnav_' + aa);
		//rel_el.style.height = '29px';
		//alert(rel_el.offsetLeft);
		dropdowns[aa] = new dropdown(rel_el,sub_el);
		}
	}
