var nn=document.layers?true:false;
var n6=document.getElementById?true:false;
var ie=document.all?true:false;
if ((ie) && (n6)) n6 = false;

var sichtbar = "visible";
var unsichtbar = "hidden";

var fJS = false;
var vn = navigator.appVersion.substring(0,1);
var anzahl = 6;
var bClicked = 0;

menuNor = new Array(anzahl);
menuFoc = new Array(anzahl);

var tmpBanner1 = -1;
var tmpCheckBanner1 = -1;
var banner_anzahl = 2;
banner = new Array(banner_anzahl);
bannerURL = new Array(banner_anzahl);
banner[0] = new Image();
banner[0].src = "gif/banner_beratung.gif";
bannerURL[0] = "http://www.rehmer-beratung.de";
banner[1] = new Image();
banner[1].src = "gif/banner_beratung.gif";
bannerURL[1] = "http://www.rehmer-beratung.de";
//banner[2] = new Image();
//banner[2].src = "gif/banner_muehlmann.gif";
//bannerURL[2] = "http://www.well-bar.de";

function bannerKlick(id) {
	if (id == 1) var tmp = tmpBanner1;
	if (bannerURL[tmp].substr(0,7) == 'http://') {
		window.open(bannerURL[tmp]);
	} else {
		document.location.href = bannerURL[tmp];
	}
}

function bannerWechsel() {
	while (tmpBanner1 == tmpCheckBanner1) tmpBanner1 = Math.floor(Math.random()*(banner_anzahl));
	tmpCheckBanner1 = tmpBanner1;
	document.images["banner1"].src = banner[tmpBanner1].src;
	setTimeout('bannerWechsel()', 5000);
}

function init() {
	if (vn >= 4) {
		for (i=1; i<=anzahl; i++) {
			menuNor[i] = new Image();
			menuNor[i].src = "gif/b_0" + i + "n.gif";
			menuFoc[i] = new Image();
			menuFoc[i].src = "gif/b_0" + i + "f.gif";
		}
		if ((ie) || (n6)) {
//			document.onmousemove=mouseMove;
		}
		if (nn) {
			sichtbar = "show";
			unsichtbar = "hide";
			window.captureEvents(Event.MOUSEMOVE);
			window.onMouseMove=mouseMove;
		}
		fJS = true;
		Focus(hauptmenu);
		bClicked = hauptmenu;
	}
}

function mouseMove(Ereignis) {
	if (nn) {
		xwert = Ereignis.pageX;
		ywert = Ereignis.pageY;
		//var outPos = 0;
	}
	if (ie) {
		xwert = window.event.clientX;
		ywert = window.event.clientY;
		//var outPos = 0 - document.body.scrollTop;
		ywert += document.body.scrollTop;
	}
	if (n6) {
		//alert("OK");
		xwert = Ereignis.pageX;
		ywert = Ereignis.pageY;
		//var outPos = 0;
	}
	//window.status = document.body.scrollTop + "/" + xwert + "/" + ywert;
	if ((lay_open >= 0) && (xwert < parseInt(lay_id[lay_open].left)-5) && (lay_open != (bClicked - 1))) Reset();
	if ((lay_open >= 0) && (ywert < 0) && (lay_open != (bClicked - 1))) Reset();
	if ((lay_open >= 0) && (ywert > 40 + hoehe[lay_open]) && (lay_open != (bClicked - 1))) Reset();
	if ((lay_open >= 0) && (xwert > parseInt(lay_id[lay_open].left)+breite[lay_open]) && (lay_open != (bClicked - 1))) Reset();
	if ((lay_open == -1) && (hauptmenu != 6)) m_go(hauptmenu-1);
}

function m_go(lay) {
	if ((fJS) && (lay != lay_open)) {
		Reset();
		lay_open = lay;
		zustand[lay] = 1;
		lay_id[lay].visibility = sichtbar;
	}
}

function Reset() {
	if((fJS) && (lay_open >= 0)) {
		for(i=0;i<l_anzahl;i++) {
			if (zustand[i] != 0) {
				lay_id[i].visibility = unsichtbar;
				zustand[i] = 0;
			}
		}
		lay_open = -1;
		for(i=1;i<=anzahl;i++) {
			Blur(i);
		}
	}
}

function ieFake(fake) {
	if ((document.all) && (fake)) fake.blur();
}

function Focus(idx) {
	// Btn fokussiert darstellen.
	if ((fJS) && (idx != bClicked)) {
		var s = "b"+idx;
		document.images[s].src = menuFoc[idx].src;
	}
}
function Blur(idx) {
	// Btn normal darstellen.
	if ((fJS) && (idx != bClicked)) {
		var s = "b"+idx;
		document.images[s].src = menuNor[idx].src;
	}
}

var tmpTxt;
function statAnzeige(txt) {
	tmpTxt = txt;
	setTimeout("window.status = tmpTxt;",0);
	return true;
}

var wi = null;
function info(datei,x,y,scbar) {
	tmpScroll = "yes";
	if (scbar == 0) tmpScroll = "no";
	if (!x) var tmpX = 520;
	else var tmpX = x+20;
	if (!y) var tmpY = 350;
	else var tmpY = y+30;
	if (wi != null) if (!wi.closed) wi.close();
	wi = window.open(datei,'Infofenster','left=' + ((screen.availWidth/2)-tmpX/2) + ',top=' + ((screen.availHeight/2)-tmpY/2) + ',marginwidth=0 marginheight=0,leftmargin=0,topmargin=0,scrollbars=' + tmpScroll + ',status=no,width=' + tmpX + ',height=' + tmpY + ',resizable=no');
	if (wi.opener==null) wi.opener=self;
	//if (vn >= "4") wi.moveTo((screen.availWidth/2)-tmpX/2,(screen.availHeight/2)-tmpY/2);
	return;
}

var ti = null;
var tmpStunde = 0;
var tmpTag = 0;
var tmpStudio = 0;
var tmpNeu = 0;
function termin(std,tag,stu,neu) {
	tmpStunde = std;
	tmpTag = tag;
	tmpStudio = stu;
	if (neu) tmpNeu = neu;
	if (ti != null) if (!ti.closed) ti.close();
	ti = window.open('termin.asp?stunde=' + tmpStunde + '&tag=' + tmpTag + '&studio=' + tmpStudio + '&neu=' + tmpNeu,'Termininfo','left=' + ((screen.availWidth/2)-600/2) + ',top=' + ((screen.availHeight/2)-400/2) + ',marginwidth=0 marginheight=0,leftmargin=0,topmargin=0,scrollbars=yes,status=no,width=600,height=400,resizable=no');
	if (ti.opener==null) ti.opener=self;
	//if (vn >= "4") ti.moveTo((screen.availWidth/2)-210,(screen.availHeight/2)-150);
	return;
}

var ana = null;
function analyse(id, studio) {
	if (ana != null) if (!ana.closed) ana.close();
	ana = window.open('analyse' + id + '.asp?studio=' + studio,'Analyse','left=' + ((screen.availWidth/2)-600/2) + ',top=' + ((screen.availHeight/2)-600/2) + ',marginwidth=0 marginheight=0,leftmargin=0,topmargin=0,scrollbars=yes,status=no,width=600,height=600,resizable=no');
	if (ana.opener==null) ana.opener=self;
	//if (vn >= "4") ana.moveTo((screen.availWidth/2)-210,(screen.availHeight/2)-175);
	return;
}

var ew = null;
function zoomFenster(datei,x,y,alt,scbar,studio) {
	if(studio == undefined) {
		studio = 0;
	}
	var tmpX = x+40;
	var tmpY = y+100;
	var tmpSc = "no";
	if (tmpX < 210) tmpX = 210;
	if (tmpY > 580) {
		tmpY = 580;
		tmpSc = "yes";
		tmpX += 16;
	}
	if (scbar == 1) {
		tmpSc = "yes";
		tmpX += 16;
	}
	if (ew != null) if (!ew.closed) ew.close();
	ew = window.open('zoom.asp?studio=' + studio + '&hoch=' + y + '&breit=' + x + '&bild=' + datei + '&titel=' + alt,'Bildvergroesserung','left=' + ((screen.availWidth/2)-tmpX/2) + ',top=' + ((screen.availHeight/2)-tmpY/2) + ',marginwidth=0 marginheight=0,leftmargin=0,topmargin=0,scrollbars=' + tmpSc + ',status=no,width=' + tmpX + ',height=' + tmpY + ',resizable=no');
	if (ew.opener==null) ew.opener=self;
	//if (vn >= "4") ew.moveTo((screen.availWidth/2)-tmpX/2,(screen.availHeight/2)-tmpY/2);
	return;
}

function feldGr(feld,inhalt,max) {
	who = feld;
	if (inhalt >= max) {
		alert('Achtung, maximale Feldgröße erreicht!');
		who.value = who.value.substr(0,max-1);
	}
}

function drucken() {
	if (window.print) self.print();
	if(document.all && navigator.appVersion.substring(22,23)==4) {
		self.focus();
	    var OLECMDID_PRINT = 6;
	    var OLECMDEXECOPT_DONTPROMPTUSER = 2;
	    var OLECMDEXECOPT_PROMPTUSER = 1;
	    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH="0" HEIGHT="0" CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
	    document.body.insertAdjacentHTML('beforeEnd',WebBrowser);
	    WebBrowser1.ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DONTPROMPTUSER);
	    WebBrowser1.outerHTML = '';
	}
}

function inhaltCheck(field,txt,url) {
	iCheck = true;

	for(i=0;i<field.value.length;i++) {
		if (field.value.substr(i,1) != ' ') {
			iCheck = false;
			i = field.value.length;
		}
	}
	if (iCheck) {
		alert(txt);
		//return false;
	}
	else document.location.href = url;
}

function checkStichwortSuche() {
	var iCheck = true;
	for(i=0;i<document.suche.stichwort.value.length;i++) {
		if (document.suche.stichwort.value.substr(i,1) != ' ') {
			iCheck = false;
			i = document.suche.stichwort.value.length;
		}
	}
	if ((document.suche.stichwort.value == '') || (document.suche.stichwort.value == 'Stichwort eingeben...') || (iCheck)) {
		alert("Bitte geben Sie ein Stichwort ein,\nnachdem gesucht werden soll.");
		return false;
	}
	return;
}

function seitenaufruf(url) {
	document.location.href = url;
}
// Submenu Functions
var bClicked_submenu = 0;
function init_submenu() {
	if (vn >= 4) {
		ButSubmenu = new Image();
		ButSubmenu.src = "gif/spc.gif";
		ButSubmenuOver = new Image();
		ButSubmenuOver.src = "gif/b_submenu_over.gif";
		Focus_submenu(submenu);
		bClicked_submenu = submenu;
	}
}
function Focus_submenu(idx) {
	if ((fJS) && (idx != bClicked_submenu)) {
		var s = "bSub_"+idx;
		document.getElementById(s).style.backgroundImage='url('+ButSubmenuOver.src+')';
	}
}
function Blur_submenu(idx) {
	if ((fJS) && (idx != bClicked_submenu)) {
		var s = "bSub_"+idx;
		document.getElementById(s).style.backgroundImage='url('+ButSubmenu.src+')';
	}
}