// JavaScript Document

function swapImgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.pgW=innerWidth; document.pgH=innerHeight; onresize=reloadPage; }}
  else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
}
reloadPage(true);

function showHideLayers() {
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

timer=null;
timer2=null;

function timeoutStop() {
	clearTimeout(timer);
	timer=null;
}

function timeoutStop2() {
	clearTimeout(timer2);
	timer2=null;
}

function getLeft(refObj)
{
	xPos=refObj.offsetLeft;
	parentObj=refObj.offsetParent;
	while(parentObj != null)
	{
		xPos +=parentObj.offsetLeft;parentObj=parentObj.offsetParent;
	}
	return xPos;
}

function getTop(refObj)
{
	yPos=refObj.offsetTop;
	parentObj=refObj.offsetParent;
	while(parentObj != null)
	{
		yPos +=parentObj.offsetTop;parentObj=parentObj.offsetParent;
	}
	return yPos;
}

function leftPos(refName)
{
	ref=document.images[refName];
	return (document.layers)? ref.x : getLeft(ref);
}

function topPos(refName)
{
	ref=document.images[refName];
	return (document.layers)? ref.y : getTop(ref);
}

function thisDiv(Ident)
{
	if(document.all)
	{
		Pointer=document.all[Ident].style;
	}
	else if(document.getElementById)
	{
		Pointer=document.getElementById(Ident).style;
	}
	else if(document.layers)
	{
		Pointer=document.layers[Ident];
	}
	return Pointer;
}

function moveDivTo(objName,l,t)
{
	thisDiv(objName).left=l;
	thisDiv(objName).top=t;
}

var activatedLayer = "DummyNavLayer";
var activatedSubLayer = "DummyNavLayer";

function dummyTest(bildID,layerID)
{
	leftEnd = leftPos(bildID);
	topEnd = topPos(bildID) + 21;
	moveDivTo(layerID,leftEnd,topEnd);
	showHideLayers(layerID,'','show');
}

function layerNavigation(bildID,layerID,leftSpacer,topSpacer)
{
	leftEnd = leftPos(bildID,layerID) + leftSpacer;
	topEnd = topPos(bildID,layerID) + topSpacer;
	moveDivTo(layerID,leftEnd,topEnd);
	showHideLayers(layerID,'','show');
	activatedLayer = layerID;
}

function layerSubNavigation(bildID,layerID,leftSpacer,topSpacer)
{
	leftEnd = leftPos(bildID,layerID) + leftSpacer;
	topEnd = topPos(bildID,layerID) + topSpacer;
	moveDivTo(layerID,leftEnd,topEnd);
	showHideLayers(layerID,'','show');
	activatedSubLayer = layerID;
}

function doHide()
{
	showHideLayers(activatedLayer,'','hide');
}

function doHide2()
{
	showHideLayers(activatedSubLayer,'','hide');
}

function delayDoHide()
{
	timer = window.setTimeout("showHideLayers(activatedLayer,'','hide');",1000);
}

function delayDoHide2()
{
	timer2 = window.setTimeout("showHideLayers(activatedSubLayer,'','hide');",1000);
}

function stopShowLayer()
{
	clearTimeout(timer);
	timer=null;
	doHide();
}

function stopShowLayer2()
{
	clearTimeout(timer2);
	timer2=null;
	doHide2();
}

function checkForm()
{	
	check = "true";

	errors = "Folgende Fehler sind aufgetreten:\n";

	if (document.forms.kontakt.name.value=="")
	{
		errors += "--> Bitte geben Sie Ihren Namen an\n";
		check = "false"; 
	}
	if (document.forms.kontakt.email.value.indexOf('@') == -1)
	{
		errors += "--> Bitte geben Sie Ihre Email-Adresse an\n";
		check = "false"; 
	}
	if (document.forms.kontakt.nachricht.value=="")
	{
		errors += "--> Bitte geben Sie eine Nachricht ein\n";
		check = "false"; 
	}
	if (check=="false")
	{
		alert (errors);
	}
	else
	{
		document.forms.kontakt.submit();
	}
}

function checkFormWahlhelfer()
{	
	check = "true";

	errors = "Folgende Fehler sind aufgetreten:\n";

	if (document.forms.form1.vorname.value=="")
	{
		errors += "--> Bitte geben Sie Ihren Vornamen an\n";
		check = "false"; 
	}
	if (document.forms.form1.nachname.value=="")
	{
		errors += "--> Bitte geben Sie Ihren Nachnamen an\n";
		check = "false"; 
	}
	if (document.forms.form1.str.value=="")
	{
		errors += "--> Bitte geben Sie Ihr Anschrift ein\n";
		check = "false"; 
	}
	if (document.forms.form1.plz.value=="")
	{
		errors += "--> Bitte geben Sie Ihre PLZ an\n";
		check = "false"; 
	}
	if (document.forms.form1.ort.value=="")
	{
		errors += "--> Bitte geben Sie Ihren Wohnort an\n";
		check = "false"; 
	}
	if (document.forms.form1.birth.value=="")
	{
		errors += "--> Bitte geben Sie Ihren Geburtstag an\n";
		check = "false"; 
	}
	if (document.forms.form1.telPrivat.value=="")
	{
		errors += "--> Bitte geben Sie Ihre Telefonnummer (privat) an\n";
		check = "false"; 
	}
	if (document.forms.form1.email.value.indexOf('@') == -1)
	{
		errors += "--> Bitte geben Sie Ihre Email-Adresse an\n";
		check = "false"; 
	}
	if (check=="false")
	{
		alert (errors);
	}
	else
	{
		document.forms.form1.submit();
	}
}

function openPopup(glossarPath) {
	if (window.netscape) {
		document.getElementsByTagName("div")["glossar"].style.left = xKoordinate;
		document.getElementsByTagName("div")["glossar"].style.top = yKoordinate;
	}
	else {
		document.all.glossar.style.left = xKoordinate;
		document.all.glossar.style.top = yKoordinate;		
	}

	inhalt =  '<table width="306" border="0" cellspacing="0" cellpadding="0">';
	inhalt += '<tr><td><img src="/img/div_abc_oben.gif" width="306" height="9"></td></tr>';
	inhalt += '<tr><td bgcolor="fafafa">';
	inhalt += '<iframe src="' + glossarPath + '" name="WahlABC" width="306" height="150" align="left" scrolling="auto" marginheight="0" marginwidth="0" frameborder="0">';
	inhalt += '<p>Ihr Browser kann leider keine eingebetteten Frames anzeigen.</p>';
	inhalt += '</iframe>';
	inhalt += '</td></tr><tr><td background="/img/div_abc_unten.gif" height="28" align="right"><a href="javascript:hidePopup();" class="bottomNavi">Schlie&szlig;en <img src="/img/close.gif" width="12" height="12" border="0"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>';
	inhalt += '</table>';

	document.getElementById("glossar").style.visibility="visible";
	document.getElementById("glossar").innerHTML=inhalt;
}

function hidePopup() {
	document.getElementById("glossar").style.visibility="hidden";

	if (window.netscape) {
		document.getElementsByTagName("div")["glossar"].style.left = 0;
		document.getElementsByTagName("div")["glossar"].style.top = 0;
	}
	else {
		document.all.glossar.style.left = 0;
		document.all.glossar.style.top = 0;		
	}
}

function LayerPos(Ereignis)
{
	hidePopup();
	
	if (window.netscape) {
		xKoordinate = Ereignis.pageX - 270;
		yKoordinate = Ereignis.pageY - 198;
	}
	else {
		xKoordinate = window.event.clientX + document.body.scrollLeft - 270;
		yKoordinate = window.event.clientY + document.body.scrollTop - 198;		
	}
}

document.onmouseup = LayerPos;

function stopError() { return true }
window.onerror = stopError;