
function img_loaded(obj){
	if(obj.src.indexOf("fd672f1213c4f8dacf855076.gif")>0)
	{
		obj.src	= decode64(obj.getAttribute('tmp'));
	}
	else
	{
		rmw_img_loaded(obj);
	}
}

function open_pseudo_link(obj){
	window.open(decode64(obj.getAttribute('tmp')), '_blank');
}

var keyStr = "ABCDEFGHIJKLMNOP" +
            "QRSTUVWXYZabcdef" +
            "ghijklmnopqrstuv" +
            "wxyz0123456789+/" +
            "=";

function encode64(input) {
	var output = "";
	var chr1, chr2, chr3 = "";
	var enc1, enc2, enc3, enc4 = "";
	var i = 0;

	do {
		chr1 = input.charCodeAt(i++);
		chr2 = input.charCodeAt(i++);
		chr3 = input.charCodeAt(i++);

		enc1 = chr1 >> 2;
		enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
		enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
		enc4 = chr3 & 63;

		if (isNaN(chr2)) {
			enc3 = enc4 = 64;
		} else if (isNaN(chr3)) {
			enc4 = 64;
		}

		output = output +
		keyStr.charAt(enc1) +
		keyStr.charAt(enc2) +
		keyStr.charAt(enc3) +
		keyStr.charAt(enc4);
		chr1 = chr2 = chr3 = "";
		enc1 = enc2 = enc3 = enc4 = "";
	} while (i < input.length);

	return output;
}

function decode64(input) {
	var output = "";
	var chr1, chr2, chr3 = "";
	var enc1, enc2, enc3, enc4 = "";
	var i = 0;

	var base64test = /[^A-Za-z0-9\+\/\=]/g;

	input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

	do {
		enc1 = keyStr.indexOf(input.charAt(i++));
		enc2 = keyStr.indexOf(input.charAt(i++));
		enc3 = keyStr.indexOf(input.charAt(i++));
		enc4 = keyStr.indexOf(input.charAt(i++));

		chr1 = (enc1 << 2) | (enc2 >> 4);
		chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
		chr3 = ((enc3 & 3) << 6) | enc4;

		output = output + String.fromCharCode(chr1);

		if (enc3 != 64) {
			output = output + String.fromCharCode(chr2);
		}
		if (enc4 != 64) {
			output = output + String.fromCharCode(chr3);
		}

		chr1 = chr2 = chr3 = "";
		enc1 = enc2 = enc3 = enc4 = "";

	} while (i < input.length);

	return output;
}

function highlightWord(node,word) {
	if (node.hasChildNodes) {
		var hi_cn;
		for (hi_cn=0;hi_cn<node.childNodes.length;hi_cn++) {
			highlightWord(node.childNodes[hi_cn],word);
		}
	}

	if (node.nodeType == 3) {
		tempNodeVal = node.nodeValue.toLowerCase();
		tempWordVal = word.toLowerCase();
		if (tempNodeVal.indexOf(tempWordVal) != -1) {
			pn = node.parentNode;
			checkn = pn;
			while (checkn.nodeType != 9 &&
			checkn.nodeName.toLowerCase() != 'body') {
				if (checkn.className.match(/\bnosearchhi\b/)) { return; }
				checkn = checkn.parentNode;
			}
			if (pn.className != "searchword") {
				nv = node.nodeValue;
				ni = tempNodeVal.indexOf(tempWordVal);
				before = document.createTextNode(nv.substr(0,ni));
				docWordVal = nv.substr(ni,word.length);
				after = document.createTextNode(nv.substr(ni+word.length));
				hiwordtext = document.createTextNode(docWordVal);
				hiword = document.createElement("span");
				hiword.className = "searchword";
				hiword.appendChild(hiwordtext);
				pn.insertBefore(before,node);
				pn.insertBefore(hiword,node);
				pn.insertBefore(after,node);
				pn.removeChild(node);
			}
		}
	}
}

function googleSearchHighlight() {
	if (!document.createElement) return;
	ref = document.referrer;
	if (ref.indexOf('?') == -1) return;
	qs = ref.substr(ref.indexOf('?')+1);
	qsa = qs.split('&');
	for (i=0;i<qsa.length;i++) {
		qsip = qsa[i].split('=');
	        if (qsip.length == 1) continue;

        	if ((qsip[0] == 'words' ||
        		qsip[0] == 'text' ) &&
        		(ref.indexOf("http://www.yandex.ru") == 0 || ref.indexOf("http://www.rambler.ru") == 0)
        	) {
				words = yr200706091933(unescape(qsip[1].replace(/\+/g,' '))).split(/\s+/);
                for (w=0;w<words.length;w++) {
	                if(words[w].length > 2)
						highlightWord(document.getElementsByTagName("body")[0],words[w]);
               	}

				words = g200706091933(unescape(qsip[1].replace(/\+/g,' '))).split(/\s+/);
                for (w=0;w<words.length;w++) {
	                if(words[w].length > 2)
						highlightWord(document.getElementsByTagName("body")[0],words[w]);
               	}
	        }


        	if ( (qsip[0] == 'q' ||
        		qsip[0] == 'p' ) &&
        		(ref.indexOf("http://www.yandex.ru") != 0 && ref.indexOf("http://www.rambler.ru") != 0)
        	) {
				words = yr200706091933(unescape(qsip[1].replace(/\+/g,' '))).split(/\s+/);
                for (w=0;w<words.length;w++) {
	                if(words[w].length > 2)
						highlightWord(document.getElementsByTagName("body")[0],words[w]);
               	}

				words = g200706091933(unescape(qsip[1].replace(/\+/g,' '))).split(/\s+/);
                for (w=0;w<words.length;w++) {
	                if(words[w].length > 2)
						highlightWord(document.getElementsByTagName("body")[0],words[w]);
               	}
	        }

	}
}

function yr200706091933 (str){
     if (str == null){ return null;}
     var result = "";
     var o_code = "";
     var i_code = "";
     for (var I=0; I < str.length; I++){
        i_code = str.charCodeAt(I);

        if (i_code == 184){
            o_code = 1105;
        } else if (i_code == 168){
            o_code = 1025;
        } else if (i_code > 191 && i_code < 256){
            o_code = i_code + 848;
        } else {
            o_code = i_code;
        }
        result = result + String.fromCharCode(o_code);
     }

     return result;
}

function g200706091933(s) {
        var tgt = '';
        var len = s.length;
        for(var i=0; i<len; i++) {
                var c = s.charAt(i);
                var x = c.charCodeAt(0);
                if (x < 0x80) {
                        tgt += ""+c;
                        continue;
                } else if ((x & 0xC0) == 0xC0) {
                        var n = 1;
                        while ((x & (0x40 >> n)) > 0) n++;
                        var code = x & (0x3F >> n);
                        for (var k=1; k<=n; k++) {
                                var y = s.charAt(i+k).charCodeAt(0) & 0x3F;
                                code = (code << 6) + y;
                        }
                        i += n;
                        tgt += "" + String.fromCharCode(code);
                } else {
                        tgt += '?';
                }
        }
        return tgt;
}

function trim(str)
{
   return str.replace(/^\s+|\s+$/g,'');
}
/*
var rmw_max_width = 560; // you can change this number, this is the max width in pixels for posted images
var rmw_border_1 = '1px solid gainsboro';
var rmw_border_2 = '2px dotted gainsboro';
var rmw_image_title = '!';

function rmw_go()
{
	var rmw_img_array = document.getElementsByTagName("IMG");
	for (var i = 0; i < rmw_img_array.length; i++)
	{
		var rmw_img = rmw_img_array[i];
		if (String(rmw_img.getAttribute('resizemod')) == 'on')
		{
			if (rmw_wait_for_width && rmw_img.width && !isNaN(rmw_img.width))
			{
				if (rmw_img.width > Number(rmw_max_width))
				{
					rmw_img.setAttribute('resizemod','off');
					rmw_img.onload = null;
					rmw_img.removeAttribute('onload');
					var rmw_clone = rmw_img.cloneNode(false);
					var rmw_parent = rmw_img.parentNode;
					rmw_clone.setAttribute('width',String(rmw_max_width));
					rmw_parent.replaceChild(rmw_clone,rmw_img);
					rmw_make_pop(rmw_clone);
				}
			}
			else if (!rmw_wait_for_width)
			{
				rmw_img.setAttribute('resizemod','off');
				var rmw_clone = rmw_img.cloneNode(false);
				rmw_img.onload = null;
				rmw_img.removeAttribute('onload');
				var rmw_parent = rmw_img.parentNode;
				var rmw_ind = rmw_count++;
				rmw_clone.setAttribute('resizemod',String(rmw_ind));
				rmw_preload[rmw_ind] = new Image();
				rmw_preload[rmw_ind].src = rmw_img.src;
				if (window.showModelessDialog)
				{
					rmw_clone.style.margin = '2px';
				}
				rmw_clone.style.border = rmw_border_1;
				rmw_clone.style.width = '28px';
				rmw_parent.replaceChild(rmw_clone,rmw_img);
			}
		}
	}
	if (!rmw_over && document.getElementById('resizemod'))
	{
		rmw_over = true;
		rmw_go();
	}
	else if (!rmw_over)
	{
		window.setTimeout('rmw_go()',2000);
	}
}
*/

function rmw_img_loaded(rmw_obj)
{
/*
	if (!document.getElementsByTagName || !document.createElement) {return;}
	var rmw_att = rmw_obj.getAttribute('resizemod');
	if(rmw_att == null)
	{
		return 0;	}

	rmw_att = String(rmw_att);
	var rmw_real_width = false;

	if ((rmw_att != 'on') && (rmw_att != 'off'))
	{
		var rmw_index = Number(rmw_att);
		if (rmw_preload[rmw_index].width)
		{
			rmw_real_width = rmw_preload[rmw_index].width;
		}
	}
	else
	{
		rmw_obj.setAttribute('resizemod','off');
		if (rmw_obj.width)
		{
			rmw_real_width = rmw_obj.width;
		}
	}
	if (!rmw_real_width || isNaN(rmw_real_width) || (rmw_real_width <= 0))
	{
		var rmw_rand1 = String(rmw_count++);
		eval("rmw_retry" + rmw_rand1 + " = rmw_obj;");
		eval("window.setTimeout('rmw_img_loaded(rmw_retry" + rmw_rand1 + ")',2000);");
		return;
	}
	if (rmw_real_width > Number(rmw_max_width))
	{
		if (window.showModelessDialog)
		{
			rmw_obj.style.margin = '2px';
		}
		rmw_make_pop(rmw_obj);
	}
	else if (!rmw_wait_for_width)
	{
		rmw_obj.style.width = String(rmw_real_width) + 'px';
		rmw_obj.style.border = '0';
		if (window.showModelessDialog)
		{
			rmw_obj.style.margin = '0px';
		}
	}
	if (window.ActiveXObject) // IE on Mac and Windows
	{
		window.clearTimeout(rmw_timer1);
		rmw_timer1 = window.setTimeout('rmw_refresh_tables()',10000);
	}
*/
}
/*
function rmw_refresh_tables()
{
	var rmw_tables = document.getElementsByTagName("TABLE");
	for (var j = 0; j < rmw_tables.length; j++)
	{
		rmw_tables[j].refresh();
	}
}
function rmw_make_pop(rmw_ref)
{
	rmw_ref.style.border = rmw_border_2;
	rmw_ref.style.width = String(rmw_max_width) + 'px';
	if (!window.opera)
	{
		rmw_ref.onclick = function()
		{
			if (!rmw_pop.closed)
			{
				rmw_pop.close();
			}
			rmw_pop = window.open('about:blank','christianfecteaudotcom',rmw_pop_features);
			rmw_pop.resizeTo(window.screen.availWidth,window.screen.availHeight);
			rmw_pop.moveTo(0,0);
			rmw_pop.focus();
			rmw_pop.location.href = this.src;
		}
	}
	else
	{
		var rmw_rand2 = String(rmw_count++);
		eval("rmw_pop" + rmw_rand2 + " = new Function(\"rmw_pop = window.open('" + rmw_ref.src + "','christianfecteaudotcom','" + rmw_pop_features + "'); if (rmw_pop) {rmw_pop.focus();}\")");
		eval("rmw_ref.onclick = rmw_pop" + rmw_rand2 + ";");
	}
	document.all ? rmw_ref.style.cursor = 'hand' : rmw_ref.style.cursor = 'pointer';
	rmw_ref.title = rmw_image_title;
	if (window.showModelessDialog)
	{
		rmw_ref.style.margin = '0px';
	}
}
if (document.getElementsByTagName && document.createElement) // W3C DOM browsers
{
	rmw_preload = new Array();
	if (window.GeckoActiveXObject || window.showModelessDialog) // Firefox, NN7.1+, and IE5+ for Win
	{
		rmw_wait_for_width = false;
	}
	else
	{
		rmw_wait_for_width = true;
	}
	rmw_pop_features = 'top=0,left=0,width=' + String(window.screen.width-80) + ',height=' + String(window.screen.height-190) + ',scrollbars=1,resizable=1';
	rmw_over = false;
	rmw_count = 1;
	rmw_timer1 = null;
	if (!window.opera)
	{
		rmw_pop = new Object();
		rmw_pop.closed = true;
		rmw_old_onunload = window.onunload;
		window.onunload = function()
		{
			if (rmw_old_onunload)
			{
				rmw_old_onunload();
				rmw_old_onunload = null;
			}
			if (!rmw_pop.closed)
			{
				rmw_pop.close();
			}
		}
	}
	window.setTimeout('rmw_go()',2000);
}
*/

if (window.addEventListener){
	window.addEventListener("load", googleSearchHighlight, false);
}else if (window.attachEvent){
	window.attachEvent("onload", googleSearchHighlight);
}


