/*
Browser:
0 = Fehler
1 = IE
2 = Firefox
3 = Safari
4 = Opera
5 = Chrome
6 = Unbekannt
*/

var browser = 0;
if (navigator.userAgent.indexOf("Opera") != -1)
{
   browser = 4;
}
else if (navigator.userAgent.indexOf("Safari") != -1)
{
   browser = 3;
}
else if (navigator.appName.indexOf("Internet Explorer") != -1)
{
   browser = 1;
}
else if (navigator.userAgent.indexOf("Firefox") != -1)
{
   browser = 2;
}
else if (navigator.userAgent.indexOf("Chrome") != -1)
{
   browser = 5;
}
else
{
   browser = 6;
}


function anmeldung()
{
	var Eingabe, a;
	for(a=0; a<21; a++)
	{
		Eingabe = window.document.forms[0].elements[a].value;
		if(a != 8 && a != 9 && a != 10 && a != 11 && a != 12 && a != 13    && a != 5  && a != 14  && a != 15  && a != 16  && a != 17  && a != 18 && a != 20)
		{
			if(a == 19)
			{
				if (window.document.forms[0].elements[a].checked==false)
				{
				alert("Sie müssen die Geschäftsbedingungen akzeptieren, um sich erfolgreich anzumelden!");
					return false;
				}
			}
			else
			{
			if(Eingabe == "" || Eingabe== " " || Eingabe==null)
				{
					alert("Bitte füllen sie alle Pflichtfelder(*) aus!");
					return false;
				}
			}
		}
		else
		{
			if(window.document.forms[0].elements[7].checked==true)
			{
				if(a != 12 &&  a !=13    && a != 5  && a != 14  && a != 15  && a != 16  && a != 17  && a != 18 )
				{
					if(Eingabe == "" || Eingabe== " " || Eingabe==null)
					{
						alert("Bitte füllen sie auch bei der zweiten Person alle Pflichtfelder(*) aus!");
						return false;
					}
				}
			}
			else
			{
				if(	a==20)
				{
					if (window.document.forms[0].elements[a].checked==false)
					{
						alert("Bitte bestätigen sie die Datenschutzbestimmungen!");
						return false;
					}
				}
			}
		}
		
	}
}
function check()
{
	var Eingabe, a;
	for(a=0; a<12; a++)
	{
		Eingabe = window.document.forms[0].elements[a].value;
		if(a != 4 && a != 5 && a != 10)
		{
			if(Eingabe == "" || Eingabe== " " || Eingabe==null)
				{
					alert("Bitte füllen sie alle Pflichtfelder(*) aus!");
					return false;
				}
		}
		
	}
}
function checkkritik()
{
	var Eingabe, a;
	for(a=0; a<12; a++)
	{
		Eingabe = window.document.forms[0].elements[a].value;
		if(a != 1 && a != 2 && a != 3 && a != 4 && a != 10 && a != 11)
		{
			if(Eingabe == "" || Eingabe== " " || Eingabe==null)
				{
					alert("Bitte füllen sie alle Pflichtfelder(*) aus!");
					return false;
				}
		}
		
	}
}
function checkplannung()
{
	var Eingabe, a;
	for(a=0; a<16; a++)
	{
		Eingabe = window.document.forms[0].elements[a].value;
		if(a != 0 && a != 1 && a != 2 && a != 3 && a != 14)
		{
			if(Eingabe == "" || Eingabe== " " || Eingabe==null)
				{
					alert("Bitte füllen sie alle Pflichtfelder(*) aus!");
					return false;
				}
		}
		
	}
}
function loeschen(sid,location,id,name)
{
	var Eingabe;
	Eingabe = confirm("Wollen sie den Eintrag \""+name+"\" wirklich löschen?"); 
	if(Eingabe == true)
	{
		document.getElementById("link"+id).href="index.php?location="+location+"&sid="+sid+"&admin=1&did="+id;
	}
}
function termine(x)
{
	document.getElementById(x).style.display="block";
	document.getElementById(x+"link").style.display="none";
	document.getElementById(x+"linkaus").style.display="block";
}
function termineweg(x)
{
	document.getElementById(x).style.display="none";
	document.getElementById(x+"link").style.display="block";
	document.getElementById(x+"linkaus").style.display="none";
}
function infos(x)
{
	document.getElementById(x+"mehrdiv").style.display="block";
	document.getElementById(x+"mehr").style.display="none";
	document.getElementById(x+"mehraus").style.display="block";
}
function infosweg(x)
{
	document.getElementById(x+"mehrdiv").style.display="none";
	document.getElementById(x+"mehr").style.display="block";
	document.getElementById(x+"mehraus").style.display="none";
}
function div(x)
{
	document.getElementById(x).style.display="block";
}
function nodiv(x)
{
	document.getElementById(x).style.display="none";
}
function erfolg()
{
	alert("Operation erfolgreich ausgeführt!"); 
}

function makieren(textid) {
var td = document.getElementsByName("aktuellestds");
 var i = td.length-1;
  while(i >= 0)
  {  	
  	document.getElementsByName("aktuellestds")[i].style.backgroundColor="#FFFFFF";
	i--;
  }
document.getElementById("td"+textid).style.backgroundColor="#ededed";
}
//-------------------------
window.addEventListener?window.addEventListener("load",so_init,false):window.attachEvent("onload",so_init);

var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;

function so_init() {
	if(!d.getElementById || !d.createElement)return;

	css = d.createElement("link");
	css.setAttribute("href","../index/xfade2.css");
	css.setAttribute("rel","stylesheet");
	css.setAttribute("type","text/css");
	d.getElementsByTagName("head")[0].appendChild(css);

	imgs = d.getElementById("imageContainer").getElementsByTagName("img");
	for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
	imgs[0].style.display = "block";
	imgs[0].xOpacity = .99;
	
	setTimeout(so_xfade,5000);
}

function so_xfade() {
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1]?current+1:0;

	nOpacity = imgs[nIndex].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;
	
	imgs[nIndex].style.display = "block";
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;
	
	setOpacity(imgs[current]); 
	setOpacity(imgs[nIndex]);
	
	if(cOpacity<=0) {
		imgs[current].style.display = "none";
		current = nIndex;
		setTimeout(so_xfade,5000);
	} else {
		setTimeout(so_xfade,50);
	}
	
	function setOpacity(obj) {
		if(obj.xOpacity>.99) {
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}
	
}
function land(pfad)
{
	if(pfad == "")
	{
		document.getElementById('landkarte').src='../design/bilder/landkarte.jpg';
		document.getElementById('landkarte_ort').value = '';
	}
	else
	{
		document.getElementById('landkarte').src='../design/bilder/'+ pfad +'.jpg';
		var x = document.getElementById(pfad).title;
		document.getElementById('landkarte_ort').value = x;
	}
}
function menue_hinzu(id,sid,location)
{
	var titel = prompt("Titel:");
	if(titel != "" && titel != " ")
	{
		document.getElementById("link"+id).href="index.php?location="+location+"&sid="+sid+"&menu_add="+id+"&titel="+titel;
	}
}
function ordner_hinzu(sid,location)
{
	var titel = prompt("Titel:");
	if(titel != "" && titel != " ")
	{
		document.getElementById("ordneradd").href="index.php?location="+location+"&admin=1&sid="+sid+"&titel="+titel;
	}
}
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 show(x,a)
{
	if(a != 0) {document.getElementById("layerbox"+a).style.display="block";}
	document.getElementById("layerbox"+x).style.display="block";
	versatz = -1;
	if(browser == 3)
	{
		versatz = 1;	
		
	}
	var element = document.getElementById('menu'+x);
	var positionX = findPosX(element);
	var positionY = findPosY(element);
	var balken = element.offsetHeight;
	if(a != 0)
	{
		positionY = positionY - 1; 
		if(browser != 2)
		{
			positionX = positionX - 1;	
		}
	}
	if(browser == 2) 
	{
		positionX = positionX - 2;
	}
	document.getElementById("balken"+x).style.height= balken;
	if(browser == 1)
	{
		var xxx = document.getElementById("tabelle"+x).offsetHeight;
		document.getElementById("luecke"+x).style.height = xxx - balken;
		positionY = positionY +2; 
		if(a == 0) 
		{
			positionX = positionX - 1;
		}
	}
	document.getElementById("layerbox"+x).style.top=positionY+versatz;
	if(a == 0) 
	{
		document.getElementById("layerbox"+x).style.left=positionX+154;
	}
	else
	{
		document.getElementById("layerbox"+x).style.left=positionX+160;	
	}
	
}
function closemenu(x,a)
{
	if(a != 0) {document.getElementById("layerbox"+a).style.display="none";}
	document.getElementById("layerbox"+x).style.display="none";
}