
	
// find out if ie runs in quirks mode
var docEl = (
 	typeof document.compatMode != "undefined" && 
 	document.compatMode        != "BackCompat"
	) ? "documentElement" : "body";




// TOOLS  ----------------------------

function _(tag) {
	return document.getElementById(tag); 
}

function getPosition(el) {
	var pL = 0; var pT = 0;
	while (el) {
		pL += el.offsetLeft;
		pT += el.offsetTop;
		el=el.offsetParent;
	}
	return new Array(pL, pT);
}

// MENU  ----------------------------

var menuImages = new Array("home","lauf","teilnahme","impressionen", "presse", "partner", "kontakt");
 
// preload
for (var i = 0; i!= menuImages.length; i++) {
	file = new Image();
	file.src="images/menu/0"+(i+1)+"_"+menuImages[i]+".gif";
	file = new Image();
	file.src="images/menu/0"+(i+1)+"_"+menuImages[i]+"_active.gif";
}

var menuHiders= new Array(5);

function showMenu(nr, el) {
	if (el) {
		pos = getPosition(el);
		_("menu"+nr).style.left=(pos[0]+parseInt(el.style.width)/2-42)+"px";
		//_("menu"+nr).style.top=(pos[1]-)+"px";
	}
	_("menu"+nr).style.visibility="visible";
	menuMouseOver(nr);
	window.clearTimeout(menuHiders[nr-1]);
}

function menuMouseOver(nr) {
	_("menu_button_"+nr).src="images/menu/0"+nr+"_"+menuImages[nr-1]+"_active.gif";
}
function menuMouseOut(nr) {
	_("menu_button_"+nr).src="images/menu/0"+nr+"_"+menuImages[nr-1]+".gif";	
}

function hideMenu(nr) {
	menuHiders[nr-1]= window.setTimeout("doHideMenu("+nr+")",200);
}

function doHideMenu(nr) {
	menuMouseOut(nr);
	_("menu"+nr).style.visibility="hidden";
}

function gotoFirstLink(el) {
	if (el.nodeName == "A") {
		window.location.href=el;
		return true;
	}
	el = el.firstChild;
	while (el != null) {
		if ( gotoFirstLink(el) ) return true;
		el = el.nextSibling;
	}
}

function getImageWidth(myImage) {
	var x, obj;
	if (document.layers) {
		var img = getImage(myImage);
		return img.width;
	} else {
		return getElementWidth(myImage);
	}
	return -1;
}

function getImageHeight(myImage) {
	var y, obj;
	if (document.layers) {
		var img = getImage(myImage);
		return img.height;
	} else {
		return getElementHeight(myImage);
	}
	return -1;
}

function fieldClick(el, text) {
	if (el.value==text) el.value="";
}

function fieldBlur(el, text) {
	if (el.value=="") el.value=text;
}

	var BalloonTimer = null;

	function mouse_pos(e) {
    	// position where mousemove fired
    	var xPos    =  (document.all) ? window.event.x :e.pageX ;
		var yPos    =  (document.all) ? window.event.y :e.pageY ;
	
		// for ie add scroll position
		if (document.all && !document.captureEvents) {
	    	xPos    += document[docEl].scrollLeft;
	    	yPos    += document[docEl].scrollTop;
    	}

		return new Array(xPos, yPos);
    }

	function positionBalloon(e) {
		var pos = mouse_pos(e);
		_("balloon").style.left = (pos[0]-15)+"px";
		_("balloon").style.top = (pos[1]-10-parseInt(_("balloon_bottom").offsetTop))+"px";
	}

	function showBalloon(e, text, width) {

		if (text) {		
			if (width) 
				_("balloon").style.width=width+"px";
			else
				_("balloon").style.width="120px";
			_("balloon_text").innerHTML = text;
			positionBalloon(e);
		}
		
		_("balloon").style.visibility="visible";
		
		if( BalloonTimer != null ) {
			window.clearTimeout(BalloonTimer);
			BalloonTimer = null;
		}
	}
	function hideBalloon() {
		BalloonTimer = window.setTimeout("doHideBalloon();", 300);
	}
	
	function doHideBalloon() {	
		_("balloon").style.visibility="hidden";
		BalloonTimer = null;
	}
