/**
* JavaScript
*
* @author	Sebastian Müller <sebastian produktivbuero de>
* @date		17/04/2007
*/


/** ************************************************************************
* Öffnet ein Popupfenster
*
* @param	$url  Zieladresse
* @return	-
* @author	Sebastian Müller <sebastian produktivbuero de>
* @date		07/02/2007
***************************************************************************/

function windowOpen (url) {
	windowProps = "width=660, height=650, dependant=no, scrollbars=yes, menubar=no, status=no";
	myWindow = window.open(url,"window",windowProps);
};


/** ************************************************************************
* Bestätigungsabfrage zum Löschen der Dtaien
*
* @param	$message  auszugebende Nachricht
* @param  url Zielseite bei erfolgter Bestätigung
* @return	Wert der Bestätigung
* @author	Sebastian Müller <sebastian produktivbuero de>
* @date		26/04/2007
***************************************************************************/

function checkCancel(message, url) {
	var msg = confirm(message);
    if (msg) {
        self.location.href = url;
    }
    return msg;
};


/** ************************************************************************
* Entschlüsselt E-Mails
*
* @param	$s  verschlüsselte E-Mail-Adresse
* @return	E-Mail-Adresse
* @author	http://jumk.de
* @date		
***************************************************************************/

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;
};


/** ************************************************************************
* Ruft den Link zur E-Mail-Adresse auf
*
* @param	$s  verschlüsselte E-Mail-Adresse
* @return	-
* @author	http://jumk.de
* @date		
***************************************************************************/

function linkTo_UnCryptMailto (s) {
	location.href=UnCryptMailto(s);
};


/** ************************************************************************
* AJAX-Dropdown-Boxes
*
* Belegt die definierten ID-Elemente mit den aufgerufenene Aktionen
*
* @param	-
* @return	-
* @author	http://www.exit404.com/2005/57/unobtrusive-persistant-scriptaculous-effects
* @date		01/11/2005
***************************************************************************/

var theRules = {
	'#block01' : function(el){
		el.onclick = function(){
			if (Element.hasClassName(this, 'invisible')) {
				new Effect.BlindDown('blockbody01');
				Element.removeClassName(this, 'invisible');
			} else {
				new Effect.BlindUp('blockbody01');
				Element.addClassName(this, 'invisible');
			}
		}		
	},
	'#block02' : function(el){
		el.onclick = function(){
			if (Element.hasClassName(this, 'invisible')) {
				new Effect.BlindDown('blockbody02');
				Element.removeClassName(this, 'invisible');
			} else {
				new Effect.BlindUp('blockbody02');
				Element.addClassName(this, 'invisible');
			}
		}		
	},
	'#block03' : function(el){
		el.onclick = function(){
			if (Element.hasClassName(this, 'invisible')) {
				new Effect.BlindDown('blockbody03');
				Element.removeClassName(this, 'invisible');
			} else {
				new Effect.BlindUp('blockbody03');
				Element.addClassName(this, 'invisible');
			}
		}		
	},
	'#block04' : function(el){
		el.onclick = function(){
			if (Element.hasClassName(this, 'invisible')) {
				new Effect.BlindDown('blockbody04');
				Element.removeClassName(this, 'invisible');
			} else {
				new Effect.BlindUp('blockbody04');
				Element.addClassName(this, 'invisible');
			}
		}		
	},
	'#block05' : function(el){
		el.onclick = function(){
			if (Element.hasClassName(this, 'invisible')) {
				new Effect.BlindDown('blockbody05');
				Element.removeClassName(this, 'invisible');
			} else {
				new Effect.BlindUp('blockbody05');
				Element.addClassName(this, 'invisible');
			}
		}		
	}
};


/** ************************************************************************
* AJAX-Dropdown-Boxes
*
* Schliesst die jeweiligen Fenster beim Laden der Seite
*
* @param	-
* @return	-
* @author	http://www.exit404.com/2005/57/unobtrusive-persistant-scriptaculous-effects
* @date		01/11/2005
***************************************************************************/

function hideBoxes() {
	
	// Id names of the invisble "boxes"
	elIds = $("block03", "block03");	
	boxIds = $("blockbody03", "blockbody03");	
	
	for (i = 0; i < boxIds.length; i++) {
		if (boxIds[i]) {
				Element.hide(boxIds[i]);
				Element.addClassName(elIds[i], 'invisible');
		}		
	}	
};

Behaviour.register(theRules);
Behaviour.addLoadEvent(hideBoxes);
