(function($) {
	$.fn.defuscate = function (settings) {
		settings = jQuery.extend({
			at: " 'at' ", // falls vorhanden, ersetze mit @
			dot: " 'punkt' ", // falls vorhanden, ersetze mit .
			useTitle: true // falls vorhanden, nutze das title-Attribut als Text anstatt der Emailadresse
		}, settings);
		
		return this.each(function() {
			var thisNode = $(this),
				email = thisNode.text().replace(settings.at, "@").replace(settings.dot, "."),
				a = document.createElement("a");
			a.setAttribute("href", "mailto:" + email);
			a.appendChild(document.createTextNode(settings.useTitle && this.title ? this.title : email));
			thisNode.empty().append(a);
		});
	};
})(jQuery);


$(document).ready(function(){

/* ====== E-Mail Defuscate ===== */	
	$('span.rewrite').defuscate().removeClass("rewrite");													 

});  // end document.ready

$(document).ready(function() {
 $('#items p').css({'padding':'0px 10px'});
 $('#home').css({'padding-top':'18px'});
 $('#contact').css({'padding-top':'18px'});
 $('#imprint').css({'padding-top':'8px'});
 $('#items div').addClass('item');
 $('#insertLinks').append(' &middot;   <a href="#contact" class="showContact">Kontakt aufnehmen</a>  &middot; <a href="#imprint" class="showImprint">Impressum</a>');

 $('#backgroundImg').ready(function() {
  $('body').css({'background-image':'url(images/bg-internetagentur-freising.jpg)', 'background-position':'50% 0','background-repeat':'no-repeat'});
 });
 

});

$(document).ready(function() {

 $('.showHome').click(function(event){
  if($('#home').is(':hidden')) {
   $('div.item').slideUp('fast');
   $('#home').slideDown('slow');
  }
 });

 $('div#content img').click(function(event){
  if($('#home').is(':hidden')) {
   $('div.item').slideUp('fast');
   $('#home').slideDown('slow');
  }
 });

 $('.showImprint').click(function(event){
  if($('#imprint').is(':hidden')) {
   $('div.item').slideUp('fast');
   $('#imprint').slideDown('slow');
  }
 });

 $('.showContact').click(function(event){
  if($('#contact').is(':hidden')) {
   $('div.item').slideUp('fast');
   $('#contact').slideDown('slow');
  }
 });

});
