var Keyboardflag = 0;			// 0= English & 1= Ethiopic
var rtsupported = false;
var typeEthiopic = false;

function testSupport()
{
	try {
		rtsupported = (document.selection != undefined)
		if (!rtsupported) 
		{
			var element = document.createElement("TEXTAREA");
			document.getElementsByTagName("BODY")[0].appendChild(element);
			if (element.selectionStart != undefined)
				rtsupported = true;
			document.getElementsByTagName("BODY")[0].removeChild(element);
		}
		
		}catch(error){}
}
function processKeys(event) 
{
	if (rtsupported) 
	{
		if (event.keyCode == 27 && !isExplorer()) 
		{ //escape to toggle
			UpdateKeyboard();		
		}else if (typeEthiopic)
			translitonkey(event);
	}
}

function UpdateKeyboard(){
//	alert("UpdateKeyboard is being called and Keyboardflag = " + Keyboardflag);
	if(Keyboardflag == 0){
	  testSupport();
//	  document.getElementById("Phontics").style.visibility = 'visible';
	  document.getElementById("btnKeyboardType").value = "Switch To English";
	  document.post.message.focus();
	  Keyboardflag = 1;
	  typeEthiopic = true;
//	  alert("Exiting if Keyboardflag = " + Keyboardflag);
	}else if(Keyboardflag == 1){
//	  document.getElementById("Phontics").style.visibility = 'hidden';
	  document.getElementById("btnKeyboardType").value = "Switch To Ethiopic";
	  document.post.message.focus();
	  Keyboardflag = 0;
	  typeEthiopic = false;
	}
}

function writeTheTable()
{
	var hash=getConversionHash();
	var hahuCounter = 0;
	for (var ch in hash){
/*	  if(hahuCounter == 0){
	    	document.write("<div><span>"+hash[ch]+ch"</span>");
	    	hahuCounter++;
		}else if(hahuCounter == 5){
	    	document.write("<span>"+hash[ch]+ch"</span></div>\n");
			hahuCounter = 0;		  
		}else{
	  		document.write("<span>"+hash[ch]+ch"</span>");
			hahuCounter++;		  
		}
*/
document.write("<span>"+hash[ch]+"</span>"+ch);
hahuCounter +=1;
if(hahuCounter == 6){
  document.write("<br>");
  hahuCounter =0;
}
		
	}
}
