is=new Is();  

function Is ()
{
    var agt=navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    this.nav2 = (this.nav && (this.major == 2));
    this.nav3 = (this.nav && (this.major == 3));
    this.nav4 = (this.nav && (this.major == 4));
    this.nav4up = (this.nav && (this.major >= 4));
    this.navonly      = (this.nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    this.nav6 = (this.nav && (this.major == 5));
    this.nav6up = (this.nav && (this.major >= 5));
    this.gecko = (agt.indexOf('gecko') != -1);
    this.ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    this.ie3    = (this.ie && (this.major < 4));
    this.ie4    = (this.ie && (this.major == 4) && (agt.indexOf("msie 4")!=-1) );
    this.ie4up  = (this.ie && (this.major >= 4));
    this.ie5    = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    this.ie5_5  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.5") !=-1));
    this.ie5up  = (this.ie && !this.ie3 && !this.ie4);
    this.ie5_5up =(this.ie && !this.ie3 && !this.ie4 && !this.ie5);
    this.ie6    = (this.ie && (this.major == 4) && (agt.indexOf("msie 6.")!=-1) );
    this.ie6up  = (this.ie && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5);
    this.aol   = (agt.indexOf("aol") != -1);
    this.aol3  = (this.aol && this.ie3);
    this.aol4  = (this.aol && this.ie4);
    this.aol5  = (agt.indexOf("aol 5") != -1);
    this.aol6  = (agt.indexOf("aol 6") != -1);
    this.opera = (agt.indexOf("opera") != -1);
    this.opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
    this.opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
    this.opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
    this.opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    this.opera5up = (this.opera && !this.opera2 && !this.opera3 && !this.opera4);
    this.webtv = (agt.indexOf("webtv") != -1); 
    this.TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); 
    this.AOLTV = this.TVNavigator;
    this.hotjava = (agt.indexOf("hotjava") != -1);
    this.hotjava3 = (this.hotjava && (this.major == 3));
    this.hotjava3up = (this.hotjava && (this.major >= 3));
}

function handleKeys(event,form,checker)
{ 


  if(event.which == 96){
       checker.checked = checker.checked ? false : true;  
       return false;
    }
     
  if(!checker.checked) return true;
 
  var s = '';
 
  switch(event.which){
 
     case 97:   s = '\u10D0';  break; 
     case 98:   s = '\u10D1';  break;
     case 103:  s = '\u10D2';  break;
     case 100:  s = '\u10D3';  break;
     case 101:  s = "\u10D4";  break; 
     case 118:  s = "\u10D5";  break;
     case 122:  s = "\u10D6";  break;
     case 84:   s = "\u10D7";  break;
     case 105:  s = "\u10D8";  break;
     case 107:  s = "\u10D9";  break;
     case 108:  s = "\u10DA";  break;
     case 109:  s = "\u10DB";  break;
     case 110:  s = "\u10DC";  break;
     case 111:  s = "\u10DD";  break;
     case 112:  s = "\u10DE";  break;
     case 74:   s = "\u10DF";  break;
     case 114:  s = "\u10E0";  break;
     case 115:  s = "\u10E1";  break;
     case 116:  s = "\u10E2";  break;
     case 117:  s = "\u10E3";  break;
     case 102:  s = "\u10E4";  break;
     case 113:  s = "\u10E5";  break;
     case 82:   s = "\u10E6";  break;
     case 121:  s = "\u10E7";  break;
     case 83:   s = "\u10E8";  break;
     case 67:   s = "\u10E9";  break;
     case 99:   s = "\u10EA";  break;
     case 90:   s = "\u10EB";  break;
     case 119:  s = "\u10EC";  break;
     case 87:   s = "\u10ED";  break;
     case 120:  s = "\u10EE";  break;
     case 106:  s = "\u10EF";  break;
     case 104:  s = "\u10F0";  break;
     default:   return true;
  }
  
  var caretPos = form.selectionStart;
  
  form.value = form.value.substring(0, caretPos)+ s+ form.value.substring(caretPos);

  caretPos++; 
  
  form.setSelectionRange(caretPos,caretPos); 
  
  return false;
}

function changeVal(form,checker)
{ 
  
  if (is.ie4up || is.opera)  {
  
    if(event.keyCode == 96){
        checker.checked = checker.checked ? false : true;  
        event.keyCode=''; 
        return;
     }
      
    if(!checker.checked) return; 
    
    event.keyCode =  switchCode(event.keyCode);     
    
  }
 else if (is.nav6up ) { 
     form.onkeypress = function(event){return handleKeys(event,form,checker);}
 } else {
  
    checker.checked=false;
  }

}


function myHandleEvent(event) {
    if(event.type=='keypress'){
        
        if(event.keyCode){
              checker = document.getElementById('geo');
              if(event.keyCode==96) { 
                   checker.checked = checker.checked ? false : true;
                   event.keyCode = '';
                }
              if(checker.checked)    
                event.keyCode = switchCode(event.keyCode);
          }
        // tinyMCE.getInstanceById('description').execCommand('mceInsertContent', false, '\u10D9');
         return true; 
      }
}
  

function switchCode(code){
   switch(code){
        case 97:    return 4304;   
        case 98:    return 4305;   
        case 103:   return 4306;  
        case 100:   return 4307;  
        case 101:   return 4308;  
        case 118:   return 4309;  
        case 122:   return 4310;  
        case 84:    return 4311;  
        case 105:   return 4312;  
        case 107:   return 4313;  
        case 108:   return 4314;  
        case 109:   return 4315;  
        case 110:   return 4316;  
        case 111:   return 4317;  
        case 112:   return 4318;  
        case 74:    return 4319;  
        case 114:   return 4320;  
        case 115:   return 4321;  
        case 116:   return 4322;  
        case 117:   return 4323;  
        case 102:   return 4324;  
        case 113:   return 4325;  
        case 82:    return 4326;  
        case 121:   return 4327;  
        case 83:    return 4328;  
        case 67:    return 4329;  
        case 99:    return 4330;  
        case 90:    return 4331;  
        case 119:   return 4332;  
        case 87:    return 4333;  
        case 120:   return 4334;  
        case 106:   return 4335;  
        case 104:   return 4336;
        case 96:    return '';  
        default:    return code;
   } 
} 