/*################ BEGIN Images-functions ##################*/
function BildDown(DownURL,winfeatures) {
	window.open(DownURL,'Filedown','top=0,left=0' + (winfeatures ? (','+winfeatures) : '') );
}
function getAttrib(selEl, nm, default_value)
{
	if(typeof(default_value) == "undefined") default_value = "";
	var v = default_value;
	if (selEl.getAttribute)
	{
		if (selEl.getAttribute(nm,0) != null) v = selEl.getAttribute(nm,0);
	}
	else if (selEl.attributes)
	{
		var oAttrColl = selEl.attributes;
		var oAttr = oAttrColl.getNamedItem(nm);
		if(oAttr != null) v = oAttr.value;
	}
	if (nm == "noWrap") v = selEl.noWrap;
	if (nm == "class") v = selEl.className;
	return '' + v;
}

function OpenFoto(BildURL, x, y) {
	var win = "";
	win = window.open("","bild",'height=' + y + ',width=' + x +',location=0,status=0,toolbar=no,resizable=0,scrollbar=no,top=0,left=0');
	win.document.writeln('<html><head><title>Das Bild</title>');
	win.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
	win.document.writeln('</head><body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
	win.document.writeln('<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">');
	win.document.writeln('<tr><td align="center">');
	win.document.writeln('<a href="javascript:window.close()">');
	win.document.writeln('<img src="' + BildURL + '" border=0  alt="Fenster schließen">');
	win.document.writeln('</a></td></tr></table></body></html>');
	win.document.close();
	win.focus();
}
function in_array(needle, arr)
{
	var CurStr = new String("," + arr + ",");
	if (CurStr.indexOf("," + needle + ",") == -1) return false;
	else return true;
}
var allCollection = new Array();
var curPos = 0;
var setLoupe = false;
function getDoBildImgs(BILD)
{
	allCollection = new Array();
	if (document.getElementsByTagName)
		var elements=document.getElementsByTagName('a');
	else if (document.all)
		var elements=document.all('a');
	var txt;
	if(elements.length > 0)
	{
		var re=new RegExp("[ \t\n\r\f]","gi");
		for (var i = 0; i < elements.length; i++)
		{
			txt = new String(elements[i].href);
			if (txt.toLowerCase().indexOf("javascript:") == -1)
			{
				txt = new String(getAttrib(elements[i],"onclick"));
				if (txt.indexOf("DoBild(") != -1) txt = "javascript:"+txt;
			}
			txt = txt.replace(re, "");
			if (txt.toLowerCase().indexOf("javascript:") != -1 && txt.indexOf("DoBild(") != -1)
			{
				txt = txt.substring(txt.indexOf("'")+1, txt.lastIndexOf("'"));
				if (!setLoupe)
				{
					//addEvent(elements[i], "mousemove", addLoupe);
					//addEvent(elements[i], "mouseover", addLoupe);
elements[i].style.cursor = "url('"+http_host+"navigation/loupe.png'), url("+http_host+"navigation/loupe.cur), pointer";
				}
				if (!in_array(txt, allCollection))
				{
					if (txt == BILD) curPos = allCollection.length;
					allCollection.push(txt);
				}
			}
		}
	}
	setLoupe = true;
}
function DoBild(BILD)
{
	getDoBildImgs(BILD);
	if (DoBildWindowClose == "") DoBildWindowClose = "Bitte klicken zum Verkleinern";
	var x = 0;
	var y = 0;

	if (typeof window.pageXOffset != 'undefined')
	{
		x = window.pageXOffset;
		y = window.pageYOffset;
	}
	else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat')
	{
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	}
	else if (typeof document.body != 'undefined')
	{
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}

	if (!document.getElementById("sashadow"))
	{
		var b = document.createElement("div");
		b.id = "sashadow";
		b.style.display = "none";
		b.innerHTML = "&nbsp;";
		addEvent(b, "click", HideImage);
		document.getElementsByTagName("body")[0].appendChild(b);
	}
	if (!document.getElementById("imagelayer"))
	{
		var b = document.createElement("div");
		b.id = "imagelayer";
		b.style.display = "none";
		document.getElementsByTagName("body")[0].appendChild(b);
	}
	
	var b_g = document.getElementById("sashadow");
	var b_i = document.getElementById("imagelayer");

	b_i.style.left = x+"px";
	b_i.style.top = y+"px";

	var h = 0, w = 0;
	if (document.documentElement) h = parseInt(document.documentElement.scrollHeight);
	if (document.body.scrollHeight > h) h = parseInt(document.body.scrollHeight);
	if (document.body.clientHeight > h) h = parseInt(document.body.clientHeight);
	if (h > 0)
	{
		if (!document.all) h += 20;
		b_g.style.height = h+"px";
	}

	if (document.documentElement) w = parseInt(document.documentElement.scrollWidth);
	if (w == 0) h = parseInt(document.body.scrollWidth);
	if (document.body.clientWidth > w) w = parseInt(document.body.clientWidth);
	if (w > 0) b_g.style.width = w+"px";


	b_i.innerHTML = "<table border=0 cellspacing=0 cellpadding=1 style='width:100%;height:100%;'><tr><td align='center' valign='middle'><table border=0 cellspacing=0 cellpadding=8 bgcolor=#FFFFFF><tr><td bgcolor=#FFFFFF><div id='CloseButtonLayer' style='display:none;'></div><a href='#' onclick='HideImage();return false;' id='ecomasResizedLink'><img src='" + BILD + "' alt='" + DoBildWindowClose + "' title='" + DoBildWindowClose + "' class='BildHidden' onLoad='resizeImage()' width='1' height='1' id='ecomasResizedImage'><img src='/navigation/img_load.gif' id='ecomasLoadImage' width='42' height='12' border='0' onClick='HideImage();'></a><div id='ArraowsLayer' style='display:none;'></div></td></tr></table></td></tr></table>";

	b_g.style.display = "";
	b_i.style.display = "";
}
function HideImage()
{
	var b_g = document.getElementById("sashadow");
	var b_i = document.getElementById("imagelayer");
	b_g.style.display = "none";
	b_i.style.display = "none";
}
function resizeImage()
{
	var ibj = document.getElementById("ecomasResizedImage");
	var img = new Image();
	img.src = ibj.src;
	var cS = 10;
	var sta = img.width/cS;
	var stb = img.height/cS;
	document.getElementById("ecomasLoadImage").style.display = "none";
	ibj.className = "BildVisible";
	dynamicImage(1,1,img.width,img.height,sta, stb);
}
function dynamicImage(wc,hc,w,h,sta,stb)
{
	var ibj = document.getElementById("ecomasResizedImage");
	wc = Math.round(wc + sta);
	hc = Math.round(hc + stb);
	if (wc >= w) wc = w;
	if (hc >= h) hc = h;
	ibj.width = wc;
	ibj.height = hc;
	if (wc == w || hc == h)
	{
		if(allCollection.length > 0)
		{
			document.getElementById("ArraowsLayer").style.display = "";
			document.getElementById("ArraowsLayer").style.paddingTop = "3px";
                        
			var  HTML = "";
			if (curPos < (allCollection.length -1))
				HTML = "<img src='/navigation/img_arrow_right.gif' align='right' style='cursor:pointer;' onClick='DoBild(\"" + allCollection[parseInt(curPos)+1] + "\");'>";
			if (curPos > 0)
				HTML += "<img src='/navigation/img_arrow_left.gif' align='left' style='cursor:pointer;' onClick='DoBild(\"" + allCollection[parseInt(curPos)-1] + "\");''>";
			document.getElementById("ArraowsLayer").innerHTML = HTML;

                        var HTML2 = "<img src='/navigation/img_close.gif' align='right' style='cursor:pointer;' onClick='HideImage();'>";
                        document.getElementById("CloseButtonLayer").innerHTML = HTML2;
                        document.getElementById("CloseButtonLayer").style.display = "";
                        document.getElementById("CloseButtonLayer").style.paddingBottom = "20px"; 
		}
		return;
	}
	window.setTimeout("dynamicImage(" + wc + ","+ hc +"," + w + "," + h + "," + sta + "," + stb + ")", 0);
}


var LTime = false;
function addLoupe(e)
{
	if (LTime) window.clearTimeout(LTime);
	var top = 0, left = 0;
	if (!document.getElementById) return;
	if (typeof window.pageXOffset != 'undefined')
	{
		left = window.pageXOffset;
		top = window.pageYOffset;
	}
	else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat')
	{
		left = document.documentElement.scrollLeft;
		top = document.documentElement.scrollTop;
	}
	else if (typeof document.body != 'undefined')
	{
		left = document.body.scrollLeft;
		top = document.body.scrollTop;
	}
	else return;

	left = parseInt(left);
	top = parseInt(top);
	if (e.x)
	{
		left += e.x;
		top += e.y;
	}
	else if (e.clientX)
	{
		left += e.clientX;
		top += e.clientY;
	}
	else return;
	
	left = left;
	top = top - 48;
	var c = document.getElementById("Layer2");
	c.innerHTML = "<img src='"+http_host+"navigation/loupe.png' style='vertical-align: middle;'> <span style='background-color:#fff;'>Vergr&ouml;&szlig;ern</span>";
	c.style.visibility = "visible";
	c.style.left = left.toString()+"px";
	c.style.top = top.toString()+"px";
	LTime = window.setTimeout("hideKommentar()",1000);
}
/*################ END Images-functions ####################*/

function Webmerk()
{
	if (document.all) // IE
	{
		if (typeof(WebmerkQuery) == "undefined") var WebmerkQuery = "";
		if (WebmerkQuery == "") WebmerkQuery = "Möchten Sie die Webseite zu Ihren Favoriten hinzufügen?";
		if (typeof(WebmerkFavtext) == "undefined") var WebmerkFavtext = "";
		if (WebmerkFavtext == "") WebmerkFavtext = "Website auf der Basis von ecomas-CMS";
		if (typeof(document.title) != "undefined") WebmerkFavtext = document.title;
		var uri = window.location.href;
		if (confirm(WebmerkQuery)) window.external.addFavorite(uri,WebmerkFavtext);
	}
	else if (document.layers) // NS 4
	{
		if (typeof(WebmerkQueryA) == "undefined") var WebmerkQueryA = "PC-Systeme:\nDrücken Sie Strg + D\n\nApple-Macintosh-Systeme:\nDrücken Sie Befehlstaste + D";
		alert(WebmerkQueryA);
	} else if (!document.all && document.getElementById) {
		if(navigator.appName == "Netscape") { // NS > 6
		if (typeof(WebmerkQueryB) == "undefined") var WebmerkQueryB = "PC-Systeme:\nDrücken Sie Strg + G\n\nApple-Macintosh-Systeme:\nDrücken Sie Befehlstaste + G";
			alert(WebmerkQueryB);
		}
	}
}

var cssHref = "";
function MakeFontSize(s)
{
	if (document.getElementById)
	{
		var Dt = new Date();
		if (cssHref == "") cssHref = document.getElementById("cssLink").href;
		if (document.getElementById("cssLink")) document.getElementById("cssLink").href = cssHref+"?t=" + Dt.getTime() + "&s="+s;
	}
}

/*############## BEGIN Comment-functions ###################*/
/***   Editable: ***/
var backcolor	= '#ffffe1';		// Hintergrund
var bordercolor	= '#000';			// Ramenfarbe
var textcolor	= '#000';			// Textfarbe
var displaytime	=  30000;		// Zeit
var tablewidth	=  230;			// Tabellenbreite in px
var object	= 'Layer2';		// objekt - Ebene ID
/*******************/
var tipTimer = false;			// dHTML Toolltip Timer

function hideKommentar() 
{
	if (document.getElementById)
	{
		if (tipTimer) window.clearTimeout(tipTimer);
		tipTimer = false;
		document.getElementById(object).style.visibility="hidden";
		document.getElementById(object).style.left = -200;
		document.getElementById(object).style.top = -200;
		return false;
	}
	else return true;
}

function showKommentar(e, tipContent)
{
	if (!document.getElementById) return true;
	if (tipTimer) window.clearTimeout(tipTimer);
	document.getElementById(object).innerHTML='<div style="text-align:left; font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 11px; border: 1px solid '+bordercolor+'; background-color: '+backcolor+'; padding:4px; width:'+tablewidth+'px; max-width:'+tablewidth+'px; color: '+textcolor+';">'+unescape(tipContent)+'</div>';
	var top = 0, left = 0;

	if (typeof window.pageXOffset != 'undefined')
	{
		left = window.pageXOffset;
		top = window.pageYOffset;
	}
	else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat')
	{
		left = document.documentElement.scrollLeft;
		top = document.documentElement.scrollTop;
	}
	else if (typeof document.body != 'undefined')
	{
		left = document.body.scrollLeft;
		top = document.body.scrollTop;
	}
	left = parseInt(left);
	top = parseInt(top);
	if (e.x)
	{
		left += e.x;
		top += e.y;
		if ( (left + tablewidth + 20) > (document.body.clientWidth + document.body.scrollLeft)) left =  left - tablewidth;
	}
	else if (e.clientX)
	{
		left += e.clientX;
		top += e.clientY;
		if ( (left + tablewidth + 20) > (window.pageXOffset + window.innerWidth) ) left =  left - tablewidth;
	}
	left = parseInt(left) - 10;
	top = parseInt(top) + 20;

	document.getElementById(object).style.top = top.toString()+"px";
	document.getElementById(object).style.left = left.toString()+"px";
	document.getElementById(object).style.visibility="visible";
	tipTimer = window.setTimeout("hideKommentar('"+object+"')", displaytime);
	return true;
}

/*############### END Comment-functions ####################*/


function CheckSendForm() {
	var dothis = true;
	
	for (i = 0; i < document.ecomasform.elements.length; i++) {
		if (document.ecomasform.elements[i].title != "") {
			if (document.ecomasform.elements[i].type == "text" && document.ecomasform.elements[i].value == "") {
				dothis = false;
			}
			else if (document.ecomasform.elements[i].type == "radio")
			{
				var currentRadiochecked = false;
				for (j = 0 ; j < document.ecomasform.elements.length; j++)
				{
					if (document.ecomasform.elements[j].type == "radio" && document.ecomasform.elements[i].name == document.ecomasform.elements[j].name )
					{
						if (!currentRadiochecked) currentRadiochecked = document.ecomasform.elements[j].checked;
						if (currentRadiochecked) break;
					}
				}
				
				if (!currentRadiochecked)
					dothis = false;
			}
			else if (document.ecomasform.elements[i].type.indexOf("select") != -1)
			{
				var selOpt = 0;
				for (var j = 0; j < document.ecomasform.elements[i].options.length; j++)
				{
					if (document.ecomasform.elements[i].options[j].selected && document.ecomasform.elements[i].options[j].value != "") selOpt ++;
				}
				if (selOpt == 0) dothis = false; 
			}
			else if (document.ecomasform.elements[i].type == "checkbox" && document.ecomasform.elements[i].checked == false)
				dothis = false;
				
			if (!dothis)
			{
				alert(document.ecomasform.elements[i].title);
				document.ecomasform.elements[i].focus();
				break;
			}
		}
	}	
	return dothis;
}

function FindFirstField()
{
	for (i = 0; i < document.ecomasform.elements.length; i++) {
		if(document.ecomasform.elements[i].type == "text" || document.ecomasform.elements[i].type == "textarea")
		{
			txt1 = new String(document.ecomasform.outerHTML);
			txt2 = new String(document.ecomasform.elements[i].outerHTML);
			if(txt1.indexOf(txt2) < 1000)
			{
				document.ecomasform.elements[i].focus();
			}
			break;
		}
		else if (i > 4)
			break;
	}
}


function dvoid()
{
}

function addEvent(o,n,h)
{
	if(o.attachEvent) o.attachEvent("on"+n,h);
	else if (o.addEventListener) o.addEventListener(n,h,false);
}

function cancelEvent (e)
{
	try
	{
		if (typeof(e) == "undefined") e = window.event;
		if (typeof(e) == "undefined") return false;
		if(e.preventDefault)
		{
			e.preventDefault();
		}
		else
		{
			e.returnValue=false;
			e.cancelBubble=true;
		}
	}
	catch(e) {}
	return false;
}

// BEGINN Highlights
function ShowHighLights()
{
	if (!document.getElementById) return;
	if (typeof(Ebene1) == "undefined") return;
	if (Ebene1 != "")
	{
		document.getElementById('e1_link_'+Ebene1).className="e1_act";
		document.getElementById('e1_link_'+Ebene1).style.backgroundImage = "url(http://www.haus-des-kindes-stockert.de/navigation/pfeil_e1_" + (Ebene2 != "" ? "u" : "r") + ".gif)";
	}
	if (Ebene2 != "") 
	{	
		document.getElementById('e2_link_'+Ebene2).className="e2_act";
		document.getElementById('e2_link_'+Ebene2).style.backgroundImage = "url(http://www.haus-des-kindes-stockert.de/navigation/pfeil_e2_" + (Ebene3 != "" ? "u" : "r") + ".gif)";
        }
	if (Ebene3 != "") 
	{	
		document.getElementById('e3_link_'+Ebene3).className="e3_act";
                document.getElementById('e3_link_'+Ebene3).style.backgroundImage = "url(http://www.haus-des-kindes-stockert.de/navigation/pfeil_e2_" + (Ebene4 != "" ? "u" : "r") + ".gif)";
        }
	if (Ebene4 != "") 
        {
                document.getElementById('e4_link_'+Ebene4).className="e4_act";
                document.getElementById('e4_link_'+Ebene4).style.backgroundImage = "url(http://www.haus-des-kindes-stockert.de/navigation/pfeil_e2_r.gif)";
        }
	getDoBildImgs("");
}
// END Highlights

addEvent(window, "load", ShowHighLights);