
//document.onmousemove=getMousePos;

var activeSub;
var menuOver = false;
var timeout = 500;
var interval = null;

function showSub(div, o)
{
	clearTimeout(interval);

	activeSub = div;
	// release all submenus
	
	document.getElementById('sub_mentoring-programme').style.display = "none";
	document.getElementById('sub_mentoringsupport').style.display = "none";
	document.getElementById('sub_faq').style.display = "none";
	document.getElementById('sub_anmeldung').style.display = "none";
	document.getElementById('sub_unser_angebot').style.display = "none";
	document.getElementById('sub_unter_uns').style.display = "none";
	
	//show chosen submenu
	submenu =  document.getElementById(div);
	submenu.style.display = "block";
	submenu.style.position = "absolute";
	submenu.style.top = o.offsetTop -1 + 'px';//yPos + 'px';
	submenu.style.left = 152 + 'px'; //xPos + 'px';
	//alert(xPos);
}

function hideSub(div) 
{

	interval = setTimeout('hide(\'' + div + '\')', timeout);
	//hide(div);

}

function hide(div)
{
	div = (div == undefined ? activeSub : div);
	if (!menuOver) {
		document.getElementById(div).style.display = "none";
		menuOver = false;
	}		
}


function cancelHide()
{

	menuOver = true;

}


function resumeHide()
{

	menuOver = false;
	//setTimeout('hide()', timeout);
	
	//interval = setTimeout('hide()', timeout);
	clearTimeout(interval);
	hideSub(activeSub);
}

function getMousePos(e){
	var offset = 5;
	var posx = 0;
	var posy = 0;
	if (!e) {
		var e = window.event;
	}
	if (e.pageX || e.pageY) {
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) {
		posx = e.clientX + document.body.scrollLeft;
		posy = e.clientY + document.body.scrollTop;
	}
	
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		winWidth = window.innerWidth;
		winHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		winWidth = document.documentElement.clientWidth;
		winHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		winWidth = document.body.clientWidth;
		winHeight = document.body.clientHeight;
	}

	//xPos = posx + offset;
	//xPos = (winWidth / 2) - 370;
	xPos = 152;
	//yPos = (Math.floor(((posy) / 19)) * 19) + 3 - 163;
	yPos = posy - 163;
	
}

function clearField(obj) {

	if (obj.oldFieldValue == undefined || obj.value == obj.oldFieldValue) {
		obj.oldFieldValue = obj.value;
		obj.value = '';
	}
	
}

function restoreField(obj) {
	
	if (obj.value == '') {
		obj.value = obj.oldFieldValue;
	}
	
}

function popWin(url, width, height) {
	width = (width == undefined ? '800' : width);
	height = (height == undefined ? '600' : height);
	
	popup = window.open(url, 'popupwindow', 'location=0,toolbar=0,width=' + width + ',height=' + height + ',scrollbars=1,resizable=1');

}

function changeBg(obj, classname) {
    
    obj.restoreBgClassName = obj.className;
    obj.className = classname;
    
}

function restoreBg(obj) {
    obj.className = obj.restoreBgClassName;
}