// ütf-8

/**
 * function rot18 - Text obfuscation.
 * Adapted from: copyright (C) 2006 Netzreport (netzreport.googlepages.com)
 * @param	(string)	input		Text to obfuscate.
 * @return  (string)	output		Obfuscated text.
 */
function rot18( input )
{
	var output = '';
	for( var ii = 0; ii < input.length; ii++ )
	{
		//letters A-Z (code 65-90) output = output + convertChar( 13, 65, 90, input.charAt( ii ) );
		if( input.charCodeAt( ii ) >= 65 && input.charCodeAt( ii ) <= 90 )
			output = output + String.fromCharCode( 65 + ( ( ( input.charAt( ii ).charCodeAt( 0 ) - 65 ) + 13 ) % ( 13 * 2 ) ) );
		else
		{
			//letters a-z (code 97-122) output = output + convertChar( 13, 97, 122, input.charAt( ii ) );
			if( input.charCodeAt( ii ) >= 97 && input.charCodeAt( ii ) <= 122 )
				output = output + String.fromCharCode( 97 + ( ( ( input.charAt( ii ).charCodeAt( 0 ) - 97 ) + 13 ) % ( 13 * 2 ) ) );
			else
			{
				//numbers 0-9 (code 48-57) output = output + convertChar( 5, 48, 57, input.charAt( ii ) );
				if( input.charCodeAt( ii ) >= 48 && input.charCodeAt( ii ) <= 57 )
					output = output + String.fromCharCode( 48 + ( ( ( input.charAt( ii ).charCodeAt( 0 ) - 48 ) + 5 ) % ( 5 * 2 ) ) );
				else
					output = output + input.charAt( ii );
			}
		}
	}
	return output;
}

/**
 * function maddress - Mail obfuscation, prevents spam.
 * @return  void
 */
$(document).ready(function(){
	$("a[href^='?maddress=']").addClass('clcom_jquery_maddress');
	$("a.clcom_jquery_maddress").mouseover(function(){
		var ahref = $(this).attr("href");
		var maddress = ahref.replace(/\?maddress\=([a-z0-9\._\-]+)\+([a-z]{2,4})\+([a-z0-9\._\-]+)/i, '$3' + '@' + '$1' + '.' + '$2');
		if(ahref != maddress){
			//var atext = $(this).html(); //bugfix ie
			$(this).attr("href", 'mailto:' + maddress);
			//$(this).html(atext); //bugfix ie
		}
	});	
	$("span.clcom_jquery_obfusemaddress").prepend("&#064;");
	$("span.clcom_jquery_obfusemaddress").css("display", "inline");
	$("span.clcom_jquery_obfusemaddress").next("span").css("display", "none");	
});
