
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function getGlobalCoord(e)
{
	var e;
	if (!e)	{
		window.MouseX = event.clientX;
		window.MouseY = event.clientY;	
	} else {
		window.MouseX = e.pageX;
		window.MouseY = e.pageY;
	}
	return false;
}


var oTimeOut = null;
var intActiveNumber = 0;
var intMo_Left = 0;
var intMo_Right = 0;
var intMo_Top = 0;
var intMo_Bottom = 0;
function showMenu(intId)
{
	window.clearTimeout(oTimeOut);
	if(intId == intActiveNumber){
		return false;
	}
	hideAll(intId);
	var objDhtmlTitle = document.getElementById('oDivDnT_' + intId );
	if(objDhtmlTitle == null)
		return false;
	
	var objDhtmlContent = document.getElementById('oDivDnC_' + intId );
	if(objDhtmlContent == null)
		return false;
	
	var objMainNavigation = document.getElementById('oDivMn_'  + intId );	
	var intLeft = findPosX(objMainNavigation)-1;
	var intTop = findPosY(objMainNavigation)-2;
	objDhtmlTitle.style.left 	= intLeft+"px";
	objDhtmlTitle.style.top 	= intTop+"px";
	var intWidth = objDhtmlTitle.offsetWidth;
	var intHeight = objDhtmlTitle.offsetHeight;
	
	objDhtmlContent.style.left 	= intLeft+"px";
	objDhtmlContent.style.top 	= intTop+intHeight+"px";
	
	if(objDhtmlContent.offsetWidth <= objDhtmlTitle.offsetWidth){
		objDhtmlContent.style.width = (objDhtmlTitle.offsetWidth + 20)+"px";
	}
	var objDhtmlBorder = document.getElementById('oDivDnB_' + intId );
	var intNewWidth = (objDhtmlContent.offsetWidth - objDhtmlTitle.offsetWidth);
	var intNewLeft = (intLeft + objDhtmlContent.offsetWidth - intNewWidth);
 	objDhtmlBorder.style.left 	= intNewLeft+"px";
	objDhtmlBorder.style.top 	= (intTop+intHeight-1)+"px";
	objDhtmlBorder.style.width = intNewWidth +"px";
	intActiveNumber = intId;
	
	intMo_Left = intLeft;
	intMo_Right = intLeft+objDhtmlContent.offsetWidth;
	intMo_Top = intTop;
	intMo_Bottom = intTop+intHeight+objDhtmlContent.offsetHeight;
	//alert(intMo_Left+" - "+intMo_Right+" :: "+window.MouseX);
	//window.status = window.MouseY +" - " +intMo_Top;
	return false;
}

function showLngMenu()
{
	window.clearTimeout(oTimeOut);
	hideAll(0);
	var objDhtml = document.getElementById('oDivLng_Sub');
	var objMainLng = document.getElementById('oDivLng');	
	var intLeft = findPosX(objMainLng);
	var intTop = findPosY(objMainLng)+objMainLng.offsetHeight-1;
	objDhtml.style.left 	= intLeft+"px";
	objDhtml.style.top 	= intTop+"px";
	intActiveNumber = 0;
	
	intMo_Left = intLeft;
	intMo_Right = intLeft+objDhtml.offsetWidth;
	intMo_Top = 0;
	intMo_Bottom = objMainLng.offsetHeight+objDhtml.offsetHeight;
	
	return false;
}

function handleMouseMoveEvents(e){
	void getGlobalCoord(e);
	
	if(intMo_Left == 0)
		return;
	var intOffset = 20;
	if(parseInt(window.MouseX+intOffset) > parseInt(intMo_Left)){
		if(parseInt(window.MouseX-intOffset) < parseInt(intMo_Right) ){
			if(parseInt(window.MouseY+intOffset) > parseInt(intMo_Top) ){
				if(parseInt(window.MouseY-intOffset) < parseInt(intMo_Bottom) ){
					return;
				}
			}
		}
	}
	
	/*
	if(intMo_Top >= window.MouseY +10){
		return;
	}
	if(intMo_Bottom <= window.MouseY +10){
		return;
	}*/
	void timeOutHideAll();
	//alert(intMo_Left+"-"+intMo_Right+"-"+ intMo_Top+"-"+ intMo_Bottom+"-");
}

function timeOutHideAll()
{
	oTimeOut = window.setTimeout('hideAll(0)', 300);
}

function hideAll(intId)
{
	var x = document.getElementsByTagName('div');
	strTest = "";
	var arrTMP = null;
	var intTMPID = 0;
	for (var i=0;i<x.length;i++) {
		if(x[i].id.indexOf("oDivDnT_") != -1){
			var arrTMP = x[i].id.split('_');
			intTMPID = parseInt(arrTMP[1]);
			if(intTMPID != intId){
				document.getElementById('oDivDnT_'+ intTMPID).style.left = "-2000px";
				document.getElementById('oDivDnC_'+ intTMPID).style.left = "-2000px";
				document.getElementById('oDivDnB_'+ intTMPID).style.left = "-2000px";
			}
		}
	}
	x = null;
	oInterval = null;
	intActiveNumber = 0;
	intMo_Left = 0;
	intMo_Right = 0;
	intMo_Top = 0;
	intMo_Bottom = 0;
	if(document.getElementById('oDivLng_Sub') != null){
	document.getElementById('oDivLng_Sub').style.left = "-2000px";
	}
	return false;
}


function setOpacity(obj, svalue) {
	obj.style.opacity = svalue/100;
	obj.style.filter = 'alpha(opacity=' + svalue + ')';
	obj = null;
}

function changeColor(strObj,strColor){
	var obj = document.getElementById(strObj);
	obj.style.color = strColor;
}

function switchClass(strObj,strClass){
	document.getElementById(strObj).className = strClass;
}

function createEMailMessage(strSubject,strBody)
{
	var strUrl="mailto:?";
 	strUrl+="subject="+escape(strSubject)+"&";
  	strUrl+="body="+escape(strBody);
  	location.href=strUrl;
}

function adviseCurrentPage()
{
	var strSubject = "Webseiten-Empfehlung";
	var strBody = "Guten Tag,\n";
	strBody += "Ihnen wurde eine Seite von "+self.location.hostname+" empfohlen.\nKlicken Sie bitte auf folgenden Link, um die Seite in Ihrem Internet-Browser anzusehen:\n"; 
	strBody += "http://"+self.location.hostname+self.location.pathname + self.location.search + "\n\n";
	void createEMailMessage(strSubject,strBody);
}
function checkSearchForm()
{
	var obj = document.getElementById("sSS");
	if(obj.value == ""){
		return false;
	}
	if(obj.value == "Suchbegriff eingeben"){
		return false;
	}
	document.getElementById("frmSimpleSearch").submit();
}

function checkEMailAdress(strEmailAdress)
{
	var a = false;
	var Result = false;
	
	if(typeof(RegExp) == 'function'){
		var b = new RegExp('abc');
		if(b.test('abc') == true)
		a = true;
	}
	if(a == true){
		reg = new RegExp('^([a-zA-Z0-9-._]+)'+
		'(@)([a-zA-Z0-9-.]+)'+
		'(.)([a-zA-Z]{2,4})$');
		Result = (reg.test(strEmailAdress));
	}
	else{
		Result = ( strEmailAdress.search('@') >= 1 && strEmailAdress.lastIndexOf('.') > strEmailAdress.search('@') && strEmailAdress.lastIndexOf('.') >= strEmailAdress.length-5 );
	}
	return( Result );
}

function checkNewsletterRegistrationForm()
{
	var obj = document.getElementById("frNLR_sEmail");
	if(obj.value == ""){
		return false;
	}
	if(checkEMailAdress(obj.value) == false){
		return false;
	}
	document.getElementById("frm_NewsletterRegistration").submit();
}

function showFalseForm(strForm){
	if(document.getElementById(strForm) != null){
	var objForm = document.getElementById(strForm);
	objForm.style.borderColor = "#EB1321";
	objForm.style.color = "#EB1321";
	}
}

function m_setObjectOpacity(obj, svalue) {
	obj.style.opacity = svalue/100;
	obj.style.filter = 'alpha(opacity=' + svalue + ')';
	obj = null;
}

document.onmousemove = handleMouseMoveEvents;