 // decrypt helper function
function decryptCharcode(n,start,end,offset) {
	n = n + offset;
	if (offset > 0 && n > end)	{
		n = start + (n - end - 1);
	} else if (offset < 0 && n < start)	{
		n = end - (start - n - 1);
	}
	return String.fromCharCode(n);
}
  // decrypt string
function decryptString(enc,offset) {
	var dec = "";
	var len = enc.length;
	for(var i=0; i < len; i++)	{
		var n = enc.charCodeAt(i);
		if (n >= 0x2B && n <= 0x3A)	{
			dec += decryptCharcode(n,0x2B,0x3A,offset);	// 0-9 . , - + / :
		} else if (n >= 0x40 && n <= 0x5A)	{
			dec += decryptCharcode(n,0x40,0x5A,offset);	// A-Z @
		} else if (n >= 0x61 && n <= 0x7A)	{
			dec += decryptCharcode(n,0x61,0x7A,offset);	// a-z
		} else {
			dec += enc.charAt(i);
		}
	}
	return dec;
}
  // decrypt spam-protected emails
function linkTo_UnCryptMailto(s)	{
	location.href = decryptString(s,-2);
}


//##########################################################################


$(document).ready(function() {
 //zebra table
	$('.contenttable tr:odd').addClass('odd');
	$('.contenttable tr:even').addClass('even');
});




//################# LABEL OVER FUNC #############################################
jQuery.fn.labelOver = function(overClass) {
	return this.each(function(){
		var label = jQuery(this);
		var f = label.attr('for');
		if (f) {
			var input = jQuery('#' + f);
			
			this.hide = function() {
			  label.css({ textIndent: -10000 })
			}
			
			this.show = function() {
			  if (input.val() == '') label.css({ textIndent: 0 })
			}

			// handlers
			input.focus(this.hide);
			input.blur(this.show);
		  label.addClass(overClass).click(function(){ input.focus() });
			
			if (input.val() != '') this.hide(); 
		}
	})
}

/*$(function() {
	$('#searchform').submit(function() {
	$('legend', this).html('Example with labelOver');
	$('label').labelOver('over');

	return false;
	})
	$('label.pre').labelOver('over');
})*/

$(function() {
	$('#teaserform').submit(function() {
	$('legend', this).html('Example with labelOver');
	$('label_teaser').labelOver('over_teaser');

	return false;
	})
	$('label.pre1').labelOver('over_teaser');
})


//################# JQUERY CO #############################################

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + options.path : '';
        var domain = options.domain ? '; domain=' + options.domain : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};



//################# JQUERY MODAL WINDOW #############################################

$(document).ready(function() {

			$('input.jqmdX')
			.hover(
				function(){ $(this).addClass('jqmdXFocus'); }, 
				function(){ $(this).removeClass('jqmdXFocus'); })
			.focus( 
				function(){ this.hideFocus=true; $(this).addClass('jqmdXFocus'); })
			.blur( 
				function(){ $(this).removeClass('jqmdXFocus'); });

});

//jedes Kontaktformular wird hier einzeln aufgerufen. Dazu wurden unter T3 Extra Seiten mit dem Typ 100 hinterlegt
$().ready(function() {
  $('#boettel').jqm({ajax: 'kontakt_boettel.html', trigger: 'a.boettel'});
});

$().ready(function() {
  $('#billen').jqm({ajax: 'kontakt_billen.html', trigger: 'a.billen'});
});

$().ready(function() {
  $('#hoffmann').jqm({ajax: 'kontakt_hoffmann.html', trigger: 'a.hoffmann'});
});

$().ready(function() {
  $('#mario').jqm({ajax: 'kontakt_mario.html', trigger: 'a.mario'});
});

$().ready(function() {
  $('#rieder').jqm({ajax: 'kontakt_rieder.html', trigger: 'a.rieder'});
});




/**
* Purpose:              Font sizer class, handles increasing and decreasing font size of a page.
*                       It increases the font in 10% increments. By getting the level / 10 + 1.
*                       i.e. level 2 is .2 + 1 so 1.2 or 120%.
*
* Requires:             JQuery and the JQuery cookies plugin.
*
* Use:                  Setup the fontsizer $.FontSizer.Init(options); the two options are
*                       min and max, for the min level and max level.
*                       Defaults are min: -3 and max: 5.
*
* Author:               Stefan Sedich (stefan.sedich@gmail.com
*/
$.FontSizer = {

        level: 0,

        options : {            
                min: -3,
                max: 5
        },

        Init : function(options) {
                if(options)
		    $.FontSizer.options = $.extend($.FontSizer.options, options);

                //Get the current level from cookies.
                var level = ($.cookie('font_level') != null) ? $.cookie('font_level') : 0;                      

                //Set the font size to the current leve.
                $.FontSizer.SetSize(level);

        },

        IncreaseSize : function() {

                if(($.FontSizer.level) + 1 <= $.FontSizer.options.max) {            
                        //If we have not exceded the max level,
                        //Get the next level and the set the size to this level.
                        var next = (parseInt($.FontSizer.level) + 1);
                        $.FontSizer.SetSize(next);  
                }

        },

        DecreaseSize : function() {
                if(($.FontSizer.level - 1) >= $.FontSizer.options.min) {
                        //If we have not exceded the min level,
                        //Get the next level and the set the size to this level.
                        var next = (parseInt($.FontSizer.level) - 1);
                        $.FontSizer.SetSize(next);  
                }      
        },      

        SetSize: function(level) {

                //Set the current level in the member variable and the cookie.
                $.FontSizer.level = level;      
                $.cookie('font_level', level);

                //Work out the new em value and set it.
                var level = (level / 10) + 1;
                $("#col3_content").css("fontSize", level+"em");    

        },

        Reset: function() {
            
            //Reset the level back to 0
            $.FontSizer.SetSize(0);
        
        }

}; 


//*********************************************** Erste-Hilfe-Tipps****************************************************/

function aufInh(z,b,lay){

 //alert(lay+z);
 //b=10;
 //lay = "eh";
 //alert(lay);
  
 
 document.getElementById(lay+z).style.display = 'block';
 document.images['zu'+z].src="http://www.drk.de/mach-mit/pix/layout/pfeilzu.gif";
};


function zuInh(z,b,lay){

 //alert(lay+z);
 //b=10;
 //lay = "eh";
 //alert(lay);
  
 
 document.getElementById(lay+z).style.display = 'none';
 document.images['zu'+z].src="http://www.drk.de/mach-mit/pix/layout/pfeilauf.gif";
};