var iActive = null;
var sNav = "main_nav_1";

function show_nav(nId,sLang)
{
	if(nId == 1)
	{
		ClearMainNav(0,8);
		document.getElementById('main_nav_1').style.visibility = "visible";
		document.getElementById('main_nav_2').style.visibility = "hidden";
		document.getElementById('head_bt_1').className = "mu_main_bt_on";
		document.getElementById('head_bt_2').className = "mu_main_bt_off";
		document.getElementById('head_bt_pkw').src = "/siteelem/menu/mu_bt_" + sLang + "_pkw_on.png";
		document.getElementById('head_bt_gew').src = "/siteelem/menu/mu_bt_" + sLang + "_gew_off.png";
		sNav = "main_nav_1";
	}
	else
	{
		ClearMainNav(7,11);
		document.getElementById('main_nav_1').style.visibility = "hidden";
		document.getElementById('main_nav_2').style.visibility = "visible";
		document.getElementById('head_bt_1').className = "mu_main_bt_off";
		document.getElementById('head_bt_2').className = "mu_main_bt_on";
		document.getElementById('head_bt_pkw').src = "/siteelem/menu/mu_bt_" + sLang + "_pkw_off.png";
		document.getElementById('head_bt_gew').src = "/siteelem/menu/mu_bt_" + sLang + "_gew_on.png";
		sNav = "main_nav_2";
	}
	
	if(iActive != null)
	{
		document.getElementById('bar_sub_' + iActive).style.visibility = "hidden";
	}
	iActive = null;
}

function menu(bActive,iNumber)
{	
	if(bActive)
	{
		iActive = iNumber;
		
		for(var i = 0; i < 11; i++)
		{
			if(i == iNumber)
			{
				document.getElementById('bt_main_' + i).style.filter = 'alpha(opacity=100)';
				document.getElementById('bt_main_' + i).style.MozOpacity = 1;
				document.getElementById('bt_main_' + i).style.opacity = 1;
				//document.getElementById('bt_main_' + i + '.bt_text').style.color = '#fff';
				document.getElementById('bar_sub_' + i).style.visibility = "visible";
			}
			else
			{
				document.getElementById('bt_main_' + i).style.filter = 'alpha(opacity=25)';
				document.getElementById('bt_main_' + i).style.MozOpacity = 0.25;
				document.getElementById('bt_main_' + i).style.opacity = 0.25;
				//document.getElementById('bt_main_' + i + '.bt_text').style.color = '#000';
				document.getElementById('bar_sub_' + i).style.visibility = "hidden";
			}
		}
	}
}

function ClearMainNav(iStart,iEnd)
{
	for(var i = iStart; i < iEnd; i++)
	{
		document.getElementById('bt_main_' + i).style.filter = 'alpha(opacity=100)';
		document.getElementById('bt_main_' + i).style.MozOpacity = 1;
		document.getElementById('bt_main_' + i).style.opacity = 1;
	}
}

//***************************************************************************
//** Submenue Funktionen
//***************************************************************************

var bActiveOpenSub = new Array();
var bActiveCloseSub = new Array();

//** 
function openSubMenu(nId) {
	var sFunction = "openSubMenuT("+nId+")";
	if(!bActiveOpenSub[nId] || bActiveOpenSub[nId]=="") {
		window.clearTimeout(bActiveOpenSub[nId]);
		bActiveOpenSub[nId] = window.setTimeout(sFunction, 500);
	}
	if(bActiveCloseSub[nId]) {
		window.clearTimeout(bActiveCloseSub[nId]);
	}
}

function openSubMenuT(nId) {

	window.clearTimeout(bActiveOpenSub[nId]);
	bActiveOpenSub[nId]="";
	document.getElementById('me_sub_' + nId).style.visibility = "visible";
	document.getElementById('me_main_' + nId).style.backgroundImage = "url(/siteelem/elements/me_nav_selected.gif)";
	if(nId == 2)
	{
		document.getElementById(sNav).style.visibility = "visible";
		if(iActive != null)
		{
			document.getElementById('bar_sub_' + iActive).style.visibility = "visible";
		}
	}
}


function openSubMenuTFlex(nId) {

	parent.window.clearTimeout(bActiveOpenSub[nId]);
	bActiveOpenSub[nId]="";
	parent.document.getElementById('me_sub_' + nId).style.visibility = "visible";
	parent.document.getElementById('me_main_' + nId).style.backgroundImage = "url(/siteelem/elements/me_nav_selected.gif)";
}


//** 
function closeSubMenu(nId) {
	
	if (navigator.appName.indexOf ("Explorer") == -1)	{ 
			if(bActiveOpenSub[nId]) {
				window.clearTimeout(bActiveOpenSub[nId]);
				bActiveOpenSub[nId]="";
			}
			var sFunction = "closeSubMenuT("+nId+")";
			bActiveCloseSub[nId] = window.setTimeout(sFunction, 200);
	
	}else{
		var toElement = event.relatedTarget || event.toElement || false;
		if(toElement.id!=null){
			var tableCheck = toElement.id.substr(0,8);
			if(tableCheck != 'NoClose1' && tableCheck != 'NoClose2'){
				/*alert("close");*/
			}
		
			if(bActiveOpenSub[nId]) {
				window.clearTimeout(bActiveOpenSub[nId]);
				bActiveOpenSub[nId]="";
			}
			var sFunction = "closeSubMenuT("+nId+")";
			bActiveCloseSub[nId] = window.setTimeout(sFunction, 200);
		
		}
	}
}

function closeSubMenuT(nId) {
	document.getElementById('me_sub_' + nId).style.visibility = "hidden";
	document.getElementById('me_main_' + nId).style.backgroundImage = "";
	
	document.getElementById(sNav).style.visibility = "hidden";
	if(iActive != null)
	{
		document.getElementById('bar_sub_' + iActive).style.visibility = "hidden";
	}
}



//***************************************************************************

function setNewSize(iWidth,iHeight,sHeadId)
{
	//alert("sHeadId: " + sHeadId);
	document.getElementById(sHeadId).width = iWidth;
	document.getElementById(sHeadId).height = iHeight;
}

var galerieClose = "Close Window";

function showImagePopup(src, width, height, xmlhttprequest){
	var agent = navigator.userAgent.toLowerCase(); 
	
	
	//alert(agent.indexOf("msie 7"));
	
	width = parseInt(width);
	height = parseInt(height);
	document.getElementById("PopUp").style.visibility = "visible";
	document.getElementById("PopUp").style.display = "block";
	if(xmlhttprequest) {
		if (agent.indexOf("msie 7")>-1) {  
			document.getElementById("PopUp").innerHTML = "<div id='galerieContainer' class='galerieContainerSingle' style='width:"+width+"px; height:"+height+"px;'><div id='galerieCloser'><a href='javascript:;' onclick='closeImagePopup();'><img src='/siteelem/elements/galerie_close.png' alt='"+galerieClose+"' title='"+galerieClose+"' /></a></div><div id='XMLHttpReq' style='height:"+(height-5)+"px;width:"+(width-40)+"px;overflow:scroll'><img src='/siteelem/elements/ajax-loader.gif' vspace='50' /><br />Loading...</div></div>";	   		
	    }else{
			document.getElementById("PopUp").innerHTML = "<div id='galerieContainer' class='galerieContainerSingle' style='width:"+width+"px; height:"+height+"px;'><div id='galerieCloser'><a href='javascript:;' onclick='closeImagePopup();'><img src='/siteelem/elements/galerie_close.png' alt='"+galerieClose+"' title='"+galerieClose+"' /></a></div><div id='XMLHttpReq' style='height:"+(height-5)+"px;width:"+(width-20)+"px;overflow:scroll'><img src='/siteelem/elements/ajax-loader.gif' vspace='50' /><br />Loading...</div></div>";			
		}
		src = sGet_XMLHttpRequest(src,'XMLHttpReq');
	} else {
		document.getElementById("PopUp").innerHTML = "<div id='galerieContainer' class='galerieContainerSingle' style='width:"+width+"px; height:"+height+"px;' onclick='closeImagePopup();'><div id='galerieCloser'><a href='javascript:;' onclick='closeImagePopup();'><img src='/siteelem/elements/galerie_close.png' alt='"+galerieClose+"' title='"+galerieClose+"' /></a></div><img id='galerieImage' src='"+src+"' /><br /></div>";
	}
	
}


function showImageDivPopup(galID, imgstart, width, height){
	var agent = navigator.userAgent.toLowerCase(); 
	//alert(agent.indexOf("msie 7"));
	width = parseInt(width);
	height = parseInt(height);
	document.getElementById("PopUp").style.visibility = "visible";
	document.getElementById("PopUp").style.display = "block";
	document.getElementById("PopUp").innerHTML = '<div id="galerieContainer" class="galerieContainerSingle" style="width:'+(width)+'px; height:'+(height+30)+'px;"><div id="galerieCloser" style="z-index:500;"><a href="javascript:;" onclick="closeImagePopup();"><img src="/siteelem/elements/galerie_close.png" alt="'+galerieClose+'" title="'+galerieClose+'" /></a></div><div id="XMLHttpReq" style="height:'+(height)+'px;width:'+(width)+'px;"><iframe marginwidth="0" marginheight="0" src="/imgpopup.php?we_lv_ws_ImageGallery='+galID+'&we_lv_start_ImageGallery='+imgstart+'&myWinHeight='+(height)+'&myWinWidth='+(width)+'" id="n_pImgGal" name="n_pImgGal" scrolling="no" frameborder="0" height="'+(height+30)+'" width="'+(width)+'"></iframe></div></div>';			
	

}





function closeImagePopup(){
	document.getElementById("PopUp").style.visibility = "hidden";
	document.getElementById("PopUp").style.display = "none";
}

function tryMapsLoad() {
	if(typeof window.load == "function") {
		load();
	}
}

//***************************************************************************
//** Ajax ** Diese Funktion laedt den Inhalt von 'src' in das Div 'DivID' **
//***************************************************************************
//** Bsp: sGet_XMLHttpRequest('/php-bin/irgendwas.php','XMLHttpReq');
//***************************************************************************
function sGet_XMLHttpRequest(src,DivID) {
	var xmlHttp = null;
	try {
			// Mozilla, Opera, Safari sowie Internet Explorer (ab v7)
			xmlHttp = new XMLHttpRequest();
	} catch(e) {
			try {
					// MS Internet Explorer (ab v6)
					xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
					try {
							// MS Internet Explorer (ab v5)
							xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
					} catch(e) {
							xmlHttp  = null;
					}
			}
	}
	if (xmlHttp) {
			xmlHttp.open('GET', src, true);
			xmlHttp.onreadystatechange = function () {
					if (xmlHttp.readyState == 4) {
							//alert(xmlHttp.responseText);
							document.getElementById(DivID).innerHTML = xmlHttp.responseText;
					}
			};
			xmlHttp.send(null);
	}	
}

function EMailAdrHandler(name, domain, country)
{
	document.write('<a href=\"mailto:' + name + '@' + domain + '.' + country + '\">');
}
