/* *************************** */
/* ***** vertikales Menu ***** */
/* *************************** */

jQuery.fn.initMenu = function() {  
    return this.each(function(){
        var theMenu = $(this).get(0);
        $('.acitem', this).hide();
        $('li.expand > .acitem', this).show();
        $('li.expand > .acitem', this).prev().addClass('active');
        $('li a', this).click(
            function(e) {
                /*e.stopImmediatePropagation();*/
                var theElement = $(this).next();
                var parent = this.parentNode.parentNode;
                var Adresse = this.href;
                if($(parent).hasClass('noaccordion')) {
                    if(theElement[0] === undefined) {
                        window.location.href = this.href;
                    }
                    $(theElement).slideToggle('normal',  function() {
                        if ($(this).is(':visible')) {
                            $(this).prev().addClass('active');
                        }
                        else {
                            $(this).prev().removeClass('active');
                        }    
                    });
                    return false;
                }
                else {
                    if(theElement.hasClass('acitem') && theElement.is(':visible')) {
                        if($(parent).hasClass('collapsible')) {
                            $('.acitem:visible', parent).first().slideUp('normal', 
                            function() {
                                $(this).prev().removeClass('active');
                            }
                        );
                        return false;  
                    }
                    return false;
                }
                if(theElement.hasClass('acitem') && !theElement.is(':visible')) {         
                    $('.acitem:visible', parent).first().slideUp('normal',  function() {
                        $(this).prev().removeClass('active');
                    });
                    theElement.slideDown('normal',  function() {
                        $(this).prev().addClass('active');
                        window.location.href = Adresse; // Ruft die URL NUR beim oeffnen auf, nicht aber beim schliessen!
                    });
                    return false;
                }
            }
        }
    );
});
};

/* *********************************************************** */
/* German initialisation for the jQuery UI date picker plugin. */
/* *********************************************************** */
jQuery(function($){
	$.datepicker.regional['de'] = {
		closeText: 'schließen',
		prevText: '&#x3c;zurück',
		nextText: 'Vor&#x3e;',
		currentText: 'heute',
		monthNames: ['Januar','Februar','März','April','Mai','Juni',
		'Juli','August','September','Oktober','November','Dezember'],
		monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
		'Jul','Aug','Sep','Okt','Nov','Dez'],
		dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
		dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
		dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
		weekHeader: 'Wo',
		dateFormat: 'dd.mm.yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['de']);
});

/* *********************************** */
/* ***** document.ready function ***** */
/* *********************************** */
$(document).ready(function() {
	$('.menu').initMenu();								// vertikales Menu Initialisierung
	
	$('a.tips').cluetip();								// Mouseovers aus cluetip.js
	$('a.title').cluetip({splitTitle: '|', arrows: true});
	$('area.title').cluetip({width: '350px', splitTitle: '|', arrows: true});
	
	/* ***************************** */
	/* ***** horizontales Menu ***** */
	/* ***************************** */
    $('#horMenu li').hoverIntent(
        function () {
            //show its submenu
//            $('ul', this).slideDown({queue:false, duration:600, easing: 'easeOutBounce'});
            $('ul', this).slideDown(400);
 
        }, 
        function () {
            //hide its submenu
//            $('ul', this).slideUp({queue:false, duration:400, easing: 'easeInOutQuad'});         
            $('ul', this).slideUp(200);         
        }
    );

    $('#GrafikSelectBox li').hoverIntent(
        function () {
            //show its submenu
//            $('ul', this).slideDown({queue:false, duration:600, easing: 'easeOutBounce'});
            $('ul', this).slideDown(400);
 
        }, 
        function () {
            //hide its submenu
//            $('ul', this).slideUp({queue:false, duration:400, easing: 'easeInOutQuad'});         
            $('ul', this).slideUp(200);         
        }
    );
    
    $("a[rel^='prettyPhoto']").prettyPhoto();			// prettyPhoto
    
   /* var $dialog = $("<div></div>")
			.html("Wollen Sie den ausgewählten Datensatz wirklich löschen?")
			.dialog(
			{
				autoOpen: false,
				title: "Datensatz löschen",
				resizable: false,
				height:240,
				width:400,
				modal: true,
			});*/
	setEqualHeights("left","content","right");
	/* Sib Accordion */
	$('.toggle_container').hide();
	$('.trigger_active').next('.toggle_container').show();
	$('.trigger').click( function() {
		var trig = $(this);
		if ( trig.hasClass('trigger_active') ) {
			trig.next('.toggle_container').slideToggle('slow');
			trig.removeClass('trigger_active');
		} else {
			$('.trigger_active').next('.toggle_container').slideToggle('slow');
			$('.trigger_active').removeClass('trigger_active');
			trig.next('.toggle_container').slideToggle('slow');
			trig.addClass('trigger_active');
			
		};
	return false;
	});
	//setEqualHeights("left","content","right");
});


$(function() {

    $('div.fieldset').hover(
        function() {
            $(this).addClass('active');
        },
        function() {
            $(this).removeClass('active');
        }
    );
    
    $('.confirmDelete').click(function() {
            return confirm("Wollen Sie den Datensatz wirklich loeschen?");
        });
        
   /* $(".confirmDelete").click(function() 
        	{
        	var targetUrl = $(this).attr("href");
        	//alert (targetUrl);
        	// Die Buttons mit der URL werden erst zur Laufzeit gesetzt, damit die URL auch einen Inhalt hat!!
        	$dialog.dialog( "option", "buttons", { 	"Löschen":   function() { window.location.href =  targetUrl; },
        											"Abbrechen": function() { $(this).dialog("close");} 
        										  } );
            $dialog.dialog("open");
//            $dialog("option", "href",$(this).attr("href")).dialog("open");
            return false;
        	});
    	});*/
});

/* ************************ */
/* ***** Die Such-Box ***** */
/* ************************ */
function lookup(inputString) 
{
if(inputString.length == 0) 
	{
	// Hide the suggestion box.
	$('#Vorschlag').hide();
	} 
	else 
	{
	$.post('include/livesearch.php', {queryString: ""+inputString+""}, function(data){
	if(data.length > 0) 
		{
		$('#Vorschlag').show();
		$('#Vorschlagsliste').html(data);
		}
		else
		{
		//$('#Vorschlag').html('Nix gefunden!');
		$('#Vorschlag').hide();
		}
	});
	}
} // ENDE - lookup
	
function fill(thisValue) 
{
$('#inputString').val(thisValue);
setTimeout("$('#Vorschlag').hide();", 200);
}


/* ************************** */
/* ***** Layout-Editor  ***** */
/* ************************** */
$(function() {
    $('div.box').not(':first').hide();

    $('#submit').attr('disabled', true).addClass('inactive');
    $('#set1, #set2').css('background', '#FFC');
    $('#sub1, #sub2').hide().css({position: 'absolute', top: '35px', left: '145px', padding: '0'});
    $('#error').append('<ul></ul>');

    $('div.fieldset').hover(
        function() {
            $(this).addClass('active');
        },
        function() {
            $(this).removeClass('active');
        }
    );

    $('input[name=width]').click(function () {
        $('#set1').css('background', '#e8e8e8');
        $('#fixWidth, #liqWidth, #maxWidth').hide();
        if ($('#fix:checked').length > 0) $('#fixWidth').animate({height: 'show'}, 200);
        if ($('#liq:checked').length > 0) $('#liqWidth, #maxWidth').animate({height: 'show'}, 200);
    });

    $('#fix').click(function() {
        $('#liqw').val('1000').removeClass('error');
        $('#maxw').val('').removeClass('error');
        $('#error li:contains("You specify too small minimum width of layout.")').remove();
        $('#error li:contains("The minimum width of layout should be specified in figures.")').remove();
        $('#error li:contains("You specify too small maximum width of layout.")').remove();
        $('#error li:contains("The maximum width of layout should be specified in figures.")').remove();
        if ( $('input.error').length < 1  ) {
            $('#error').fadeOut(100);
        }
    });

    $('#liq').click(function() {
        $('#fixw').val('1000').removeClass('error');
        $('#error li:contains("You specify too small width of layout.")').remove();
        $('#error li:contains("The width of layout should be specified in figures.")').remove();
        if ( $('input.error').length < 1  ) {
            $('#error').fadeOut(100);
        }
    });

    $('#tkr').click(function() {
        if ( $('#tkr:checked').length > 0 ) {
            $('#tkrFarbe').animate({height: 'show'}, 200);
        } else {
            $('#tkrFarbe').hide();
        }
    });

    $('#zkr').click(function() {
        if ( $('#zkr:checked').length > 0 ) {
            $('#headerTHeight').animate({height: 'show'}, 200);
        } else {
            $('#headerTHeight').hide();
        }
    });

    $('#zfr').click(function() {
        if ( $('#zfr:checked').length > 0 ) {
            $('#headerBHeight').animate({height: 'show'}, 200);
        } else {
            $('#headerBHeight').hide();
        }
    });

    $('#headerh').click(function() {
        if ( $('#headerh:checked').length > 0 ) {
            $('#headerHeight').animate({height: 'show'}, 200);
        } else {
            $('#headerHeight').hide();
        }
    });

    $('#footerh').click(function() {
        if ( $('#footerh:checked').length > 0 ) {
            $('#footerHeight').animate({height: 'show'}, 200);
        } else {
            $('#footerHeight').hide();
        }
    });

    $('#lc, #cr').click(function() {
        if ( $('#lc:checked, #cr:checked').length > 0 ) {
            $('#lSidebarWidth').hide();
            $('#lSidebarWidth').animate({height: 'show'}, 200);
        } else {
            $('#lSidebarWidth').hide();
        }
    });

    $('#sub2 input').click(function() {
        $('#lSidebarWidth, #rSidebarWidth').hide();
        $('#lSidebarWidth, #rSidebarWidth').animate({height: 'show'}, 200);
    });

    $('#set2 input').click(function() {
        $('#eh').attr('disabled', false);
        $('label[for=eh]').css({color: '#444444'});
    });

    $('input[name=sidebar]').click(function() {
        $('#set2').css('background', '#e8e8e8');
    });

    $('#s1').click(function() {
        $('input[name=sidebar]').attr('checked', false);
        if ( $('input[name=sidebar]:checked').length < 1 ) $('#set2').css('background', '#FFFFCC');
        $('#sub2, #lSidebarWidth, #rSidebarWidth').hide();
        $('#sub1').animate({height: 'show'}, 200);
        $('#submit').attr('disabled', true).addClass('inactive');
    });

    $('#s2').click(function() {
        $('input[name=sidebar]').attr('checked', false);
        if ( $('input[name=sidebar]:checked').length < 1 ) $('#set2').css('background', '#FFFFCC');
        $('#sub1, #lSidebarWidth').hide();
        $('#sub2').animate({height: 'show'}, 200);
        $('#lsw').val('250').removeClass('error');
        if ( $('input.error').length < 1  ) {
            $('#error').fadeOut(100);
        }
        $('#submit').attr('disabled', true).addClass('inactive');
    });

    $('#s0').click(function() {
        $('#sub1, #sub2, #lSidebarWidth, #rSidebarWidth').hide();
        $('#set2').css('background', '#e8e8e8');
        $('input[name=sidebar]').attr('checked', false);
        $('#eh').attr('disabled', true).attr('checked', false);
        $('label[for=eh]').css({color: '#A7A6AA'});
        $('#lsw').val('250').removeClass('error');
        $('#rsw').val('250').removeClass('error');
        $('#error li:contains("You specify too small left sidebar width.")').remove();
        $('#error li:contains("The left sidebar width should be specified in figures.")').remove();
        $('#error li:contains("You specify too small right sidebar width.")').remove();
        $('#error li:contains("The right sidebar width should be specified in figures.")').remove();
        $('#error li:contains("You specify too small sidebar width.")').remove();
        $('#error li:contains("The sidebar width should be specified in figures.")').remove();
        if ( $('input.error').length < 1  ) {
            $('#error').fadeOut(100);
        }
    });

    $('input[name=width], input[name=sidebar], #s0').click(function() {
        $('#picture').css({opacity: 0});
        $('#picture').animate({opacity: 1});
    });

    function ieAlert() {
        if ( $('#maxw').val() !='' && $('#fb:checked').length > 0 ) {
            $('#alert').show(200);
            if ( $('#alert').length < 1 ) {
                $('#error').after('<div id="alert"></div>');
                $('#alert').hide();
                $('#alert').show(200);
            }
            $('#alert').text('With this set of options the maximum width will not work in IE6.');
        } else {
            $('#alert').hide(200);
        }
    }

    $('form div input').click(function () {
        $('#preview').removeClass();
        var liq = '';
        if ($('#liq:checked').length > 0) liq = 'liq ';
        if (($('#fix:checked').length > 0 || $('#liq:checked').length > 0) && $('#lc:checked').length > 0) $('#preview').addClass(liq+'ex1');
        if (($('#fix:checked').length > 0 || $('#liq:checked').length > 0) && $('#cr:checked').length > 0) $('#preview').addClass(liq+'ex2');
        if (($('#fix:checked').length > 0 || $('#liq:checked').length > 0) && $('#lcr:checked').length > 0) $('#preview').addClass(liq+'ex3');
        if (($('#fix:checked').length > 0 || $('#liq:checked').length > 0) && $('#lrc:checked').length > 0) $('#preview').addClass(liq+'ex4');
        if (($('#fix:checked').length > 0 || $('#liq:checked').length > 0) && $('#clr:checked').length > 0) $('#preview').addClass(liq+'ex5');
        if (($('#fix:checked').length > 0 || $('#liq:checked').length > 0) && $('#s0:checked').length > 0) $('#preview').removeClass().addClass(liq+'ex6');
        if ($('#tkr:checked').length > 0) $('#preview').addClass(liq+'ex7');
        if ($('#tfr:checked').length > 0) $('#preview').addClass(liq+'ex8');
        if ($('#zkr:checked').length > 0) $('#preview').addClass(liq+'ex9');
        if ($('#tkr:checked').length > 0 && $('#zkr:checked').length > 0) $('#preview').addClass(liq+'ex10');
        if ($('#zfr:checked').length > 0) $('#preview').addClass(liq+'ex11');
        if (
            $('#fixw').val() >= 400 &&
            $('#liqw').val() >= 10 &&
            $('#hh').val() >= 1 &&
            $('#fh').val() >= 1 &&
            $('#lsw').val() >= 1 &&
            $('#rsw').val() >= 1 &&
            /^\d*$/.test( $('#fixw').val() && $('#liqw').val() && $('#hh').val() && $('#fh').val() && $('#lsw').val() && $('#rsw').val() ) == 1 &&
            ($('#maxw').val() == '' || ($('#maxw').val() >= 1000 && /^\d*$/.test($('#maxw').val()) == 1))
        ) {
            $('#error').fadeOut(100);
            if ( $('input[name=width]:checked').length > 0 && ( $('input[name=sidebar]:checked').length > 0 || $('#s0:checked').length > 0 ) ) {
                $('#submit').removeAttr('disabled').removeClass('inactive');
            }
        }
        if ( $('input[name=width]:checked').length > 0 && ( $('input[name=sidebar]:checked').length > 0 || $('#s0:checked').length > 0 ) ) {
            $('#info').hide(200);
        } else {
            $('#info').show(200);
        }
        ieAlert();
    });

    $('#fixw, #liqw, #maxw, #hh, #fh, #lsw, #rsw').keyup(function () {
        if ( $('#error ul').length < 1 ) {
            $('#error').append('<ul></ul>');
        }
        if (
            $('#fixw').val() >= 400 &&
            $('#liqw').val() >= 10 &&
            $('#hh').val() >= 1 &&
            $('#fh').val() >= 1 &&
            $('#lsw').val() >= 1 &&
            $('#rsw').val() >= 1 &&
            /^\d*$/.test( $('#fixw').val() && $('#liqw').val() && $('#hh').val() && $('#fh').val() && $('#lsw').val() && $('#rsw').val() ) == 1 &&
            ($('#maxw').val() == '' || ($('#maxw').val() >= 1000 && /^\d*$/.test($('#maxw').val()) == 1))
        ) {
            $('#error').fadeOut(100);
            if ( $('input[name=width]:checked').length > 0 && ( $('input[name=sidebar]:checked').length > 0 || $('input[id=s0]:checked').length > 0 ) ) {
                $('#submit').removeAttr('disabled').removeClass('inactive');
            }
        } else {
            $('#submit').attr('disabled', true).addClass('inactive');
        }
    });

    window.$errors = {
        root_node : '#error',
        add : function(str, condition) {
            if (typeof condition == 'undefined') condition = true;
            if (typeof str == 'string') var arr = [[str, condition]];
            else var arr = arguments;
            var result = 0;
            for (var i = 0; i < arr.length; i++) {
                result = (result || arr[i][1]);
                if (arr[i][1]) {
                    if (!$errors.find(arr[i][0]).length) $($errors.root_node + ' ul').append('<li>' + arr[i][0] + '</li>');
                }
                else $errors.find(arr[i][0]).remove();
            }
            $errors[ ($($errors.root_node + ' li').length ? 'show' : 'hide') ]();
            return result;
        },
        find : function(str) {
            var el = $($errors.root_node + ' li');
            for (var i = 0; i < el.length; i++)
                if (el[i].innerHTML == str) return $(el[i]);
            return {length : 0, remove : function(){}};
        },
        show : function(){ $($errors.root_node).fadeIn(300); },
        hide : function(){ $($errors.root_node).fadeOut(100); }
    };

    $('#fixw').keyup(function () {
        $(this)[ ($errors.add(
            ['Die Mindestbreite ist 400!', (this.value < 400)],
            ['Es sind nur Zahlen erlaubt!', (/^\d*$/.test(this.value) != 1)]
        ) ? 'addClass' : 'removeClass') ]('error');
    });

    $('#liqw').keyup(function () {
        $(this)[ ($errors.add(
            ['You specify too small minimum width of layout.', (this.value < 10)],
            ['The minimum width of layout should be specified in figures.', (/^\d*$/.test(this.value) != 1)]
        ) ? 'addClass' : 'removeClass') ]('error');
    });

    $('#maxw').keyup(function () {
        if ($(this).val() != '' ) {
            $(this)[ ($errors.add(
                ['You specify too small maximum width of layout.', (this.value < 1000)],
                ['The maximum width of layout should be specified in figures.', (/^\d*$/.test(this.value) != 1)]
            ) ? 'addClass' : 'removeClass') ]('error');
        } else {
            $(this).removeClass('error');
        }
        ieAlert();
    });

    $('#hh').keyup(function () {
        $(this)[ ($errors.add(
            ['You specify too small header height.', (this.value < 1)],
            ['The header height should be specified in figures.', (/^\d*$/.test(this.value) != 1)]
        ) ? 'addClass' : 'removeClass') ]('error');
    });

    $('#fh').keyup(function () {
        $(this)[ ($errors.add(
            ['You specify too small footer height.', (this.value < 1)],
            ['The footer height should be specified in figures.', (/^\d*$/.test(this.value) != 1)]
        ) ? 'addClass' : 'removeClass') ]('error');
    });

    $('#lsw').keyup(function () {
        if ($('#s1:checked').length > 0) {
            $(this)[ ($errors.add(
                ['You specify too small sidebar width.', (this.value < 1)],
                ['The sidebar width should be specified in figures.', (/^\d*$/.test(this.value) != 1)]
            ) ? 'addClass' : 'removeClass') ]('error');
        } else {
            $(this)[ ($errors.add(
                ['You specify too small left sidebar width.', (this.value < 1)],
                ['The left sidebar width should be specified in figures.', (/^\d*$/.test(this.value) != 1)]
            ) ? 'addClass' : 'removeClass') ]('error');
        }
    });

    $('#rsw').keyup(function () {
        $(this)[ ($errors.add(
            ['You specify too small right sidebar width.', (this.value < 1)],
            ['The right sidebar width should be specified in figures.', (/^\d*$/.test(this.value) != 1)]
        ) ? 'addClass' : 'removeClass') ]('error');
    });

}); /* Layout-Editor Ende */

/* ************************************************************************************ */
/* ***** Eigene Funktionen zur direkten Darstellung von Farb- und Stilaenderungen ***** */
/* ************************************************************************************ */
function ChangeBGC(idFarbwahl,idDemoFeld)
{
	Farbe  = document.getElementById(idFarbwahl).value;
	//alert ('Change Color to '+Farbe);
	document.getElementById(idDemoFeld).style.backgroundColor = Farbe;
}

function ChangeTC(idFarbwahl,idDemoFeld)
{
	Farbe  = document.getElementById(idFarbwahl).value;
	 //alert ('Change Color to '+Farbe);
	document.getElementById(idDemoFeld).style.color = Farbe;
}

function ChangeBB(idFarbwahl,idDemoFeld)
{
	Farbe  = document.getElementById(idFarbwahl).value;
	 //alert ('Change Color to '+Farbe);
	document.getElementById(idDemoFeld).style.borderBottomColor = Farbe;
}

function ChangeTB(idFarbwahl,idDemoFeld)
{
	Farbe  = document.getElementById(idFarbwahl).value;
	 //alert ('Change Color to '+Farbe);
	document.getElementById(idDemoFeld).style.borderTopColor = Farbe;
}

function ChangeFS(idFarbwahl,idDemoFeld)
{
	Groesse  = document.getElementById(idFarbwahl).value;
	 //alert ('Change Color to '+Farbe);
	document.getElementById(idDemoFeld).style.fontSize = Groesse;
}

function ChangeFF(idFarbwahl,idDemoFeld)
{
	Schriftart  = document.getElementById(idFarbwahl).value;
	 //alert ('Change Color to '+Farbe);
	document.getElementById(idDemoFeld).style.fontFamily = Schriftart;
}

function ChangeLB(idFarbwahl,idDemoFeld)
{
	Farbe  = document.getElementById(idFarbwahl).value;
	 //alert ('Change Color to '+Farbe);
	document.getElementById(idDemoFeld).style.borderLeftColor = Farbe;
}

function setEqualHeights(idLinks,idMitte,idRechts)
{
	if (document.getElementById(idLinks))  {var HL  = document.getElementById(idLinks).clientHeight;}  else {HL = 1;}
	if (document.getElementById(idMitte))  {var HM  = document.getElementById(idMitte).clientHeight;}  else {HM = 1;}
	if (document.getElementById(idRechts)) {var HR  = document.getElementById(idRechts).clientHeight;} else {HR = 1;}

	var allElems = document.getElementsByTagName('*');
	for (var i = 0; i < allElems.length; i++) 
		{
		var thisElem = allElems[i];
		if (thisElem.className && thisElem.className == 'box') 
			{
			HPDBH = thisElem.clientHeight;
			HPDBH = HPDBH + 500;
			}
		}
	var HPDMB = document.getElementById('Menublock').clientHeight;
	//alert ('height of Box '+HPDBH);
//	if (HPDBH > HL) HL = HPDBH + 100;
//	if (HPDMB > HPDBH) HL = HPDMB + 100;
	if (HPDMB > HL) HL = HPDMB + 100;
	var array   = [HL, HM, HR];
	var largest = Math.max.apply(Math, array);
	var hoeheM  = largest - 30; // Das padding der Content-Box muss abgezogen werden!
	//alert ('Change height to '+largest);
	
	if (HL > 1) {document.getElementById(idLinks).style.height  = largest+"px";}
	if (HM > 1) {document.getElementById(idMitte).style.height  = hoeheM+"px";}
	if (HR > 1) {document.getElementById(idRechts).style.height = largest+"px";}
}

function setzePfad(Pfad)
{
	document.form_news.ubergrafik.value = Pfad;
}

function showAnmeldung(divid)
{
	//alert ('Show Anmeldung '+divid);
//	$(id).animate({height: ['toggle', 'swing']}, 100);
	//$(id).slidedown('slow');
//	if ($(divid).is(":hidden")) 
	if ($(divid).hasClass("active"))
		{
		$(divid).slideUp("fast");
		delta = -500;
		$(divid).removeClass("active");
		//alert ('Show Anmeldung else');
		}
		else
		{
		$(divid).slideDown("slow");
		delta = 500;
		$(divid).addClass("active");
		alert ('Show Anmeldung');
		}

//		{
//		$(divid).slideDown("slow");
//		delta = 500;
//		alert ('Show Anmeldung');
//		}
//		else
//		{
//		$(divid).slideUp("fast");
//		delta = -500;
//		alert ('Show Anmeldung else');
//		}
//	setEqualHeights("left","content","right");
	if (document.getElementById("content"))  {var HM  = document.getElementById("content").clientHeight;}  else {HM = 1;}
	var hoeheM  = HM + delta;
	if (HM > 1) {document.getElementById("content").style.height  = hoeheM+"px";}
}

// Wir verschleiern eine e-Mail Adresse
function str_shuffle(str)
{ str = str.split("");
  var str2 = new Array();
  while (str.length>0)
  { str2.push(str.splice(rand(0,str.length-1),1));
  }
  return str2.join("");
}

function rand(min,max)
{ return min+Math.floor(Math.random() * ((max-min)+1));
}

function hide_email(email)
{ var character_set = '+-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
  var key = str_shuffle(character_set); var cipher_text = ''; var id = 'e'+rand(1,999999999);
  for (var i=0;i<email.length;i+=1) cipher_text += key.charAt(character_set.indexOf(email.charAt(i)));
  script = 'var a="'+key+'";var b=a.split("").sort().join("");var c="'+cipher_text+'";var d="";';
  script+= 'for(var e=0;e<c.length;e++)d+=b.charAt(a.indexOf(c.charAt(e)));';
  script+= 'document.getElementById("'+id+'").innerHTML="<a href=\\"mailto:"+d+"\\">"+d+"</a>"';
  script = "eval(\""+script.replace(/([\\"'])/g, "\\$1")+"\")"; 
  script = '<script type="text/javascript">/*<![CDATA[*/'+script+'/*]]>*/</script>';
  return '<span id="'+id+'">[javascript protected email address]</span>'+script;
}

function generate()
{ var xhtml = hide_email(document.getElementById('email').value);
  document.getElementById('xhtml').value = xhtml;
  return false;
}
