﻿// JScript File
/*
Script que se encarga de tracucir caracteres en lenguaje Cirilico a Latino.
Ultima modificacion: viernes 16-mayo-2008.
*/

    //-----------------------
    //TAblas de teclados:
    //-----------------------
        Cirilico = [ // Russian Standard Keyboard
    ["1105", "1025"], ["49", "33"], ["50", "34"], ["51", "8470"], 
    ["52", "59"], ["53", "37"], ["54", "58"], ["55", "63"],
    ["56", "42"], ["57", "40"], ["48", "41"], ["45", "95"], 
    ["61", "43"], ["Bksp", "Bksp"], 
    ["9", "9"], ["1081", "1049"], ["1094", "1062"], ["1091", "1059"], 
    ["1082", "1050"], ["1077", "1045"], ["1085", "1053"], ["1075", "1043"], 
    ["1096", "1064"], ["1097", "1065"], ["1079", "1047"], ["1093", "1061"], 
    ["1098", "1066"], ["Enter", "Enter"], ["Caps", "Caps"], ["1092", "1060"], 
    ["1099", "1067"], ["1074", "1042"], ["1072", "1040"], ["1087", "1055"], 
    ["1088", "1056"], ["1086", "1054"], ["1083", "1051"], ["1076", "1044"], 
    ["1078", "1046"], ["1101", "1069"], ["92", "47"],["Shift", "Shift"], 
    ["47", "124"], ["1103", "1071"], ["1095", "1063"],["1089", "1057"], 
    ["1084", "1052"], ["1080", "1048"], ["1090", "1058"], ["1100", "1068"], 
    ["1073", "1041"], ["1102", "1070"], ["46", "44"], ["Shift", "Shift"],
    ["32", "32"]
  ];
  
      Spanish = [ // Spanish (Spain) Standard Keyboard
    ["\u00EB", "\u00CB"], ["1", "!"], ["2", /*antes \\" */''], ["3", "\u2116"], 
    ["4", ";"], ["5", "%"], ["6", ":"], ["7", "?"], 
    ["8", "*"], ["9", "("], ["0", ")"], ["-", "_"],
    ["=", "+"], ["Bksp", "Bksp"],
    /*antes: tab*/[" ", " "], /*antes: j*/["y", "Y"], /*antes: c */["ts", "TS"], /*antes: g*/["u", "U"], 
    ["k", "K"], ["e", "E"], ["n", "N"], ["g", "G"], 
    ["sh", /*antes: \u0060*/"SH"], [/*antes: u\0161 u\010B  antes: ''*/"sht", "SHT"], ["z", "Z"], /*antes x*/["h","H"],
    /*antes: \u0022*/['', ''], ["Enter", "Enter"], ["Caps", "Caps"], ["f", "F"], 
    /*antes: y */["i", "I"], ["v", "V"], ["a", "A"], ["p", "P"], 
    ["r", "R"], ["o", "O"], ["l", "L"], ["d", "D"],
    /*antes: \u017E, \u017D*/["zh", "ZH"], ["e", "E"], ["\\", "/"], ["Shift", "Shift"], 
    ["/", "|"], ["ya", "YA"], [/*antes u\010D*/"u\010D", "u\010C"], ["s", "S"], 
    ["m", "M"], /**/["i", "I"], ["t", "T"], /*antes: ' */["",""], 
    ["b", "B"], /*antes: ju*/["yu", "YU"],[".", ","], ["Shift", "Shift"],
    [" ", " "]
    ];
    
//Funcion que realiza la traduccion.
function cirilico2latin(text)
  {
    var salida="";
    for(i=0;i<text.length; i++)
    {
       var seleccion = 0;
       for(a=0;a<Cirilico.length;a++)
       {
            if(Cirilico[a][0]==String(text.charCodeAt(i)))
            {
                salida = salida + Spanish[a][0];
                seleccion = 1;
            }else if(Cirilico[a][1]==String(text.charCodeAt(i)))
            {    
                salida = salida + Spanish[a][1];
                seleccion = 1; 
            }
       }
       if(seleccion==0) {salida = salida + text.charAt(i);}
    }
    return salida;
  }


