// JavaScript Document

var menuDelayUp = 1000; // milliseconds

var mtimer = null;
var locking = 0;

// ----------------------------------------------
// internal functions take arguments
function findParent(el)
{
	var list;
	if (el.parentNode && (list=el.parentNode.parentNode) && 
		list.nodeName=='DL') { return list;
	} return false;
}

function findSibling(el)
{
	var sb;
	if (el.parentNode && (sibling=el.parentNode.nextSibling) && 
		sibling.nodeName=='DD') { return sibling;
	} return false;
}

function shrink(id)
{
	var d,l;
	var m=document.getElementById(id);
	if (locking==0&&(d=findSibling(m))&&(l=findParent(m))) with (l.style) {
		height = m.offsetHeight + 'px';
	}
}

function expand(id)
{
	var d,l;
	var m=document.getElementById(id);
	if ((d=findSibling(m))&&(l=findParent(m))) with (l.style) {
		height = m.offsetHeight + d.offsetHeight + 'px';
	}
}

function down(id)
{
	var d;
	var m=document.getElementById(id);
	if (d=findSibling(m)) with (d.style) {
		top = m.offsetTop + m.offsetHeight + 'px';
		left = m.offsetLeft + 'px';
	} return false;
}
function up(id)
{
	var d;
	var m=document.getElementById(id);
	if ((d=findSibling(m))&&!d.locked) with (d.style) {
		top = m.offsetTop - d.offsetHeight + 'px';
		left = m.offsetLeft + 'px';
	} return false;
}

// ----------------------------------------------
// object functions take no arguments

function myFunc(evt) {
    evt = (evt) ? evt : ((window.event) ? window.event : "")
    if (evt) {
        // process event here
		alert(evt);
    }
}

function activate()
{
	var d;
	if (d=findSibling(this)) with (d.style) { 
		down(this.id);
		expand(this.id);
		visibility = 'visible';
		clearTimeout(this.timer);
		clearTimeout(mtimer);
		this.timer = setTimeout('up("'+this.id+'")', menuDelayUp);
		mtimer = setTimeout('shrink("'+this.id+'")', menuDelayUp);
	} return false;
}

function initialise()
{
	document.getElementById==null && alert('getElementById not present');
	document.getElementsByTagName==null && alert('getElementsByTagName not present');
	var n,a,d; var m=0;
	for(n=0; (a=document.getElementsByTagName("a")[n]); n++) {
		if (a.className && (a.className.indexOf("activator")!=-1) && (d=findSibling(a))) {
			//a.onmouseover = activate;
			//onmouseout = deactivate;
			//onclick = toggle;
			//a.onclick = myFunc;
			//a.id=(a.id)?a.id:'actuator'+m;
			//a.id=a.id||'actuator'+m;
			//id || id='actuator'+m; 
			//alert(id || id='actuator'+m;);
			//up(a.id);
			//shrink(a.id);
			m++;
		}
	}
	window.status = 'built ' + m + ' menus. ' + n + ' links.';
}

window.onload = function() {
	initialise();
}	
