isDOM=document.getElementById 
isOpera=isOpera5=window.opera && isDOM 
isOpera6=isOpera && window.print 
isOpera7=isOpera && document.readyState 
isMSIE=document.all && document.all.item && !isOpera 
isMSIE5=isDOM && isMSIE 
isNetscape4=document.layers 
isMozilla=isDOM && navigator.appName=="Netscape";



// Pre-definitions

BG_COLOR = '#174A89';
BG_OVER_COLOR = '#FF8400';


var POPUP_PREFIX = 'popup_';

var OFFSET_Y = 15;
var OFFSET_X = 0;
if(isMozilla){
	OFFSET_X--;
}

var TIMEOUT = 500;

/**
* Handles mouse over menu item event
* @param	HTMLElement	ctrl
*/
function handleMouseOverMenuItem(ctrl){
	if(!ctrl.id) return false;

//	alert(getLeft(ctrl));

	return true;
}

/**
* Handles mouse out menu item event
* @param	HTMLElement	ctrl
*/
function handleMouseOutMenuItem(ctrl){
	if(!ctrl.id)
		return false;

	//if(ctrl.getAttribute('menu_selected'))
	//	return false;

	return true;
}

function getTop(ctrl){
	var value = 0;
	if(ctrl.offsetParent)
		value = getTop(ctrl.offsetParent);

	return ctrl.offsetTop + value;
}
function getLeft(ctrl){
	var value = 0;
	if(ctrl.offsetParent)
		value = getLeft(ctrl.offsetParent);

	return ctrl.offsetLeft + value;
}
/**
* Handles mouse over menu item event
* @param	HTMLElement	ctrl
*/

var openItems = new Array();
var totalOpenItems = 0;
var popTimeout = new Array();

function handlePopupMouseOverMenuItem(ctrl, event){
	if(!ctrl.id)
		return false;
	handleMouseOverMenuItem(ctrl);
	var __ctrl = document.getElementById(POPUP_PREFIX + ctrl.id);

	openItems[totalOpenItems+1] = POPUP_PREFIX + ctrl.id;
	clearItems(POPUP_PREFIX + ctrl.id);

	if (!__ctrl) return false;
	__ctrl.style.top = getTop(ctrl) + OFFSET_Y + 'px';
	__ctrl.style.left = getLeft(ctrl.offsetParent) + OFFSET_X + 'px';// + 50;
	__ctrl.style.display = 'block';
	return true;
}

/**
* Handles mouse out menu item event
* @param	HTMLElement	ctrl
*/
function clearItems(Item){
	for(i=1;i<=totalOpenItems;i++){
		if(openItems[i]!=Item)clear(openItems[i]);
	}
	totalOpenItems=1;
	openItems[1]=Item;
}

function handlePopupMouseOutMenuItem(ctrl){
	if(!ctrl.id)
		return false;
	handleMouseOutMenuItem(ctrl);
	popTimeout[POPUP_PREFIX+ctrl.id] = setTimeout("clear('"+POPUP_PREFIX + ctrl.id+"')", TIMEOUT);
	return true;
}

function handleMouseOverPopupMenu(ctrl, event){
//	alert("h1");
	handleMouseOverMenuItem(ctrl);
	clearTimeout(popTimeout[ctrl.id]);
}

function handleMouseOutPopupMenu(ctrl, event){
//	alert(ctrl.id);
	handleMouseOutMenuItem(ctrl);
	popTimeout[ctrl.id] = setTimeout("clear('"+ctrl.id+"')", TIMEOUT);
}

function clear(c){
	var __ctrl = document.getElementById(c);
	clearTimeout(popTimeout[c]);
	if(__ctrl)__ctrl.style.display = 'none';
}


function handle2(obj, id){
	clearTimeout(popTimeout[id]);
	try{
		obj.style.cursor = 'hand';
		obj.style.backgroundColor = BG_OVER_COLOR;
		window.status = obj.childNodes[0].href;
	}catch(e){}
}

function handle3(obj){
	try{
		obj.style.cursor = 'auto';
		obj.style.backgroundColor = BG_COLOR;
		window.status = '';
	}	catch (e){}

}

function go(obj){
	try{
		location.href = obj.childNodes[0].href;
	}catch(e){}
}
