// TODO: Commented for messenger masking
var host = window.external;
// Hash containg Start and End Characters for different Languages.
 StartHash =new Array();
 StartHash["HI"] = '\u0900';
 StartHash["MA"] = '\u0900';
 StartHash["GU"] = '\u0a80';
 StartHash["PN"] = '\u0a00';
 StartHash["ML"] = '\u0d00';
 StartHash["AS"] = '\u0980';
 StartHash["BN"] = '\u0980';
 StartHash["TM"] = '\u0b80';
 StartHash["TG"] = '\u0c00';
 StartHash["KN"] = '\u0c80';
 StartHash["OR"] = '\u0b00';
 
 EndHash = new Array();
 
 EndHash["HI"] = '\u097f';
 EndHash["MA"] = '\u097f';
 EndHash["GU"] = '\u0aff';
 EndHash["PN"] = '\u0a7f';
 EndHash["ML"] = '\u0d7f';
 EndHash["AS"] = '\u09ff';
 EndHash["BN"] = '\u09ff';
 EndHash["TM"] = '\u0bff';
 EndHash["TG"] = '\u0c7f';
 EndHash["KN"] = '\u0cff';
 EndHash["OR"] = '\u0b7f';
 
 PHONETIC=0;
 
 INSCRIPT=1;
 
 var textBox = null;
 
function Common(langid,kbdid,textBox1)
{
//Variables
 this.MIN_NUMBER_OF_WORDS = 0; //Minimum number of Words in HELP
 this.MAX_NUMBER_OF_WORDS = 0; //Maximum number of Words in HELP
 this.PREVIOUS_TRAVEL_HELP = 0; 
 this.NEXT_TRAVEL_HELP = 0;
 this.golbalConso;

 this.isPrev;
  
 this.langid=langid; 
 
 this.kbdid=kbdid;
 
 this.kdbname =kbdid; 
 
 this.common;
 
 textBox = textBox1; 
  
 
 // Methods
 this.Initialize = Initialize;
 
 this.Initialize_KeyBoard=Initialize_KeyBoard;
 
 this.calculateNumberOfWords=calculateNumberOfWords;
 
 this.toUnicode=toUnicode;
 
 this.DisplayHelp=DisplayHelp;
 
 this.inscriptToUnicode=inscriptToUnicode;
 
 this.toUnicode_PN=toUnicode_PN;
 
 this.toUnicode_TM=toUnicode_TM;
 
 this.toUnicode_TG=toUnicode_TG;
 
 this.toUnicode_KN=toUnicode_KN;
 
 this.toUnicode_ML=toUnicode_ML;
 
 this.replace=replace;
 
 this.getUnicodeMatra = getUnicodeMatra;
 
 this.getUnicodeVowel=getUnicodeVowel;
 
 this.CreatePrevTable=CreatePrevTable;
 
 this.CreateNextTable=CreateNextTable;
 
 this.CreateTable=CreateTable;
 
 this.getUnicodeConsonant=getUnicodeConsonant;
 
 this.getIndicStart=getIndicStart;
 
 this.getIndicEnd=getIndicEnd;
  
 this.DisplayKeyBoard=DisplayKeyBoard;
 
 this.trim=trim;
 
 this.Send_Msg=Send_Msg;
 
 this.stripHTML=stripHTML;
 
 this.Search_Msg=Search_Msg;
 
 this.onLoad=onLoad;
 
 this.limitText=limitText;
 
 this.setObject= setObject;
 
 this.getObject = getObject;
 
 this.setTextBox = setTextBox;
  
 this.resource = new Resource();  
 
}

function showHelp(langid)
{    
  document.getElementById('helpLanguage').value= langid;
  var win = window.open('langHelp.html','Help','width=570,height=180,left=10,top=100,screenX=10,screenY=100,status=no,scrollbars=no,directories=no,location=center,resizable=no,titlebar=no,modal=yes');
  win.focus();
}

function setTextBox(textBoxid)
{
 textBox = textBoxid;
}

function setObject(common)
{
 this.common = common;
}
function getObject()
{
 	 return common;
}

/* 
** Method for decide this.MAX_NUMBER_OF_WORDS or this.MIN_NUMBER_OF_WORDS for help
*/

function calculateNumberOfWords()
 {
 
 
 if(document.getElementById('help') == null)
  {
    this.MAX_NUMBER_OF_WORDS = 8;
    this.MIN_NUMBER_OF_WORDS = 5;
  }
  else
  {   
        var divWidth = 0;    	
	    if(document.getElementById('help').style.width.indexOf('px') > -1)
    	 {
	      divWidth = document.getElementById('help').style.width.substring(0,document.getElementById('help').style.width.indexOf('px'));
	      divWidth = Math.round(divWidth / 35);	      
	      this.MIN_NUMBER_OF_WORDS = Math.abs(divWidth - 3);	      
	      this.MAX_NUMBER_OF_WORDS = Math.abs(divWidth);	      	 
	     }
	     else if(document.getElementById('help').style.width.indexOf('%') > -1)
	     {
	      divWidth =document.getElementById('help').style.width.substring(0,document.getElementById('help').style.width.indexOf('px'));
	      divWidth = Math.round(divWidth / 35);	      
	      this.MIN_NUMBER_OF_WORDS = Math.abs(divWidth - 3);	      
	      this.MAX_NUMBER_OF_WORDS = Math.abs(divWidth);	      
	     }   
	     else
	     {
	       this.MAX_NUMBER_OF_WORDS = 8;
	       this.MIN_NUMBER_OF_WORDS = 5;
	     }   	      
   }
 }

		/**
	 *
	 * Method to convert English word(without spaces) into unicode word.
	 * @param engWord English word to convert.
	 * @param Starting unicode character for selected language in which unicode output is required.
	 * @return Unicode String
	 */
function toUnicode(textBox,startChar)
{  
	var engWord =	textBox;
	var unicode;
	
	//If current keyboard is INSCRIPT 
	if(this.kbdid == INSCRIPT)
         return this.inscriptToUnicode(textBox);
		
	if(startChar == '\u0a00')
         return this.toUnicode_PN(textBox,startChar);
    else if(startChar == '\u0b80')
		return this.toUnicode_TM(textBox,startChar);
	else if(startChar == '\u0C00')
		return this.toUnicode_TG(textBox,startChar);	
		else if(startChar == '\u0C80')
		return this.toUnicode_KN(textBox,startChar);	
		
	else if(startChar == '\u0D00')
		return this.toUnicode_ML(textBox,startChar);		
	
	
	if(engWord == null || engWord.length == 0)
		return "";

	if(startChar.charCodeAt() == 0)
		return "Language not supported";


	if(this.resource.userSpell[engWord])
	{
		engWord = this.resource.userSpell[engWord];
	}

	var engWordLength = engWord.length;

	var k = 0;
	var l = 0;
	var find = 0;
	var tempEngWord = "";

	//To change Uppercase Charecter to Lowercase

	for (k = 0 ; k < engWordLength; k++)
	{
		find = 0; 
		cChar = engWord.charAt(k);
		// Certain uppercase characters are used to indicate a hindi characters.
		// Such characters should not be converted to lower case.
		for (l = 0 ; l < this.resource.charOnlyUppercase.length ; l++)
		{
			if (cChar == this.resource.charOnlyUppercase[l])
			{
				find = 1;
			}
		}
		if(find)
		{
                  tempEngWord= tempEngWord.concat(cChar);
		}
		else
		{ 
			cChar=cChar.toLowerCase();
			tempEngWord= tempEngWord.concat(cChar);
		}
	}

	engWord = tempEngWord;
	engWord = this.replace(engWord);
	engWordLength = engWord.length;	
	// If a word end with 'a' and preceded by consonant, then append 'a'. e.g. babita should be changed to babitaa


	/*if(engWordLength > 2 && engWord.charAt(engWordLength-1) == 'a' && !indicResource.isVowel(engWord.charAt (engWordLength-2)))
	{
	engWord.append('a') ;
	engWordLength +=1;
	}*/

	var i = 0;
	var found = 0;
	var j;


	// Unicode string
	var unicodeWord = "";
	var tmpChar ;

	// Variable for checking if previous character is consonant or not

	var prevConsoFlag = 0;
	var prevVowelFlag = 0;
	
	
	while(i < engWordLength)
	{
		// check for vowel and matra.
		found = 0;

		for( j = 2; j > 0; j--)
		{
			if(i+j <= engWordLength)
			{
				var stTmp = engWord.substring(i, i+j);
				if(engWord.substring(i, i+j)=="M")
				{
					tmpChar = String.fromCharCode(startChar.charCodeAt() + 1);
					i+=j;
					if(unicodeWord.length > 1 && unicodeWord.charAt(unicodeWord.length-1)==String.fromCharCode(startChar.charCodeAt() + 77))
					unicodeWord=unicodeWord.substring(0,unicodeWord.length-1);	
					unicodeWord=unicodeWord.concat(tmpChar);
      				engGlyph=engBase+stTmp;
					found = 1;
					break;
				}
				else if(engWord.substring(i, i+j)== "^")
				{
					tmpChar = String.fromCharCode(startChar.charCodeAt() + 2);
					i+=j;
					if(unicodeWord.length > 1 && unicodeWord.charAt(unicodeWord.length-1)==String.fromCharCode(startChar.charCodeAt() + 77))
					unicodeWord=unicodeWord.substring(0,unicodeWord.length-1);	
					unicodeWord=unicodeWord.concat(tmpChar);
					engGlyph=engBase+stTmp;
					found = 1;
					break;
				}
				else if(engWord.substring(i, i+j)=="H")
				{
					tmpChar = String.fromCharCode(startChar.charCodeAt() + 3);													
					i+=j;
					if(unicodeWord.length > 1 && unicodeWord.charAt(unicodeWord.length-1)==String.fromCharCode(startChar.charCodeAt() + 77))
					unicodeWord=unicodeWord.substring(0,unicodeWord.length-1);	
					unicodeWord=unicodeWord.concat(tmpChar);
					engGlyph=engBase+stTmp;
					found = 1;
					break;
				}	

				// If previous character is consonant, then append matra, else append vowel.
				if(prevConsoFlag)
				{
					if(engWord.charAt(i-1)=="R" && (engWord.substring(i, i+j)=="a" || engWord.substring(i, i+j)=="u" || engWord.substring(i, i+j)=="i"))
					{
						tmpChar="";
					}
					else
					{
						tmpChar = this.getUnicodeMatra(engWord.substring(i, i+j), startChar);
					}

					// Append matra if it is not 'a'
					if(tmpChar != 'a' && tmpChar != '?')
					{
						if(prevConsoFlag)
						{
							unicodeWord = unicodeWord.substring(0, unicodeWord.length-1);
						}
						unicodeWord=unicodeWord.concat(tmpChar);
						engGlyph=engBase+stTmp;
      					prevConsoFlag = 0;
						prevVowelFlag = 0;
					}
					else if(tmpChar =='a')
					{
						if(prevConsoFlag)
						{
							unicodeWord = unicodeWord.substring(0, unicodeWord.length-1);
                                     	engGlyph=engBase+stTmp;
      		
						}
					}
				}
				else
				{
					if(engWord.charAt(i-1)=="R" && (engWord.substring(i, i+j)=="a" || engWord.substring(i, i+j)=="u" || engWord.substring(i, i+j)=="i"))
					{
						tmpChar="";
					}
					else
						tmpChar = this.getUnicodeVowel(engWord.substring(i, i+j), startChar);
						
					if(tmpChar != '?')
					{

						unicodeWord=unicodeWord.concat(tmpChar);
						engBase=stTmp;
						engGlyph=engBase;
                                    prevVowelFlag = 1;
					}
				}
				if(tmpChar != '?')
				{
					prevConsoFlag=0;
					found = 1;
					i += j;
					break;
				}
			}
		}
		if(found) 
		{
			continue;
		}

		// check for consonant.
		found = 0;

		for(j = 3; j > 0; j--)
		{
			if(i+j <=engWordLength)
			{
				var stTmp = engWord.substring(i, i+j);
				tmpChar = this.getUnicodeConsonant(engWord.substring(i, i+j), startChar);
				if(tmpChar != '?')
				{
					if(prevConsoFlag && engWord.charAt(i-1)=='n' && i-1 != 0)
					{
					unicodeWord = unicodeWord.substring(0,unicodeWord.length-2);
					unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 2));
					}

					unicodeWord = unicodeWord.concat(tmpChar);
					// If consonant is followed by consonant, append halant
					unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 77));
					
					engBase = stTmp;
					engGlyph=engBase;
					prevConsoFlag = 1;
					found = 1;
					this.golbalConso = engWord.substring(i, i+j);
					i += j;
					break;
				}
			}
		}

		if(found)
		{
			continue;
		}
		else // if no match found, append input char as is e.g. number, symbols etc) 
		{	
			var stTmp="";
			stTmp = stTmp + engWord.charAt(i).toLowerCase();
			prevConsoFlag=0;

			if(!prevConsoFlag)
				tmpChar = this.getUnicodeVowel(stTmp,startChar);
			else
				tmpChar = this.getUnicodeMatra(stTmp,startChar);

			if(tmpChar=='?')
			{
				tmpChar = this.getUnicodeConsonant(stTmp,startChar);
				if(tmpChar!='?')
				prevConsoFlag=1;
			}

			if(tmpChar!='?')
				unicodeWord =unicodeWord.concat(tmpChar);
			else
			{
				if(engWord.charAt(i)!='?')
					unicodeWord = unicodeWord.concat(engWord.charAt(i));
			}
			if(prevConsoFlag)
			{
				unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 77));
			}
		}
		i++;
			
	}

	if(unicodeWord.length > 1 && unicodeWord.charAt(unicodeWord.length-1)==String.fromCharCode(startChar.charCodeAt() + 77))
	unicodeWord=unicodeWord.substring(0,unicodeWord.length-1);		
	return unicodeWord;
}
 
/**
 *
 * Method to convert English word(without spaces) into unicode word.
 * @param engWord English word to convert.
 * @param Starting unicode character for selected language in which unicode output is required.
 * @return Unicode String
 */

	 /**
	 * Get Unicode Vowel
	 **/

	 function getUnicodeVowel(engString, startChar)
	 {
			 var i;
		 //engString = this.replace(engString);
		
		 for(i=0; i < this.resource.vowelLength; i++)
		 {
				if(engString == this.resource.engToUniVowel[i])
					{
			 return String.fromCharCode(startChar.charCodeAt()+ 5+i);
					} 
				//return uniVowel[i];
		 }
			 /*if(engString=="om")
		 { 
		return String.fromCharCode(startChar.charCodeAt() + 80);
		 }*/
	
		 return '?';

	 }

	 /**
	 * Get Unicode Matra
	 **/
	 function getUnicodeMatra(engString,startChar)
	 {
			 if(engString == "a")
				return 'a';
		 //engString = this.replace(engString);
			 	
		 for(i=1; i < this.resource.vowelLength; i++)
		 {
				if(engString ==this.resource.engToUniVowel[i])
				return String.fromCharCode(startChar.charCodeAt() + 61+i);

		 }

/*		if(engString=="aM" || engString=="M")
		{ 
				return String.fromCharCode(startChar.charCodeAt() + 1)
		}
		 else if(engString=="aH" || engString=="H")
		 {
	 		return String.fromCharCode(startChar.charCodeAt() + 3)
 		 } 
		 else if(engString=="a^" || engString=="^")
		 { 
			 return String.fromCharCode(startChar.charCodeAt() + 2)
 		 }
*/	
			 return '?';
	}



	/**
	 * Get Unicode Consonant
	 **/
	function getUnicodeConsonant(engString,startChar)
	{
				
		 //engString = this.replace(engString);
						 		
		for(i=0; i < this.resource.consonantLength; i++)
		{
			if(engString == this.resource.engConsonant[i])
						{
					return String.fromCharCode(startChar.charCodeAt() + 21+i);
						} 
				//return uniConsonant[i];
		}

		if(this.resource.langConjuncts[engString])
		{
			 return this.resource.langConjuncts[engString];
		}

					 
		return '?';
	}

	function replace(engString)
	{
		var i=0;
			/*	var len = engString.length;
				
				while (i < len)
				{
				 var c = engString.charAt(i);
				 if(c == 'c')
				 {
						var cNext = "";
						if(i+1< len)
						{
							cNext = engString.charAt(i+1);
						}
						if(cNext != 'h' && len > 1)
						{
									 engString = engString.replace(c,k);
						}
					}
					else
					{
							for(i=0;i<this.resource.engReplace.length;i++)
							{
								if(engString.indexOf(this.resource.engReplace[i])!=-1)
									 engString = engString.replace(this.resource.engReplace[i],this.resource.engReplaceBy[i]);
							}

					}
					i++;
				}*/

		var npos = 	-1;	
		if(engString.charAt(0)=='M' || engString.charAt(0)=='H')
		{
			//abhishek to add code
			 engString = engString.replace(engString.charAt(0),engString.charAt(0).toLowerCase());
						
		}
			 for(i=0; i<this.resource.engReplace.length; i++)
			{
			npos = engString.indexOf(this.resource.engReplace[i],npos+1);
			while(npos!=-1)
			{
					/*if(npos!=-1 && this.resource.engReplace[i] == "c" && engString.length > npos+1 && engString.charAt(npos+1)=='h')
	 			{
				//npos+=1;
				//break;	
				}
				 else*/
						 engString = engString.replace(this.resource.engReplace[i],this.resource.engReplaceBy[i]);
			 
			 npos = engString.indexOf(this.resource.engReplace[i],npos+1);
		
				 }	
				}				 
	
		return engString;	
	}


		 /**
		 * Get Start Unicode char for language
		 */
	 function getIndicStart(lang)
	 {							
			var startc= StartHash[lang];
			if(startc != null)
				return startc;
			else
			return 0;
		 }
 
 
		/**
	 * Get end Unicode char for language
	 */
	function getIndicEnd(lang)
	{
				var endc= EndHash[lang];
		if(endc != null)
			return endc;
		else
			return 0;
	}

		 /**
		 * Display Dynamic Unicode Help for each character selected in Keyboard.
		 */
function DisplayHelp(uniChar,engWord,startChar,Matra)
{            
  
    // Method calling for calculate number of words will be display in help div
    this.calculateNumberOfWords();   
    
    this.PREVIOUS_TRAVEL_HELP = 1; 
    
    this.NEXT_TRAVEL_HELP = 1;
    
	var temp;
	
	var unicode;
	
	var isVowel = 0;  	
	
    this.CreateNextTable(uniChar,engWord,startChar,Matra);     
}

/**
* Display Next button if word length is greater than 2.
**/
function CreateNextTable(uniChar,engWord,startChar,Matra)
{         

   
 	var temp ="";	
	var HTML = "";
	var unicode;
	var isVowel = 0;	
	
    temp = "<LABEL onclick=\"getObject().CreateNextTable('" + uniChar + "','" + engWord +"','" + startChar + "','" + Matra + "')\">";
    temp = temp + "<img src='images/leftArrow.gif' align='left'></LABEL>";    
          
	 var HTML = "<table class='HelpOuterTable'><tr><td width='10' align='left'>" + temp + "</td><td>";
         HTML = HTML + "<table id='HelpInnerTable1' class='HelpInnerTable'>";        
         
	if((uniChar.charCodeAt() >= startChar.charCodeAt()+ this.resource.vowelStart) && (uniChar.charCodeAt() <= startChar.charCodeAt()+ this.resource.vowelEnd))
	{
		 engWord = "";
		 isVowel = 1;
			if(this.resource.engToUniVowel[0] == Matra)
			{ 
			 temp_eng = "<LABEL size='1' class=TdHeader3 onClick=\"return updatePositionOnHelp(document.getElementById (this.textBox),'" + this.trim(this.resource.engToUniVowel[0]) + "','false','true','" + startChar + "')\">" + this.resource.engToUniVowel[0] + "</LABEL>" ;
      		 unicode = this.toUnicode(this.resource.engToUniVowel[0], startChar);
			 temp_uni = "<LABEL size='1' class=TdHeader3 onClick=\"return updatePositionOnHelp(document.getElementById (this.textBox),'" + this.trim(this.resource.engToUniVowel[0]) + "','false','true','" + startChar + "')\">" + unicode + "</LABEL>" ;
      		 }
		 else
		 {
			 temp_eng = "<LABEL size='1' class=TdHeader1 onClick=\"return updatePositionOnHelp(document.getElementById (this.textBox),'" + this.trim(this.resource.engToUniVowel[0]) + "','false','true','" + startChar + "')\">" + this.resource.engToUniVowel[0] + "</LABEL>" ;
			 unicode = this.toUnicode(this.resource.engToUniVowel[0], startChar);
			 temp_uni = "<LABEL size='1' class=TdHeader1 onClick=\"return updatePositionOnHelp(document.getElementById (this.textBox),'" + this.trim(this.resource.engToUniVowel[0]) + "','false','true','" + startChar + "')\">" + unicode + "</LABEL>" ;
		 }
	}
	else
	{
		 if(engWord == Matra)
		 {
			 temp_eng = "<LABEL size='1' class=TdHeader3 onClick=\" return updatePositionOnHelp(document.getElementById (this.textBox),'" + this.trim(engWord) + "','false','true','" + startChar + "')\">" + engWord + "</LABEL>";
			 unicode = this.toUnicode(engWord, startChar);
			 temp_uni = "<LABEL size='1' class=TdHeader3 onClick=\"return updatePositionOnHelp(document.getElementById (this.textBox),'" + this.trim(engWord) + "','false','true','" + startChar + "')\">" + unicode + "</LABEL>" ;
		 }
		 else
		 {
			 temp_eng = "<LABEL size='1' class=TdHeader1 onClick=\" return updatePositionOnHelp(document.getElementById (this.textBox),'" + this.trim(engWord) + "','false','true','" + startChar + "')\">" + engWord + "</LABEL>";
			 unicode = this.toUnicode(engWord, startChar);
			 temp_uni = "<LABEL size='1' class=TdHeader1 onClick=\"return updatePositionOnHelp(document.getElementById (this.textBox),'" + this.trim(engWord) + "','false','true','" + startChar + "')\">" + unicode + "</LABEL>" ;
		 } 
	}	
       temp = "<LABEL size='1' onclick=\"getObject().CreatePrevTable('" + uniChar + "','" + engWord +"','" + startChar + "','" + Matra + "')\">";
       temp = temp + "<img src='images/rightArrow.gif'></LABEL>";     
       
       if(engWord.length > 2)
        {    
         // LOGIC FOR HELP TRAVELSAL ACCORDING TO HELP DIV WIDTH   
         this.NEXT_TRAVEL_HELP = ((this.PREVIOUS_TRAVEL_HELP + this.MIN_NUMBER_OF_WORDS) -1);            
       	 HTML = HTML.concat(this.CreateTable(this.PREVIOUS_TRAVEL_HELP,this.NEXT_TRAVEL_HELP,engWord,startChar,temp_eng,temp_uni,Matra));
       	 this.PREVIOUS_TRAVEL_HELP = (this.PREVIOUS_TRAVEL_HELP - this.MIN_NUMBER_OF_WORDS);
       	 if(this.PREVIOUS_TRAVEL_HELP <= 0)
       	  {
       	   this.PREVIOUS_TRAVEL_HELP = 1;
       	  }
       	}
       else
        {      
        
         // LOGIC FOR HELP TRAVELSAL ACCORDING TO HELP DIV WIDTH  
         this.NEXT_TRAVEL_HELP = ((this.PREVIOUS_TRAVEL_HELP + this.MAX_NUMBER_OF_WORDS) -1);       
        // alert(" this.PREVIOUS_TRAVEL_HELP : "+this.PREVIOUS_TRAVEL_HELP+" this.NEXT_TRAVEL_HELP : "+this.NEXT_TRAVEL_HELP);
       	 HTML = HTML.concat(this.CreateTable(this.PREVIOUS_TRAVEL_HELP,this.NEXT_TRAVEL_HELP,engWord,startChar,temp_eng,temp_uni,Matra));
       	 this.PREVIOUS_TRAVEL_HELP = (this.PREVIOUS_TRAVEL_HELP - this.MAX_NUMBER_OF_WORDS);
       	 if(this.PREVIOUS_TRAVEL_HELP <= 0)
       	  {
       	   this.PREVIOUS_TRAVEL_HELP = 1;
       	  }
       	}

	 HTML = HTML.concat("</table>");
     HTML = HTML + "</td><td width='10' align='right'>"+ temp + "</td></tr></table>";
    
    if(document.getElementById('help') != null)		 	  
		document.getElementById('help').innerHTML = HTML ;
     this.isPrev = 0;    
    
	 return false;	
	 
}


/**
* Display Prev button if word length is greater than 2.
*/
function CreatePrevTable(uniChar,engWord,startChar,Matra)
{       
	 var temp ="";	
	 var HTML = "";
	 var unicode;
	 var isVowel = 0;
	 
    temp = "<LABEL onclick=\"getObject().CreateNextTable('" + uniChar + "','" + engWord +"','" + startChar + "','" + Matra + "')\">";
    
    temp = temp + "<img src='images/leftArrow.gif' align='left'></LABEL>";
    

    var HTML = "<table class='HelpOuterTable'><tr><td width='10' align='right'>" + temp + "</td><td>";
        HTML = HTML + "<table id='HelpInnerTable1' class='HelpInnerTable'>";

	if((uniChar.charCodeAt() >= startChar.charCodeAt()+ this.resource.vowelStart) && (uniChar.charCodeAt() <= startChar.charCodeAt()+ this.resource.vowelEnd))
	{
		  engWord = "";
		  isVowel = 1;
			if(this.resource.engToUniVowel[0] == Matra)
			{ 
			 temp_eng = "<LABEL size='1' class=TdHeader3 onClick=\" return updatePositionOnHelp(document.getElementById (this.textBox),'" + this.trim(engWord) + "','false','true','" + startChar + "')\">" + this.resource.engToUniVowel[0] + "</LABEL>" ;
			 unicode = this.toUnicode(this.resource.engToUniVowel[0], startChar);
			 temp_uni = "<LABEL size='1' class=TdHeader3 onClick=\"return updatePositionOnHelp(document.getElementById (this.textBox),'" + this.trim(this.resource.engToUniVowel[0]) + "','false','true','" + startChar + "')\">" + unicode + "</LABEL>" ;
		    }
		    else
		    {
			 temp_eng = "<LABEL size='1' class=TdHeader1 onClick=\" return updatePositionOnHelp(document.getElementById (this.textBox),'" + this.trim(engWord) + "','false','true','" + startChar + "')\">" + this.resource.engToUniVowel[0] + "</LABEL>" ;
			 unicode = this.toUnicode(this.resource.engToUniVowel[0], startChar);
			 temp_uni = "<LABEL size='1' class=TdHeader1 onClick=\"return updatePositionOnHelp(document.getElementById (this.textBox),'" + this.trim(this.resource.engToUniVowel[0]) + "','false','true','" + startChar + "')\">" + unicode + "</LABEL>" ;
		    }
	}  
	else
	{
		 if(engWord == Matra)
		 {
			 temp_eng = "<LABEL size='1' class=TdHeader3 onClick=\" return updatePositionOnHelp(document.getElementById (this.textBox),'" + this.trim(engWord) + "','false','true','" + startChar + "')\">" + engWord + "</LABEL>";
			 unicode = this.toUnicode(engWord, startChar);
			 temp_uni = "<LABEL size='1' class=TdHeader3 onClick=\"return updatePositionOnHelp(document.getElementById (this.textBox),'" + this.trim(engWord) + "','false','true','" + startChar + "')\">" + unicode + "</LABEL>" ;
		 }
		 else
		 {
			 temp_eng = "<LABEL size='1' class=TdHeader1 onClick=\" return updatePositionOnHelp(document.getElementById (this.textBox),'" + this.trim(engWord) + "','false','true','" + startChar + "')\">" + engWord + "</LABEL>";
			 unicode = this.toUnicode(engWord, startChar);
			 temp_uni = "<LABEL size='1' class=TdHeader1 onClick=\"return updatePositionOnHelp(document.getElementById (this.textBox),'" + this.trim(engWord) + "','false','true','" + startChar + "')\">" + unicode + "</LABEL>" ;
		 } 
	 }

	   temp = "<LABEL size='1' onclick=\"getObject().CreatePrevTable('" + uniChar + "','" + engWord +"','" + startChar + "','" + Matra + "')\">";
       temp = temp + "<img src='images/rightArrow.gif'></LABEL>";
      
       if(engWord.length > 2)
        {         
           // LOGIC FOR HELP TRAVELSAL ACCORDING TO HELP DIV WIDTH
         this.PREVIOUS_TRAVEL_HELP = (this.NEXT_TRAVEL_HELP - this.MIN_NUMBER_OF_WORDS);
         if(this.PREVIOUS_TRAVEL_HELP <= 0)
         {
          this.PREVIOUS_TRAVEL_HELP = 1;
         }      
         
         var MAX_LENGTH = (this.NEXT_TRAVEL_HELP + this.MIN_NUMBER_OF_WORDS);
         
         if(MAX_LENGTH >= (this.resource.engToUniVowel.length+3))
       	  {
       	   MAX_LENGTH = (this.resource.engToUniVowel.length+3);
       	  }       
       	  
       	  
       	  if(this.NEXT_TRAVEL_HELP >= MAX_LENGTH-3)
       	  {       	       
        	HTML = HTML.concat(this.CreateTable((this.NEXT_TRAVEL_HELP - this.MIN_NUMBER_OF_WORDS),MAX_LENGTH,engWord,startChar,temp_eng,temp_uni,Matra));       	 	   	           	            	
        	this.NEXT_TRAVEL_HELP = this.NEXT_TRAVEL_HELP - this.MIN_NUMBER_OF_WORDS;
        	this.PREVIOUS_TRAVEL_HELP = (this.NEXT_TRAVEL_HELP - this.MIN_NUMBER_OF_WORDS);         
         	if(this.PREVIOUS_TRAVEL_HELP <= 0)
        	 {
         	 this.PREVIOUS_TRAVEL_HELP = 1;
        	 }      
       	  }
       	  else
       	  {
        	HTML = HTML.concat(this.CreateTable(this.NEXT_TRAVEL_HELP,MAX_LENGTH,engWord,startChar,temp_eng,temp_uni,Matra));       	 	   	           	           	  
        	this.NEXT_TRAVEL_HELP = MAX_LENGTH;  
       	  }       	         	    	
       	}
        else
        {    
         
         // LOGIC FOR HELP TRAVELSAL ACCORDING TO HELP DIV WIDTH
                    
         this.PREVIOUS_TRAVEL_HELP = (this.NEXT_TRAVEL_HELP - this.MAX_NUMBER_OF_WORDS);         
         if(this.PREVIOUS_TRAVEL_HELP <= 0)
         {
          this.PREVIOUS_TRAVEL_HELP = 1;
         }      
         
         var MAX_LENGTH = (this.NEXT_TRAVEL_HELP + this.MAX_NUMBER_OF_WORDS);
         
         if(MAX_LENGTH >= (this.resource.engToUniVowel.length+3))
       	 {
       	   MAX_LENGTH = (this.resource.engToUniVowel.length+3);
       	 }       	    	         	
       
          //alert(" this.PREVIOUS_TRAVEL_HELP : "+this.PREVIOUS_TRAVEL_HELP+" 	this.NEXT_TRAVEL_HELP : "+this.NEXT_TRAVEL_HELP+" MAX_LENGTH : "+MAX_LENGTH);  
       	  if(this.NEXT_TRAVEL_HELP >= MAX_LENGTH-3)
       	  {       	       
        	HTML = HTML.concat(this.CreateTable((this.NEXT_TRAVEL_HELP - this.MAX_NUMBER_OF_WORDS),MAX_LENGTH,engWord,startChar,temp_eng,temp_uni,Matra));       	 	   	           	            	
        	this.NEXT_TRAVEL_HELP = this.NEXT_TRAVEL_HELP - this.MAX_NUMBER_OF_WORDS;
        	this.PREVIOUS_TRAVEL_HELP = (this.NEXT_TRAVEL_HELP - this.MAX_NUMBER_OF_WORDS);         
         	if(this.PREVIOUS_TRAVEL_HELP <= 0)
        	 {
         	 this.PREVIOUS_TRAVEL_HELP = 1;
        	 }      
       	  }
       	  else
       	  {
        	HTML = HTML.concat(this.CreateTable(this.NEXT_TRAVEL_HELP,MAX_LENGTH,engWord,startChar,temp_eng,temp_uni,Matra));       	 	   	           	           	  
        	this.NEXT_TRAVEL_HELP = MAX_LENGTH; 
       	  }       	                    	      
       	 }
 	   HTML = HTML.concat("</table>");
 	   HTML = HTML + "</td><td width='10' align='right'>" + temp +  "</td></tr></table>";
       if(document.getElementById('help') != null)	
		   document.getElementById('help').innerHTML = HTML ;
       this.isPrev = 1;
	 return false;
}

/**
*** Create Table for help
**/
function CreateTable(loopstart,loopend,engWord,startChar,temp_eng,temp_uni,Matra)
{   
 var j,i;
 j = 0;
 var k;
 var temp;
 var unicode;
 var HTML = "";	
 var fontstyle;
 var fontstyle1;    
  var joo = 0;
 var temp1 = "";
    
 fontstyle = "<font class=" + this.langid + "Font>";
 fontstyle1 = "<font class=" + this.langid + "Font1>";

 // LANGUAGE CHARACTER LIST ROW	
 HTML = HTML.concat("<tr>");
  
 // if(loopend <= this.resource.engToUniVowel.length)
 if(loopstart == 1)
  {      
   if(engWord == Matra || this.resource.engToUniVowel[0] == Matra)
   {
     HTML = HTML.concat("<td class='TdHeader3'>");
     HTML = HTML.concat(fontstyle1);
   }
   else
   {
     HTML = HTML.concat("<td class='TdHeader1'>");
     HTML = HTML.concat(fontstyle);
   }
   HTML = HTML + temp_uni;
   HTML = HTML.concat("</font></td>");
  
  }   
             
  j= 0;	
  
  for(i=loopstart;i<loopend; i++)
   {
    if(typeof this.resource.engToUniVowel[i] == 'undefined')
    {     
    }//END IF   
	else if(this.resource.engToUniVowel[i] != "")
	{	
     if (i == (loopend-4) && loopend > this.resource.engToUniVowel.length) 
      {      
       for(k=0; k<this.resource.VowelModifiers.length;k++)
        {                              
         if(engWord == "")
          {
           temp = "a" + this.resource.VowelModifiers[k] ;
          }//End of IF 
         else
          {
           temp = engWord + this.resource.VowelModifiers[k];
          }// End Else            
 		  unicode = this.toUnicode(temp, startChar);				
    	  if(temp == Matra)
		  {
		   HTML = HTML.concat("<td class=TdHeader4>");
		   HTML = HTML.concat(fontstyle1);
		   temp_uni = "<LABEL size='1' class=TdHeader4 onClick=\"return updatePositionOnHelp(document.getElementById (textBox),'" + this.trim(temp) + "','false','true','" + startChar + "')\">" + unicode + "</LABEL>" ;
		  }//End IF
		  else
		  {
		   HTML = HTML.concat("<td class=TdHeader2>");
		   HTML = HTML.concat(fontstyle);
		   temp_uni = "<LABEL size='1' class=TdHeader2 onClick=\"return updatePositionOnHelp(document.getElementById (textBox),'" + this.trim(temp) + "','false','true','" + startChar + "')\">" + unicode + "</LABEL>" ;
		  }//End Else                  
   	      HTML = HTML + temp_uni;
		  HTML = HTML.concat("</font></td>");	
	   }//End For    
      if(loopstart == loopend)
       {                       
         temp = "&nbsp;";
         for(k=0;k<12;k++)
          {
            unicode = "&nbsp;";                              
            if(temp == Matra)
	  	    {
		     HTML = HTML.concat("<td class=TdHeader4>");
			 HTML = HTML.concat(fontstyle1);
			 temp_uni = "<LABEL size='1' class=TdHeader4 onClick=\"return updatePositionOnHelp(document.getElementById (textBox),'" + this.trim(temp) + "','false','true','" + startChar + "')\">" + unicode + "</LABEL>" ;
			}//END IF
		    else
			{
			 HTML = HTML.concat("<td class=TdHeader2>");
		     HTML = HTML.concat(fontstyle);
			 temp_uni = "<LABEL size='1' class=TdHeader2 onClick=\"return updatePositionOnHelp(document.getElementById (textBox),'" + this.trim(temp) + "','false','true','" + startChar + "')\">" + unicode + "</LABEL>" ;
			}//END ELSE
	        HTML = HTML + temp_uni;
			HTML = HTML.concat("</font></td>");
			  
           }//END FOR 
         }//END IF                      
        break;		  
	   }//END IF
	  else
	  {  
	   if(j%2 == 0)
	   {
	    temp = engWord + this.resource.engToUniVowel[i];     
		unicode = this.toUnicode(temp, startChar);					   
		if(temp == Matra)
		{
		  HTML = HTML.concat("<td class='TdHeader4'>");
		  HTML = HTML.concat(fontstyle1);
		  temp_uni = "<LABEL size='1' class='TdHeader4' onClick=\"return updatePositionOnHelp(document.getElementById (textBox),'" + this.trim(temp) + "','false','true','" + startChar + "')\">" + unicode + "</LABEL>" ;
		}//END IF
		else
		{
		  HTML = HTML.concat("<td class='TdHeader2'>");
		  HTML = HTML.concat(fontstyle);
		  temp_uni = "<LABEL size='1' class='TdHeader2' onClick=\"return updatePositionOnHelp(document.getElementById (textBox),'" + this.trim(temp) + "','false','true','" + startChar + "')\">" + unicode + "</LABEL>" ;
   		}//END ELSE
        HTML = HTML + temp_uni;
	    HTML = HTML.concat("</font></td>");	       
	   }//END IF
	  else
      {		      		     
	   temp = engWord + this.resource.engToUniVowel[i]; 	  
	       unicode = this.toUnicode(temp, startChar);
		   if(temp == Matra)
		   {
   		 	 HTML = HTML.concat("<td class='TdHeader3'>");
			 HTML = HTML.concat(fontstyle1);
			 temp_uni = "<LABEL size='1' class='TdHeader3' onClick=\"return updatePositionOnHelp(document.getElementById (textBox),'" + this.trim(temp) + "','false','true','" + startChar + "')\">" + unicode + "</LABEL>";
		   }//END IF
		   else
		   {
			 HTML = HTML.concat("<td class='TdHeader1'>");
			 HTML = HTML.concat(fontstyle);
			 temp_uni = "<LABEL size='1' class='TdHeader1' onClick=\"return updatePositionOnHelp(document.getElementById (textBox),'" + this.trim(temp) + "','false','true','" + startChar + "')\">" + unicode + "</LABEL>";
		   }//END ELSE
		   HTML = HTML + temp_uni;
		   HTML = HTML.concat("</font></td>");		 
	  }//END ELSE
     }//END ELSE
	 j++;
	}//END IF
	else
	{
	 //CHECK FOR EMPTY CHARACTER	 	
	 loopend++;
	}//END ELSE
  }//END FOR  
 //END OF LANGUAGE ROW	   
 HTML = HTML.concat("</tr>");
   
 //ROW OF ENGLISH CHARACTER CORRESPONDING TO LANGUAGE CHAR
 HTML = HTML.concat("<tr>");

// if(loopend <= this.resource.engToUniVowel.length)
 if(loopstart == 1)
 {        
  if(engWord == Matra || this.resource.engToUniVowel[0] == Matra)
  {
   HTML = HTML.concat("<td class='TdHeader3'><font class=HelpFont3>");
  }//END IF
  else
  {
   HTML = HTML.concat("<td class='TdHeader1'><font class=HelpFont1>");
  }//END ELSE
  HTML = HTML + temp_eng;
  HTML = HTML.concat("</font></td>");

 }//END IF
 
 j = 0;
 for(i=loopstart;i< loopend; i++)
 {	
  if(typeof this.resource.engToUniVowel[i] == 'undefined')
  {   
  }//END IF  
  else if(this.resource.engToUniVowel[i] != "")
   {
    if (i == (loopend-4) && loopend > this.resource.engToUniVowel.length)
     {
      for(k=0; k< this.resource.VowelModifiers.length;k++)
      {  
       if(engWord == "")
       {
         temp = "a" + this.resource.VowelModifiers[k] ;
       }//END IF
       else
       {
         temp = engWord + this.resource.VowelModifiers[k];
       }//END ELSE
       if(k%2 ==0)
       { 
        if(temp == Matra)
	    {
		 HTML = HTML.concat("<td class='TdHeader4'><font class=HelpFont4>");
		 temp_eng = "<LABEL size='1' class='TdHeader4' onClick=\" return updatePositionOnHelp(document.getElementById (textBox),' " + this.trim(temp) + "','false','true','" + startChar + "')\">" + temp + "</LABEL>" ;
	    }//END IF
	    else
	    {
         HTML = HTML.concat("<td class='TdHeader2'><font class=HelpFont2>");
 		 temp_eng = "<LABEL size='1' class='TdHeader2' onClick=\" return updatePositionOnHelp(document.getElementById (textBox),' " + this.trim(temp) + "','false','true','" + startChar + "')\">" + temp + "</LABEL>" ;
        }//END ELSE
       }//END IF
       else
       { 
        if(temp == Matra)
	    {
	     HTML = HTML.concat("<td class='TdHeader4'><font class=HelpFont3>");
	     temp_eng = "<LABEL size='1' class='TdHeader4' onClick=\" return updatePositionOnHelp(document.getElementById (textBox),' " + this.trim(temp) + "','false','true','" + startChar + "')\">" + temp + "</LABEL>" ;
	    }//END IF
	    else
        {
         HTML = HTML.concat("<td class='TdHeader2'><font class=HelpFont1>");
	     temp_eng = "<LABEL size='1' class='TdHeader2' onClick=\" return updatePositionOnHelp(document.getElementById (textBox),' " + this.trim(temp) + "','false','true','" + startChar + "')\">" + temp + "</LABEL>" ;
        }//END ELSE
       }//END ELSE
	   HTML = HTML + temp_eng;
       HTML = HTML.concat("</font></td>");
    
      }//END FOR    
      if(loopstart == loopend)
      {
        temp ="&nbsp;"
        for(k=0;k<12;k++)
        {
          unicode = "&nbsp;";
          if(temp == Matra)
		   {
        	HTML = HTML.concat("<td class='TdHeader4'>");
		    HTML = HTML.concat(fontstyle1);
			temp_uni = "<LABEL size='1' class='TdHeader4' onClick=\"return updatePositionOnHelp(document.getElementById (textBox),'" + this.trim(temp) + "','false','true','" + startChar + "')\">" + unicode + "</LABEL>" ;
		   }//END IF
	      else
	       {
		     HTML = HTML.concat("<td class='TdHeader2'>");
             HTML = HTML.concat(fontstyle);
		     temp_uni = "<LABEL size='1' class='TdHeader2' onClick=\"return updatePositionOnHelp(document.getElementById (textBox),'" + this.trim(temp) + "','false','true','" + startChar + "')\">" + unicode + "</LABEL>" ;
		   }//END ELSE
           HTML = HTML + temp_uni;
		   HTML = HTML.concat("</font></td>");
		 
         }//END FOR 
        }//END IF                      
       break;		  
	  }//END IF 
     else        
      {             
       if(j%2 == 0)
		{
		  temp = engWord + this.resource.engToUniVowel[i];
		 	  
	        if(temp == Matra)
			{
		     HTML = HTML.concat("<td class='TdHeader4'><font class=HelpFont4>");
			 temp_eng = "<LABEL size='1' class='TdHeader4' onClick=\" return updatePositionOnHelp(document.getElementById (textBox),' " + this.trim(temp) + "','false','true','" + startChar + "')\">" + temp + "</LABEL>" ;
		    }//END IF
		  	else
		   	{
		    	HTML = HTML.concat("<td class='TdHeader2'><font class=HelpFont2>");
    	     	temp_eng = "<LABEL size='1' class=TdHeader2 onClick=\" return updatePositionOnHelp(document.getElementById (textBox),' " + this.trim(temp) + "','false','true','" + startChar + "')\">" + temp + "</LABEL>" ;
		    }//END ELSE
		    HTML = HTML + temp_eng;
		    HTML = HTML.concat("</font></td>");
		  	
		}//END IF
       else
	    {
		 temp = engWord + this.resource.engToUniVowel[i];
		
	     	if(temp == Matra)
	        {
		      HTML = HTML.concat("<td class='TdHeader3'><font class=HelpFont3>");
	  	      temp_eng = "<LABEL size='1' class='TdHeader3' onClick=\" return updatePositionOnHelp(document.getElementById (textBox),'" + this.trim(temp) + "','false','true','" + startChar + "')\">" + temp + "</LABEL>" ;
	  	    }//END IF
 		    else
		    {			      
		     HTML = HTML.concat("<td class='TdHeader1'><font class=HelpFont1>");
		     temp_eng = "<LABEL size='1' class='TdHeader1' onClick=\" return updatePositionOnHelp(document.getElementById (textBox),'" + this.trim(temp) + "','false','true','" + startChar + "')\">" + temp + "</LABEL>" ;
		    }//END ELSE
     	    HTML = HTML + temp_eng;
    	    HTML = HTML.concat("</font></td>");
    	 
		 }//END ELSE 
       }//END ELSE
	  j++;
   }//END IF
 }//END FOR
   
 HTML = HTML.concat("</tr>");	
 return HTML;
}//END FUNCTION CREATE TABLE

/*
Initialize Language arrays
*/

function Initialize(langid)
{       
    var unicode; 
    var startChar = this.getIndicStart(this.langid);
   
    this.langid= langid;
       
	//this.onLoad();
	if(this.kbdid=="PH")
	{
	    this.kbdid=PHONETIC;
	 }
	else if(this.kbdid=="IN")
	{
	   this.kbdid=INSCRIPT;
	}
	else
	{
	    this.kbdid=PHONETIC;
	 }    
	 
	 		 
	if(this.langid == "HI")
	{		
	 this.resource.Initialize_HI(this.kbdid);	
	}
	else if (this.langid == "MA")
	{
	 this.resource.Initialize_MA(this.kbdid);
	}
	else if (this.langid == "TM")
	{
	 this.resource.Initialize_TM(this.kbdid);
	}
	else if (this.langid == "GU")
	{
	 this.resource.Initialize_GU(this.kbdid);
	}
	else if (this.langid == "PN")
	{
	 this.resource.Initialize_PN(this.kbdid);
	}
	else if (this.langid == "BN")
	{
	 this.resource.Initialize_BN(this.kbdid);
	}
	else if (this.langid == "TG")
	{
	 this.resource.Initialize_TG(this.kbdid);
	}
	else if (this.langid == "KN")
	{
	 this.resource.Initialize_KN(this.kbdid);
	}
	else if (this.langid == "ML")
	{
	 this.resource.Initialize_ML(this.kbdid);
	}
	
	// if(document.getElementById(textBox) != null)
	//     document.getElementById(textBox).focus();
     
	  //this.DisplayKeyBoard(this.langid);
	  if(this.kbdid==PHONETIC)	 
	  {	   
        unicode = this.toUnicode('a',startChar);      
        this.DisplayHelp(unicode, 'a',startChar,'a');                
      }
     
}


/*
Initialize Language arrays
*/

function Initialize_KeyBoard(kbdid)
{       
    var unicode; 
    var startChar = this.getIndicStart(this.langid);

    this.kbdid = kbdid;
        
	//this.onLoad();
	if(this.kbdid=="PH")
	{
	    this.kbdid=PHONETIC;
	 }
	else if(this.kbdid=="IN")
	{
	   this.kbdid=INSCRIPT;
	}
	else
	{
	    this.kbdid=PHONETIC;
	 }    
	 
	 		 
	if(this.langid == "HI")
	{		
	 this.resource.Initialize_HI(this.kbdid);	
	}
	else if (this.langid == "MA")
	{
	 this.resource.Initialize_MA(this.kbdid);
	}
	else if (this.langid == "TM")
	{
	 this.resource.Initialize_TM(this.kbdid);
	}
	else if (this.langid == "GU")
	{
	 this.resource.Initialize_GU(this.kbdid);
	}
	else if (this.langid == "PN")
	{
	 this.resource.Initialize_PN(this.kbdid);
	}
	else if (this.langid == "BN")
	{
	 this.resource.Initialize_BN(this.kbdid);
	}
	else if (this.langid == "TG")
	{
	 this.resource.Initialize_TG(this.kbdid);
	}
	else if (this.langid == "KN")
	{
	 this.resource.Initialize_KN(this.kbdid);
	}
	else if (this.langid == "ML")
	{
	 this.resource.Initialize_ML(this.kbdid);
	}
	
	 //if(document.getElementById(textBox) != null)
	   //  document.getElementById(textBox).focus();
     
	  //this.DisplayKeyBoard(this.langid);
	  if(this.kbdid==PHONETIC)	 
	  {	   
        unicode = this.toUnicode('a',startChar);      
        this.DisplayHelp(unicode, 'a',startChar,'a');                
      }
     
}
	/**
	 *
	 * Method to convert INSCRIPT key combination sequence into unicode word.
	 * 
	 */
function inscriptToUnicode(textBox)
{
    var inscriptWord = textBox;
    var length = inscriptWord.length;
    unicodeWord ="";   
    for(i=0; i < length;i++)
    {
        unicodeWord += this.resource.InArray[inscriptWord.charAt(i)];
    }
//    alert(unicodeWord);
    return unicodeWord;
}



/**
*** KeyBoard of Diffenrent Languaues
**/
function DisplayKeyBoard(lang)
{      
	var startChar = this.getIndicStart(lang);
	var i;
	var j;
	var unicode;
	var temp_eng ="";
	var temp_uni ="";
	var endloop1;
	var endloop2;

	fontstyle = "<font class=" + lang + "Font>";

	 if(startChar == '\u0900')
	 {
		 endloop1 = 8;
		 endloop2 = 9;
	 }
	 if(startChar == '\u0a80')
	 {
		 endloop1 = 7;
		 endloop2 = 9;
	 }
	 if(startChar == '\u0a00')
	 {
		 endloop1 = 7;
		 endloop2 = 9;
	 }
	 if(startChar == '\u0d00')
	 {
		 endloop1 = 8;
		 endloop2 = 9;
	 }
	 if(startChar == '\u0980')
	 {
             endloop1 = 7;
		 endloop2 = 9;

	 }
	 if(startChar == '\u0b80')
	 {
		 endloop1 = 7;
		 endloop2 = 7;
	 }
	 if(startChar == '\u0c00')
	 {
		 endloop1 = 8;
		 endloop2 = 9;

	 }
	 if(startChar == '\u0c80')
	 {
		 endloop1 = 8;
		 endloop2 = 9;

	 }
	
	var HTML = "<table id='table1' align=left class='table1' cellpadding=0 cellspacing=0 >";

	for(i=0;i< endloop1; i++)
	{
		 HTML = HTML + "<tr>";
		 for(j=0;j < endloop2; j++)
		 {
       		 if(this.resource.uniKeyboardchars[i][j] == "&nbsp;")
			 {
				 unicode = "&nbsp;";
			 }
			 else
			 {
				 unicode = this.toUnicode(this.resource.uniKeyboardchars[i][j],startChar);
              }
                if(startChar == '\u0c00' || startChar == '\u0c80' || startChar == '\u0d00')
                  {
					//temp_eng = "<LABEL size='1' class=TdHeader1 onClick=\" return this.DisplayHelpKeyboard('" + unicode + "','" + this.trim (this.resource.uniKeywordHelpChar[i][j]) + "','" + startChar + "','" +  this.trim (this.resource.uniKeywordHelpChar[i][j]) + "')\">" + this.resource.uniKeyboardchars[i][j] + "</LABEL>" ;
					//temp_uni = "<LABEL size='1' class=TdHeader1 onClick=\" return this.DisplayHelpKeyboard('" + unicode + "','" + this.trim (this.resource.uniKeywordHelpChar[i][j]) + "','" + startChar + "','" +  this.trim (this.resource.uniKeywordHelpChar[i][j]) + "')\">&nbsp;" + fontstyle +  unicode  + "</font></LABEL>" ;                                            
                      temp_eng = "<LABEL size='1' class=TdHeader1>" + this.resource.uniKeyboardchars[i][j] + "</LABEL>" ;
                      temp_uni = "<LABEL size='1' class=TdHeader1>&nbsp;" + fontstyle +  unicode  + "</font></LABEL>" ;                                            
                  }                  
                  else
                  {
                      //temp_eng = "<LABEL size='1' class=TdHeader1 onClick=\" return this.DisplayHelpKeyboard('" + unicode + "','" + this.trim (this.resource.uniKeywordHelpChar[i][j]) + "','" + startChar + "','" + this.trim (this.resource.uniKeywordHelpChar[i][j]) + "')\">" + this.resource.uniKeyboardchars[i][j] + "&nbsp;</LABEL>" ;                      
                      //temp_uni = "<LABEL size='1' class=TdHeader1 onClick=\" return this.DisplayHelpKeyboard('" + unicode + "','" + this.trim (this.resource.uniKeywordHelpChar[i][j]) + "','" + startChar + "','" + this.trim (this.resource.uniKeywordHelpChar[i][j]) + "')\">&nbsp;" + fontstyle +  unicode  + "</font></LABEL>" ;        
                      temp_eng = "<LABEL size='1' class=TdHeader1>" + this.resource.uniKeyboardchars[i][j] + "&nbsp;</LABEL>" ;
                      temp_uni = "<LABEL size='1' class=TdHeader1>&nbsp;" + fontstyle +  unicode  + "</font></LABEL>" ;                  
                                
                  }   
          
                  /*temp_eng = "<LABEL size='1' onmouseover=\"popUp(event,'t2')\" class=TdHeader1 onClick=\" return this.DisplayHelpKeyboard('" + unicode + "','" + this.trim (this.resource.uniKeywordHelpChar[i][j]) + "','" + startChar + "','" +  this.trim (this.resource.uniKeywordHelpChar[i][j]) + "')\">" + this.resource.uniKeyboardchars[i][j] + "&nbsp;</LABEL>" ;
                  temp_uni = "<LABEL size='1' onmouseover=\"popUp(event,'t2')\" class=TdHeader1 onClick=\" return this.DisplayHelpKeyboard('" + unicode + "','" + this.trim (this.resource.uniKeywordHelpChar[i][j]) + "','" + startChar + "','" +  this.trim (this.resource.uniKeywordHelpChar[i][j]) + "')\">&nbsp;" + fontstyle +  unicode  + "</font></LABEL>" ;*/

                  if(startChar == '\u0c00' || startChar == '\u0c80' || startChar == '\u0d00')
                  {
			   if(j%2 == 0)
			   {
			 	 HTML = HTML + "<td style=\"WIDTH: 22px; HEIGHT: 15px\" align=center>" + temp_uni + "</td><td  style=\"WIDTH: 22px; HEIGHT: 15px\" align=center class=alternetTdColor><font class=HelpFont1>" + temp_eng + "</font></td>";
			   }
			   else
			   {
			 	 HTML = HTML + "<td align=center style=\"WIDTH: 22px; HEIGHT: 15px\" >" + temp_uni + "</td><td style=\"WIDTH: 22px; HEIGHT: 15px\"  align=center class=alternetTdColor><font class=HelpFont2>" + temp_eng + "</font></td>";
			   }
                  }
                  else
                  {
			   if(j%2 == 0)
			   {
			 	 HTML = HTML + "<td style=\"WIDTH: 18px; HEIGHT: 15px\" align=center>" + temp_uni + "</td><td  style=\"WIDTH: 22px; HEIGHT: 15px\" align=center class=alternetTdColor><font class=HelpFont1>" + temp_eng + "</font></td>";
			   }
			   else
			   {
			 	 HTML = HTML + "<td align=center style=\"WIDTH: 18px; HEIGHT: 15px\" >" + temp_uni + "</td><td style=\"WIDTH: 22px; HEIGHT: 15px\"  align=center class=alternetTdColor><font class=HelpFont2>" + temp_eng + "</font></td>";
			   }

                  } 
 

		}
		HTML = HTML + "</tr>";
	}
      
	HTML = HTML.concat("</table>");			
	document.getElementById('keyBoard').innerHTML = HTML ;		
}

/* function to this.trim white spaces from string*/
function trim(s)
{
return s.replace(/^\s*(.*?)\s*$/,"$1")
}

var search = 0;
function Send_Msg(msg)
{	
	if (search==1)
	{
 //		alert("Please enter a message to send.");
//		return false;
	}
	else
	{
		search = 0;
		// TODO: Commented for messenger masking
		//host.SendIM(msg);
		
		/*var some = host.window.CurrentIdentity.Name;
		msg = "<b>" + some + ": </b>" + msg;
		host.SendPluginMessage(msg); 
		host.InsertInHistoryWindow(msg);
		host.InputWindowText=""; // Uncommented beast
		*/
		//document.frm.txt.value="";
		//document.frm.txt.focus();
		var invite = 'Hey, you can chat in Indian languages by clicking at ymsgr:getplugin?&type=1&id=21d034a9-0ce0-42e5-464d-ad2da3273b55&name=IndiChat&version=1.0.0';
		host.InputWindowText=invite;
            return false;  
	}
}

function stripHTML(oldString) {
	var newString = "";
	var inTag = false;
	for(var i = 0; i < oldString.length; i++) {
		if(oldString.charAt(i) == '<') inTag = true;
		if(oldString.charAt(i) == '>') {
			inTag = false;
			i++;
		}
		if(!inTag) newString += oldString.charAt(i);
	}
	return newString;
}




function Search_Msg( msg )
{
	document.getElementById(this.textBox).value = this.stripHTML(document.getElementById(this.textBox).value);
	var check = document.getElementById(this.textBox).value;
	search = 1;
	if (msg.length <= 0)
	{
		alert("Please enter a Search Query");
		return false;
	}
	else
	{
		var sString = document.getElementById(this.textBox).value;
		var yurl = "http://in.search.yahoo.com/search?p=";
		sString = sString + "&ei=utf-8&fr=indichat";
		yurl = yurl + sString;
		yurl = encodeURI(yurl);
		yahoowindow=window.open(yurl, "ysearch");
            return false;            
 }
}



function onLoad()
{
// setLang(1);
//startPos=0;
//endPos=0;
//var sendB = document.getElementById("submit2");
//var searchB = document.getElementById("submit3");
//sendB.value="???????? (Invite)";
//searchB.value="??? (Web Search)";
//document.getElementById("hsuggest").style.display="none";
//document.getElementById("ksuggest").style.display="none";
//document.getElementById("tsuggest").style.display="block";

// TODO: Commented for messenger masking
 host = window.external; 
// host.SetEventHandler( 'PluginMessage', onPluginMessage );
// myWindow = host.window;
// myWindow.SetEventHandler("Activated", OnWindowActivated);
 host.LocalReady ();
// host.InputWindowText= "";// Uncommented beast
 //initialize();
 //document.frm.txtLayoutViewer.focus();
}


function toUnicode_TM(textBox,startChar)
{

	var engWord =	textBox;
	var unicode;		
	
	if(engWord == null || engWord.length == 0)
		return "";

	if(startChar.charCodeAt() == 0)
		return "Language not supported";


	if(this.resource.userSpell[engWord])
	{
		engWord = this.resource.userSpell[engWord];
	}

	var engWordLength = engWord.length;

	var k = 0;
	var l = 0;
	var find = 0;
	var tempEngWord = "";

	//To change Uppercase Charecter to Lowercase

	for (k = 0 ; k < engWordLength; k++)
	{
		find = 0; 
		cChar = engWord.charAt(k);
		// Certain uppercase characters are used to indicate a hindi characters.
		// Such characters should not be converted to lower case.
		for (l = 0 ; l < this.resource.charOnlyUppercase.length ; l++)
		{
			if (cChar == this.resource.charOnlyUppercase[l])
			{
				find = 1;
			}
		}
		if(find)
		{
                  tempEngWord= tempEngWord.concat(cChar);
		}
		else
		{ 
			cChar=cChar.toLowerCase();
			tempEngWord= tempEngWord.concat(cChar);
		}
	}

	engWord = tempEngWord;
	engWord = this.replace(engWord);
	engWordLength = engWord.length;	

	// If a word end with 'a' and preceded by consonant, then append 'a'. e.g. babita should be changed to babitaa


	/*if(engWordLength > 2 && engWord.charAt(engWordLength-1) == 'a' && !indicResource.isVowel(engWord.charAt (engWordLength-2)))
	{
	engWord.append('a') ;
	engWordLength +=1;
	}*/

	var i = 0;
	var found = 0;
	var j;


	// Unicode string
	var unicodeWord = "";
	var tmpChar ;

	// Variable for checking if previous character is consonant or not

	var prevConsoFlag = 0;
	var prevVowelFlag = 0;

	while(i < engWordLength)
	{
		// check for vowel and matra.
		found = 0;

		for( j = 2; j > 0; j--)
		{
			if(i+j <= engWordLength)
			{
				var stTmp = engWord.substring(i, i+j);
				if(engWord.substring(i, i+j)=="H")
				{
					tmpChar = String.fromCharCode(startChar.charCodeAt() + 3);													
					i+=j;
					if(unicodeWord.length > 1 && unicodeWord.charAt(unicodeWord.length-1)==String.fromCharCode(startChar.charCodeAt() + 77))
					unicodeWord=unicodeWord.substring(0,unicodeWord.length-1);	
					unicodeWord=unicodeWord.concat(tmpChar);
					engGlyph=engBase+stTmp;
					found = 1;
					break;
				}	

				// If previous character is consonant, then append matra, else append vowel.
				if(prevConsoFlag)
				{
					tmpChar = this.getUnicodeMatra(engWord.substring(i, i+j), startChar);
				
					// Append matra if it is not 'a'
					if(tmpChar != 'a' && tmpChar != '?')
					{
						if(prevConsoFlag)
						{
							unicodeWord = unicodeWord.substring(0, unicodeWord.length-1);
						}
						unicodeWord=unicodeWord.concat(tmpChar);
						engGlyph=engBase+stTmp;
      					prevConsoFlag = 0;
						prevVowelFlag = 0;
					}
					else if(tmpChar =='a')
					{
						if(prevConsoFlag)
						{
							unicodeWord = unicodeWord.substring(0, unicodeWord.length-1);
                       			engGlyph=engBase+stTmp;
      		
						}
					}
				}
				else
				{
					tmpChar = this.getUnicodeVowel(engWord.substring(i, i+j), startChar);
					if(tmpChar != '?')
					{
						unicodeWord=unicodeWord.concat(tmpChar);
						engBase=stTmp;
						engGlyph=engBase;
						prevVowelFlag = 1;
					}
				}
				if(tmpChar != '?')
				{
					prevConsoFlag=0;
					found = 1;
					i += j;
					break;
				}
			}
		}
		if(found) 
		{
			continue;
		}

		// check for consonant.
		found = 0;

		for(j = 3; j > 0; j--)
		{
			if(i+j <=engWordLength)
			{
				var stTmp = engWord.substring(i, i+j);
				
				tmpChar = this.getUnicodeConsonant(engWord.substring(i, i+j), startChar);
				
				if(tmpChar != '?')
				{
					unicodeWord = unicodeWord.concat(tmpChar);
					// If consonant is followed by consonant, append halant
					unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 77));
					
					engBase = stTmp;
					engGlyph=engBase;
					
					prevConsoFlag = 1;
					found = 1;
					this.golbalConso = engWord.substring(i, i+j);
					i += j;
					break;
				}
			}
		}

		if(found)
		{
			continue;
		}
		else // if no match found, append input char as is e.g. number, symbols etc) 
		{	
			var stTmp="";
			stTmp = stTmp + engWord.charAt(i).toLowerCase();
			prevConsoFlag=0;

			if(!prevConsoFlag)
				tmpChar = this.getUnicodeVowel(stTmp,startChar);
			else
				tmpChar = this.getUnicodeMatra(stTmp,startChar);

			if(tmpChar=='?')
			{
				tmpChar = this.getUnicodeConsonant(stTmp,startChar);
				if(tmpChar!='?')
				prevConsoFlag=1;
			}

			if(tmpChar!='?')
				unicodeWord =unicodeWord.concat(tmpChar);
			else
			{
				if(engWord.charAt(i)!='?')
					unicodeWord = unicodeWord.concat(engWord.charAt(i));
			}
			if(prevConsoFlag)
			{
				unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 77));
			}
		}
		i++;
			
	}

	if(unicodeWord.length > 1 && unicodeWord.charAt(unicodeWord.length-1)==String.fromCharCode(startChar.charCodeAt() + 77))
	unicodeWord=unicodeWord.substring(0,unicodeWord.length-1);

	return unicodeWord;

}

function toUnicode_PN(textBox,startChar)
{
  
	var engWord =	textBox;
	var unicode;		
	
	if(engWord == null || engWord.length == 0)
		return "";

	if(startChar.charCodeAt() == 0)
		return "Language not supported";


	if(this.resource.userSpell[engWord])
	{
		engWord = this.resource.userSpell[engWord];
	}

	var engWordLength = engWord.length;

	var k = 0;
	var l = 0;
	var find = 0;
	var tempEngWord = "";

	//To change Uppercase Charecter to Lowercase
	
	for (k = 0 ; k < engWordLength; k++)
	{
		find = 0; 
		cChar = engWord.charAt(k);
		// Certain uppercase characters are used to indicate a hindi characters.
		// Such characters should not be converted to lower case.
		for (l = 0 ; l < this.resource.charOnlyUppercase.length ; l++)
		{
			if (cChar == this.resource.charOnlyUppercase[l])
			{
				find = 1;
			}
		}
		if(find)
		{
			tempEngWord= tempEngWord.concat(cChar);
		}
		else
		{ 
			cChar=cChar.toLowerCase();
			tempEngWord= tempEngWord.concat(cChar);
		}
	}
	

	engWord = tempEngWord;

	engWord = this.replace(engWord);

	engWordLength = engWord.length;	

	// If a word end with 'a' and preceded by consonant, then append 'a'. e.g. babita should be changed to babitaa


	/*if(engWordLength > 2 && engWord.charAt(engWordLength-1) == 'a' && !indicResource.isVowel(engWord.charAt (engWordLength-2)))
	{
	engWord.append('a') ;
	engWordLength +=1;
	}*/

	var i = 0;
	var found = 0;
	var j;


	// Unicode string
	var unicodeWord = "";
	var tmpChar ;

	// Variable for checking if previous character is consonant or not

	var prevConsoFlag = 0;
	var prevVowelFlag = 0;

	while(i < engWordLength)
	{
		// check for vowel and matra.
		found = 0;

		for( j = 2; j > 0; j--)
		{
			if(i+j <= engWordLength)
			{
				var stTmp = engWord.substring(i, i+j);
				if(engWord.substring(i, i+j)== "^")
				{
					tmpChar = String.fromCharCode(startChar.charCodeAt() + 2);
					i+=j;
					if(unicodeWord.length > 1 && unicodeWord.charAt(unicodeWord.length-1)==String.fromCharCode(startChar.charCodeAt() + 77))
					unicodeWord=unicodeWord.substring(0,unicodeWord.length-1);	
					unicodeWord=unicodeWord.concat(tmpChar);
					engGlyph=engBase+stTmp;
					found = 1;
					break;
				}
			
				// If previous character is consonant, then append matra, else append vowel.
				if(prevConsoFlag)
				{
					tmpChar = this.getUnicodeMatra(engWord.substring(i, i+j), startChar);
				
					if(tmpChar == 'a')
						tmpChar ="";
					// Append matra if it is not 'a'
					if(tmpChar != '?')
					{
						unicodeWord=unicodeWord.concat(tmpChar);
						engGlyph=engBase+stTmp;
      					prevConsoFlag = 0;
						prevVowelFlag = 0;
					}
				}
				else
				{
					tmpChar = this.getUnicodeVowel(engWord.substring(i, i+j), startChar);
					if(tmpChar != '?' && tmpChar != 'a')
					{
                                    unicodeWord=unicodeWord.concat(tmpChar);
                                    engBase=stTmp;
                                    engGlyph=engBase;
						 prevVowelFlag = 1;
					}
				}
				if(tmpChar != '?')
				{
					prevConsoFlag=0;
					found = 1;
					i += j;
					break;
				}
			}
		}
		if(found) 
		{
			continue;
		}

		// check for consonant.
		found = 0;

		for(j = 3; j > 0; j--)
		{
			if(i+j <=engWordLength)
			{
				var stTmp = engWord.substring(i, i+j);
				
				
				tmpChar = this.getUnicodeConsonant(engWord.substring(i, i+j), startChar);
				if(tmpChar != '?')
				{
					if(prevConsoFlag && (engWord.charAt(i-1)=='n' || engWord.charAt(i-1)=='m') && i-1 != 0)
					{
						//append TIPPI
						unicodeWord = unicodeWord.substring(0,unicodeWord.length-1);
						unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 112));
					}
					
					if(prevConsoFlag && (engWord.charAt(i-1)==engWord.charAt(i)))
					{
						//append ADDAK
						unicodeWord = unicodeWord.substring(0,unicodeWord.length-1);
						unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 113));
					}
					
					if(prevConsoFlag && (stTmp =="r" || stTmp =="v" || stTmp =="y" ) && (engWord.charAt(i-1)!='n' && engWord.charAt(i-1)!='m'))
					{
						unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 77));
					}
					else if(prevConsoFlag && stTmp =="H")
					{
						unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 77));
					}

					unicodeWord = unicodeWord.concat(tmpChar);
				
					engBase = stTmp;
					engGlyph=engBase;
					
					prevConsoFlag = 1;
					found = 1;
					this.golbalConso = engWord.substring(i, i+j);
					i += j;
					break;
				}
			}
		}

		if(found)
		{
			continue;
		}
		else // if no match found, append input char as is e.g. number, symbols etc) 
		{	
			var stTmp="";
			stTmp = stTmp + engWord.charAt(i).toLowerCase();
			prevConsoFlag=0;

			if(!prevConsoFlag)
				tmpChar = this.getUnicodeVowel(stTmp,startChar);
			else
				tmpChar = this.getUnicodeMatra(stTmp,startChar);

			if(tmpChar=='?')
			{
				tmpChar = this.getUnicodeConsonant(stTmp,startChar);
				if(tmpChar!='?')
				prevConsoFlag=1;
			}

			if(tmpChar!='?')
				unicodeWord =unicodeWord.concat(tmpChar);
			else
			{
				if(engWord.charAt(i)!='?')
					unicodeWord = unicodeWord.concat(engWord.charAt(i));
			}
			if(prevConsoFlag)
			{
				unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 77));
			}
		}
		i++;
			
	}

	if(unicodeWord.length > 1 && unicodeWord.charAt(unicodeWord.length-1)==String.fromCharCode(startChar.charCodeAt() + 77))
		unicodeWord=unicodeWord.substring(0,unicodeWord.length-1);

	return unicodeWord;

}


function toUnicode_TG(textBox,startChar)
{

	var engWord =	textBox;
	var unicode;		
	
	if(engWord == null || engWord.length == 0)
		return "";

	if(startChar.charCodeAt() == 0)
		return "Language not supported";


	if(this.resource.userSpell[engWord])
	{
		engWord = this.resource.userSpell[engWord];
	}

	var engWordLength = engWord.length;

	var k = 0;
	var l = 0;
	var find = 0;
	var tempEngWord = "";

	//To change Uppercase Charecter to Lowercase

	for (k = 0 ; k < engWordLength; k++)
	{
		find = 0; 
		cChar = engWord.charAt(k);
		// Certain uppercase characters are used to indicate a hindi characters.
		// Such characters should not be converted to lower case.
		for (l = 0 ; l < this.resource.charOnlyUppercase.length ; l++)
		{
			if (cChar == this.resource.charOnlyUppercase[l])
			{
				find = 1;
			}
		}
		if(find)
		{
			tempEngWord= tempEngWord.concat(cChar);
		}
		else
		{ 
			cChar=cChar.toLowerCase();
			tempEngWord= tempEngWord.concat(cChar);
		}
	}

	engWord = tempEngWord;

	engWord = this.replace(engWord);

	engWordLength = engWord.length;	

	var i = 0;
	var found = 0;
	var j;


	// Unicode string
	var unicodeWord = "";
	var tmpChar ;

	// Variable for checking if previous character is consonant or not

	var prevConsoFlag = 0;
	var prevVowelFlag = 0;
	
	
	while(i < engWordLength)
	{
		// check for vowel and matra.
		found = 0;

		for( j = 2; j > 0; j--)
		{
			if(i+j <= engWordLength)
			{
				var stTmp = engWord.substring(i, i+j);
			          
				if(engWord.substring(i, i+j)=="M" && startChar =='\u0C00')
				{
					tmpChar = String.fromCharCode(startChar.charCodeAt() + 1);
					i+=j;
					if(unicodeWord.length > 1 && unicodeWord.charAt(unicodeWord.length-1)==String.fromCharCode(startChar.charCodeAt() + 77))
					unicodeWord=unicodeWord.substring(0,unicodeWord.length-1);	
					unicodeWord=unicodeWord.concat(tmpChar);
      				engGlyph=engBase+stTmp;
					found = 1;
					break;
				}
				//if 'm' comes after any vowel treat it as ANUSWAR
				//else if(engWordLength > 1 && (engWord.substring(i, i+j)=="m" || engWord.substring(i, i+j)=="n" )
				else if(engWordLength > 1 && (engWord.substring(i, i+j)=="m")
									&& (engWord.charAt(i-1)=='a' 
										|| engWord.charAt(i-1)=='e' 
										|| engWord.charAt(i-1)=='i' 
										|| engWord.charAt(i-1)=='o' 
										|| engWord.charAt(i-1)=='u'))
								{
									tmpChar = String.fromCharCode(startChar.charCodeAt() + 2);
									i+=j;
									unicodeWord=unicodeWord.concat(tmpChar);
									engGlyph=engBase+stTmp;
									found = 1;
									break;
				}
				else if(engWord.substring(i, i+j)=="H")
				{
					tmpChar = String.fromCharCode(startChar.charCodeAt() + 3);													
					i+=j;
					if(unicodeWord.length > 1 && unicodeWord.charAt(unicodeWord.length-1)==String.fromCharCode(startChar.charCodeAt() + 77))
					unicodeWord=unicodeWord.substring(0,unicodeWord.length-1);	
					unicodeWord=unicodeWord.concat(tmpChar);
					engGlyph=engBase+stTmp;
					found = 1;
					break;
				}	

				// If previous character is consonant, then append matra, else append vowel.
				if(prevConsoFlag)
				{
                                 
					if(engWordLength >2 && engWord.charAt(i-2)=="R" && engWord.charAt(i-1)=="R" && engWord.substring(i, i+j)=="u")
					{
                         tmpChar="";
                                    
					}
					else
					{
                        tmpChar = this.getUnicodeMatra(engWord.substring(i, i+j), startChar);
					}

					// Append matra if it is not 'a'
					if(tmpChar != 'a' && tmpChar != '?')
					{
						if(prevConsoFlag)
						{
							unicodeWord = unicodeWord.substring(0, unicodeWord.length-1);
						}
						unicodeWord=unicodeWord.concat(tmpChar);
						engGlyph=engBase+stTmp;
                        prevConsoFlag = 0;
						prevVowelFlag = 0;
					}
					else if(tmpChar =='a')
					{
						if(prevConsoFlag)
						{
							unicodeWord = unicodeWord.substring(0, unicodeWord.length-1);
                                    	engGlyph=engBase+stTmp;
          		      		}
					}
				}
				else
				{
					if(engWordLength >2 && engWord.charAt(i-2)=="R" && engWord.charAt(i-1)=="R" && engWord.substring(i, i+j)=="u")
					{
						tmpChar="";
					}
					else
						tmpChar = this.getUnicodeVowel(engWord.substring(i, i+j), startChar);
						
					if(engWordLength >1 && (engWord.charAt(i-1)=='m') && tmpChar!='?')
					{
						//alert("2");
						if(unicodeWord.length > 0 && unicodeWord.charAt(unicodeWord.length-1) == String.fromCharCode(startChar.charCodeAt() + 2))
						{
							unicodeWord = unicodeWord.substring(0,unicodeWord.length-1);
							unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 46));
							tmpChar = this.getUnicodeMatra(engWord.substring(i, i+j), startChar);
							if(tmpChar=='a')
							tmpChar="";
							engBase = "m";
							engGlyph = "m"+engWord.substring(i, i+j);				
							unicodeWord=unicodeWord.concat(tmpChar);
							prevVowelFlag = 1;
						}
					}
					else if(tmpChar != '?')
					{
						unicodeWord=unicodeWord.concat(tmpChar);
						engBase=stTmp;
						engGlyph=engBase;
      					prevVowelFlag = 1;

					}
				}
				if(tmpChar != '?')
				{
					prevConsoFlag=0;
					found = 1;
					i += j;
					break;
				}
			}
		}
		if(found) 
		{
			continue;
		}

		// check for consonant.
		found = 0;

		for(j = 3; j > 0; j--)
		{
			if(i+j <=engWordLength)
			{
				var stTmp = engWord.substring(i, i+j);
				tmpChar = this.getUnicodeConsonant(engWord.substring(i, i+j), startChar);
				if(tmpChar != '?')
				{
				    if(prevConsoFlag && (engWord.charAt(i-1)=='n' || engWord.charAt(i-1)=='m') && i-1 != 0)
					{
					    unicodeWord = unicodeWord.substring(0,unicodeWord.length-2);
					    unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 2));
					} 
				
				    if(engWord.charAt(i-1)=='m' && i-1 != 0 && ((stTmp == "m") || (stTmp == "r") || (stTmp == "y") || (stTmp == "n") || (stTmp == "h") || (stTmp == "l") || (stTmp == "L") || (stTmp == "R") ))
					{
					    unicodeWord = unicodeWord.substring(0,unicodeWord.length-1);
					    unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 46));
					    unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 77));
					}
					
					if(engWord.charAt(i-1)=='n' && i-1 != 0 && ((stTmp == "m") || (stTmp == "r") || (stTmp == "y") || (stTmp == "n") || (stTmp == "h") || (stTmp == "l") || (stTmp == "L") || (stTmp == "R") ))
					{
					    unicodeWord = unicodeWord.substring(0,unicodeWord.length-1);
					    unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 40));
					    unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 77));
					}
					

					unicodeWord = unicodeWord.concat(tmpChar);
					// If consonant is followed by consonant, append halant
					unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 77));
					
					engBase = stTmp;
					engGlyph=engBase;
					prevConsoFlag = 1;
					found = 1;
					this.golbalConso = engWord.substring(i, i+j);
					i += j;
					break;
				}
			}
		}

		if(found)
		{
			continue;
		}
		else // if no match found, append input char as is e.g. number, symbols etc) 
		{	
			var stTmp="";
			stTmp = stTmp + engWord.charAt(i).toLowerCase();
			prevConsoFlag=0;

			if(!prevConsoFlag)
				tmpChar = this.getUnicodeVowel(stTmp,startChar);
			else
				tmpChar = this.getUnicodeMatra(stTmp,startChar);

			if(tmpChar=='?')
			{
				tmpChar = this.getUnicodeConsonant(stTmp,startChar);
				if(tmpChar!='?')
				prevConsoFlag=1;
			}

			if(tmpChar!='?')
				unicodeWord =unicodeWord.concat(tmpChar);
			else
			{
				if(engWord.charAt(i)!='?')
					unicodeWord = unicodeWord.concat(engWord.charAt(i));
			}
			if(prevConsoFlag)
			{
				unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 77));
			}
		}
		i++;
			
	}

    //if(unicodeWord.length > 1 && unicodeWord.charAt(unicodeWord.length-1)==String.fromCharCode(startChar.charCodeAt() + 77))
	  //  unicodeWord=unicodeWord.substring(0,unicodeWord.length-1);

	return unicodeWord;
}

function toUnicode_KN(textBox,startChar)
{
	var engWord =	textBox;
	var unicode;		
	
	if(engWord == null || engWord.length == 0)
		return "";

	if(startChar.charCodeAt() == 0)
		return "Language not supported";


	if(this.resource.userSpell[engWord])
	{
		engWord = this.resource.userSpell[engWord];
	}

	var engWordLength = engWord.length;

	var k = 0;
	var l = 0;
	var find = 0;
	var tempEngWord = "";

	//To change Uppercase Charecter to Lowercase

	for (k = 0 ; k < engWordLength; k++)
	{
		find = 0; 
		cChar = engWord.charAt(k);
		// Certain uppercase characters are used to indicate a hindi characters.
		// Such characters should not be converted to lower case.
		for (l = 0 ; l < this.resource.charOnlyUppercase.length ; l++)
		{
			if (cChar == this.resource.charOnlyUppercase[l])
			{
				find = 1;
			}
		}
		if(find)
		{
			tempEngWord= tempEngWord.concat(cChar);
		}
		else
		{ 
			cChar=cChar.toLowerCase();
			tempEngWord= tempEngWord.concat(cChar);
		}
	}

	engWord = tempEngWord;

	engWord = this.replace(engWord);

	engWordLength = engWord.length;	

	// If a word end with 'a' and preceded by consonant, then append 'a'. e.g. babita should be changed to babitaa


	/*if(engWordLength > 2 && engWord.charAt(engWordLength-1) == 'a' && !indicResource.isVowel(engWord.charAt (engWordLength-2)))
	{
	engWord.append('a') ;
	engWordLength +=1;
	}*/

	var i = 0;
	var found = 0;
	var j;


	// Unicode string
	var unicodeWord = "";
	var tmpChar ;

	// Variable for checking if previous character is consonant or not

	var prevConsoFlag = 0;
	var prevVowelFlag = 0;
	
	
	while(i < engWordLength)
	{
		// check for vowel and matra.
		found = 0;

		for( j = 2; j > 0; j--)
		{
			if(i+j <= engWordLength)
			{
				var stTmp = engWord.substring(i, i+j);
			          
				if(engWord.substring(i, i+j)=="M")
				{
					tmpChar = String.fromCharCode(startChar.charCodeAt() + 2);
					i+=j;
					if(unicodeWord.length > 1 && unicodeWord.charAt(unicodeWord.length-1)==String.fromCharCode(startChar.charCodeAt() + 77))
					unicodeWord=unicodeWord.substring(0,unicodeWord.length-1);	
					unicodeWord=unicodeWord.concat(tmpChar);
      				engGlyph=engBase+stTmp;
					found = 1;
					break;
				}
				
				else if(engWord.substring(i, i+j)=="H")
				{
					tmpChar = String.fromCharCode(startChar.charCodeAt() + 3);													
					i+=j;
					if(unicodeWord.length > 1 && unicodeWord.charAt(unicodeWord.length-1)==String.fromCharCode(startChar.charCodeAt() + 77))
					unicodeWord=unicodeWord.substring(0,unicodeWord.length-1);	
					unicodeWord=unicodeWord.concat(tmpChar);
					engGlyph=engBase+stTmp;
					found = 1;
					break;
				}
				//Zero Width Non joiner
				else if(engWord.substring(i, i+j)=="^^")
				{
					tmpChar = '\u200C';													
					i+=j;
					unicodeWord=unicodeWord.concat(tmpChar);
					engGlyph=engBase+stTmp;
					found = 1;
					break;
				}
				//Zero Width Joiner
				else if(engWord.substring(i, i+j)=="^")
				{
					tmpChar = '\u200D';													
					i+=j;
					unicodeWord=unicodeWord.concat(tmpChar);
					engGlyph=engBase+stTmp;
					found = 1;
					break;
				}

				// If previous character is consonant, then append matra, else append vowel.
				if(prevConsoFlag)
				{
					if(engWordLength >2 && engWord.charAt(i-2)=="R" && engWord.charAt(i-1)=="u" && (stTmp=="u" || stTmp=="a" || stTmp=="e" || stTmp=="i" || stTmp=="o"))
					{
						tmpChar="";
					}
					else
					{
						tmpChar = this.getUnicodeMatra(engWord.substring(i, i+j), startChar);

						if(engWord.substring(i, i+j)=="RU")
						{
							tmpChar = String.fromCharCode(startChar.charCodeAt() + 68);
						}
					}

					// Append matra if it is not 'a'
					if(tmpChar != 'a' && tmpChar != '?')
					{
						if(prevConsoFlag)
						{
						unicodeWord = unicodeWord.substring(0, unicodeWord.length-1);
						}
						unicodeWord=unicodeWord.concat(tmpChar);
						engGlyph=engBase+stTmp;
						prevConsoFlag = 0;
						prevVowelFlag = 0;
					}
					else if(tmpChar =='a')
					{
						if(prevConsoFlag)
						{
							unicodeWord = unicodeWord.substring(0, unicodeWord.length-1);
							engGlyph=engBase+stTmp;
						}
					}
				}
				else
				{
					if(engWordLength >2 && engWord.charAt(i-2)=="R" && engWord.charAt(i-1)=="u" && (engWord.substring(i, i+j)=="u" || engWord.substring(i, i+j)=="a" || engWord.substring(i, i+j)=="e" || engWord.substring(i, i+j)=="i" || engWord.substring(i, i+j)=="o"))
					{
						tmpChar="";
					}
					else
					{
						
						tmpChar = this.getUnicodeVowel(engWord.substring(i, i+j), startChar);
						
						if(engWord.substring(i, i+j)=="RU")
						{
							
							tmpChar = String.fromCharCode(startChar.charCodeAt() + 96);
						}
					}		
										
					
					 if(tmpChar != '?')
					{
						unicodeWord=unicodeWord.concat(tmpChar);
						engBase=stTmp;
						engGlyph=engBase;
      					prevVowelFlag = 1;

					}
				}
				if(tmpChar != '?')
				{
					prevConsoFlag=0;
					found = 1;
					i += j;
					break;
				}
			}
		}
		if(found) 
		{
			continue;
		}

		// check for consonant.
		found = 0;

		for(j = 2; j > 0; j--)
		{
			if(i+j <=engWordLength)
			{
				var stTmp = engWord.substring(i, i+j);
				tmpChar = this.getUnicodeConsonant(engWord.substring(i, i+j), startChar);
				if(tmpChar != '?')
				{
					unicodeWord = unicodeWord.concat(tmpChar);
					// If consonant is followed by consonant, append halant
					unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 77));
					
					engBase = stTmp;
					engGlyph=engBase;
					prevConsoFlag = 1;
					found = 1;
					this.golbalConso = engWord.substring(i, i+j);
					i += j;
					break;
				}
			}
		}

		if(found)
		{
			continue;
		}
		else // if no match found, append input char as is e.g. number, symbols etc) 
		{	
			var stTmp="";
			stTmp = stTmp + engWord.charAt(i).toLowerCase();
			prevConsoFlag=0;

			if(!prevConsoFlag)
				tmpChar = this.getUnicodeVowel(stTmp,startChar);
			else
				tmpChar = this.getUnicodeMatra(stTmp,startChar);

			if(tmpChar=='?')
			{
				tmpChar = this.getUnicodeConsonant(stTmp,startChar);
				if(tmpChar!='?')
				prevConsoFlag=1;
			}

			if(tmpChar!='?')
				unicodeWord =unicodeWord.concat(tmpChar);
			else
			{
				if(engWord.charAt(i)!='?')
					unicodeWord = unicodeWord.concat(engWord.charAt(i));
			}
			if(prevConsoFlag)
			{
				unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 77));
			}
		}
		i++;
			
	}
	return unicodeWord;
}



function toUnicode_ML(textBox,startChar)
{
  
	var engWord =	textBox;
	var unicode;		
	
	if(engWord == null || engWord.length == 0)
		return "";

	if(startChar.charCodeAt() == 0)
		return "Language not supported";


	if(this.resource.userSpell[engWord])
	{
		engWord = this.resource.userSpell[engWord];
	}

	var engWordLength = engWord.length;

	var k = 0;
	var l = 0;
	var find = 0;
	var tempEngWord = "";

	//To change Uppercase Charecter to Lowercase

	for (k = 0 ; k < engWordLength; k++)
	{
		find = 0; 
		cChar = engWord.charAt(k);
		// Certain uppercase characters are used to indicate a hindi characters.
		// Such characters should not be converted to lower case.
		for (l = 0 ; l < this.resource.charOnlyUppercase.length ; l++)
		{
			if (cChar == this.resource.charOnlyUppercase[l])
			{
				find = 1;
			}
		}
		if(find)
		{
			tempEngWord= tempEngWord.concat(cChar);
		}
		else
		{ 
			cChar=cChar.toLowerCase();
			tempEngWord= tempEngWord.concat(cChar);
		}
	}

	engWord = tempEngWord;

	engWord = this.replace(engWord);

	engWordLength = engWord.length;	

	// If a word end with 'a' and preceded by consonant, then append 'a'. e.g. babita should be changed to babitaa


	/*if(engWordLength > 2 && engWord.charAt(engWordLength-1) == 'a' && !indicResource.isVowel(engWord.charAt (engWordLength-2)))
	{
	engWord.append('a') ;
	engWordLength +=1;
	}*/

	var i = 0;
	var found = 0;
	var j;


	// Unicode string
	var unicodeWord = "";
	var tmpChar ;

	// Variable for checking if previous character is consonant or not

	var prevConsoFlag = 0;
	var prevVowelFlag = 0;
	
	
	while(i < engWordLength)
	{
		// check for vowel and matra.
		found = 0;

		for( j = 2; j > 0; j--)
		{
			if(i+j <= engWordLength)
			{
				var stTmp = engWord.substring(i, i+j);
				
				if(engWord.substring(i, i+j)=="_" && unicodeWord.length > 2 
						&& unicodeWord.charAt(unicodeWord.length-1)=='\u200D'
						&&unicodeWord.charAt(unicodeWord.length-2)==String.fromCharCode(startChar.charCodeAt() + 77))
				{
					prevConsoFlag=false;
					i+=j;
					found=true;
					break;
				}
				
				
				if(engWordLength > 1 && engWord.substring(i, i+j)=="m" 
					&& (engWord.charAt(i-1)=='a' 
						|| engWord.charAt(i-1)=='e' 
						|| engWord.charAt(i-1)=='i' 
						|| engWord.charAt(i-1)=='o' 
						|| engWord.charAt(i-1)=='u'))
				{
					tmpChar = String.fromCharCode(startChar.charCodeAt() + 2);
					i+=j;
					unicodeWord=unicodeWord.concat(tmpChar);
					engGlyph=engBase+stTmp;
					found = 1;
					break;
				}
				else if(engWord.substring(i, i+j)=="H")
				{
					tmpChar = String.fromCharCode(startChar.charCodeAt() + 3);													
					i+=j;
					if(unicodeWord.length > 1 && unicodeWord.charAt(unicodeWord.length-1)==String.fromCharCode(startChar.charCodeAt() + 77))
					unicodeWord=unicodeWord.substring(0,unicodeWord.length-1);	
					unicodeWord=unicodeWord.concat(tmpChar);
					engGlyph=engBase+stTmp;
					found = 1;
					break;
				}
				else if(engWord.substring(i, i+j)=="~")
				{
					tmpChar = String.fromCharCode(startChar.charCodeAt() + 77);													
					i+=j;
					unicodeWord=unicodeWord.concat(tmpChar);
					engGlyph=engBase+stTmp;
					found = 1;
					break;
				}					
				else if(engWord.substring(i, i+j)=="_")
				{
					tmpChar = '\u200D';													
					i+=j;
					unicodeWord=unicodeWord.concat(tmpChar);
					engGlyph=engBase+stTmp;
					found = 1;
					break;
				}
				
				
				// If previous character is consonant, then append matra, else append vowel.
				if(prevConsoFlag)
				{
					tmpChar = this.getUnicodeMatra(engWord.substring(i, i+j), startChar);
					
						
					// Append matra if it is not 'a'
					if(tmpChar != 'a' && tmpChar != '?')
					{
						if(prevConsoFlag)
						{
							if(unicodeWord.charAt(unicodeWord.length-1)=='\u200d')
								unicodeWord = unicodeWord.substring(0, unicodeWord.length-1);
								
							//remove halant	
							unicodeWord = unicodeWord.substring(0, unicodeWord.length-1);
						}
						
						unicodeWord=unicodeWord.concat(tmpChar);
						engGlyph=engBase+stTmp;
      					prevConsoFlag = 0;
						prevVowelFlag = 0;
					}
					else if(tmpChar =='a')
					{
						if(prevConsoFlag)
						{
							if(unicodeWord.charAt(unicodeWord.length-1)=='\u200d')
								unicodeWord = unicodeWord.substring(0, unicodeWord.length-1);
								
							unicodeWord = unicodeWord.substring(0, unicodeWord.length-1);
                         	engGlyph=engBase+stTmp;
      					}
					}
				}
				else
				{
					tmpChar = this.getUnicodeVowel(engWord.substring(i, i+j), startChar);
					
					if(engWordLength >1 && engWord.charAt(i-1)=='m' && tmpChar!='?')
					{
						if(unicodeWord.length > 0 && unicodeWord.charAt(unicodeWord.length-1) == String.fromCharCode(startChar.charCodeAt() + 2))
						{
							unicodeWord = unicodeWord.substring(0,unicodeWord.length-1);
							unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 46));
							tmpChar = this.getUnicodeMatra(engWord.substring(i, i+j), startChar);
							if(tmpChar=='a')
								tmpChar="";
								
							engBase = "m";
							engGlyph = "m"+engWord.substring(i, i+j);
							
							unicodeWord=unicodeWord.concat(tmpChar);
							prevVowelFlag = 1;
						}
					}
					else if(tmpChar != '?')
					{
						unicodeWord=unicodeWord.concat(tmpChar);
						engBase=stTmp;
						engGlyph=engBase;
						prevVowelFlag = 1;
					}
				}
				if(tmpChar != '?')
				{
					prevConsoFlag=0;
					found = 1;
					i += j;
					break;
				}
			}
		}
		if(found) 
		{
			continue;
		}

		// check for consonant.
		found = 0;

		for(j = 3; j > 0; j--)
		{
			if(i+j <=engWordLength)
			{
				var stTmp = engWord.substring(i, i+j);
				tmpChar = this.getUnicodeConsonant(engWord.substring(i, i+j), startChar);
				if(tmpChar != '?')
				{
					if(engWord.charAt(i-1)=='m' && i-1 != 0 && (stTmp == "m" || stTmp == "r" || stTmp == "y" || stTmp == "l"))
					{
						unicodeWord = unicodeWord.substring(0,unicodeWord.length-1);
						unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 46));
						unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 77));
					}
					
					if(unicodeWord.charAt(unicodeWord.length-1)=='\u200d' && engWord.charAt(i-1)!='_')
						unicodeWord = unicodeWord.substring(0, unicodeWord.length-1);
					
									
					unicodeWord = unicodeWord.concat(tmpChar);
					
					if(stTmp=="N" || stTmp=="n"||stTmp=="r"||stTmp=="l"||stTmp=="L")
					{
						unicodeWord = unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 77));
						unicodeWord = unicodeWord.concat('\u200D');
					}
					else
					{
						// If consonant is followed by consonant, append halant
						unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 77));
					}
					
					engBase = stTmp;
					engGlyph=engBase;
					
					prevConsoFlag = 1;
					found = 1;
					this.golbalConso = engWord.substring(i, i+j);
					i += j;
					break;
				}
			}
		}

		if(found)
		{
			continue;
		}
		else // if no match found, append input char as is e.g. number, symbols etc) 
		{	
			var stTmp="";
			stTmp = stTmp + engWord.charAt(i).toLowerCase();
			prevConsoFlag=0;

			if(!prevConsoFlag)
				tmpChar = this.getUnicodeVowel(stTmp,startChar);
			else
				tmpChar = this.getUnicodeMatra(stTmp,startChar);

			if(tmpChar=='?')
			{
				tmpChar = this.getUnicodeConsonant(stTmp,startChar);
				if(tmpChar!='?')
				prevConsoFlag=1;
			}

			if(tmpChar!='?')
				unicodeWord =unicodeWord.concat(tmpChar);
			else
			{
				if(engWord.charAt(i)!='?')
					unicodeWord = unicodeWord.concat(engWord.charAt(i));
			}
			if(prevConsoFlag)
			{
				unicodeWord=unicodeWord.concat(String.fromCharCode(startChar.charCodeAt() + 77));
			}
		}
		i++;
			
	}

	//if(unicodeWord.length > 1 && unicodeWord.charAt(unicodeWord.length-1)==String.fromCharCode(startChar.charCodeAt() + 77))
	//	unicodeWord=unicodeWord.substring(0,unicodeWord.length-1);

	return unicodeWord;
}

/* function to limit the textarea */
function limitText(limitField, limitNum) 
{
       if (limitField.value.length > limitNum) 
      {
            limitField.value = limitField.value.substring(0, limitNum); 
            return false;
      } 
 } 

/*functions to create tooltip */
var DH = 0;var an = 0;var al = 0;var ai = 0;if (document.getElementById) {ai = 1; DH = 1;}else {if (document.all) {al = 1; DH = 1;} else { browserVersion = parseInt(navigator.appVersion); if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {an = 1; DH = 1;}}} function fd(oi, wS) {if (ai) return wS ? document.getElementById(oi).style:document.getElementById(oi); if (al) return wS ? document.all[oi].style: document.all[oi]; if (an) return document.layers[oi];}
function pw() {return window.innerWidth != null? window.innerWidth: document.body.clientWidth != null? document.body.clientWidth:null;}
function mouseX(evt) {if (evt.pageX) return evt.pageX; else if (evt.clientX)return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); else return null;}
function mouseY(evt) {if (evt.pageY) return evt.pageY; else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return null;}
function popUp(evt,oi) {if (DH) {var wp = pw(); ds = fd(oi,1); dm = fd(oi,0); st = ds.visibility; if (dm.offsetWidth) ew = dm.offsetWidth; else if (dm.clip.width) ew = dm.clip.width; if (st == "visible" || st == "show") { ds.visibility = "hidden"; } else {tv = mouseY(evt) + 20; lv = mouseX(evt) - (ew/4); if (lv < 2) lv = 2; else if (lv + ew > wp) lv -= ew/2; if (!an) {lv += 'px';tv += 'px';} ds.left = lv; ds.top = tv; ds.visibility = "visible";}}}
                  
