// JavaScript Document
var drin=1;
var aktiv=0; // Timer
var scrollx=10;
var rand_w=0; //Randbreite
var raus=0; //rausgefahrene breite

var cIn, cOut;

function navi_over(butt,ggprefix){
	cIn = butt.style.color;
	butt.style.backgroundImage='url(images/butt_aktiv'+ggprefix+'.jpg)'; 
	butt.style.color='#FFFFFF';
}

function navi_out(butt,ggprefix){
	butt.style.backgroundImage='url(images/butt.jpg)';
	butt.style.color=cIn;
}

function suche_over(butt,ggprefix){
	butt.style.backgroundImage='url(images/butt_aktiv'+ggprefix+'.jpg)'; 
	butt.style.color='#FFFFFF';
}

function suche_out(butt,ggprefix){
	butt.style.backgroundImage='url(images/butt.jpg)';
	butt.style.color='#009aa4';
}	

function top_over(butt,ggprefix){
	cIn = butt.style.color;
	butt.style.backgroundImage='url(images/topbutt_aktiv'+ggprefix+'.jpg)'; 
	butt.style.color='#FFFFFF';
}

function top_out(butt,ggprefix){
	butt.style.backgroundImage='url(images/pixel.gif)';
	butt.style.color=cIn;
}
	
function body(id,sec,third,did){
	var rand_w=document.getElementById('rand').offsetWidth;
	if(id<=7){//Navigation angeklickt
		// Wenn Rand groß genug nur Submenü rausfahren
		if(drin==1&id>=0){
			if ((sec==0||sec=='') && (third==0||third=='') && (did==0||did=='')) {
				if (document.getElementById('sub_'+id)) {
					document.getElementById('sub_'+id).style.top= 154;
					document.getElementById('sub_'+id).style.display = 'block';
					document.getElementById('sub_'+id).style.left=(rand_w+69)+'px';
					if(rand_w>=112){//randbreite genügt für Submenü
						aktiv = setInterval("scroll_out("+id+","+true+")", 1);
					}
					else{//randbreite zu klein für Submenü
						aktiv = setInterval("scroll_out("+id+","+false+")", 1);
					}
				}	
			} else {
				if (document.getElementById('sub_'+id)) {
				
					//alert ("offsetLeft / offsetWidth\nstyle.left / style.width\n\nall:\n"+document.getElementById('all').offsetLeft + " / " + document.getElementById('all').offsetWidth+"\n"+document.getElementById('all').style.left+ " / " + document.getElementById('all').style.width+"\n"+"RandR:\n"+document.getElementById('randR').offsetLeft + " / " + document.getElementById('randR').offsetWidth+"\n"+document.getElementById('randR').style.left+ " / " + document.getElementById('randR').style.width+"\n"+"content:\n"+document.getElementById('content').offsetLeft + " / " + document.getElementById('content').offsetWidth+"\n"+document.getElementById('content').style.left+ " / " + document.getElementById('content').style.width+"\n"+"sub_id:\n"+document.getElementById('sub_'+id).offsetLeft + " / " + document.getElementById('sub_'+id).offsetWidth+"\n"+document.getElementById('sub_'+id).style.left+ " / " + document.getElementById('sub_'+id).style.width+"\n")

					document.getElementById('sub_'+id).style.top= 154;
					//document.getElementById('all').style.width = document.getElementById('all').offsetWidth +parseInt(document.getElementById('sub_'+id).style.width)+"px";
					//document.getElementById('randR').style.width = '50%';
					
					if(rand_w>=112) {
						document.getElementById('sub_'+id).style.left = document.getElementById('content').offsetLeft-parseInt(document.getElementById('sub_'+id).style.width)+"px";
					} else {
						document.getElementById('all').style.width = document.getElementById('all').offsetWidth +parseInt(document.getElementById('sub_'+id).style.width)-69+"px";
						document.getElementById('randR').style.width = '';
						document.getElementById('sub_'+id).style.left = document.getElementById('content').offsetLeft-parseInt(document.getElementById('sub_'+id).style.width)+"px";
					}
					
					//alert ("offsetLeft / offsetWidth\nstyle.left / style.width\n\nall:\n"+document.getElementById('all').offsetLeft + " / " + document.getElementById('all').offsetWidth+"\n"+document.getElementById('all').style.left+ " / " + document.getElementById('all').style.width+"\n"+"RandR:\n"+document.getElementById('randR').offsetLeft + " / " + document.getElementById('randR').offsetWidth+"\n"+document.getElementById('randR').style.left+ " / " + document.getElementById('randR').style.width+"\n"+"content:\n"+document.getElementById('content').offsetLeft + " / " + document.getElementById('content').offsetWidth+"\n"+document.getElementById('content').style.left+ " / " + document.getElementById('content').style.width+"\n"+"sub_id:\n"+document.getElementById('sub_'+id).offsetLeft + " / " + document.getElementById('sub_'+id).offsetWidth+"\n"+document.getElementById('sub_'+id).style.left+ " / " + document.getElementById('sub_'+id).style.width+"\n")

					document.getElementById('sub_'+id).style.display = 'block';
				}
			}
		}
	} else {
		if (document.getElementById('sub_'+id)){
			document.getElementById('sub_'+id).style.top= 154;
			document.getElementById('sub_'+id).style.left= (rand_w+69-180)+'px';
			document.getElementById('sub_'+id).style.display = 'block';
			if(sec>0){//third anzeigen
				for (var i = 0; i <= 20; i++){
					if(document.getElementById('subsub_'+sec+'_'+i)){
						document.getElementById('subsub_'+sec+'_'+i).style.display=setto;
					}
				}
				document.images['pfeil_'+sec].src = 'images/pfeil_aktiv.gif';
				document.images['pfeil_'+sec].height = 6;
				if(document.getElementById('subsub_'+sec+'_'+third)){
					document.getElementById('subsub_'+sec+'_'+third).style.backgroundColor='#b8b8b8';
					document.getElementById('subsub_'+sec+'_'+third).style.color='#FFFFFF';
				}
			}
		}
	}
}

function navi_click(id,did){
	if( id >= 0 ){
		location.href= ('page.asp?did='+did+'&amp;main='+id+'&amp;sec=0&amp;third=0');
	}
}

function top_click(butt,num,id){
	var name = butt.innerHTML;
	location.href= ('page.asp?did='+ id +'&amp;main='+(7+num)+'&amp;sec=0&amp;third=0' );
}
/*  private  */
	
	
	
function scroll_out(id,rand){
	akt=document.getElementById('sub_'+id).offsetLeft;
	if(rand){
		document.getElementById('sub_'+id).style.left =(akt-10)+'px';
		drin++;
		raus= document.getElementById('content').offsetLeft -document.getElementById('sub_'+id).offsetLeft;
		if(raus>=190){
			clearInterval(aktiv);
			drin=0;
		}
	} else{
		if(document.getElementById('sub_'+id).offsetLeft<=20){
			var rand_r=document.getElementById('randR').offsetWidth; // Randbreichte Rechts
			var platz= 190-(document.getElementById('content').offsetLeft -document.getElementById('sub_'+id).offsetLeft);
			if(platz <10){
				document.getElementById('all').style.width=document.getElementById('all').offsetWidth +platz+'px'; 
			}
			else{
				document.getElementById('all').style.width=document.getElementById('all').offsetWidth +10+'px'; 
			}
			document.getElementById('randR').style.width=rand_r +'px';
		} else {
			var platz= 190-(document.getElementById('content').offsetLeft -document.getElementById('sub_'+id).offsetLeft);
			if(platz <10){
				document.getElementById('sub_'+id).style.left =(akt- platz)+'px';
			} else{
				document.getElementById('sub_'+id).style.left =(akt- 10)+'px';
			}
		}
		breite =(document.getElementById('links').offsetLeft+79)-document.getElementById('sub_'+id).offsetLeft;
		raus= document.getElementById('content').offsetLeft -document.getElementById('sub_'+id).offsetLeft;
		if(raus >=190){
			clearInterval(aktiv);
			drin=0;
		}
	}	
	window.status = "sub_left: "+document.getElementById('sub_'+id).style.left+"px"+" - "+"all_width: "+document.getElementById('all').style.width+" - "+"randR_width: "+document.getElementById('randR').style.width;
}	






function sub_up(id,length,sub_length,third){
	var inhalt=-1;
	
	for(var i=0; i< sub_length;i++){
		if(document.getElementById('subsub_'+id+'_'+i)){
			inhalt=i;
			break;
		}
	}
	
	if(inhalt>=0){
		
		if(document.getElementById('subsub_'+id+'_'+inhalt).style.display =='none'){
			for (var i = 0; i <= length; i++){
					if(document.getElementById('subsub_'+id+'_'+i)){
					document.getElementById('subsub_'+id+'_'+i).style.display=setto;
					}
			}
			document.images['pfeil_'+id].src = 'images/pfeil_aktiv.gif';
			document.images['pfeil_'+id].height = 6;
		}
		
		else{
			
			for (var i = 0; i <= length; i++){
					if(document.getElementById('subsub_'+id+'_'+i)){
						document.getElementById('subsub_'+id+'_'+i).style.display='none';
					}
					
			}
			document.images['pfeil_'+id].src = 'images/pfeil.gif';
			document.images['pfeil_'+id].height = 11;
		
		}
	}
}

function sub_out(id){
//document.getElementById('subsub_'+id).style.display='none';

}

function subsub_over(id){
	cIn = id.style.backgroundColor;
	id.style.backgroundColor='#b8b8b8';
	id.style.color='#FFFFFF';

}

function subsub_out(id){
	id.style.backgroundColor=cIn;
	id.style.color='#009aa4';

}


/*
Alte Funktionen aus der alten Website für statische Seiten Typ "Feste Programmierung"
*/

function doVoid() { }
		
function openWin(vCountry) {
	if (vCountry=='n') {
		var newWindow = window.open("anfahrt_n.asp?lang=d", "Anfahrt", "width=750,height=600,top=50,left=50,status=no,scrollbars=yes,resizable=yes,menubar=no,toolbar=no");
		newWindow.focus();
	} else {
		var newWindow = window.open("anfahrt_b.asp?lang=d", "Anfahrt", "width=750,height=600,top=50,left=50,status=no,scrollbars=yes,resizable=yes,menubar=no,toolbar=no");
		newWindow.focus();
	}
}
		
		
	function checkForm() {
	var fehler = 0;
	var fehler1 = 0;
	var missing = "";
	var missing1 = "";
	var missingout = "";
	
	if (document.kontForm.vorname.value == "") {
		missing = missing+"   Vorname\n";
		fehler = 1;
	}
	if (document.kontForm.nachname.value == "") {
		missing = missing+"   Nachname\n";
		fehler = 1;
	}
	if (document.kontForm.strasse.value == "") {
		missing = missing+"   StrasseStrasse\n";
		fehler = 1;
	}
	if (document.kontForm.plz_ort.value == "") {
		missing = missing+"   PLZ/Ort\n";
		fehler = 1;
	}
	if (document.kontForm.telefon.value == "") {
		missing = missing+"   Telefon\n";
		fehler = 1;
	}

	if (document.kontForm.email.value == "") {
		missing = missing+"   e.Mail\n";
		fehler = 1;
	}
	else {
		 if (document.kontForm.email.value.indexOf("@") > -1 && document.kontForm.email.value.indexOf(".") > -1){
        }
		else {
	         missing1 = missing1+"   Fehlerhafte EMail\n";
			fehler1 = 1;
        }
	}
	
	if (document.kontForm.bemerkung.value == "") {
		missing = missing+"   Bemerkung\n";
		fehler = 1;
	}

	if (fehler == 1 || fehler1==1) {
		if (fehler1==1) {
			missingout = "Es sind Fehler aufgetreten:\n"+missing1+"\n\n";
		}
		
		if (fehler==1) {
			missingout = missingout + "Folgende Felder wurden nicht ausgefüllt:\n"+missing;
		}
	}
		
	if (fehler1==1 && fehler ==0) {
		alert (missingout);
	}
	else if (fehler1==0 && fehler==1) {
		alert (missingout);
		document.kontForm.vorname.focus();
	}
	else if (fehler1==1 && fehler==1) {
		alert (missingout);
		document.kontForm.vorname.focus();
	}
	else {
		document.kontForm.submit();
	}
}
