//-------------------------translit--------------------------
var rusCh = new Array('À','Á','Â','Ã','Ä','Å','¨', 'Æ', 'Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','×' ,'Ø', 'Ù'  ,'Ü' ,'Û','Ú' ,'Ý','Þ' ,'ß',
                       'à','á','â','ã','ä','å','¸', 'æ', 'ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷' ,'ø', 'ù'  ,'ü' ,'û','ú' ,'ý','þ' ,'\ÿ');
var latCh = new Array('A','B','V','G','D','E','Jo','Zh','Z','I','J','K','L','M','N','O','P','R','S','T','U','F','H','C','Ch','Sh','Sch','\'','Y','\'','E','Ju','Ja',
                       'a','b','v','g','d','e','jo','zh','z','i','j','k','l','m','n','o','p','r','s','t','u','f','h','c','ch','sh','sch',"'",'y',"'",'e','ju','ja');

var t0Last=""
var t1Last=""



function emoticon(text) {var txtarea = document.frmMain.board;text = ' ' + text + ' ';
if (txtarea.createTextRange && txtarea.caretPos) {var caretPos = txtarea.caretPos;caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;txtarea.focus();} else {txtarea.value  += text;txtarea.focus();}}

function convert(textEl){
 var t0 = document.forms[0].board.value;
 var t0l = t0.length;
 var i0=t0Last.length;
 var t1="";

if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();

 if (t0l<i0 || (t0Last != t0.substr(0, i0 )) )
   i0=0;
 else
   t1=document.forms[0].sm.value.substr(0,t1Last.length);

  for(i=i0; i < t0l; i++){
   ch1 = t0.substr(i,1);
   isRus = false;

   for(j=0; j < rusCh.length; j++){
     if(ch1 == rusCh[j]){
         isRus = true;
         break;
         }
   }
   t1 += (isRus) ? latCh[j] : ch1;
  }
  document.forms[0].sm.value = t1;


 t0Last=document.forms[0].board.value;
 t1Last=document.forms[0].sm.value;

//-------------------------translit--------------------------


text = document.all.board.value;
textlgth = count(text);
document.all.texta.value = maxLength - textlgth;
if (textlgth > maxLength) {
changeValues(text, textlgth);
}

  return true;

}




var code = new Array(7);
code[0]='';
code[1]='+3 8050';
code[2]='+3 8095';
code[3]='+3 8066';
code[4]='+3 8095';
code[5]='+3 8099';
code[6]='+3 8099';
code[7]='+3 8067';
code[8]='+3 8097';
code[9]='+3 8098';
code[10]='+3 8067';
code[11]='+3 8097';
code[12]='+3 8096';
code[13]='+3 8063';
code[14]='+3 8093';
code[15]='+3 8068';
code[16]='+3 8068';
code[17]='+3 8068';
code[18]='+3 8068';
code[19]='+3 8039';
code[20]='+3 8044';
code[21]='+3 8048';
code[22]='+3 8062';
code[23]='+3 8044';
code[24]='+3 8068';


function chan(ndx)
{ document.frmMain.oper.value=code[ndx]; }

function chan_1(ndx)
{ document.frmMain.oper_1.value=code[ndx]; }

function chan_2(ndx)
{ document.frmMain.oper_2.value=code[ndx]; }

var maxLength = 140;



function count(str) {
var count = 0;
for (i=0;i<str.length;i++) {
val = str.charCodeAt(i);
if (val >31 || val==13) count++;
}
return count;
}

function find(str,num) {
var count = 0;
var i=0;
while (count < num) {
val = str.charCodeAt(i);
if (val >31 || val==13) count++;
i++;
}
return i;
}

function changeValues(text, textlgth) {
cutoff = find(text,maxLength)
document.all.board.value=text.substring(0,cutoff);
text=document.all.board.value;
textlgth = text.length;
document.all.texta.value = maxLength-count(text);
}



 




 


