// JavaScript Document

var tablica = {};
tablica["160"] = "&nbsp;";
tablica["161"] = "&iexcl;";
tablica["162"] = "&cent;";
tablica["163"] = "&pound;";
tablica["164"] = "&curren;";
tablica["165"] = "&yen;";
tablica["166"] = "&brvbar;";
tablica["167"] = "&sect;";
tablica["168"] = "&uml;";
tablica["169"] = "&copy;";
tablica["170"] = "&ordf;";
tablica["171"] = "&laquo;";
tablica["172"] = "&not;";
tablica["173"] = "&shy;";
tablica["174"] = "&reg;";
tablica["175"] = "&macr;";
tablica["176"] = "&deg;";
tablica["177"] = "&plusmn;";
tablica["178"] = "&sup2;";
tablica["179"] = "&sup3;";
tablica["180"] = "&acute;";
tablica["181"] = "&micro;";
tablica["182"] = "&para;";
tablica["183"] = "&middot;";
tablica["184"] = "&cedil;";
tablica["185"] = "&sup1;";
tablica["186"] = "&ordm;";
tablica["187"] = "&raquo;";
tablica["188"] = "&frac14;";
tablica["189"] = "&frac12;";
tablica["190"] = "&frac34;";
tablica["191"] = "&iquest;";
tablica["215"] = "&times;";
tablica["247"] = "&divide;";
tablica["034"] = "&quot;";
tablica["039"] = "&apos;";
tablica["038"] = "&amp;";
tablica["060"] = "&lt;";
tablica["062"] = "&gt;";


//alert

function asci2ent(id1,id2,id3){

zrodlo = document.getElementById(id1);
cel = document.getElementById(id2);
cel.value = "";
celhtml = document.getElementById(id3);
celhtml.value = "";
tekst = zrodlo.value;
  for (i=0;i<tekst.length;i++){
    tmp = String(tekst.charCodeAt(i));  
    while (tmp.length<3){
      tmp = "0" + tmp;
    }
    cel.value = cel.value + "&#" + tmp + ";";
    if (tablica[tmp]) celhtml.value = celhtml.value + tablica[tmp];
    else celhtml.value = celhtml.value + tekst.charAt(i)
   //break;
  }
    //document.write(tekst.charCodeAt(i) + " ") ;
}

function ent2asci(id1,id2){
  //  alert (String.fromCharCode(116));
    zrodlo = document.getElementById(id1);
    cel = document.getElementById(id2);
    cel.value = "";
    var myregexp = /[0-9]+/g;
    tekst = zrodlo.value;
    var strMatch = "";
    while ((match = myregexp.exec(tekst)) != undefined) {
          strMatch += String.fromCharCode(match[0]);
    }
    
    cel.value = strMatch;
    //document.write(tekst.charCodeAt(i) + " ") ;
}
function htmlent2asci(id1,id2){
  //  alert (String.fromCharCode(116));
    zrodlo = document.getElementById(id1);
    cel = document.getElementById(id2);
    cel.value = "";
    
    tekst = zrodlo.value;

    for (encja in tablica)
    {
      rX = eval('/'+tablica[encja]+'/gi');
      tekst = tekst.replace(rX,String.fromCharCode(encja));
      //alert(tablica[encja]);
    }
          
    
    cel.value = tekst;
    //document.write(tekst.charCodeAt(i) + " ") ;
}


