// JavaScript Document

var theaterB = 841;//breite des zentrums
var theaterH = 595;//höhe des zentrums
var theaterVH = 0;//horizontale versetzung des zentrums
var theaterVV = 0;//horizontale versetzung des zentrums
var farben = new Array('#ffb000', '#850016', '#F2D397');

var thema = new Array ('startseite', 'person', 'therapie', 'praxis', 'kontakt', 'impressum');
var knopf = new Array();//für menuebuttons
var inhalt = new Array();//für kapitelinhalt
var richtung = 1;
var nr;
var merke_nr;
var ani_kap;
//
		
	/*	*/	
window.onload = function() {

		inpos();
		bilderVorladen();
		karte_laden();
		//
		//
	
		
		for (i=0;i<=thema.length;i++) { //positionierung der menüelemente
			knopf.push(document.getElementById('m'+i));
			inhalt.push(document.getElementById('kapitel'+ i));
			if (knopf[i]) {
				//positionierung der menuebuttons:
				with (knopf[i].style) {	
					left = (i*140)+'px';
					top = '8px';
					width = '138px';
					backgroundColor = farben[1];
					backgroundImage = 'url(b/menue-' + (i+1) +'.png)';
				}
				inhalt[i].style.backgroundColor = farben[0];
				dhtmlweiche(knopf[i], menue_ueber, "mouseover");
				dhtmlweiche(knopf[i], menue_raus, "mouseout");
				dhtmlweiche(knopf[i], menue_klick, "click");
				}
			}
			
		kapitelwechsel(knopf[0]);
		javaScriptCSS_laden();
		verlinkungen();
		
}	
		
window.onresize =  inpos;

		
//------------------------------ mausaktionen -----------------------------------

//
function dhtmlweiche(taeter, aufgabe, ereignis){
	if (document.addEventListener) taeter.addEventListener(ereignis, aufgabe, true);
	else switch (ereignis) {
		case "mouseover": taeter.onmouseover = aufgabe; break; 
		case "mouseout": taeter.onmouseout = aufgabe; break; 
		case "click": taeter.onclick = aufgabe; break; 
		}
	}


function menue_ueber() {
	var ich = parseInt(this.id.substr(1))+1;
	if (this.style.backgroundImage != 'url(b/menue_aktiv-' + ich +'.png)') this.style.backgroundImage = 'url(b/menue_over-' + ich +'.png)';
	}


function menue_raus() {
	var ich = parseInt(this.id.substr(1))+1;
	if (this.style.backgroundImage != 'url(b/menue_aktiv-' + ich +'.png)') this.style.backgroundImage = 'url(b/menue-' + ich +'.png)';
	}


function menue_klick() {kapitelwechsel(this);}

//------------------------------  -----------------------------------


function javaScriptCSS_laden(){
	
		var el = document.getElementsByTagName("link");
		  for (var i = 0; i < el.length; i++ ) {
			if (el[i].getAttribute("rel").indexOf("style") != -1 && el[i].getAttribute("title")) {
			  el[i].disabled = true;
			  if (el[i].getAttribute("title") == "standard") el[i].disabled = false;
			}
		  }
}


		
function inpos() {
		//
		
		var div_tag = document.body.getElementsByTagName('div');//zentrumscontainer festlegen
		var theater = document.getElementById('buehne');
		var streifen = document.getElementById('balken');
		var navigation = document.getElementById('nav');
		var fuss = document.getElementById('fuss');
		var fuss_hg = document.getElementById('fuss_hg');
		var capitulo = document.getElementById('kapitel');

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



		bodyVermessen();//scripte/positionierung.js
		styleZuweisen(theater,"absolute",theaterB,theaterH,0,0);//scripte/positionierung.js//zentrum definieren:
		ebenePositionieren(theater,theaterVH,theaterVV);//scripte/positionierung.js
		
		//
		//

	
		with (navigation.style){
			width = "100%";
			height = "66px";
			backgroundColor = farben[0];
			zIndex= 5;
			}
		//
		//

	
		with (fuss.style){
			width = (theaterB -8) + "px";
			height = "20px";
			fontSize = "0.85em";
			color = farben[1];
			padding = "2px";
			top = (theaterH - 38) + "px";
			backgroundColor = farben[2];
			border = "2px solid #850016";
			zIndex= 5;
			}
		//
		//

	
		with (fuss_hg.style){
			width = "100%";
			top = fuss.style.top;
			height = "40px";
			backgroundColor = farben[0];
			zIndex= 5;
			}

		//
		//
		
		with (capitulo.style) {
			top = "110px";
			width = '841px';
			height ='485px';
			left ='0px';
			backgroundColor = farben[1];
			zIndex= 4;
			overflow = 'hidden';
			}
		//
		//

	
		with (streifen.style){
			top = (parseInt(theater.style.top) +  64) +"px";
			width = "100%";
			height = "55px";
			backgroundColor = farben[1];
			zIndex = 100;
			}
		//
		//

		with (theater.style){
			backgroundColor = farben[0];		
			visibility = "visible";	
			}
		//
	
}	

//
//


function bilderVorladen(){
	if(document.images){
		if(!document.imageArray) document.imageArray = new Array();
		var j = 0;
		for(i=0; i< thema.length; i++)  {
		  if (thema[i]!="") {
			document.imageArray[j] = new Image;
			document.imageArray[j++].src = 'b/menue_aktiv-' + (i+1) +'.png';
			document.imageArray[j] = new Image;
			document.imageArray[j++].src = 'b/menue_over-' + (i+1) +'.png';
			document.imageArray[j] = new Image;
			document.imageArray[j++].src = 'b/menue-' + (i+1) +'.png';
		  }
		}
	  }
}
//

function seiteEinrichten(wer){
	textLaden(wer,0);
	var z = 0;
	for (i=0; i<wer; i++) if (thema[i] != "") z++;
	var bild_1 = getElementsByClassName('kap','DIV')[z].getElementsByTagName('IMG')[0];
	var quelle_1 = "b/"+thema[wer]+"_1.png";
	if (bild_1){
		if (quelle_1) bild_1.setAttribute("src", quelle_1);
		bild_1.setAttribute("alt", thema[wer]+" erstes bild");
	}
}

//

function textLaden(kapitel,absatz){
	var du = document.getElementById('kapitel' + kapitel + '_text');
	var ich = document.getElementById('kapitel' + kapitel + '_text_' + absatz);
	if (du) du.innerHTML = ich.innerHTML;
}


function kapitelwechsel(taeter) {
	/*if (pfeiltat == false) {// wenn von einem button ausgelöst*/
		nr = parseInt(taeter.id.substr(1));
		richtung = 1;
		//richtung = (merke_nr>nr) ? -1:1;
		/*}	
	else taeter = knopf[nr];// wenn von einem pfeil ausgelöst*/
	opfer = inhalt[nr];
	for (k=0; k<thema.length; k++) {
		if (knopf[k] && nr < thema.length) {
			knopf[k].style.backgroundImage = 'url(b/menue-' + (k+1) +'.png)'
		}
	}
	//
	for (k=0; k<thema.length; k++) if (knopf[k]) inhalt[k].style.zIndex = '1';
	//
	if (nr <= thema.length) {
		knopf[nr].style.backgroundImage = 'url(b/menue_aktiv-' + (nr+1) +'.png)'
		seiteEinrichten(nr);
		}
	with (opfer.style) {
		if (top) top = (richtung ==1) ? '495px' : '-495px';
		zIndex = '50';
		}
	kap_ani();
	}
	
	
	
function kap_ani() {
	wert = parseInt(opfer.style.top);
	if (richtung == 1 && wert > 0) {
		var ani_kap = window.setTimeout("kap_ani()",1);
		opfer.style.top = (wert-10) + 'px';
		altopfer.style.top = (wert-495) + 'px';
	}else if (richtung == -1 && wert < 0) {
		var ani_kap = window.setTimeout("kap_ani()",1);
		opfer.style.top = (wert+10) + 'px';
		altopfer.style.top = (wert+495) + 'px';
		altopfer.style.zIndex = parseInt(opfer.style.zIndex) + 1 + '';
	}else{
		clearTimeout(ani_kap);
		opfer.style.top = '0px';
		altopfer = opfer;
		for (k=0; k<knopf.length; k++) if (knopf[k] && inhalt[k] != altopfer) {inhalt[k].style.top = '495px';}
		}
	}
	
	

//------------------------------ dom  -----------------------------------	
	
//elemente nach klasse selektieren: Ergebnis ist array mit allen tags ders gesuchten klasse (und optional des gesuchten typs)
	function getElementsByClassName(klasse,tagTyp){
		var klassenReihe = [];
		var tags = document.getElementsByTagName("*") // ein array mit allen tags des dokuments
		for (var i=0; i < tags.length; i++) {
			if (tagTyp)	{// nur wenn das 2. argument (tagTyp) gesucht wird
			   if (tags[i].tagName != tagTyp) continue; // dann wird die funktion verlassen, falls es sich nicht um das ggesuchte tag handelt
			}//endif
			if (tags[i].className == klasse) klassenReihe[klassenReihe.length] = tags[i]; // wenn die übriggebliebenen tags der gesuchten klasse entsprechen, dann wird das array klassenreihe damit gefüllt
		}//endfor
		return klassenReihe;
	}
	
	
//------------------------------ google maps  -----------------------------------	
	
function karte_laden() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));       
	//alert(map);
		map.addControl(new GLargeMapControl());
        map.setCenter(new GLatLng(48.065934, 7.902256), 16);
		map.addOverlay(new GMarker(new GLatLng(48.065934, 7.902256)))
		
      }
    }
	

	
//------------------------------ links  -----------------------------------
function verlinkungen(){
	for (var i = 0; i<document.links.length; i++) {
		document.links[i].onfocus = function() { this.blur(); }
	}

}
