
// Written by Dmitry Zhemchuzhin

// This script is designed to make spam robots' task harder.

//**************** START DATA SECTION ********************

//***************** END DATA SECTION *********************

var LNKCodec_endTag;

// If this is going to be a full link, then HTML between start and end LNKCodec tags
// (which supposed to be an image) is hidden and a link is created, otherwise,
// a link is created over existing HTML

function LNKCodec_startLink(code,text) {
	var address = LNKCodec_decodeString(code);
	document.write('<a href="' + address + '">' + text + '</a>');
	document.write('<span style="display:none">');
	LNKCodec_endTag = '</span>';
}

function LNKCodec_end() {
	document.write(LNKCodec_endTag);
}

// This should be called to generate an encoded string
function LNKCodec_showEncoded(string) {
	document.write(LNKCodec_encodeString(string));
}

function LNKCodec_encodeString(string) {
	var result = "";
	for(var i=0; i<string.length; i++) {
		result += LNKCodec_encodeCharacter(string.charAt(i));
	}
	return result;
}

function LNKCodec_decodeString(string) {
	var result = "";
	for(var i=0; i<string.length; i+=2) {
		result += LNKCodec_decodeCharacter(string.substring(i,i + 2));
	}
	return result;
}

function LNKCodec_encodeCharacter(ch) {
	var num = LNKCodec_getCharCode(ch);
	var c1 = String.fromCharCode((num & 0xF0) / 0x10 + 0x61);
	var c2 = String.fromCharCode((num & 0xF) + 0x61);
	return c1 + c2;
}

function LNKCodec_decodeCharacter(char_pair) {
	var num1 = LNKCodec_getCharCode(char_pair.charAt(0)) - 0x61;
	var num2 = LNKCodec_getCharCode(char_pair.charAt(1)) - 0x61;
	return String.fromCharCode(num1 * 0x10 + num2);
}

function LNKCodec_getCharCode(ch) {
	for(var i=0x20; i<0x80; i++) {
		if(ch == String.fromCharCode(i)) return i;
	}
	return 0;
}

