

function FensterOeffnen (Adresse) {
  MeinFenster = window.open(Adresse, "Zweitfenster", "width=900,height=700,scrollbars=yes,menubar=no,resizable=yes,status=no,toolbar=no,location=no");
  MeinFenster.focus();
}


// Formularfelder ÃƒÂ¼berprÃƒÂ¼fen
function chkMail() {
	var chkOK = true;
	var chkMail = true;
	var chkEmpty = true;
	var msg = "";

	$$(".chkEmpty").each( function(item){
		if($F(item)=="") {
			chkOK = false;
			chkEmpty = false;
			//item.setStyle({backgroundColor: '#FF9999'});
			var s = item.siblings();
			s[0].style.visibility = 'visible';
		} else {
			//item.setStyle({backgroundColor: '#FFFFFF'});
			var s = item.siblings();
			s[0].style.visibility = 'hidden';
		}
	} );

	$$(".chkEmail").each( function(item){
                var reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)'+'(\\@)([a-zA-Z0-9\\-\\.]+)'+'(\\.)([a-zA-Z]{2,4})$');
                
		if(!reg.test($F(item)))	{
		//if($F(item)=="") {
			chkOK = false;
			chkMail = false;
			//item.setStyle({backgroundColor: '#FF9999'});
			var s = item.siblings();
			s[0].style.visibility = 'visible';
		} else {
			//item.setStyle({backgroundColor: '#FFFFFF'});
			var s = item.siblings();
			s[0].style.visibility = 'hidden';
		}
	} );

	if(!chkEmpty) msg += ixTransFromJsEmpty +"\n";
	if(!chkMail) msg += ixTransFromJsEmail +"\n";
	if(msg!="") {$('formError').update('<div style="float:left; padding-right:5px;"><img src="/libImages/global/iconError.png" /></div> '+msg);} else {$('formError').update('');}
	return chkOK;
}

function mouseRollOver()
{
	$$('.rollOver').each(function (i)
	{
		var index = i.src.lastIndexOf('.');
		if (index > -1) {var newSrc = i.src.substring(0, index)+'.mo'+i.src.substring(index);}
		
		if (newSrc)
		{
			var img = new Image();
			img.src = newSrc;
		}
		
		i.observe('mouseover', function (e)
		{
			if (newSrc) {i.src = newSrc;}
		});
		
		i.observe('mouseout', function (e)
		{
			i.src = i.src.replace('.mo.', '.');
		});
	});
}


//**************************
//*** SPAMSCHUTZ ***  
//**************************


// UnCryptMailto() entschluesselt die Mail-Adresse, zu zuvor mit
// der PHP-Funktion encryptEmail() verschlÃ¼sselt wurde
// Anwendung:
/*
<?php $link="javascript:linkTo_UnCryptMailto('".encryptEmail("john@doe.de")."');"; ?>
<a href="<?php echo $link ?>">E-Mail an John Doe schreiben</a>
*/
 
// JS function for uncrypting spam-protected emails:
function UnCryptMailto(s) {	//
	var n=0;
	var r="";
	for(var i=0; i < s.length; i++) {
		n=s.charCodeAt(i);
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-(1));
	}
	return r;
}

  // JS function for uncrypting spam-protected emails:
function linkTo_UnCryptMailto(s)	{	//
	location.href="mailto:"+UnCryptMailto(s);
}


// Image-Preloader
function preloadImage(gSrc, gFinish)
{
	var img = new Image();
	img.src = gSrc;
	if (gFinish) {var int = setInterval(function () {if (img.complete) {clearInterval(int); this.finish = gFinish; this.finish();}}, 50);}
}


// Setzt den Menü-Marker
function resetMarker()
{
	if ($browser != 'IE 5x' && $browser != 'IE 6' && $browser != 'IE 7')
	{
		$$('.menu1Active').each(function (i) // setzt den Menuemarker
		{
			$('menuMarker').style.display = 'block';
			$('menuMarker').style.top = (i.offsetTop + 21)+'px';
			$('menuMarker').style.left = Math.round(i.offsetLeft + i.getWidth() / 2 - 7)+'px';
		});
	}
}

function faq()
{
	var preLoadImg = new Image();
	preLoadImg.src = '/libImages/global/arrowFaqActive.png';
	
	$$('.question').each(function (v)
	{
		v.stopObserving('click');
		v.observe('click', function ()
		{
			$$('.answer').each(function (v2) {v2.style.display = 'none'; v2.up().down('.question').style.backgroundImage = 'url(/libImages/global/arrowFaq.png)'; v2.up().style.zIndex = '0';});
			
			this.style.backgroundImage = 'url(/libImages/global/arrowFaqActive.png)';
			var height = this.up().down('.answer').getHeight();
			this.up().style.zIndex = '998';
			this.up().down('.answer').style.height = '0px';
			this.up().down('.answer').style.overflow = 'hidden';
			this.up().down('.answer').style.display = 'block';
			new Effect.Morph(this.up().down('.answer'), {style: 'height:'+height+'px;', duration: 0.75});
			
			this.stopObserving('click');
			this.observe('click', function ()
			{
				var height = this.up().down('.answer').getHeight();
				var element = this;
				new Effect.Morph(this.up().down('.answer'), {style: 'height:0px;', duration: 0.75, afterFinish: function ()
				{
					element.up().down('.answer').style.display = 'none';
					if ($browser == 'IE 6') {height += 2;} else {height -= 12;}
					element.up().down('.answer').style.height = height+'px';
					element.up().style.zIndex = '0';
					element.style.backgroundImage = 'url(/libImages/global/arrowFaq.png)';
					faq();
				}});
			});
		});
	});
}

function persons()
{

	$$('.personsOnClick').each(function (v)
	{
		v.stopObserving('click');
		v.observe('click', function ()
		{
			$$('.info').each(function (v2) {v2.style.display = 'none'; v2.up().style.zIndex = '0';});
			
			this.up().style.zIndex = '998';
			this.up().down('.info').style.display = 'block';
			this.up().down('.info').style.top = (document.viewport.getScrollOffsets().top-250)+'px';
			
			this.stopObserving('click');
			this.observe('click', function ()
			{
				this.up().down('.info').style.display = 'none';
				persons();
			});
		});
		
		v.up().down('.buttonClose').stopObserving('click');
		v.up().down('.buttonClose').observe('click', function ()
		{
			this.up('.info').style.display = 'none';
			persons();
		});
	});
}

function getWidth() {
var de = document.documentElement;
var myWidth = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
return myWidth;
}
document.getWidth=getWidth;

function googleMaps(gElement, gPoint)
{
	if (!map)
	{
		map = new GMap2(document.getElementById("map_canvas"));
		map.addControl(new GSmallZoomControl());
	}
	$('info').style.top = ($(gElement).up('.blockSite').getHeight() + 150)+'px';
	$('info').style.left = Math.floor(document.getWidth() / 2 - 326)+'px';
	$('info').down('.buttonClose').stopObserving('click');
	eval('var point = new GLatLng('+gPoint+');');
	var marker = new GMarker(point);
	GEvent.addListener(marker, "mouseover", function() {this.openInfoWindowHtml('<div>'+$(gElement).up('.blockSite').down('h2').innerHTML+'</div>');});
	map.addOverlay(marker);
	map.setCenter(point, 15);
	$('info').down('.buttonClose').observe('click', function ()
	{
		$('info').style.top = '-1000px'; // positionierung statt ausblenden ist ein workaround, da display:none; probleme verursacht
		$('info').style.left = '-1000px';
	});
}
