// ginka, 23.9.2010 (Auszug von mystuff => tools.js)

list1 = new Array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '-', '_', '.', 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, '@');
list2 = new Array(576, 915, 488, 371, 321, 654, 120, 632, 843, 657, 947, 782, 173, 844, 373, 264, 597, 624, 187, 465, 168, 468, 178, 267, 137, 429, 815, 679, 810, 724, 976, 544, 667, 499, 525, 861, 722, 989, 865, 444);

(function(){

    var s = window.location.search.substring(1).split('&');

    if(!s.length) return;

    window.$_GET = {};

    for(var i  = 0; i < s.length; i++) {

        var parts = s[i].split('=');

        window.$_GET[unescape(parts[0])] = unescape(parts[1]);

    }

}())


function stringChange ( string, nmb ) {
	var items = string.split(":");
	
	nmb = parseInt(nmb);
	
	newString = "";
	for( var i = 0; i < items.length; i++)
	{
		check = parseInt(items[i]);
		check += nmb;
		
		for ( var j = 0; j < list2.length; j++ )
		{
			if ( check == list2[j] )
			{
				character = list1[j];
				newString += character;
				break;
			}
		}
	}
	//alert("done: " + newString);
	return newString;
}

function decodeString ( first, second, third, fourth, tagID ) {
	firstPart = stringChange( first, second );
	secondPart = stringChange( third, fourth );
	result = firstPart + '@' + secondPart; 
	//alert(result);
	
	var lang = $_GET['L'];
	
	toReplace = '<a href="mai';
	if ( lang == 1 )
	{
		toReplace += 'lto:' + result + '" title="send em';
		toReplace += 'ail to ' + result + '">' + result + '</a>';
	}
	else
	{
		toReplace += 'lto:' + result + '" title="E-M';
		toReplace += 'ail an ' + result + ' schreiben">' + result + '</a>';
	}
	
	document.getElementById(tagID).innerHTML = toReplace;
}

