var agt			=	navigator.userAgent.toLowerCase();

var ie 			= ((document.all) && (window.offscreenBuffering)) ? true : false;

var nn 			= ((document.captureEvents) && (!document.getElementById)) ? true : false;

var mz 			= ((document.getElementById) && (!document.all) && (document.documentElement)) ? true : false;

var op 			= ((document.getElementById) && (navigator.userAgent.indexOf('Opera') != -1)) ? true :false;

var safari 	= ((document.getElementById) && (navigator.userAgent.indexOf('Safari') != -1)) ? true :false;

var is_mac 	= (agt.indexOf("mac")!=-1);







function MM_reloadPage(init) {  //reloads the window if Nav4 resized

  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {

    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}

  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();

}

MM_reloadPage(true);



function MM_findObj(n, d) { //v4.0

  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=MM_findObj(n,d.layers[i].document);

  if(!x && document.getElementById) x=document.getElementById(n); return x;

}



function MM_showHideLayers() { //v3.0

  var i,p,v,obj,args=MM_showHideLayers.arguments;

  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];

    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v='hide')?'none':v; }

    obj.display=v; }

}



function MM_jumpMenu(targ,selObj,restore){

  eval(targ+".location='index.php?site_id="+ca_site_id+"&"+selObj.options[selObj.selectedIndex].value+"&seminare_pos=0'");

  if (restore) selObj.selectedIndex=0;

}



function loadColorCSS()

{

	var colFileCSS = "farbe_uebergreifend.css";

	var colFolderID = ca_folder_path[ca_folder_path.length-2];	

	

	for (i=0; i<CSS_FOLDER_ITEMS.length; i++)

	{

		for (ar=1; ar<CSS_FOLDER_ITEMS[i].length; ar++)

		{

				if (CSS_FOLDER_ITEMS[i][ar] == colFolderID) colFileCSS = CSS_FOLDER_ITEMS[i][0];

		}

	}

	document.write('<link href="public/styles/'+colFileCSS+'" rel="stylesheet" type="text/css">');

}



function istEmail(feld)

{

	var supported = 0;

	if (window.RegExp)

	{

		var tempStr = "a";

		var tempReg = new RegExp(tempStr);

		if (tempReg.test(tempStr)) supported = 1;

	}

	if (!supported)	return (feld.indexOf(".") > 2) && (feld.indexOf("@") > 0);

	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");

	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");

	return (!r1.test(feld) && r2.test(feld));

}



lastDIV = "";

function zeigeLayer(ebene)

{

	if (lastDIV)

	{

	 MM_showHideLayers(lastDIV,'','hide');

	 if (MM_findObj("select_pdf")) { MM_findObj("select_pdf").style.display = "block"; }

	}

	if (lastDIV != ebene)

	{

		MM_showHideLayers(ebene,'','show');

		lastDIV = ebene;

		if (MM_findObj("select_pdf")) { MM_findObj("select_pdf").style.display = "none"; }

	}

	else

	{

		lastDIV = "";

	}	

}



function showExtLayer(ebene)

{

		if (lastDIV)

		{

		 MM_showHideLayers(lastDIV,'','hide');

		 if (MM_findObj("select_pdf")) {  MM_findObj("select_pdf").style.display = "block"; } 

		 }


		if (lastDIV != ebene)

		{

			$('praxisbeispiele').innerHTML = "";

			var seiten_id = ebene.split("-");		

			var seite = "praxisbeispiel.php";

			var pars = "site_id="+seiten_id[1];

			var myAjax = new Ajax.Updater('praxisbeispiele', seite, {method: 'get', parameters: pars, onComplete: showSearchStringInPraxisbeispiel });

			lastDIV = ebene;
			if (MM_findObj("select_pdf")) { MM_findObj("select_pdf").style.display = "none";  } 

		}

		else

		{

			$('praxisbeispiele').innerHTML = "";

			lastDIV = "";

		}

}



showSearchStringInPraxisbeispiel = function ()

{

	if (parameter['searchString'] != undefined)

	{

		showSearchString(parameter['searchString']);

	}

}



function regenerate()

{

	window.location.reload()

}



function regenerate2()

{

	if (document.layers)

	setTimeout("window.onresize=regenerate",400);

}



var backgroundcolor="";

//Set duration message should appear on screen, in seconds (10000=10 sec, 0=perpetual)

var displayduration=0;



var ie=document.all;

var ieNOTopera=document.all&&navigator.userAgent.indexOf("Opera")==-1;

var which=0;

var topmsg_obj = null;



function init()

{

	topmsg_obj = MM_findObj("topmsg");

	setmessage();

	

	// Suche

	initSuche();

	// Anmelde Layer oeffnen ?
     if (document.location.search.search(/zl=anmeldung/) > 0) {zeigeLayer ("anmeldung")} 

}



function setzeHoeheCN()

{

	// Die erste Grafik im Container infobox hat nicht den ueblichen Abstand

	var infobox = MM_findObj("infobox");

	var seminarangebot = MM_findObj("seminarangebot");

	var abstand = "24px";

	

  Try.these	(

		function()

		{

			if (infobox.firstChild.className != "bild") infobox.firstChild.style.marginTop = abstand;

			else if (seminarangebot && seminarangebot.firstChild && seminarangebot.firstChild.className != "bild") infobox.firstChild.style.marginTop = abstand;

		},

		function()

		{

			if (seminarangebot.firstChild.nextSibling.className != "bild") infobox.firstChild.nextSibling.style.marginTop = abstand;

			else if (infobox.firstChild.nextSibling.className != "bild") infobox.firstChild.nextSibling.style.marginTop = abstand;

		},

		function()

		{

			if (infobox.firstChild.nextSibling.className != "bild") infobox.firstChild.nextSibling.style.marginTop = abstand;

			else if (seminarangebot.firstChild.className != "bild") infobox.firstChild.nextSibling.style.marginTop = abstand;

		}

	);

	

	Try.these	(

		function()

		{

			if (seminarangebot && seminarangebot.firstChild && seminarangebot.firstChild.className == "bild")

			{

				// marginTop bei 0;

				if (infobox.firstChild.className != "bild") seminarangebot.style.marginTop = abstand;		

			}

			else

			{

				seminarangebot.style.marginTop = abstand;

			}

		});

	

}



var parameter;

function initSuche()

{

	parameter = new Werteliste(window.location.search);

	

	if (parameter['seminare_pbid'] != undefined && parameter['seminare_pbid'] > 0)

	{

		showExtLayer('layer-'+parameter['seminare_pbid']);	

	}

	else

	{

		if (parameter['searchString'] != undefined)

		{

			showSearchString(parameter['searchString']);

		}

	}	

}



function showSearchString(sstring)

{

	if (!document.createElement) return;

	words = unescape(sstring.replace(/\+/g,' ')).split(/\s+/);

	for (w=0;w<words.length;w++)

	{		

		if (document.getElementById('ccontainer'))

		{

			highlightWord(document.getElementById('ccontainer'),words[w]);

		}

		if (document.getElementById('ccontainer1'))

		{

			highlightWord(document.getElementById('ccontainer1'),words[w]);

		}

		if (document.getElementById('ccontainer2'))

		{

			highlightWord(document.getElementById('ccontainer2'),words[w]);

		}

		if (document.getElementById('seminarangebot'))

		{

			highlightWord(document.getElementById('seminarangebot'),words[w]);

		}

		if (document.getElementById('infobox'))

		{

			highlightWord(document.getElementById('infobox'),words[w]);

		}

		if (document.getElementById('praxisbeispiele'))

		{

			highlightWord(document.getElementById('praxisbeispiele'),words[w]);

		}

  }

}



function highlightWord(node,word) {

	// Iterate into this nodes childNodes

	if (node.hasChildNodes) {

		var hi_cn;

		for (hi_cn=0;hi_cn<node.childNodes.length;hi_cn++) {

			highlightWord(node.childNodes[hi_cn],word);

		}

	}

	

	// And do this node itself

	if (node.nodeType == 3) { // text node

		tempNodeVal = node.nodeValue.toLowerCase();

		tempWordVal = word.toLowerCase();

		if (tempNodeVal.indexOf(tempWordVal) != -1) {

			pn = node.parentNode;

			if (pn.className != "searchword") {

				// word has not already been highlighted!

				nv = node.nodeValue;

				ni = tempNodeVal.indexOf(tempWordVal);

				// Create a load of replacement nodes

				before = document.createTextNode(nv.substr(0,ni));

				docWordVal = nv.substr(ni,word.length);

				after = document.createTextNode(nv.substr(ni+word.length));

				hiwordtext = document.createTextNode(docWordVal);

				hiword = document.createElement("span");

				hiword.className = "searchword";

				hiword.appendChild(hiwordtext);

				pn.insertBefore(before,node);

				pn.insertBefore(hiword,node);

				pn.insertBefore(after,node);

				pn.removeChild(node);

			}

		}

	}

}



function Werteliste(querystring)

{

  if(querystring == '') return;

  var wertestring = decodeURI(querystring);

  wertestring = wertestring.slice(1);

  var paare = wertestring.split("&");

  for (var i=0; i < paare.length; i++)

  {

    var name = paare[i].substring(0, paare[i].indexOf("="));

    var wert = paare[i].substring(paare[i].indexOf("=")+1, paare[i].length);

    this[name] = wert;

  }

}



function positionit()

{

	var dsocleft = ie ? document.documentElement.scrollLeft : pageXOffset;

	var dsoctop = ie ? document.documentElement.scrollTop : pageYOffset;

	var window_width = ieNOTopera ? document.documentElement.clientWidth : window.innerWidth - 20;

	var window_height = ieNOTopera ? document.documentElement.clientHeight : window.innerHeight;

	

	/*

	text = "dsocleft: " + dsocleft;

	text += " | dsoctop:" +dsoctop;

	text += " | window_width:" + window_width;

	text += " | window_height:" + window_height;

	window.status = text;*/



	if (ie || document.getElementById)

	{

		tmp = parseInt(dsoctop) + parseInt(window_height) - topmsg_obj.offsetHeight - 20;

		if (tmp < 400) tmp = 400;

		topmsg_obj.style.top = tmp + "px";

	}

	else if (document.layers)

	{

		tmp = dsoctop+window_height-topmsg_obj.document.height-5;

		if (tmp < 400) tmp = 400;

		topmsg_obj.top = tmp + "px";

	}

}



function setmessage()

{

	if (document.layers)

	{

		topmsg_obj=new Layer(window.innerWidth);

		topmsg_obj.bgColor=backgroundcolor;

		regenerate2();

		topmsg_obj.document.write(message);

		topmsg_obj.document.close();

		positionit();

		topmsg_obj.visibility="show";

		if (displayduration!=0)

			setTimeout("topmsg_obj.visibility='hide'",displayduration);

	}

	else

	{

		positionit();

		topmsg_obj.style.backgroundColor=backgroundcolor;

		topmsg_obj.style.visibility="visible";

		if (displayduration!=0)

			setTimeout("topmsg_obj.style.visibility='hidden'",displayduration);

	}

	setInterval("positionit()",100);

}



function writeAbstand(bereich, pixel)

{

	if((document.all && MM_findObj(bereich) && 1 == MM_findObj(bereich).childNodes.length) || (!document.all && MM_findObj(bereich) && 2 == MM_findObj(bereich).childNodes.length))

	{

		document.write('<img src="public/images/leer.gif" width="1" height="'+pixel+'" /><br>');

	}

}



var Fenster = null;

function neuesFenster(meineSeite,meinName,w,h,scroll)

{

	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;

	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;

	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable';

	Fenster = window.open(meineSeite,meinName,settings)

}



function initFlashIntro()

{

	var inhalt = "";

	

	if (mz || nn || (ie && is_mac))

	{

		inhalt =  '<object data="public/flash/start.swf" type="application/x-shockwave-flash" width="840" height="680">';

		inhalt += '<param name="wmode" value="transparent" />';

		inhalt += '<param name="menu" value="false" />';

		inhalt += '<param name="quality" value="high" />';

		inhalt += '</object>';

	}

	else

	{

		inhalt =  '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="840" height="680" id="flashintro">';

		inhalt += '<param name="movie" value="public/flash/start.swf" />';

		inhalt += '<param name="menu" value="false" />';

		inhalt += '<param name="quality" value="high" />';

		inhalt += '<param name="wmode" value="transparent" />';

		inhalt += '</object>';

	}

	MM_findObj("intro").innerHTML = inhalt;

}