var font = ""; var description = ""; var row2 =	new	Array(); var keys =	new	Array();

//////////////////// THE PAGE APPEARANCE (IF YOU HAVE NOTHING ELSE TO DO) ////////////////////
///font	sizes (choices:	 xx-small, x-small,	small, medium, large, x-large, xx-large):
var	page = "x-small";
var	character_map =	"medium";
var	Unicode_keys = "medium";
var	standard_keys =	"medium";
var	text_area =	"medium";
var	text_boxes = "medium";

// colors:

var	cntrlvalue = "32";	// This	is the value at	and	below which	are	assumed	to be control comment.
var lastKey0;
var lastKey1;

var lastKeyType0;
var lastKeyType1;

lastKeyType0 = "s";
function matchlist(matc1, matc2) 
{
	var	re = eval("/\\|" + matc1 + "\\|/");
	if (matc2.replace(re, "") != matc2)	return true;
}

function mouse() {
	return 'onMouseOver	= "window.status =	\' ' + keys[i][j][1] + ' \'"; '	+
	'onMouseOut	= "window.status = \'\'"';
}


function asgn(x, n)	{ with (Math) {
	alert("asgn");
	if (x >	300)  var y	= n%1000;
	else {
	var	pl = floor(log(x)/LN10);
	var	y =	round(n%pow(10,	pl+1) -	n%pow(10, pl));	}
	if (x==y)  n = n-x;
	else n = n-y+x/1;
	return n;
} 
}

var	val	= 0; var m = 0;

function cursor(textar)	{
	if (textar.createTextRange)	{
	textar.cursorPos = document.selection.createRange().duplicate();	
	}
}

function getCombo(lKey,cKey)
{	
	var	i;
	var	j;
	var	d =	String.fromCharCode(uni[cKey][1]); 
	for	(i=0;i<=33;i++){
		for	(j=0;j<4;j++){
		if (combo[i][0]	== lKey	&& combo[i][1] == cKey)
			{d = String.fromCharCode(combo[i][2]);  return	d; }	
		}
	}
	
}


function getCombo2(lKey,cKey)
{	var	i;
	var	j;
	var	d =	String.fromCharCode(uni[cKey][1]); 
	for	(i=0;i<=33;i++){
		for	(j=0;j<6;j++){
			if (combo[i][0]	== lKey	&& combo[i][1] == cKey)
				{d = String.fromCharCode(combo[i][4]); return	d; }	
		}
	}
	return	d;
	
}


function insert2 (textar, event)
{	
	var	text = "";
	var kc	= (event.which ? event.which : event.keyCode);
	if ((kc	>= 48 && kc	<= 57) || (kc >= 65	&& kc <= 90) ||	(kc	>= 97 && kc	<= 122)	|| (kc == 32) || (kc ==	94))
	{	if (textar.value.length == 0)
		{
			lastKey0 = 48;
			lastKey1 = 48;
			lastKeyType0 = "s";
			lastKeyType1 = "s";
		}
		
		document.commentform.X1.value = lastKeyType1 + " " + lastKeyType0 + " " + uni[kc][0] + " " + lastKey1 + " " + lastKey0 + " " + kc; 
		
		if (kc == 94	|| kc == 97	|| kc == 101 ||	kc == 105 || kc	== 111 || kc ==	117	|| kc == 77	|| kc == 72	 ||	kc == 65 ||	kc == 79 || kc == 82)	
		{	if (lastKeyType0 == "h")
			{   m = -1;
				if (kc == 65 ||	kc == 79 || kc == 82) {
				text = String.fromCharCode(uni[kc][3]);
				lastKeyType1 = lastKeyType0;
				lastKeyType0 = uni[kc][2];
				lastKey1 = lastKey0;
				lastKey0 = kc;
				}
				else {	
					text = String.fromCharCode(uni[kc][1]); 
					 }
				 	lastKeyType1 = lastKeyType0;
					lastKeyType0 = uni[kc][0];
					lastKey1 = lastKey0;
					lastKey0 = kc;
			}
				
			else if	(lastKeyType0	== "s" || lastKeyType0 == "n"	)
			{	if ((kc	== 97) || (kc == 111) )
				{	text =	String.fromCharCode(uni[kc][3]); 
					lastKeyType1 = lastKeyType0;
					lastKeyType0 = uni[kc][2];
					lastKey1 = lastKey0;
					lastKey0 = kc;
				}
				else if	(kc	>= 97 )
				{	kc = kc -	32;
					text = String.fromCharCode(uni[kc][1]);
					lastKeyType1 = lastKeyType0;
					lastKeyType0 = uni[kc][0];
					lastKey1 = lastKey0;
					lastKey0 = kc;
				}
				else 
				{text = String.fromCharCode(uni[kc][1]);
				 lastKeyType1 = lastKeyType0;
				 lastKeyType0 = uni[kc][0];
				 lastKey1 = lastKey0;
				 lastKey0 = kc;
				}
			}
			
			else if	(lastKeyType0	== "v")
			{	if (lastKeyType1 ==	"v") { 
					text = getCombo2(lastKey0,kc);
					if (text == null)
					{text = String.fromCharCode(uni[kc][3]);
					 lastKeyType1 = lastKeyType0;
					 lastKeyType0 = uni[kc][2];
					 lastKey1 = lastKey0;
					 lastKey0 = kc;}
					else 
					{
					 lastKeyType1 = lastKeyType0;
					 lastKeyType0 = "v";
					 lastKey1 = lastKey0;
					 lastKey0 = kc;}
				}
				else if (lastKeyType1 == "s") {
					text	= getCombo2(lastKey0,kc);
					lastKeyType1 = lastKeyType0;
					lastKeyType0 = "v";
					lastKey1 = lastKey0;
					lastKey0 = kc;
					}
				else if (lastKeyType1 == "h") {	text = getCombo(lastKey0,kc);
								lastKeyType1 = lastKeyType0;
								lastKeyType0 = uni[kc][0];
								lastKey1 = lastKey0;
								lastKey0 = kc;	
								}
				else if (lastKeyType1 == "c") {	text = getCombo(lastKey0,kc);
								lastKeyType1 = lastKeyType0;
								lastKeyType0 = uni[kc][0];
								lastKey1 = lastKey0;
								lastKey0 = kc;
								}
				else if (lastKeyType1 == "n") {	text = getCombo2(lastKey0,kc);
								lastKeyType1 = lastKeyType0;
								lastKeyType0 = "v";
								lastKey1 = lastKey0;
								lastKey0 = kc;
								}
				else if (lastKeyType1 == "m") { text = getCombo2(lastKey0,kc);
								if (text == null)
								{text = String.fromCharCode(uni[kc][3]);
								 lastKeyType1 = lastKeyType0;
								 lastKeyType0 = uni[kc][2];
								 lastKey1 = lastKey0;
								 lastKey0 = kc;}
								else 
								{
								 lastKeyType1 = lastKeyType0;
								 lastKeyType0 = "v";
								 lastKey1 = lastKey0;
								 lastKey0 = kc;}
								}
				else { 	text = getCombo(lastKey0,kc);
					lastKeyType1 = lastKeyType0;
					lastKeyType0 = uni[kc][0];
					lastKey1 = lastKey0;
					lastKey0 = kc;	}
				
				
				if (text == String.fromCharCode(uni[kc][1]))
				{	
					if ((kc	== 97) || (kc == 111))
					{text =	String.fromCharCode(uni[kc][3]);
					 lastKeyType0 = uni[kc][2]; 	
					}
					
					else if	(kc	>= 97 )
					{	kc	= kc - 32; 
						text =	String.fromCharCode(uni[kc][1]); 
						lastKeyType0 = uni[kc][0];
						lastKey0 = kc;
					}
				}
				else{	if ( lastKeyType1 != "h" ) { m = -1; }
					
				}
			}
				
			else if	(lastKeyType0	== "m")
			{	
				if	(lastKeyType1	== "v")	{ 	text = getCombo(lastKey0,kc); 
									lastKeyType1 = lastKeyType0;
									lastKeyType0 = uni[kc][0];
									lastKey1 = lastKey0;
									lastKey0 = kc;}
				else if (lastKeyType1 ==	"s") { 	text	= getCombo(lastKey0,kc); 
									if (text == null)
									{text = String.fromCharCode(uni[kc][3])
									 lastKeyType1 = lastKeyType0;
									 lastKeyType0 = uni[kc][2];
									 lastKey1 = lastKey0;
									 lastKey0 = kc; 
									}
									else {
									lastKeyType1 = lastKeyType0;
									lastKeyType0 = uni[kc][0];
									lastKey1 = lastKey0;
									lastKey0 = kc;}
								     }		
				else if (lastKeyType1 ==	"h") { 					
					text = getCombo(lastKey0,kc);
					if (text == null)
					{ text = String.fromCharCode(uni[kc][3]);
					  lastKeyType1 = lastKeyType0;
					  lastKeyType0 = uni[kc][2];
					  lastKey1 = lastKey0;
					  lastKey0 = kc; 
					}
					else { lastKeyType1 = lastKeyType0;
						lastKeyType0 = uni[kc][0];
						lastKey1 = lastKey0;
						lastKey0 = kc;}
					}
					
				else if (lastKeyType1 ==	"c") { 	text	= getCombo(lastKey0,kc); 
								  	lastKeyType1 = lastKeyType0;
									lastKeyType0 = uni[kc][0];
									lastKey1 = lastKey0;
									lastKey0 = kc;	}
				else if (lastKeyType1 ==	"m") { 
					if (getCombo(lastKey0,kc) == null)
					{ 
						if (uni[kc][3] == null) 
						{ 
							text = String.fromCharCode(uni[kc][1]) ; 
							lastKeyType1 = lastKeyType0;
							lastKeyType0 = uni[kc][0];
							lastKey1 = lastKey0;
							lastKey0 = kc;}
						else {
							text = String.fromCharCode(uni[kc][3]) ; 
							lastKeyType1 = lastKeyType0;
							lastKeyType0 = uni[kc][2];
							lastKey1 = lastKey0;
							lastKey0 = kc;
						}
							
					}
					else { 
						text = String.fromCharCode(uni[kc][3])
						lastKeyType1 = lastKeyType0;
						lastKeyType0 = uni[kc][2];
						lastKey1 = lastKey0;
						lastKey0 = kc; 
					}
				}
				else {	text = getCombo(lastKey0,kc); 
					lastKeyType1 = lastKeyType0;
					lastKeyType0 = uni[kc][0];
					lastKey1 = lastKey0;
					lastKey0 = kc;	}
				
				if	(text == String.fromCharCode(uni[kc][1]))
				{	
					if ((kc	== 97) || (kc == 111))
					{ text = String.fromCharCode(uni[kc][1]); }
					else if	(kc	>= 97 )	{ kc = kc -	32;}
					text = String.fromCharCode(uni[kc][1]);	
					lastKeyType0 = uni[kc][0];
					lastKey0 = kc;
				}
				else if	(text == String.fromCharCode(combo[13][2]) || text == String.fromCharCode(combo[14][2]) )
				{	m =	-1;}
				
			}
				
			else if(lastKeyType1 == "c")	{
				
				text = getCombo(lastKey0,kc);
				lastKeyType1 = lastKeyType0;
				lastKeyType0 = uni[kc][0];
				lastKey1 = lastKey0;
				lastKey0 = kc;
			}
			else 
			{
				if ((kc	== 97) || (kc == 111))
				{text =	String.fromCharCode(uni[kc][3]); 
				lastKeyType1 = lastKeyType0;
				lastKeyType0 = uni[kc][2];
				lastKey1 = lastKey0;
				lastKey0 = kc;	
				}
				else if	(kc	>= 97 )	{ kc = kc -	32;
					text = String.fromCharCode(uni[kc][1]);
					lastKeyType1 = lastKeyType0;
					lastKeyType0 = uni[kc][0];
					lastKey1 = lastKey0;
					lastKey0 = kc;	
				}
			}
		}
		else
		{
			if (kc == 32){	
				if (lastKeyType0 == "h") 
				{m	= -1;}
				text = String.fromCharCode(uni[kc][1])
				lastKeyType0 = uni[kc][0];
				lastKey0 = kc;
			}
			else if	(uni[kc][0]	== "c")	
			{	if (lastKeyType0 == "h" || lastKeyType0	== "c")
				{	text = getCombo(lastKey0,kc);
					if (text == null ) {text = String.fromCharCode(uni[kc][1])}
					if (text == String.fromCharCode(uni[kc][1]))
					{
						text =	String.fromCharCode(uni[kc][1])	 + String.fromCharCode(2381);
						lastKeyType0	= "h";
						lastKey0	= kc;
					}
					else {
						m = -2	 ; 
						text =	text + String.fromCharCode(2381);	
						lastKeyType0	= "h";
						lastKey0	= kc;
					}
				}
				else 
				{	text = String.fromCharCode(uni[kc][1]) + String.fromCharCode(2381);
					lastKeyType0 = "h";
					lastKey0 = kc;
				}
			}
			else if	(uni[kc][0]	== "s" || uni[kc][0] ==	"n") 
			{
				text	= String.fromCharCode(uni[kc][1]);
				lastKeyType0 =	uni[kc][0];
			}
			else
			{   text	= String.fromCharCode(uni[kc][1]);
				lastKeyType0 =	uni[kc][0];
						
			} 
		}
	}
	else
	{
		text =	String.fromCharCode(kc);
		lastKeyType0	= "s";
	}
	if (textar.createTextRange && textar.cursorPos)
	{	var	rang = textar.cursorPos;
		rang.moveStart("character",	m);
		rang.text =	(rang.text.charAt(rang.text.length - 1)	== ' ' ? text +	' '	: text);
		rang.collapse(false); rang.scrollIntoView(true);
	}
	else
	{	if (m==0) textar.value += text;
		else textar.value =	textar.value.substring(0, textar.value.length-1) + text;
	}
	textar.focus();	m=0; 
}

function Uni(event)	{
if	((event.which >	31 || event.keyCode	> 31) && document.commentform.q.style.fontFamily==font &&	document.commentform.C2.checked)
return true; else return false;
}

function reval(event) {
if (event.keyCode == 123) 
{ document.commentform.C2.checked =	!(document.commentform.C2.checked);	} 
var	temp = (event.which	? event.which :	event.keyCode);
if (temp==13 &&	val==963) insert2(document.commentform.q,	event);
else if	(matchlist(temp, "|8|9|13|37|38|39|40|"))  val = 0;
}

var	mem	= ""; var isithtml = "";

function resetfont() {
(document.commentform.q.style.fontFamily==font) ? toHTML()	: fromHTML();
document.commentform.q.style.fontSize	= ((document.commentform.q.style.fontFamily==font) ? "" :	text_area);
document.commentform.q.style.fontFamily =	((document.commentform.q.style.fontFamily==font) ? ""	: font); 
}

function toHTML() {
var	HTMLtext = ""; var len = document.commentform.q.value.length;
for	(i=0; i<len; i++) {

if (( document.commentform.q.value.charCodeAt(i) > cntrlvalue) )
{HTMLtext +=  document.commentform.q.value.charCodeAt(i) ;}
else HTMLtext += document.commentform.q.value.charAt(i);
}

if (document.commentform.C2.checked)  HTMLtext = HTMLtext.replace(/	 /g, "&nbsp; ").replace(/(\r?\n)/g,	"<br>$1");
document.commentform.q.value = HTMLtext;
}

function enable() {	 }
var	toChar = function (match, p1) {	return String.fromCharCode(p1);	}
function fromHTML() {
document.commentform.q.value = document.commentform.q.value.replace(/&#(\d+);/g, toChar).replace(/&nbsp;/gi, " ").replace(/<br>/gi,	"");
} 