jQuery.fn.decoder = function (settings) 
{
	return this.each ( function ()
	{
		this.config = {};
		
		config = jQuery.extend (this.config, jQuery.fn.decoder.defaults, settings);
					
		var encText = $(this).attr ("encodedText");

		$(this).css ("cursor", "pointer");
		
		if ( (config.script != "") && (config.script) )
		{
			$(this).html ('<img src="' + config.script + '?t=' + escape (encText) + '&s=' + config.size + '" />');
		}
		
		if (config.mailto)
		{
			$(this).click ( jQuery.fn.decoder.mailto );
		}
	});
};

jQuery.fn.decoder.decodeText = function (txt)
{
	var decoded = "";
	
	eval ("var arr = " + txt + ";");
	
	for (var i = 0; i < arr.length; i++)
	{
 		decoded += String.fromCharCode (arr[i])
	}
	
	return decoded;
}

jQuery.fn.decoder.mailto = function ()
{
	var encText = $(this).attr ("encodedText");
		
	window.location.href = "mailto:" + jQuery.fn.decoder.decodeText (encText) + "?subject=" + this.config.subject + "&body=" + this.config.body;
}


/**
 *
 */
jQuery.fn.decoder.defaults = 
{
	mailto: true,
	script: 'index.php', // wenn leerstring oder false wird kein decoded Image eingefügt
	size: 3,
	subject: '',
	body: ''
};
