/*
*	This JavaScript file is for handling the header menu of the application.
*
*   It has been modified to run with IE6 and Mozilla (Netscape 6)
*
*	Date: 19.11.2003 
* 	last modified by: Christian Langhirt, NEXTware GmbH
*/

var mmtItem = [];
var mTime = [];
var mWait = 250;

var str = "";

function mClear(id) {
	if (mTime[id]) {
		clearTimeout(mTime[id]);
		mTime[id] = null;
	}
}

// initializing the menu items with events
function mSet(div)
{
	if (document.getElementById(div) != null) 
	{
		var li = document.getElementById(div).getElementsByTagName('ul');
		var i, j, e, a, f, b;
		var m = mmtItem.length;
		
		for (i = 0; i < li.length; i++) 
		{
			if(e = li[i].getAttribute('id')) 
			{
				mmtItem[m] = e;
				mTime[mmtItem[m]] = null;
				e = li[i]; 
				f = new Function('mShow(\'' + mmtItem[m] + '\',\'Unten\');');
				b = new Function('mBlur(\'' + mmtItem[m] + '\',\'Unten\');');
				e.onmouseover = f;
				e.onmouseout = b;
				e.style.display = 'none';
				
				a = e.getElementsByTagName('a');
				for (j = 0; j < a.length; j++) {
//'					a[j].onfocus = f;
//'					a[j].onblur = b;					         
				}
				m++;			    
			}
		}
	}	
}

// show a menu with the given id
function mShow(id,src) {
	//str += "show" + src + id + "\n"; 
	//alert(str)
	for (var i = 0; i < mmtItem.length; i++)
	{
		if (document.getElementById(mmtItem[i]).style.display != 'none') 
		{
			if (mmtItem[i] != id){
				 mHide(mmtItem[i],src);
			}	 
			else{
				 mClear(mmtItem[i],src);
			}	 
		}
	}
	
	// set menu item activated
	if(parent.frames.headerFrame && parent.frames.headerFrame.mActivate) {parent.frames.headerFrame.mActivate(id)};
    
	if( document.getElementById(id) )
    {
		//setContentShow(false);
		var tmDivLeft = 0;
		var tmElemLeft = 0;
		if( parent.frames.headerFrame )
		{
			//tmDivLeft = parent.frames.headerFrame.document.getElementById("tmDivMenu").offsetLeft;
			tmElemLeft = parent.frames.headerFrame.document.getElementById(id).offsetLeft;
			//Anpassung für die verschiebung des Menüs
			tmElemLeft = tmElemLeft - 100;
	    }
		var li = document.getElementById(id).getElementsByTagName('li');
		//alert(tmDivLeft + " - " + tmElemLeft);
		li[0].style.left = parseInt(tmDivLeft) + parseInt(tmElemLeft);
		li[0].style.top = document.body.scrollTop; //getYPosition();
		li[0].style.display = 'block';
	    document.getElementById(id).style.display = 'block';
	 }   
}

function mHide(id,src) {

	if( document.getElementById(id) )
	{
		//setContentShow(true);
		mClear(id);
	    document.getElementById(id).style.display = 'none';

		// set menu item de-activated
		if(parent.frames.headerFrame && parent.frames.headerFrame.mDeactivate) parent.frames.headerFrame.mDeactivate(id);
 
 		//if(parent.frames.frameHidden.mHideOben) parent.frames.frameTop.mHideOben(id);	    
		//'alert(str + src + "-" +id);
		str="";
	}    
}

function mBlur(id,src) {
	str += "blur" + src + id + "\n"; 
	if( mTime[id] == null ) 
	{
		str += "blurTimeout" + src + id + "\n"; 
		mTime[id] = setTimeout('mHide(\'' + id + '\',\'' + src + '\');', mWait);
	}	
}
