function RegisterWindowLoadEvent(fnHandler)
{
	if ( typeof window.addEventListener != "undefined" )
	{
		window.addEventListener( "load", fnHandler, false );
	}
	else 
	{
		if ( typeof window.attachEvent != "undefined" ) 
		{
			window.attachEvent( "onload", fnHandler );
		}
		else {
			if ( window.onload != null ) 
			{
				var oldOnload = window.onload
				window.onload = function ( e ) {
					oldOnload( e );
					fnHandler;
				}
			}
			else
			{ 
				window.onload = fnHandler;
			}
		}
	}
}
	
var isOver = new Array(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false);
var arrVal = new Array(0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
var ALPHA_FINAL = 100;
var load = false;

function getAbsoluteTop(objectId) {
	// Get an object top position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId)
	oTop = o.offsetTop            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent  // Get parent object reference
		oTop += oParent.offsetTop // Add parent top position
		o = oParent
	}
	// Return top position
	return oTop
}

function getAbsoluteLeft(objectId) {
	// Get an object left position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId);
	oLeft = o.offsetLeft            // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent    // Get parent object reference
		oLeft += oParent.offsetLeft // Add parent left position
		o = oParent
	}
	// Return left postion
	return oLeft
}

function GetPosition(MenuLink)
{

		i =getAbsoluteLeft(MenuLink);//GetPosition(obj.parentElement);
		//alert(i);
		//obj.clientLeft+obj.offsetLeft+obj.offsetWidth+
	//alert(i);
	return i;
	
}
var TopConst = 22;
function StartFadeIn(id,MenuLink)
{
	if (load) {
		isOver[id] = true;
		i = getAbsoluteLeft("MenuModelLinkItem"+id);
		h = getAbsoluteTop("MenuModelLinkItem"+id) + TopConst;
		
		var db_back = document.getElementById("d" + id + "_back");
		var db = document.getElementById("d" + id );
		
		db_back.style.visibility = 'visible';
		db_back.style.left = i;
		db_back.style.top = h;
		db_back.style.zIndex = 162;

		db.style.visibility = 'visible';
		db.style.left = i;
		db.style.top = h - 1;
		db.style.zIndex = 162;
		
		clearTimeout(eval("timer" + id));
		eval("tIn" + id + " = setTimeout('FadeIn(" + id + ")', 0)");
		
	}
}

function StartFadeOut(id) {
	if (load)
	{
		isOver[id] = false;
		clearTimeout(eval("timer" + id));
		eval("tIn" + id + " = setTimeout('FadeOut(" + id + ")', 100)");
	}
}

function FadeIn(id)
{
    if (isOver[id]) {
	    arrVal[id] += 20;
		if (arrVal[id] <= ALPHA_FINAL) eval("d" + id + "_back.filters.alpha.opacity = arrVal[id]");
		eval("d" + id + ".filters.alpha.opacity = arrVal[id]");
		if (arrVal[id] < 100) eval("timer" + id + " = setTimeout('FadeIn(" + id + ")', 40)");
	}
}

function FadeOut(id)
{
	if (!isOver[id])
	{
		arrVal[id] -= 20;
		if (arrVal[id] < ALPHA_FINAL) eval("d" + id + "_back.filters.alpha.opacity = arrVal[id]");
		eval("d" + id + ".filters.alpha.opacity = arrVal[id]");
		if (arrVal[id] == 0)
		{
			eval("d" + id + "_back.style.visibility = 'hidden'");
			eval("d" + id + ".style.visibility = 'hidden'");
		}
		if (arrVal[id] > 0) eval("timer" + id + " = setTimeout('FadeOut(" + id + ")', 40)");
	}
}