
var Netscape, MSIE, Opera, Unknown, NN1, NN2;
var Win, Mac, Other;
var NetscapeVer, MSIEVer, OperaVer, NetscapeOK, AlertMsg;
var strOperaPos;

var Br = "1";

// detect browser

Netscape = navigator.appName == "Netscape";
MSIE = navigator.appName == "Microsoft Internet Explorer";
Opera = navigator.userAgent.indexOf("Opera") > -1;

Unknown = !(Netscape || MSIE || Opera);

NetscapeOK = false;

// detect platform

Win = navigator.userAgent.indexOf("Win") > -1;
Mac = navigator.userAgent.indexOf("Mac") > -1;
Other = !(Win || Mac);

// now extract version numbers

if(Netscape)
{
  NetscapeVer = parseFloat(navigator.appVersion);
  if (NetscapeVer>4)
  {
    n = navigator.userAgent;
    if (n.indexOf("Netscape/") != -1)
    {
       NN1 = n.substr(n.indexOf("Netscape/")+9);
       NN1 = parseFloat(NN1);
    }
    NN1 = n.substr(n.indexOf("rv:")+3);
    NN1 = parseFloat(NN1); 

    if (NN1 >= "1.3")
        NetscapeOK = true;
  }
  if (NetscapeOK)
      Br="NN";    
}
else if(MSIE)
{
  n = navigator.userAgent;
  MSIEVer = n.substr(n.indexOf("MSIE ")+("MSIE ").length, 4);
  MSIEVer = parseFloat(MSIEVer); 
  // converts it into a floatint point number

  if(Opera)
  {
     strOperaPos = n.indexOf("Opera/"); // "Opera " or "Opera/"
     if (strOperaPos == -1)
       OperaVer = n.substr(n.indexOf("Opera ")+("Opera ").length, 4);
     else
       OperaVer = n.substr(strOperaPos + ("Opera/").length, 4);    
        
     OperaVer = parseFloat(OperaVer);
  }
  else
    Br = "IE";
}
else if(Opera)  // Opera does not identify itself as MSIE
{
  n = navigator.userAgent;
  strOperaPos = n.indexOf("Opera/"); // "Opera " or "Opera/"

  if (strOperaPos == -1)
      OperaVer = n.substr(n.indexOf("Opera ")+("Opera ").length, 4);
  else
      OperaVer = n.substr(strOperaPos + ("Opera/").length, 4);    
        
  OperaVer = parseFloat(OperaVer);        
}


////////////////////////
     
// MS Standard éöóêåí
  var KbdVariant1 = {  
    "~": "¨",
    "!": "!",    
    "@": "\"",
    "#": "¹",
    "$": ";",
    "%": "%",
    "^": ":",
    "&": "?",
    "*": "*",
    "(": "(",
    ")": ")",
    "_": "_",
    "+": "+",
    
    "`": "¸",
    "1": "1",
    "2": "2",
    "3": "3",
    "4": "4",
    "5": "5",
    "6": "6",
    "7": "7",
    "8": "8",
    "9": "9",
    "0": "0",
    "-": "-",    
    "=": "=",    
    
    "Q": "É",
    "W": "Ö",
    "E": "Ó",
    "R": "Ê",
    "T": "Å",
    "Y": "Í",
    "U": "Ã",
    "I": "Ø",
    "O": "Ù",
    "P": "Ç",
    "{": "Õ",
    "}": "Ú",
    "|": "/",
    
    "q": "é",
    "w": "ö",
    "e": "ó",
    "r": "ê",
    "t": "å",
    "y": "í",
    "u": "ã",
    "i": "ø",
    "o": "ù",
    "p": "ç",
    "[": "õ",
    "]": "ú",
    "\\": "\\",
    
    "A": "Ô",
    "S": "Û",
    "D": "Â",
    "F": "À",
    "G": "Ï",
    "H": "Ð",
    "J": "Î",
    "K": "Ë",
    "L": "Ä",
    ":": "Æ",
    "\"": "Ý",
    
    "a": "ô",
    "s": "û",
    "d": "â",
    "f": "à",
    "g": "ï",
    "h": "ð",
    "j": "î",
    "k": "ë",
    "l": "ä",
    ";": "æ",
    "'": "ý",
    
    "Z": "ß",
    "X": "×",
    "C": "Ñ",
    "V": "Ì",
    "B": "È",
    "N": "Ò",
    "M": "Ü",    
    "<": "Á",
    ">": "Þ",
    "?": ",",    
    
    "z": "ÿ",
    "x": "÷",
    "c": "ñ",
    "v": "ì",
    "b": "è",
    "n": "ò",
    "m": "ü",    
    ",": "á",
    ".": "þ",
    "/": "."
  };        
  
  var KbdVariant2 = {
    "~": "Þ",
    "!": "!",    
    "@": "¨",
    "#": "¸",
    "$": "$",
    "%": "%",
    "^": "Ú",
    "&": "ú",
    "*": "*",
    "(": "(",
    ")": ")",
    "_": "_",
    "+": "Ü",
    
    "`": "þ",
    "1": "1",
    "2": "2",
    "3": "3",
    "4": "4",
    "5": "5",
    "6": "6",
    "7": "7",
    "8": "8",
    "9": "9",
    "0": "0",
    "-": "-",    
    "=": "ü",    
    
    "Q": "ß",
    "W": "Ø",
    "E": "Å",
    "R": "Ð",
    "T": "Ò",
    "Y": "Û",
    "U": "Ó",
    "I": "È",
    "O": "Î",
    "P": "Ï",
    "{": "Æ",
    "}": "Ù",
    "|": "Ý",
    
    "q": "ÿ",
    "w": "ø",
    "e": "å",
    "r": "ð",
    "t": "ò",
    "y": "û",
    "u": "ó",
    "i": "è",
    "o": "î",
    "p": "ï",
    "[": "æ",
    "]": "ù",
    "\\": "ý",
    
    "A": "À",
    "S": "Ñ",
    "D": "Ä",
    "F": "Ô",
    "G": "Ã",
    "H": "×",
    "J": "É",
    "K": "Ê",
    "L": "Ë",
    ":": ":",
    "\"": "\"",
    
    "a": "à",
    "s": "ñ",
    "d": "ä",
    "f": "ô",
    "g": "ã",
    "h": "÷",
    "j": "é",
    "k": "ê",
    "l": "ë",
    ";": ";",
    "'": "'",
    
    "Z": "Ç",
    "X": "Õ",
    "C": "Ö",
    "V": "Â",
    "B": "Á",
    "N": "Í",
    "M": "Ì",    
    "<": "<",
    ">": ">",
    "?": "?",    
    
    "z": "ç",
    "x": "õ",
    "c": "ö",
    "v": "â",
    "b": "á",
    "n": "í",
    "m": "ì",    
    ",": ",",
    ".": ".",
    "/": "/"
  };  
        
//////////////////////////////////////////////////////////
if (Opera)
	if (OperaVer >= 8) Br = "NN"; // Opera 8 works as Mozilla

function changeKey(textControl, evt, keyChecker1, param)
{
if (evt.ctrlKey)
	return true;
      
var keyChecker = eval(keyChecker1); // function name
var keyCode = void 0;

keyCode = evt.keyCode ? evt.keyCode : evt.charCode ? evt.charCode : evt.which ? evt.which : void 0;   

if (evt.which == 0)
	return true;
		
var CurrentKey;

if (keyCode)
	CurrentKey = String.fromCharCode(keyCode);
  
var keyCheck = keyChecker(keyCode, CurrentKey, param);
  
if (keyCode && window.event && !window.opera)   // IE
{
	if (keyCheck.cancelKey)
		return false;
	else 
		if (keyCheck.replaceKey)  
		{
			window.event.keyCode = keyCheck.newKeyCode;
			if (window.event.preventDefault)
				window.event.preventDefault();
			return true;
		}
		else
			return true;
}
else 
	if (typeof textControl.setSelectionRange != 'undefined') // NN
	{
		if (keyCheck.cancelKey)
		{
			if (evt.preventDefault)
				evt.preventDefault();
			return false;
		}
		else 
			if (keyCheck.replaceKey)
			{
    		  // cancel the key event and insert the newKey for the current selection
				if (evt.preventDefault)
					evt.preventDefault();
 
				var oldSelectionStart = textControl.selectionStart;
				var oldSelectionEnd = textControl.selectionEnd;
				var selectedText = textControl.value.substring(oldSelectionStart, oldSelectionEnd);
				var newText = typeof keyCheck.newKey != 'undefined' ? keyCheck.newKey : String.fromCharCode(keyCheck.newKeyCode);
                    
				var scrollTop, scrollLeft;                                            
				if (textControl.type == 'textarea' && typeof textControl.scrollTop != 'undefined')
				{                                                        
					scrollTop  = textControl.scrollTop;                                 
					scrollLeft = textControl.scrollLeft;                               
				}                                                                     
				textControl.value = textControl.value.substring(0, oldSelectionStart) + newText + textControl.value.substring(oldSelectionEnd);                
        	       
				if (typeof scrollTop != 'undefined')
				{                                
					textControl.scrollTop  = scrollTop;                                 
					textControl.scrollLeft = scrollLeft;                               
				}                                                                     
				textControl.setSelectionRange(oldSelectionStart + newText.length, oldSelectionStart + newText.length);
				return false;
			}
			else
				return true;
	}          // Other browser:
	else
		if (keyCheck.cancelKey)
		{
			if (evt.preventDefault)
				evt.preventDefault();
			return false;
		}
		else
			return true;
}


function fIE (keyCode, CurrentKey, param) {
var newKeyOut = eval("KbdVariant"+param)[CurrentKey];
if (newKeyOut)
	return { replaceKey: true, newKeyCode: newKeyOut.charCodeAt(), newKey: newKeyOut };    
else
	return { cancelKey: false };
}

function fNN (keyCode, CurrentKey, param) {
var newKeyOut = eval("KbdVariant"+param)[CurrentKey];
if (newKeyOut)
	return { replaceKey: true, newKeyCode: keyCode, newKey: newKeyOut };
else
	return { cancelKey: false };
}

function fOther (keyCode, CurrentKey, param) {
var newKeyOut = eval("KbdVariant"+param)[CurrentKey];
if (newKeyOut){
	txtControl.value += newKeyOut;
	return { cancelKey: true };
}
else
	return { cancelKey: false };
}

function Kbd_OnOff(form,ev)
{
	if (window.event) 
		return window.event.keyCode
	else 
		if (ev) 
			return ev.which
		else 
			return null;
}                       