//************************************************************************************************************//
// Kazakh -Latin Unicode Converter.                                                                                          // 
// Main functions of the converter page.                                                                                //
// This file is created by Bakytnur Baytel Massagan.com in 2005. 
// The function ConvertInRealTime() is taken from QazTranslit.com 
//************************************************************************************************************//
function ConvertInRealTime()
{
	//the entered character
        var code = event.keyCode;
	txt=String.fromCharCode(code); 
	//make selection
	cursor_pos_selection = document.selection.createRange();
	//delete something selected before
	cursor_pos_selection.text="";
	//get the previous character
        cursor_pos_selection.moveStart("character",-1);
	pretxt = cursor_pos_selection.text;
	if (pretxt.length>1) {pretxt="";}
	event.keyCode = 0;
	
	if (pretxt!="I") result=toconvertln2(pretxt+txt);
	else result=pretxt+txt;
	//delete the previous symbol if it is exists (if the entered symbol is not the first one)
	if (pretxt!="") { cursor_pos_selection.select(); cursor_pos_selection.collapse();}
	with(document.selection.createRange()) {text = result; collapse(); select()}
	return;

}

function toconvertln2(text)
{
	var sourceareastr = text;
	var strlen = sourceareastr.length;
	var sourceStr=sourceareastr.substr(0, strlen-2);
	var resultStr="";
	var resultCode=""; //i-45
	kzLetter= new Array(1040,1041,1042,1043,1044,1045,1025,1046,1047,1030,1049,1050,1051,1052,1053,1054,1256,1055,1056,1057,1058,1200,1198,1060,1210,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1105,1078,1079,1110,1081,1082,1083,1084,1085,1086,1257,1087,1088,1089,1090,1201,1199,1092,1211,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,1178,1179,1240,1241,1059,1091,1061,1093,1170,1171,1048,1080,1186,1187);
	lnLetter= new Array("A","B","V","G","D","E","Yo","J","Z","I","I","K","L","M","N","O","O'","P","R","S","T","U","U'","F","H","C","Ch","Sh","Sh'",'"',"Y","'","E'","Yu","Ya","a","b","v","g","d","e","yo","j","z","i","i","k","l","m","n","o","o'","p","r","s","t","u","u'","f","h","c","ch","sh","sh",'"',"y","'","e'","yu","ya","Q","q","A'","a'","W","w","X","x","Gh","gh","I'","i'","Ng","ng");
			//latin to cryllic convert
		
	if (document.board.toutf[0].checked) { 
	
	 i=strlen-2;
	
	 while(i<strlen) { 
		  var charstr = sourceareastr.charAt(i);
		  var valcharstr=sourceareastr.charCodeAt(i);

			bool1=0;
		  j=0;
	    while (j<84 && bool1==0){
			if (valcharstr==1067) { 
			bool2=0; bool1=1; 
			
		switch(sourceareastr.charAt(i+1)) {
			
		case "O": resultStr+=String.fromCharCode(kzLetter[6]); resultCode+="&#"+kzLetter[6]+";"; bool2=1; break;  //YO
		case "o": resultStr+=String.fromCharCode(kzLetter[6]); resultCode+="&#"+kzLetter[6]+";"; bool2=1; break;  //Yo
		case "U": resultStr+=String.fromCharCode(kzLetter[33]); resultCode+="&#"+kzLetter[33]+";"; bool2=1; break; //YU
		case "u": resultStr+=String.fromCharCode(kzLetter[33]); resultCode+="&#"+kzLetter[33]+";"; bool2=1; break; //Yu
		case "A": resultStr+=String.fromCharCode(kzLetter[34]); resultCode+="&#"+kzLetter[34]+";"; bool2=1; break; //YA
		case "a": resultStr+=String.fromCharCode(kzLetter[34]); resultCode+="&#"+kzLetter[34]+";"; bool2=1; break; //Ya
		
		}
	if (bool2==0) {resultStr+=String.fromCharCode(kzLetter[30]); resultCode+="&#"+kzLetter[30]+";"; bool1==1} //Y
	               else i=i+1;  
	} 
	if (valcharstr==1099) { bool2=0; bool1=1;
	          switch(sourceareastr.charAt(i+1)) {
	          case "o": resultStr+=String.fromCharCode(kzLetter[41]); resultCode+="&#"+kzLetter[41]+";"; bool2=1; break;  //yo
	          case "u": resultStr+=String.fromCharCode(kzLetter[68]); resultCode+="&#"+kzLetter[68]+";"; bool2=1; break; //yu
	          case "a": resultStr+=String.fromCharCode(kzLetter[69]); resultCode+="&#"+kzLetter[69]+";"; bool2=1; break; //ya
	          }
	          if (bool2==0) {resultStr+=String.fromCharCode(kzLetter[65]); resultCode+="&#"+kzLetter[65]+";"; bool1==1} //y
		                        else i=i+1;  
		  } 
	
	
	if (valcharstr==1054) { if (sourceareastr.charAt(i+1)=="'")
	   if (sourceareastr.charAt(i+2)=="i" || sourceareastr.charAt(i+2)=="I"){
		resultStr+=String.fromCharCode(kzLetter[16]); resultCode+="&#"+kzLetter[16]+";"; 
		resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+2;} //O'I
		else
		 if (sourceareastr.charAt(i+2)=="y" || sourceareastr.charAt(i+2)=="Y"){
		resultStr+=String.fromCharCode(kzLetter[16]); resultCode+="&#"+kzLetter[16]+";"; 
		resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+2;} //O'I
		
		else {resultStr+=String.fromCharCode(kzLetter[16]); resultCode+="&#"+kzLetter[16]+";"; i=i+1;}//O'
		
		else if (sourceareastr.charAt(i+1)=="I" || sourceareastr.charAt(i+1)=="i")
		{resultStr+=String.fromCharCode(kzLetter[15]); resultCode+="&#"+kzLetter[15]+";"; 
		resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;}//UI
		
		else if (sourceareastr.charAt(i+1)=="Y" || sourceareastr.charAt(i+1)=="y")
		{resultStr+=String.fromCharCode(kzLetter[15]); resultCode+="&#"+kzLetter[15]+";"; 
		resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;}//UI
		
		else { resultStr+=String.fromCharCode(kzLetter[15]); resultCode+="&#"+kzLetter[15]+";"; }//U
		bool1=1;
		}
	
	
	if (valcharstr==1086) { if (sourceareastr.charAt(i+1)=="'")
	        if (sourceareastr.charAt(i+2)=="i" || sourceareastr.charAt(i+2)=="I"){
		resultStr+=String.fromCharCode(kzLetter[51]); resultCode+="&#"+kzLetter[51]+";"; 
		resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+2;} //U'I
		else {resultStr+=String.fromCharCode(kzLetter[51]); resultCode+="&#"+kzLetter[51]+";"; i=i+1;}//U'
		else if (sourceareastr.charAt(i+1)=="I" || sourceareastr.charAt(i+1)=="i")
		{resultStr+=String.fromCharCode(kzLetter[50]); resultCode+="&#"+kzLetter[50]+";"; 
		resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;}//UI
		else { resultStr+=String.fromCharCode(kzLetter[50]); resultCode+="&#"+kzLetter[50]+";"; }//U
		bool1=1;
		}
		
	 if (valcharstr==1072) { if (sourceareastr.charAt(i+1)=="'")
	        if (sourceareastr.charAt(i+2)=="i" || sourceareastr.charAt(i+2)=="I"){
	        resultStr+=String.fromCharCode(kzLetter[73]); resultCode+="&#"+kzLetter[73]+";"; 
	        resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+2;} //a'i
	        else {resultStr+=String.fromCharCode(kzLetter[73]); resultCode+="&#"+kzLetter[73]+";"; i=i+1;}//a'
	        else if (sourceareastr.charAt(i+1)=="I" || sourceareastr.charAt(i+1)=="i")
	        {resultStr+=String.fromCharCode(kzLetter[35]); resultCode+="&#"+kzLetter[35]+";"; 
	        resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;}//ai
	        else { resultStr+=String.fromCharCode(kzLetter[35]); resultCode+="&#"+kzLetter[35]+";"; }//a
	        bool1=1;
	}
	
	 if (valcharstr==1040) { if (sourceareastr.charAt(i+1)=="'")
	        if (sourceareastr.charAt(i+2)=="i" || sourceareastr.charAt(i+2)=="I"){
	        resultStr+=String.fromCharCode(kzLetter[72]); resultCode+="&#"+kzLetter[72]+";"; 
	        resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+2;} //a'i
	        else {resultStr+=String.fromCharCode(kzLetter[72]); resultCode+="&#"+kzLetter[72]+";"; i=i+1;}//a'
	        else if (sourceareastr.charAt(i+1)=="I" || sourceareastr.charAt(i+1)=="i")
	        {resultStr+=String.fromCharCode(kzLetter[0]); resultCode+="&#"+kzLetter[0]+";"; 
	        resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;}//ai
	        else { resultStr+=String.fromCharCode(kzLetter[0]); resultCode+="&#"+kzLetter[0]+";"; }//a
	        bool1=1;
	}
	
	if (valcharstr==1064) { 
		if (sourceareastr.charAt(i+1)=="'")
	        {resultStr+=String.fromCharCode(kzLetter[28]); resultCode+="&#"+kzLetter[28]+";"; i=i+1;}//Sh'
	    else 	
			{ resultStr+=String.fromCharCode(kzLetter[27]); resultCode+="&#"+kzLetter[27]+";"; }//SH
	        bool1=1;
	}
	
	if (valcharstr==1096) { 
		if (sourceareastr.charAt(i+1)=="'")
	        {resultStr+=String.fromCharCode(kzLetter[63]); resultCode+="&#"+kzLetter[63]+";"; i=i+1;}//sh'
	    else 	
			{ resultStr+=String.fromCharCode(kzLetter[62]); resultCode+="&#"+kzLetter[62]+";"; }//sh
	        bool1=1;
	}
	
	if (valcharstr==1200) { if (sourceareastr.charAt(i+1)=="'")
	        if (sourceareastr.charAt(i+2)=="i" || sourceareastr.charAt(i+2)=="I"){
		resultStr+=String.fromCharCode(kzLetter[22]); resultCode+="&#"+kzLetter[22]+";"; 
		resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+2;} //U'I
		else {resultStr+=String.fromCharCode(kzLetter[22]); resultCode+="&#"+kzLetter[22]+";"; i=i+1;}//U'
		else if (sourceareastr.charAt(i+1)=="I" || sourceareastr.charAt(i+1)=="i")
		{resultStr+=String.fromCharCode(kzLetter[21]); resultCode+="&#"+kzLetter[21]+";"; 
		resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;}//UI
		else { resultStr+=String.fromCharCode(kzLetter[21]); resultCode+="&#"+kzLetter[21]+";"; }//U
		bool1=1;
		}
	
    if (valcharstr==1201) { if (sourceareastr.charAt(i+1)=="'")
	        if (sourceareastr.charAt(i+2)=="i" || sourceareastr.charAt(i+2)=="I"){
	        resultStr+=String.fromCharCode(kzLetter[57]); resultCode+="&#"+kzLetter[57]+";"; 
	        resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+2;} //u'i
	        else {resultStr+=String.fromCharCode(kzLetter[57]); resultCode+="&#"+kzLetter[57]+";"; i=i+1;}//ue
	        else if (sourceareastr.charAt(i+1)=="I" || sourceareastr.charAt(i+1)=="i")
	        {resultStr+=String.fromCharCode(kzLetter[56]); resultCode+="&#"+kzLetter[56]+";"; 
	        resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;}//ui
	        else { resultStr+=String.fromCharCode(kzLetter[56]); resultCode+="&#"+kzLetter[56]+";"; }//u
	        bool1=1;
	}
	if (valcharstr==1062) { if (sourceareastr.charAt(i+1)=="h" || sourceareastr.charAt(i+1)=="H"){
	        resultStr+=String.fromCharCode(kzLetter[26]); resultCode+="&#"+kzLetter[26]+";"; i=i+1; }//CH
		else {resultStr+=String.fromCharCode(kzLetter[25]); resultCode+="&#"+kzLetter[25]+";"; }//C
		bool1=1;
        }
		
	if (valcharstr==1094) { if (sourceareastr.charAt(i+1)=="h" || sourceareastr.charAt(i+1)=="H"){
	        resultStr+=String.fromCharCode(kzLetter[61]); resultCode+="&#"+kzLetter[61]+";"; i=i+1; }//ch
	        else { resultStr+=String.fromCharCode(kzLetter[60]); resultCode+="&#"+kzLetter[60]+";"; }//c
	        bool1=1;
	}
	
	
		
	if (valcharstr==1043) { if (sourceareastr.charAt(i+1)=="h" || sourceareastr.charAt(i+1)=="H"){
	        resultStr+=String.fromCharCode(kzLetter[78]); resultCode+="&#"+kzLetter[78]+";"; i=i+1; }//GH
		else {resultStr+=String.fromCharCode(kzLetter[3]); resultCode+="&#"+kzLetter[3]+";"; }//G
		bool1=1;
        }
	if (valcharstr==1075) { if (sourceareastr.charAt(i+1)=="h" || sourceareastr.charAt(i+1)=="H"){
	        resultStr+=String.fromCharCode(kzLetter[79]); resultCode+="&#"+kzLetter[79]+";"; i=i+1; }//gh
		else {resultStr+=String.fromCharCode(kzLetter[38]); resultCode+="&#"+kzLetter[38]+";"; }//g
		bool1=1;
        }	
	
	if (valcharstr==1053) { if (sourceareastr.charAt(i+1)=="g" || sourceareastr.charAt(i+1)=="G"){
	        resultStr+=String.fromCharCode(kzLetter[82]); resultCode+="&#"+kzLetter[82]+";"; i=i+1; }//Ng
		else {resultStr+=String.fromCharCode(kzLetter[14]); resultCode+="&#"+kzLetter[14]+";"; }//N
		bool1=1;
        }
		
	if (valcharstr==1085) { if (sourceareastr.charAt(i+1)=="g" || sourceareastr.charAt(i+1)=="G"){
	        resultStr+=String.fromCharCode(kzLetter[83]); resultCode+="&#"+kzLetter[83]+";"; i=i+1; }//ng
		else {resultStr+=String.fromCharCode(kzLetter[49]); resultCode+="&#"+kzLetter[49]+";"; }//n
		bool1=1;
        }	
	
	if (valcharstr==1057) { if (sourceareastr.charAt(i+1)=="h" || sourceareastr.charAt(i+1)=="H") {
	        resultStr+=String.fromCharCode(kzLetter[27]); resultCode+="&#"+kzLetter[27]+";"; i=i+1;}//SH
		else { resultStr+=String.fromCharCode(kzLetter[19]); resultCode+="&#"+kzLetter[19]+";";  }//S
		bool1=1;
        }
	if (valcharstr==1089) { if (sourceareastr.charAt(i+1)=="h" || sourceareastr.charAt(i+1)=="H") {
	        resultStr+=String.fromCharCode(kzLetter[62]); resultCode+="&#"+kzLetter[62]+";"; i=i+1;}//sh
		else {resultStr+=String.fromCharCode(kzLetter[54]); resultCode+="&#"+kzLetter[54]+";"; }//s
		bool1=1;
        }
        if (charstr=="'") {resultStr+=String.fromCharCode(kzLetter[66]); resultCode+="&#"+kzLetter[66]+";"; //Jinishkertu belgisi
                           bool1=1;
        }
        if (charstr=='"') {resultStr+=String.fromCharCode(kzLetter[64]); resultCode+="&#"+kzLetter[64]+";"; //Juandyk belgisi
                           bool1=1;
        }
       
	
	if (valcharstr==1030) { // I-ning I' boluy
		if (sourceareastr.charAt(i+1)=="i" || sourceareastr.charAt(i+1)=="I") {
	        resultStr+=String.fromCharCode(kzLetter[9]); resultCode+="&#"+kzLetter[9]+";"; 
			resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;
			}//II
		else
		if (sourceareastr.charAt(i+1)=="'")
		 {
			resultStr+=String.fromCharCode(kzLetter[80]); resultCode+="&#"+kzLetter[80]+";"; 
			i=i+1;
		 }
		else { resultStr+=String.fromCharCode(kzLetter[9]); resultCode+="&#"+kzLetter[9]+";"; }//I
		bool1=1;
	}
	
	if (valcharstr==1110) { // i-ning i' boluy
	if (sourceareastr.charAt(i+1)=="i" || sourceareastr.charAt(i+1)=="I") 
		{
	        resultStr+=String.fromCharCode(kzLetter[44]); resultCode+="&#"+kzLetter[44]+";"; 
			resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;
		}//ii
	else
	if (sourceareastr.charAt(i+1)=="'")
		{
			resultStr+=String.fromCharCode(kzLetter[81]); resultCode+="&#"+kzLetter[81]+";"; 
			i=i+1;
			}
		else { resultStr+=String.fromCharCode(kzLetter[44]); resultCode+="&#"+kzLetter[44]+";"; }//i
		bool1=1;
	}
	
	if (valcharstr==1240) { //A'i
	if (sourceareastr.charAt(i+1)=="i" || sourceareastr.charAt(i+1)=="I") 
		{
	        resultStr+=String.fromCharCode(kzLetter[72]); resultCode+="&#"+kzLetter[72]+";"; 
			resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;
		}//ii
	else
	if (sourceareastr.charAt(i+1)=="'")
		{
			resultStr+=String.fromCharCode(kzLetter[81]); resultCode+="&#"+kzLetter[81]+";"; 
			i=i+1;
			}
		else { resultStr+=String.fromCharCode(kzLetter[72]); resultCode+="&#"+kzLetter[72]+";"; }//i
		bool1=1;
	}
	
	if (valcharstr==1241) { //a'i
	if (sourceareastr.charAt(i+1)=="i" || sourceareastr.charAt(i+1)=="I") 
		{
	        resultStr+=String.fromCharCode(kzLetter[73]); resultCode+="&#"+kzLetter[73]+";"; 
			resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;
		}//ii
	else
	if (sourceareastr.charAt(i+1)=="'")
		{
			resultStr+=String.fromCharCode(kzLetter[81]); resultCode+="&#"+kzLetter[81]+";"; 
			i=i+1;
			}
		else { resultStr+=String.fromCharCode(kzLetter[73]); resultCode+="&#"+kzLetter[73]+";"; }//i
		bool1=1;
	}
	
	if (valcharstr==1256) { //O'i
	if (sourceareastr.charAt(i+1)=="i" || sourceareastr.charAt(i+1)=="I") 
		{
	        resultStr+=String.fromCharCode(kzLetter[16]); resultCode+="&#"+kzLetter[16]+";"; 
			resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;
		}//ii
	else
	if (sourceareastr.charAt(i+1)=="'")
		{
			resultStr+=String.fromCharCode(kzLetter[81]); resultCode+="&#"+kzLetter[81]+";"; 
			i=i+1;
			}
		else { resultStr+=String.fromCharCode(kzLetter[16]); resultCode+="&#"+kzLetter[16]+";"; }//i
		bool1=1;
	}
	
	if (valcharstr==1257) { //o'i
	if (sourceareastr.charAt(i+1)=="i" || sourceareastr.charAt(i+1)=="I") 
		{
	        resultStr+=String.fromCharCode(kzLetter[51]); resultCode+="&#"+kzLetter[51]+";"; 
			resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;
		}//ii
	else
	if (sourceareastr.charAt(i+1)=="'")
		{
			resultStr+=String.fromCharCode(kzLetter[81]); resultCode+="&#"+kzLetter[81]+";"; 
			i=i+1;
			}
		else { resultStr+=String.fromCharCode(kzLetter[51]); resultCode+="&#"+kzLetter[51]+";"; }//i
		bool1=1;
	}
	
	if (valcharstr==1198) { //U'i
	if (sourceareastr.charAt(i+1)=="i" || sourceareastr.charAt(i+1)=="I") 
		{
	        resultStr+=String.fromCharCode(kzLetter[22]); resultCode+="&#"+kzLetter[22]+";"; 
			resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;
		}//ii
	else
	if (sourceareastr.charAt(i+1)=="'")
		{
			resultStr+=String.fromCharCode(kzLetter[81]); resultCode+="&#"+kzLetter[81]+";"; 
			i=i+1;
			}
		else { resultStr+=String.fromCharCode(kzLetter[22]); resultCode+="&#"+kzLetter[22]+";"; }//i
		bool1=1;
	}
	
	if (valcharstr==1069) { //E'i
	if (sourceareastr.charAt(i+1)=="i" || sourceareastr.charAt(i+1)=="I") 
		{
	        resultStr+=String.fromCharCode(kzLetter[32]); resultCode+="&#"+kzLetter[32]+";"; 
			resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;
		}//ii
	else
	if (sourceareastr.charAt(i+1)=="'")
		{
			resultStr+=String.fromCharCode(kzLetter[81]); resultCode+="&#"+kzLetter[81]+";"; 
			i=i+1;
			}
		else { resultStr+=String.fromCharCode(kzLetter[32]); resultCode+="&#"+kzLetter[32]+";"; }//i
		bool1=1;
	}
	
	if (valcharstr==1101) { //e'i
	if (sourceareastr.charAt(i+1)=="i" || sourceareastr.charAt(i+1)=="I") 
		{
	        resultStr+=String.fromCharCode(kzLetter[67]); resultCode+="&#"+kzLetter[67]+";"; 
			resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;
		}//ii
	else
	if (sourceareastr.charAt(i+1)=="'")
		{
			resultStr+=String.fromCharCode(kzLetter[81]); resultCode+="&#"+kzLetter[81]+";"; 
			i=i+1;
			}
		else { resultStr+=String.fromCharCode(kzLetter[67]); resultCode+="&#"+kzLetter[67]+";"; }//i
		bool1=1;
	}
	
	if (valcharstr==1199) { //u'i
	if (sourceareastr.charAt(i+1)=="i" || sourceareastr.charAt(i+1)=="I") 
		{
	        resultStr+=String.fromCharCode(kzLetter[57]); resultCode+="&#"+kzLetter[57]+";"; 
			resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;
		}//ii
	else
	if (sourceareastr.charAt(i+1)=="'")
		{
			resultStr+=String.fromCharCode(kzLetter[81]); resultCode+="&#"+kzLetter[81]+";"; 
			i=i+1;
			}
		else { resultStr+=String.fromCharCode(kzLetter[57]); resultCode+="&#"+kzLetter[57]+";"; }//i
		bool1=1;
	}
	
	if (valcharstr==1045) { 
	if (sourceareastr.charAt(i+1)=="'")
	        if (sourceareastr.charAt(i+2)=="i" || sourceareastr.charAt(i+2)=="I"){
	        resultStr+=String.fromCharCode(kzLetter[32]); resultCode+="&#"+kzLetter[32]+";"; 
	        resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+2;} //E'i
	        else {resultStr+=String.fromCharCode(kzLetter[32]); resultCode+="&#"+kzLetter[2]+";"; i=i+1;}//E'
	        else if (sourceareastr.charAt(i+1)=="I" || sourceareastr.charAt(i+1)=="i")
	        {resultStr+=String.fromCharCode(kzLetter[5]); resultCode+="&#"+kzLetter[5]+";"; 
	        resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;}//Ei
	        else { resultStr+=String.fromCharCode(kzLetter[5]); resultCode+="&#"+kzLetter[5]+";"; }//E
	        bool1=1;
	}
	
	if (valcharstr==1077) { if (sourceareastr.charAt(i+1)=="'")
	        if (sourceareastr.charAt(i+2)=="i" || sourceareastr.charAt(i+2)=="I"){
	        resultStr+=String.fromCharCode(kzLetter[67]); resultCode+="&#"+kzLetter[67]+";"; 
	        resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+2;} //e'i
	        else {resultStr+=String.fromCharCode(kzLetter[67]); resultCode+="&#"+kzLetter[67]+";"; i=i+1;}//e'
	        else if (sourceareastr.charAt(i+1)=="I" || sourceareastr.charAt(i+1)=="i")
	        {resultStr+=String.fromCharCode(kzLetter[40]); resultCode+="&#"+kzLetter[40]+";"; 
	        resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;}//ei
	        else { resultStr+=String.fromCharCode(kzLetter[40]); resultCode+="&#"+kzLetter[40]+";"; }//e
	        bool1=1;
	}
	
	//Ydan kein i keletin bolsa nukteli i 31 1067
	if (valcharstr==1067) { //Yi
	if (sourceareastr.charAt(i+1)=="i" || sourceareastr.charAt(i+1)=="I") 
		{
	//        resultStr+=String.fromCharCode(kzLetter[30]); resultCode+="&#"+kzLetter[30]+";"; 
			resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;
		}
	}
	//ydan kein i kelse
	if (valcharstr==1099) { //yi
	if (sourceareastr.charAt(i+1)=="i" || sourceareastr.charAt(i+1)=="I") 
		{
	//        resultStr+=String.fromCharCode(kzLetter[30]); resultCode+="&#"+kzLetter[30]+";"; 
			resultStr+=String.fromCharCode(kzLetter[45]); resultCode+="&#"+kzLetter[45]+";"; i=i+1;
		}
	}
	
	if (charstr==lnLetter[j]) {resultStr+= String.fromCharCode(kzLetter[j]); resultCode+="&#"+kzLetter[j]+";"; bool1=1;}
	    j++;
	} // while j end

if (bool1==0) 
{ if (charstr=="[") while(sourceareastr.charAt(i)!="]" && i<strlen){
	                          	   resultStr+=sourceareastr.charAt(i); resultCode+=sourceareastr.charAt(i); 
	                                   i++;
	                                  }
		       resultStr+=sourceareastr.charAt(i); resultCode+=sourceareastr.charAt(i); }
	   i++;
       } //while i end

	return resultStr;
	}
	else
	return text;
 } 