var negY, negX = 285;
var subnavistartY = 70;
var subnavieleheight = 20;

var fadeabstand = 20;

var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
var tempX = 0
var tempY = 0

function getMouseXY(e) {
	if (IE) {
		tempX = event.clientX + document.body.scrollLeft;
		tempY = event.clientY + document.body.scrollTop;
	}
	else {
		tempX = e.pageX;
		tempY = e.pageY;
	}
	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}  
	return true;
}
function navi_mouseover(parentli) {
	parentli.style.backgroundColor = '#7CB6EF';

	var list = parentli.getElementsByTagName('ul')[0];
	var x;
	list.style.display = 'block';	
	for(var i=0;i<li_len;i++) {
		if (li_arr[i].nodeType != 1) { continue; }
		x = li_arr[i].getElementsByTagName('ul')[0];
		if (x == list) { continue; }
		x.style.display = 'none'; 
		li_arr[i].style.backgroundColor = '#609DD4'
	}

	
}
function navi_mouseout() {
	var theY,minX,maxX,sitewidth,
		theDisplay;
		
	for(var i=0;i<li_len;i++) {
		if (li_arr[i].nodeType != 1) { continue; }
		var subnaviul = li_arr[i].getElementsByTagName('ul')[0];
		if(tempX+fadeabstand < negX) { subnaviul.style.display = 'none'; li_arr[i].style.backgroundColor = '#609DD4'; continue; }
		theY = subnavistartY + (subnaviul.getElementsByTagName('li').length * subnavieleheight);
		if(tempY-fadeabstand > theY) { subnaviul.style.display = 'none'; li_arr[i].style.backgroundColor = '#609DD4'; continue; }
		sitewidth = document.getElementById('bild').clientWidth + 12;
		if(tempX-fadeabstand > sitewidth) { subnaviul.style.display = 'none'; li_arr[i].style.backgroundColor = '#609DD4'; continue; }
		minX = subnaviul.clientX;
		maxX = subnaviul.clientWidth + minX;
		
	}	
}


document.onmousemove = getMouseXY;
var li_arr;
var li_len;

window.onload = function() {
	li_arr = document.getElementById('navigation').childNodes;
	li_len = li_arr.length;
	for(var i=0;i<li_len;i++) {
		if (li_arr[i].nodeType != 1) { continue; }
		li_arr[i].onmouseover = function() { navi_mouseover(this); }
	}

	suchfeld('kurs','Ihr Suchbegriff');
	suchfeld('suchwort','Ihr Suchbegriff');
	suchfeld('nachricht','Ihre Nachricht');
}

var mouseoutInt = window.setInterval("navi_mouseout()",50);

function suchfeld(name,meldung) {
	var kurs = document.getElementsByName(name)[0];

	if (kurs.value == '') {
		kurs.value = meldung;
		kurs.style.color = '#ccc';
	}

	kurs.onblur = function() {
		if (kurs.value == '') {
			kurs.value = meldung;
			kurs.style.color = '#ccc';
		}
	}

	kurs.onfocus = function() {
		if (kurs.value == meldung) {
			kurs.value = '';
		}
		kurs.style.color = '#000';
	}	
}

