//<SCRIPT language="JavaScript" type="text/javascript">
//<!--

/*****************************************************************

   Projectname: translit.ru JavaScript source code
   Author: Igor Ilin (Èãîðü Èëüèí) <info@translit.ru>
   Author's website: http://www.translit.ru/programming
   Copyright (c): 2002-2006 Igor Ilin (Èãîðü Èëüèí), all rights reserved

   * This program is distributed in the hope that it will
   * be useful, but WITHOUT ANY WARRANTY; without even the
   * implied warranty of MERCHANTABILITY or FITNESS FOR A
   * PARTICULAR PURPOSE.

   Description: the JavaScript code performs the transliteration and supports the virtual keyboard functionality on the user's browser side. The code you see on your screen is the result of server side JavaScript source code combing for the particular user's browser, such as Intenet Explore, Mozilla Firefox, Opera and others.

******************************************************************/

var language = 0;
var prelanguage = 0;

var processhtmltags = 0;
var processbbcodetags = 0;

function setfoc()
{
	document.getElementById('message').focus();
	return false;
}

function highlightall()
{
	document.getElementById('message').focus();
	document.getElementById('message').select();
	return false;
}

function getselectedtext()
{
	document.addmessage.selsubject.value = gettextareaval(document.getElementById('message'));
	return false;
}

function shortcut_service(buttonname)
{
	getselectedtext();
	with(document.forms.addmessage)
	{
		action="tools/redirect.php?"+buttonname;
		submit();
		action="tools/redirect.php";
	}
	return false;
}

function kukish(name,cval) // set cookies
{
	var cexpire = new Date();
	var year = cexpire.getTime() + (365 * 24 * 60 * 60 * 1000);
	cexpire.setTime(year);
	document.cookie = name+"="+cval+"; expires=" + cexpire.toGMTString();
}

function services()
{
	open("/info/services.shtml", "displayWindow", "scrollbars=yes,status=no,toolbar=no,menubar=no");
	return false;
}


var tra = new Array();
var abc2 = new Array();
var abc1 = new Array();

tra[String.fromCharCode(97)] = new Array ('û+','É+','Û+','é+','Û','é','û','É','','');
abc2[String.fromCharCode(97)] = new Array ('ûà','Éà','Ûà','éà','ß','ÿ','ÿ','ß','à','a');

tra[String.fromCharCode(98)] = new Array ('','');
abc2[String.fromCharCode(98)] = new Array ('á','b');

tra[String.fromCharCode(118)] = new Array ('','');
abc2[String.fromCharCode(118)] = new Array ('â','v');

tra[String.fromCharCode(103)] = new Array ('','');
abc2[String.fromCharCode(103)] = new Array ('ã','g');

tra[String.fromCharCode(100)] = new Array ('','');
abc2[String.fromCharCode(100)] = new Array ('ä','d');

tra[String.fromCharCode(101)] = new Array ('É+','é+','É','é','','');
abc2[String.fromCharCode(101)] = new Array ('Éå','éå','Ý','ý','å','e');

tra[String.fromCharCode(111)] = new Array ('û+','É+','Û+','é+','Û','û','É','é','','');
abc2[String.fromCharCode(111)] = new Array ('ûî','Éî','Ûî','éî','¨','¸','¨','¸','î','o');

tra[String.fromCharCode(246)] = new Array ('','');
abc2[String.fromCharCode(246)] = new Array ('¸','ö');

tra[String.fromCharCode(104)] = new Array ('ñõ+','Ñõ+','ç+','Ñõ','ñ+','ø+','Ö+','Ø+','Ñ+','ñõ','ö+','Ç+','Ø','ñ','ö','ø','Ç','Ñ','Ö','ç','','');
abc2[String.fromCharCode(104)] = new Array ('ñõõ','Ñõõ','çõ','Ù','ñõ','øõ','Öõ','Øõ','Ñõ','ù','öõ','Çõ','Ù','ø','÷','ù','Æ','Ø','×','æ','õ','h');

tra[String.fromCharCode(122)] = new Array ('','');
abc2[String.fromCharCode(122)] = new Array ('ç','z');

tra[String.fromCharCode(105)] = new Array ('','');
abc2[String.fromCharCode(105)] = new Array ('è','i');

tra[String.fromCharCode(106)] = new Array ('','');
abc2[String.fromCharCode(106)] = new Array ('é','j');

tra[String.fromCharCode(107)] = new Array ('','');
abc2[String.fromCharCode(107)] = new Array ('ê','k');

tra[String.fromCharCode(108)] = new Array ('','');
abc2[String.fromCharCode(108)] = new Array ('ë','l');

tra[String.fromCharCode(109)] = new Array ('','');
abc2[String.fromCharCode(109)] = new Array ('ì','m');

tra[String.fromCharCode(110)] = new Array ('','');
abc2[String.fromCharCode(110)] = new Array ('í','n');

tra[String.fromCharCode(112)] = new Array ('','');
abc2[String.fromCharCode(112)] = new Array ('ï','p');

tra[String.fromCharCode(114)] = new Array ('','');
abc2[String.fromCharCode(114)] = new Array ('ð','r');

tra[String.fromCharCode(115)] = new Array ('','');
abc2[String.fromCharCode(115)] = new Array ('ñ','s');

tra[String.fromCharCode(116)] = new Array ('','');
abc2[String.fromCharCode(116)] = new Array ('ò','t');

tra[String.fromCharCode(117)] = new Array ('û+','É+','Û+','é+','Û','é','û','É','','');
abc2[String.fromCharCode(117)] = new Array ('ûó','Éó','Ûó','éó','Þ','þ','þ','Þ','ó','u');

tra[String.fromCharCode(102)] = new Array ('','');
abc2[String.fromCharCode(102)] = new Array ('ô','f');

tra[String.fromCharCode(120)] = new Array ('','');
abc2[String.fromCharCode(120)] = new Array ('õ','x');

tra[String.fromCharCode(99)] = new Array ('','');
abc2[String.fromCharCode(99)] = new Array ('ö','c');

tra[String.fromCharCode(119)] = new Array ('','');
abc2[String.fromCharCode(119)] = new Array ('ù','w');

tra[String.fromCharCode(35)] = new Array ('ú+','ú','','');
abc2[String.fromCharCode(35)] = new Array ('úú','Ú','ú','#');

tra[String.fromCharCode(121)] = new Array ('','');
abc2[String.fromCharCode(121)] = new Array ('û','y');

tra[String.fromCharCode(39)] = new Array ('ü+','ü','','');
abc2[String.fromCharCode(39)] = new Array ('üü','Ü','ü','\'');

tra[String.fromCharCode(228)] = new Array ('','');
abc2[String.fromCharCode(228)] = new Array ('ý','ä');

tra[String.fromCharCode(252)] = new Array ('','');
abc2[String.fromCharCode(252)] = new Array ('þ','ü');

tra[String.fromCharCode(65)] = new Array ('Û+','É+','Û','É','','');
abc2[String.fromCharCode(65)] = new Array ('ÛÀ','ÉÀ','ß','ß','À','A');

tra[String.fromCharCode(66)] = new Array ('','');
abc2[String.fromCharCode(66)] = new Array ('Á','B');

tra[String.fromCharCode(86)] = new Array ('','');
abc2[String.fromCharCode(86)] = new Array ('Â','V');

tra[String.fromCharCode(71)] = new Array ('','');
abc2[String.fromCharCode(71)] = new Array ('Ã','G');

tra[String.fromCharCode(68)] = new Array ('','');
abc2[String.fromCharCode(68)] = new Array ('Ä','D');

tra[String.fromCharCode(69)] = new Array ('É+','É','','');
abc2[String.fromCharCode(69)] = new Array ('ÉÅ','Ý','Å','E');

tra[String.fromCharCode(79)] = new Array ('Û+','É+','Û','É','','');
abc2[String.fromCharCode(79)] = new Array ('ÛÎ','ÉÎ','¨','¨','Î','O');

tra[String.fromCharCode(214)] = new Array ('','');
abc2[String.fromCharCode(214)] = new Array ('¨','Ö');

tra[String.fromCharCode(72)] = new Array ('ÑÕ+','Ö+','ÑÕ','Ñ+','Ç+','Ø+','Ø','Ö','Ñ','Ç','','');
abc2[String.fromCharCode(72)] = new Array ('ÑÕÕ','ÖÕ','Ù','ÑÕ','ÇÕ','ØÕ','Ù','×','Ø','Æ','Õ','H');

tra[String.fromCharCode(90)] = new Array ('','');
abc2[String.fromCharCode(90)] = new Array ('Ç','Z');

tra[String.fromCharCode(73)] = new Array ('','');
abc2[String.fromCharCode(73)] = new Array ('È','I');

tra[String.fromCharCode(74)] = new Array ('','');
abc2[String.fromCharCode(74)] = new Array ('É','J');

tra[String.fromCharCode(75)] = new Array ('','');
abc2[String.fromCharCode(75)] = new Array ('Ê','K');

tra[String.fromCharCode(76)] = new Array ('','');
abc2[String.fromCharCode(76)] = new Array ('Ë','L');

tra[String.fromCharCode(77)] = new Array ('','');
abc2[String.fromCharCode(77)] = new Array ('Ì','M');

tra[String.fromCharCode(78)] = new Array ('','');
abc2[String.fromCharCode(78)] = new Array ('Í','N');

tra[String.fromCharCode(80)] = new Array ('','');
abc2[String.fromCharCode(80)] = new Array ('Ï','P');

tra[String.fromCharCode(82)] = new Array ('','');
abc2[String.fromCharCode(82)] = new Array ('Ð','R');

tra[String.fromCharCode(83)] = new Array ('','');
abc2[String.fromCharCode(83)] = new Array ('Ñ','S');

tra[String.fromCharCode(84)] = new Array ('','');
abc2[String.fromCharCode(84)] = new Array ('Ò','T');

tra[String.fromCharCode(85)] = new Array ('Û+','É+','Û','É','','');
abc2[String.fromCharCode(85)] = new Array ('ÛÓ','ÉÓ','Þ','Þ','Ó','U');

tra[String.fromCharCode(70)] = new Array ('','');
abc2[String.fromCharCode(70)] = new Array ('Ô','F');

tra[String.fromCharCode(88)] = new Array ('','');
abc2[String.fromCharCode(88)] = new Array ('Õ','X');

tra[String.fromCharCode(67)] = new Array ('','');
abc2[String.fromCharCode(67)] = new Array ('Ö','C');

tra[String.fromCharCode(87)] = new Array ('','');
abc2[String.fromCharCode(87)] = new Array ('Ù','W');

tra[String.fromCharCode(89)] = new Array ('','');
abc2[String.fromCharCode(89)] = new Array ('Û','Y');

tra[String.fromCharCode(196)] = new Array ('','');
abc2[String.fromCharCode(196)] = new Array ('Ý','Ä');

tra[String.fromCharCode(220)] = new Array ('','');
abc2[String.fromCharCode(220)] = new Array ('Þ','Ü');

abc1['à'] = 'a';
abc1['á'] = 'b';
abc1['â'] = 'v';
abc1['ã'] = 'g';
abc1['ä'] = 'd';
abc1['å'] = 'e';
abc1['¸'] = 'jo';
abc1['æ'] = 'zh';
abc1['ç'] = 'z';
abc1['è'] = 'i';
abc1['é'] = 'j';
abc1['ê'] = 'k';
abc1['ë'] = 'l';
abc1['ì'] = 'm';
abc1['í'] = 'n';
abc1['î'] = 'o';
abc1['ï'] = 'p';
abc1['ð'] = 'r';
abc1['ñ'] = 's';
abc1['ò'] = 't';
abc1['ó'] = 'u';
abc1['ô'] = 'f';
abc1['õ'] = 'h';
abc1['ö'] = 'c';
abc1['÷'] = 'ch';
abc1['ø'] = 'sh';
abc1['ù'] = 'w';
abc1['ú'] = '#';
abc1['û'] = 'y';
abc1['ü'] = '\'';
abc1['ý'] = 'je';
abc1['þ'] = 'ju';
abc1['ÿ'] = 'ja';
abc1['À'] = 'A';
abc1['Á'] = 'B';
abc1['Â'] = 'V';
abc1['Ã'] = 'G';
abc1['Ä'] = 'D';
abc1['Å'] = 'E';
abc1['¨'] = 'JO';
abc1['Æ'] = 'ZH';
abc1['Ç'] = 'Z';
abc1['È'] = 'I';
abc1['É'] = 'J';
abc1['Ê'] = 'K';
abc1['Ë'] = 'L';
abc1['Ì'] = 'M';
abc1['Í'] = 'N';
abc1['Î'] = 'O';
abc1['Ï'] = 'P';
abc1['Ð'] = 'R';
abc1['Ñ'] = 'S';
abc1['Ò'] = 'T';
abc1['Ó'] = 'U';
abc1['Ô'] = 'F';
abc1['Õ'] = 'H';
abc1['Ö'] = 'C';
abc1['×'] = 'CH';
abc1['Ø'] = 'SH';
abc1['Ù'] = 'W';
abc1['Ú'] = '##';
abc1['Û'] = 'Y';
abc1['Ü'] = '\'\'';
abc1['Ý'] = 'JE';
abc1['Þ'] = 'JU';
abc1['ß'] = 'JA';
var textareafontsize = 14; // warning: the value is also defined in the css-file !!!
var textreafontwidth = 7; // the width of the text is supposed to be 7 !!!

function addchar(result)
{
	setfoc();
	var tt = window.document.getElementById('message');
	var p1 = tt.selectionStart;
	tt.value = tt.value.substring(0, p1)+result+tt.value.substring(tt.selectionEnd);
	tt.setSelectionRange(p1+result.length,p1+result.length);
	return false;
}

function setfoc_end()
{
	setfoc();
	var tt = window.document.getElementById('message');
	tt.setSelectionRange(tt.value.length,tt.value.length);
	return false;
}

function setlangpicture()
{
	document.ruslat.src = swrus_src;
}

function changelanguage()
{
	if (!language) {
		language=1;
		document.images['ruslat'].src = swlat_src;
	}
	else {
		language=0;
		document.images['ruslat'].src = swrus_src;
	}
	setfoc();
	return false;
}

function setlat()
{
	language=1;
	document.images['ruslat'].src = swlat_src;
	setfoc();
	return false;
}

function setrus()
{
	language=0;
	document.images['ruslat'].src = swrus_src;
	setfoc();
	return false;
}

function AkeyIsDown(evnt)
{
	var code = 0;
	code = evnt.keyCode;
	if ((code==13)&&(evnt.altKey)) {
		document.forms.addmessage.target='_blank';shortcut_service('orfochk');
		evnt.preventDefault();
	}
	if ((code==13)&&(evnt.ctrlKey)) {
		document.forms.addmessage.target='_blank';shortcut_service('orfochk');
		evnt.preventDefault();
	}
	if (code==27) {
		changelanguage();
		evnt.preventDefault();
	}
	return false;
}

function translate_letter(evnt)
{
	var code = void 0;

	var code = evnt.charCode ? evnt.charCode : void 0;
	if (!evnt.which)
	{
		return true;
	}
	var txt = String.fromCharCode(code);
	if (processhtmltags&&(txt=='<')) {
		prelanguage=language; setlat();
	}
	if (processhtmltags&&(txt=='>')) {
		if(prelanguage) setlat(); else setrus();
	}
	if (processbbcodetags&&(txt=='[')) {
		prelanguage=language; setlat();
	}
	if (processbbcodetags&&(txt==']'))
	{
		if(prelanguage) setlat(); else setrus();
	}
        if (code&&code>33&&(!(evnt.ctrlKey||evnt.altKey)))
        {
        	if (evnt.preventDefault)
        	{
        		evnt.preventDefault();
        	}
        	txt = String.fromCharCode(code);
        	tt = window.document.getElementById('message');
        	var pretxt = tt.value.substring(0, tt.selectionStart);
        	var result = "";
        	var pXpix = tt.scrollTop;
        	var pYpix = tt.scrollLeft;
        	if (language)
        	{
        		result = pretxt+translatesymboltolatin(txt);  // to latin
        	}
        	else
        	{
        		result = translatesymboltocyrillic(pretxt+txt); // to cyrillic
        	}
        	var therest = tt.value.substr(tt.selectionEnd);
        	tt.value = result+therest;
        	tt.setSelectionRange(result.length,result.length);
        	var vv = therest.search(/[\n\s]/);
		var r = laststringlength(result)*(textreafontwidth+1)-pYpix-tt.clientWidth/2;
		var dd = Math.abs(2*r)<tt.clientWidth?0:r-tt.clientWidth/2*(r>0?1:-1);
		tt.scrollLeft = pYpix+dd+(dd==0?0:(dd>0)?2:-textreafontwidth-1);
		r = (nofstrings(result+(vv==-1?therest:therest.substring(0, vv)),tt.clientWidth, textreafontwidth)-0.5)*(textareafontsize+3)-pXpix-tt.clientHeight/2;
		tt.scrollTop = pXpix+(Math.abs(2*r)<(tt.clientHeight-textareafontsize-3)?0:r-(tt.clientHeight-textareafontsize-3)/2*(r>0?1:-1));
		setfoc();
        }
        return false;
}


function translatesymboltocyrillic(txt)
{
	var pretxt = txt.substr(0,txt.length-1);
	var last = txt.substr(txt.length-1,1);
	var lat = tra[last];
	var rus = abc2[last];
	if (lat)
	{
		for (var ii=0; ii<lat.length; ii++)
		{
			var pos = pretxt.length>lat[ii].length?(pretxt.length-lat[ii].length):0;
			if (lat[ii]==pretxt.substr(pos,pretxt.length-pos))
			{
				return pretxt.substr(0,pretxt.length-lat[ii].length)+rus[ii];
			}
		}
	}
	return txt;
}

function translatesymboltolatin(symb)
{
	return abc1[symb]?abc1[symb]:symb;
}

function translateAlltoCyrillic()
{
	var inloop=1;
	var tt = window.document.getElementById('message');
	var p1 = tt.selectionStart;
	var p2 = tt.selectionEnd;
	var preval = "";
	var postval="";
	if (p1==p2) {txt = tt.value;}
	else
	{
		preval = tt.value.substring(0, p1);
		txt = tt.value.substring(p1,p2);
		postval = tt.value.substring(p2);
	}
	var txtnew = "";
	if ((!processhtmltags)&&(!processbbcodetags))
	{
		txtnew = translateStringtoCyrillic(txt);
	}
	else
	{
		var htt1,pbb1,t1,t2,txt1,txt2,tag_open,tag_close;
		var noinputtag=0;
		if (processhtmltags) {tag_open="<";tag_close=">";}
		if (processbbcodetags) {tag_open="[";tag_close="]";}
		while(inloop)
		{
			if (processhtmltags&&processbbcodetags)
			{
				htt1 = txt.indexOf("<");
				pbb1 = txt.indexOf("[");
				if (pbb1==htt1) {noinputtag=1}
				if (pbb1==-1) {pbb1=txt.length;}
				if (htt1==-1) {htt1=txt.length;}
				if (htt1<pbb1) {t1=htt1; tag_close=">";} else {t1=pbb1; tag_close="]";}
			}
			else
			{
				t1 = txt.indexOf(tag_open);
				if (t1==-1) noinputtag=1;
			}
			if (noinputtag) {inloop=0;t1=txt.length;t2=txt.length;}
			else
			{
				txt2=txt.substring(t1,txt.length);
				t2=txt2.indexOf(tag_close);
				//if (t2==-1) {t2=txt.length; inloop=0;} else {t2=t2+t1+1};
				if (t2==-1) {t2=t1+1} else {t2=t2+t1+1};
			}
			txt1 = txt.substring(0,t1);
			txt2 = txt.substring(t1,t2);
			txt = txt.substring(t2,txt.length);
			txtnew = txtnew+translateStringtoCyrillic(txt1)+txt2;
		}
	}
	tt.value = preval+txtnew+postval;
	if (p1!=p2) {tt.setSelectionRange(p1+txtnew.length,p1+txtnew.length);}
	tt.focus();
	return false;
}

function translateStringtoCyrillic(thestringlat)
{
	var symbb,fromm,howmuch,thestringcyr="";
	for (kk=0;kk<thestringlat.length;kk++)
	{
		thestringcyr = translatesymboltocyrillic(thestringcyr+thestringlat.substr(kk,1))
	}
	return thestringcyr;
}

function translateAlltoLatin()
{
	tt = window.document.getElementById('message');
	p1 = tt.selectionStart; p2 = tt.selectionEnd;
	var preval = ""; var postval="";
	if (p1==p2) {txt = tt.value;}
	else
	{
		preval = tt.value.substring(0, p1);
		txt = tt.value.substring(p1,p2);
		postval = tt.value.substring(p2);
	}
	txtnew="";
	var symb = "";
	for (kk=0;kk<txt.length;kk++)
	{
		symb = translatesymboltolatin(txt.substr(kk,1));
		txtnew = txtnew.substr(0,txtnew.length) + symb;
	}
	tt.value = preval+txtnew+postval;
	if (p1!=p2) {tt.setSelectionRange(p1+txtnew.length,p1+txtnew.length);}
	tt.focus();
	return false;
}

function gettextareaval(thetextarea)
{
	with (thetextarea)
	{
		if (selectionStart==selectionEnd) return value;
		return value.substring(selectionStart,selectionEnd);
	}
}

function btcvalue(thetextarea)
{
	return thetextarea.value.substring(0,thetextarea.selectionEnd);
}

function Cleartrans()
{
	var textinputform = window.document.getElementById('message');
	var p1 = textinputform.selectionStart;
	var p2 = textinputform.selectionEnd;
	if (p1==p2) {
		textinputform.value="";
	} else {
		textinputform.value = textinputform.value.substring(0, p1)+textinputform.value.substring(p2);
	}
	textinputform.focus();
	textinputform.setSelectionRange(p1,p1);
	return false;
}

function clipboardinfo()
{
	open("/info/clipboard.shtml", "displayWindow", "scrollbars=yes,status=no,toolbar=no,menubar=no");
	setfoc();
	return false;
}

if (document.images) {
	swrus_src = new Image;
	swrus_src = "pict/swrus.gif";
	swlat_src = new Image; swlat_src = "pict/swlat.gif";
}

function nofstrings(thetext, txtareawidthpix, symbolwidth)
{
	var maxstrlengthallowed = Math.floor(txtareawidthpix/(symbolwidth+1))+1;
	var tt, pp, ppp, tuntil, ii;
	var t2 = thetext.split("\n");
	var s = t2.length;
	for (ii=0; ii<t2.length; ii++)
	{
		tt=t2[ii]+" ";
		pp = 0;
		tuntil = maxstrlengthallowed;
		while(tt.indexOf(" ",pp)!=-1)
		{
			ppp = pp;
			pp = tt.indexOf(" ",pp)+1;
			if (pp>tuntil&&pp-ppp-1)
			{
				tuntil = ppp+maxstrlengthallowed;
				if (pp<tuntil)
				{
					pp = ppp;
				}
				s++;
			}
		}
	}
	return s;
}

function laststringlength(thetext)
{
	var t = thetext.replace(/\n/g, " ");
	return thetext.replace(/\n/g, " ").length-thetext.replace(/\n/g, " ").lastIndexOf(" ")-1;
}

function lettcount()
{
	var vv = gettextareaval(document.getElementById('message'));
	var txtt = btcvalue(document.getElementById('message'));
	document.addmessage.letterscounter2.value = txtt.replace(/\r/g,'').length;
	document.addmessage.letterscounter.value = vv.replace(/\r/g,'').length;
	return false;
}

var undotext = new Array('');
var undodepth = 10;

function savechanges()
{
	var undotext_last = undotext.length?undotext[undotext.length-1]:'';
	if (undotext_last != document.getElementById('message').value)
	{
		with (document.addmessage.rtext)
		{
			if (value == '> ')
			{
				value = '<-';
			}
		}
		undotext.push(document.getElementById('message').value);
		if (undotext.length > (undodepth+1))
		{
			undotext.shift();
		}
	}
	return false;
}

function common_string(s1,s2)
{
	var count1 = 0;
	while((s1.charAt(count1) == s2.charAt(count1))&&(count1 < s1.length)&&(count1 < s2.length))
	{
		count1++;
	}
	var count2 = 0;
	while((s1.charAt(s1.length-count2-1) == s2.charAt(s2.length-count2-1))&&(count2 < s1.length-count1)&&(count2 < s2.length-count1))
	{
		count2++;
	}
	return s1.substring(0,s1.length-count2);
}

function recovertext()
{
	if (undotext.length > 1)
	{

		var tt = document.getElementById('message');
        	var pXpix = tt.scrollTop;
        	var pYpix = tt.scrollLeft;
		tt.value = undotext[undotext.length-2];
		var result = common_string(undotext[undotext.length-2],undotext[undotext.length-1]);
		tt.setSelectionRange(result.length,result.length);
		var r = laststringlength(result)*(textreafontwidth+1)-pYpix-tt.clientWidth/2;
		var dd = Math.abs(2*r)<tt.clientWidth?0:r-tt.clientWidth/2*(r>0?1:-1);
		tt.scrollLeft = pYpix+dd+(dd==0?0:(dd>0)?2:-textreafontwidth-1);
		r = (nofstrings(result,tt.clientWidth, textreafontwidth)-0.5)*(textareafontsize+3)-pXpix-tt.clientHeight/2;
		tt.scrollTop = pXpix+(Math.abs(2*r)<(tt.clientHeight-textareafontsize-3)?0:r-(tt.clientHeight-textareafontsize-3)/2*(r>0?1:-1));
		undotext.pop();
	}
	if (undotext.length < 2)
	{
		document.addmessage.rtext.value = '> ';
	}
	return false;
}
//-->
//</SCRIPT>