(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");	

/* ====== ColorBox ===== */	

	/* Standardaufruf der Colorbox */
	$("a[rel='colorbox']").colorbox();
	
	/* Fotogalerie */
	/*
	$(".fotogalerie").each(function(){
		$(this).find("a").colorbox();
	});
	*/
	var i = 1;
	$(".fotogalerie").each(function(){
		$(this).find("a").colorbox({ rel: 'group'+i, title: function() {
   			var alt = $(this).children('img').attr('alt');
    		return alt;
		}
		});
		i++;
	});

});  // end document.ready
