var nIdPrev = "1";
var nSubIdPrev = "1";

function show_nav(nId)
{
	hide_nav();
	document.getElementById('nav_' + nId).style.visibility = "visible";
	if(document.getElementById('vogtland') )
	{
		/*var sColorOn = "#e30065";*/
		var sColorOn = "#7b0025";
	}
	else
	{
		var sColorOn = "#004277";
	}
	
	document.getElementById('head_' + nId).style.color = sColorOn;
	document.getElementById('head_' + nId).style.borderBottomColor = sColorOn;
	nIdPrev = nId;
}

function hide_nav()
{
	document.getElementById('nav_' + nIdPrev).style.visibility = "hidden";
	
	if(document.getElementById('vogtland') )
	{
		var sColorOff = "#ffffff";
	}
	else
	{
		var sColorOff = "#353535";
	}
	
	document.getElementById('head_' + nIdPrev).style.color = sColorOff;
	document.getElementById('head_' + nIdPrev).style.borderBottomColor = "transparent";
}

function show_subnav(nId)
{
	hide_subnav();
	document.getElementById('sub_' + nId).style.visibility = "visible";
	var vParent = document.getElementById('sub_' + nId).parentNode;
	vParent.style.backgroundColor = "#004f9e";
	nSubIdPrev = nId;
}

function hide_subnav()
{
	document.getElementById('sub_' + nSubIdPrev).style.visibility = "hidden";
	var vParent = document.getElementById('sub_' + nSubIdPrev).parentNode;
	vParent.style.backgroundColor = "";
}


function ACAj_showEmpfehlung(url,site,domain){

	with(document.getElementById('htmlMain').style) { 
		overflow="hidden"; 
	} 
	
	with(document.getElementById('acaGreyOutThisSite').style) { 
		visibility="visible"; 
	} 
	
		
	$('acaGreyOutThisSite').innerHTML = "<center><span class = 'LoadingDivSpanText'><br><br>Loading ... </span><br><br></center>";
	$('acaGreyOutThisSite').innerHTML = "<center><iframe id='' name = '' src='"+url+"?myRecommendedSite="+site+"&myRecommendedDoamin="+domain+"' width = '700' height='620' ></iframe></center>";
	
}

function ACAj_hideEmpfehlung(){
	
	with(parent.document.getElementById('htmlMain').style) { 
		overflow="auto"; 
	} 
	
	with(parent.document.getElementById('acaGreyOutThisSite').style) { 
		visibility="hidden"; 
	}
}

function showImage()
{
	var imgs = document.getElementById("fader").getElementsByTagName("img");
	if (typeof(counter) != "number")
	{
			counter = 0;
	}
	counter++;
	if (counter < imgs.length)
	{
		fade();
	}
	else
	{
		counter = 0;
		step = 0;
		stepRS = 0;
		fadeRestart();
	}
}

function fade(step)
{
	var imgs = document.getElementById("fader").getElementsByTagName("img");
	step = step || 0;
	imgs[counter].style.opacity = step/100;
	imgs[counter].style.filter = "alpha(opacity=" + step + ")";	
	imgs[(counter-1)].style.opacity = (100-step)/100;
	imgs[(counter-1)].style.filter = "alpha(opacity="+(100-step)+")";	
	step = step + 2;
	if (step <= 100)
	{
		window.setTimeout(function () { fade(step); }, 1);
	}
	else
	{
		window.setTimeout(showImage, 5000);
	}
}

function fadeRestart(stepRS)
{
	var imgs = document.getElementById("fader").getElementsByTagName("img");
	var iMyLastImage = imgs.length;
	stepRS = stepRS || 0;
	imgs[0].style.opacity = stepRS/100;
	imgs[0].style.filter = "alpha(opacity=" + stepRS + ")"; // 
	imgs[(iMyLastImage-1)].style.opacity = (100-stepRS)/100;
	imgs[(iMyLastImage-1)].style.filter = "alpha(opacity="+(100-stepRS)+")"; 
	stepRS = stepRS + 2;	
	if (stepRS <= 100)
	{
		window.setTimeout(function () { fadeRestart(stepRS); }, 1);
	}
	else
	{
		window.setTimeout(showImage, 5000);
	}
}

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

function opnDealerPopup() {
	var sPLZ = document.getElementById("PLZ").value;
	var sANZ = document.getElementById("SELECT_ANZ").value;
	//var sGEO = document.getElementById("GEO").checked;
	var sGEO = document.getElementById("GEO").value;
	showImagePopup('/php-bin/DealerShow.req.php?PLZ='+sPLZ+'&SELECT_ANZ='+sANZ+'&GEO='+sGEO+'&sLng=de_DE',860,400,true);
}
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='/images/elements/galerie_close.png' alt='"+galerieClose+"' title='"+galerieClose+"' /></a></div><div id='XMLHttpReq' style='height:"+(height-5)+"px;width:"+(width-40)+"px;overflow-y:scroll;overflow-x:hidden;'><img src='/images/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='/images/elements/galerie_close.png' alt='"+galerieClose+"' title='"+galerieClose+"' /></a></div><div id='XMLHttpReq' style='height:"+(height-5)+"px;width:"+(width-20)+"px;overflow-y:scroll;overflow-x:hidden;'><img src='/images/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='/images/elements/galerie_close.png' alt='"+galerieClose+"' title='"+galerieClose+"' /></a></div><img id='galerieImage' src='"+src+"' /><br /></div>";
	}
	
}

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

//***************************************************************************
//** 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) {
							
							document.getElementById(DivID).innerHTML = xmlHttp.responseText;
					}
			};
			xmlHttp.send(null);
	}	
}
