/*  --------------------------------------------------------------------------- *  MENU DOM *  Christoph Studer *  version 1.0, 16.06.2003 *  --------------------------------------------------------------------------- *  This scripts handle the interaction between the menu structure (in menu.js) *  and the DOM / HTML *  e.g. it catches the onclick event, marks menus, opens and closes them etc. *  --------------------------------------------------------------------------- */ // the last menu clicked on or marked by a page load.var lastselected = null;var lastmainselected = null; // put click handlers here if you like!function clicked(num){	pageLoaded(num);	return true;	}// use this function from within an other page to open the// menu at a certain node...function pageLoaded(id){			var menuitem = sasmenu.getById(id);		if (menuitem)	{		if ( (lastselected && lastselected.id != id) || !lastselected)		// only do something if the menu is not already open and selected...		{						openMenu(id);			markItem(id);		}	}	else	{		if (lastselected)		{			closeMenu(lastselected.id,true);			markItem(lastselected.id,'off');		}		lastselected = null;	}}// open the menu (inclusive the parents...)function openMenu(num){	var el = document.getElementById('submenus'+num);	// exit if it's already open	/*	if (el && el.style.display != 'none')		return;	*/	var others = new Array();	var parent = null;	curitem = sasmenu.getById(num);	parent = curitem.parent;	others = curitem.getBrothers();		// close lastselected recursively (inclusive parents)	if (lastselected && (lastselected.top.id != activeid || curitem.top.id == activeid) )	{		closeMenu(lastselected.id,true);	}		if (lastmainselected && curitem.top.id == activeid)	{		closeMenu(lastmainselected.id,true);	}		// also open the parent's menu	if (parent)	{		//alert('also open my parent');		openMenu(parent.id);	}	//menuitemel.className = menuitemel.className + 'on';	if (el) 		el.style.display = "block";}// close the menu (leave children open)function closeMenu(id,recursive){	var el = document.getElementById('submenus'+id);	if (el)	{		el.style.display = "none";	}	if (recursive)	{		var menuitem = sasmenu.getById(id);		var parent = menuitem.parent;		if (parent)			closeMenu(parent.id,true);	}}function menuOver(id){	if (!lastselected || lastselected.level==0 || lastselected.id!=id)	{			menuitem = sasmenu.getById(id);			curstyles = levels[menuitem.level];			for (i=0;i<curstyles['ids'].length;i++)			{				el = document.getElementById(curstyles['ids'][i]+id);				if(el)				{					el.className = menuitem.color+'-'+curstyles['over'][i];									}			}	}}function menuOut(id){	if (!lastselected || lastselected.id!=id)	{		menuitem = sasmenu.getById(id);		curstyles = levels[menuitem.level];		for (i=0;i<curstyles['ids'].length;i++)		{			el = document.getElementById(curstyles['ids'][i]+id);			if(el)			{				el.className = menuitem.color+'-'+curstyles['off'][i];							}		}	}}// mark this menu item (including parents...) as selected// unmark all othersfunction markItem(id,off,recursed){		var curid = "";	var curstyles = new Array();	var menuitem = sasmenu.getById(id);	var curitem = menuitem;	var parent = menuitem.parent;	var el = null;	var mode = null;	//if (!off) off = 'on';	//mode = off;	mode = off ? 'off':'on';		//if (id==2) alert('id 2 '+mode);		if ( id == activeid && mode != 'on' ) return;	if (lastselected && lastselected.id == id && mode == 'on')		return;	if (lastselected && mode == 'on' && lastselected.level>=menuitem.level)	{		if (lastselected && lastselected.top.id == activeid && curitem.top.id != activeid)		{			//lastmainselected = lastselected;		} else		{						// unmark the last selected item but only if it's on the same level or deeper			markItem(lastselected.id,'off',true);		}		if (lastmainselected && curitem.top.id == activeid)			markItem(lastmainselected.id,'off',true);	}	if (parent)	{		markItem(parent.id,off,true);	}	curstyles = levels[menuitem.level];	for (i=0;i<curstyles['ids'].length;i++)	{		el = document.getElementById(curstyles['ids'][i]+menuitem.id);		if(el)		{			el.className = curitem.color + '-' + curstyles[mode][i];					}	}	if (!recursed)	{		if (menuitem.top.id == activeid)			lastmainselected = menuitem;		lastselected = menuitem;	}}function writePathHTML(id){	if (typeof(pathframe) == 'undefined') return;	var menuitem = sasmenu.getById(id);	var el = pathframe.document.getElementById('pathcontainer');	var html = '';	if (menuitem)	{		var path = menuitem.getPath();		var itemhtml = '';			for (var i=0;i<path.length;i++)		{			if (i==0)				itemhtml = pathitemfirst;			else if (i==path.length-1)				itemhtml = pathitemlast;			else				itemhtml = pathitem;						if (i>0) html += pathseperator;			html += itemhtml.replace('%name%',path[i].name).replace('%url%',path[i].link).replace('%id%',path[i].id);		}	} else		html = '';	el.innerHTML = html;}function docjslib_getRealLeft(imgElem) {        xPos = imgElem.offsetLeft;        tempEl = imgElem.offsetParent;          while (tempEl != null) {                  xPos += tempEl.offsetLeft;                  tempEl = tempEl.offsetParent;          }        return xPos;}function docjslib_getRealTop(imgElem) {        yPos = imgElem.offsetTop;        tempEl = imgElem.offsetParent;        while (tempEl != null) {                  yPos += tempEl.offsetTop;                  tempEl = tempEl.offsetParent;          }        return yPos;}
