// $Id: default.js 517 2007-12-28 12:28:37Z Simon Wunderlin $

// main and subnavigation handling /////////////////////////////////////////////
var killnav = new Array();

function opennav(lid, caller) {
	// position the div below the caller object, left aligned
	
	// close already opened pulldowns
	closeall();
	
	// position the layer
	var pos = findPos(caller);
	var top = caller.offsetHeight;
	top = top - 3;
	document.getElementById(lid).style.left = pos[0] + "px";
	document.getElementById(lid).style.top  = top + "px";
	
	// firefox seems to call out and over repedately (argh) prevent menus 
	// from disapearing when mouse stays over main nav button
	killnav[lid] = false;

	// open current nav
	document.getElementById(lid).style.display = "block";

	return true;
}

function closenav(lid) {
//	alert("closenav");
	// if the user moves the mouse out of the main button, we give him a 
	// a change to reach the pulldown. if now close it.
	killnav[lid] = true;
	setTimeout('closetimed(\''+lid+'\')', 500);
	
	return true;
}

function closetimed(lid) {
	if (killnav[lid])
		document.getElementById(lid).style.display = "none";
		
	return true;
}

function closeall() {
	// close all other pulldowns (if any)
	var subnav = document.getElementById("subnav");
	for(i=0; i<subnav.childNodes.length; i++) {
		if (!subnav.childNodes.item(i).style)
			continue;
		subnav.childNodes.item(i).style.display = "none";
	}
	
	return true;
}

// positioning /////////////////////////////////////////////////////////////////
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

// font handling ///////////////////////////////////////////////////////////////
function set_fontsize(s) {
	window.cookies.set("fontsize", s, 24*356);
	// alert(jimAuld.utils.cookies.get("fontsize"));
	loc = document.location.href + '?x=1';
	//alert("redirecting to: " + loc);
	document.location.reload(); //href=loc;
}

window.onload = function() {
	if (!window.cookies.get("fontsize")) 
		set_fontsize("medium");
	return true;
	//alert(document.cookie);
}

