var sIndx = 0;
var eIndx = 0;
var srTxt = "";
var bObj = null;
var tBxid;
var ctxt;
tlpObj = new Array();
objHM = new Array();
function WCtrlUI(fullUrl)
{ 
this.common;  
  this.imgDir;
  this.ctxPH= "";
  this.tbWd;
  this.ctlid;
  this.ctltp;
  this.kbType;
  this.isDcOn;
  this.isDcOp;
  this.isET;
  this.isKbOp;
  this.isELOp;
  this.lang;
  this.lngDt;
  this.isPh = false;
  this.isIn = false;
  this.isEn = false;
  this.isLg = false;
  this.isTbA;
  this.isDic = false;
  this.rows;
  this.cols;  
  this.hasFocus=true;
  this.isHelpbarOn;
  this.isHelpOption;
  this.isHelp = false;  
  this.bfrSpc=""; 
  this.ctlKey = 0;
  this.isEgEn = false;
  this.bfrSI = 0;
  this.crtIdx = 0; 
  this.bSet = "N";
  this.bfr = new Array(); 
  this.msSI = 0;	
  this.lstMC = 0; 
  this.isTltp=false;
  this.index=0;
  this.Iindx = 0; 
  this.isEntr=false;
  this.uiObj = null;
  this.left = 0; 
  this.top = 0; 
  this.egWrd = "";
  this.hideSg=false;
  this.tRec = 0; 
  this.obj = null;
  this.srURL = "";
  this.wopt =0;
  this.cxtP ="";
  this.temp=0;
  //this.isBt = "0";
  this.genTb= genTb;
  this.togTb = togTb;
  this.fTxt = fTxt;
 // this.opHlpPg=opHlpPg;
  this.ChLng = ChLng;
  this.sLng = sLng;
  this.selLng = selLng;
  this.selDc = selDc;
  this.selKb = selKb;
  this.disKC = disKC;
  this.wGFoc = wGFoc;
  this.wLFoc=wLFoc;
  this.wKeyp = wKeyp;
  this.cKeyUp = cKeyUp
  this.cKeyDn = cKeyDn;
  this.uPosUD = uPosUD;
  this.uPos = uPos;
  this.clrSel = clrSel;
  this.uCrtHP = uCrtHP;
  this.clrBfr = clrBfr;
  this.gCrt = gCrt;
  this.sCrt = sCrt;
  this.inCrt = inCrt;
  this.fxCrt = fxCrt;
  this.lTrm = lTrm ;
  this.rTrm = rTrm;
  this.gFCtrl = gFCtrl;
  this.prHelp=prHelp;
  this.aPrHlp = aPrHlp;
  this.dPrHlp = dPrHlp;
  this.aPNO = aPNO;
  this.dPNO = dPNO;
  this.aApBfr=aApBfr;
  this.dAhBfr = dAhBfr;
  this.sUIObj = sUIObj;
  this.hdeTp =hdeTp;
  this.shTp=shTp;
  this.srchDb = srchDb; 
  this.rplcTx = rplcTx;
  this.sgOvr=sgOvr;
  this.sgOut=sgOut; 
  this.storBf = storBf;
  this.shwSg = shwSg;
  this.gSData = gSData; 
  this.gMore = gMore;
  this.uCrtPos = uCrtPos;
  this.updatePositionOnHelp = updatePositionOnHelp;
  this.selectHelp = selectHelp;
}

function isIE()
{
   var brwsr=navigator.appName;	   
   if(brwsr == "Microsoft Internet Explorer")
   {
     return true;
   }
   else
   { 
     return false;	    
   }
}

function wKeyp(event)
{ 
this.temp = this.temp + 1; 
 
 try
 {
     //return _wiocliteKeypressed(this.ctlid,event);
     return true;
 }
 catch(e)
 {
 }
 
 return true;
}

function wGFoc()
{
if(this.lang != "EN"){
  try{
    this.shTp();
  }catch(e){
  }
 } 
  try
  {    
   _wiocliteGotFocus(this.ctlid);
  }
  catch(e)
  {
  }  
}

function wLFoc()
{
  try
  {
    this.hdeTp();
  }
  catch(e)
  {
  }  
}

function disKC(event)
{ 
  var code;
  if(isIE)
   {
     	code = event.keyCode;
   }
   else
   {
   	 code = event.which;
   }
   
   if(code == 13)
   {   
   
  	if(isIE)
   	{
      		event.keyCode = "";
   	}
 	else
 	{
      		event.preventDefault();
  	} 
  	
  	 try
  	 {    	 
  	  if(isIE)
  	  {  	    	   
  	   _wiocliteEnterKeyEvent(this.ctlid);  	   
  	  }
  	  else
  	  {
  	   if(!this.isEntr)
  	   {  	      	    
  	   	_wiocliteEnterKeyEvent(this.ctlid);  	   
  	   }
  	   else
  	   {
  	    this.isEntr = false;
  	   }  	   
  	  }
  	 }
  	 catch(e)
  	 {
  	 }
     return false;
   } 
   
  return true;
}

function genTb()
{ 
 
 var id = this.ctlid;  		

 var bNm = new Array();

 var i =0;

 if(this.isDcOp == "1" && (this.lang == 'BN' ||this.lang == 'PN' || this.lang == 'GU' || this.lang == 'TM' || this.lang == 'KN' || this.lang == 'TG' || this.lang == 'ML' || this.lang == 'MA' || this.lang == 'HI'))
 {
	bNm[i++]  = "dictionary";
 }
 
 if(this.isELOp == "1")
 {
    bNm[i++]  = "seperator";
	bNm[i++]  = "english";
	bNm[i++]  = "lingual";
 }

 if(this.isKbOp == "1")
 {
    bNm[i++]  = "seperator"; 
	bNm[i++]  = "keyboard";
 }
 if(this.isHelpOption == "1")
 {
    bNm[i++]  = "seperator";
	bNm[i++]  = "helpTool";
 }
/* if(this.isBt == "1")
 {
	bNm[i++]  = "beta";
 }*/
 
var TbLst = {
  //Name            btID                 btTtl             btImg                          buttonImageRollover
  "seperator":      ['',                     '',                         this.imgDir + 'seperator.gif',         this.imgDir + 'seperator.gif'],
  "helpTool":     	['HelpTool_'+id,           	 'Enable Keyboard Help',    this.imgDir + 'help_off.gif',              this.imgDir + 'help_on.gif'],
  "dictionary":     ['Dictionary_'+id,           'Enable Predictive Help',  this.imgDir + 'dictionary_off.gif',    this.imgDir + 'dictionary_on.gif'],
  "english":        ['English_'+id,              'Write in English',     this.imgDir + 'English.gif',        	  this.imgDir + 'English.gif'],
  "lingual":        ['Lingual_'+id,              'Write in '+this.lngDt, this.imgDir +this.lngDt+'.gif',        this.imgDir +this.lngDt+'.gif'],
  "keyboard":       ['Keyboard_'+id,             'Select Keyboard',      '',                                  '']
//  "beta":           ['Beta_'+id,                 'Learn more',         this.imgDir + 'help.png',              this.imgDir + 'help.png']
  
};

   var tlbar="";
                   
	   tlbar +=  '<table cellpadding="0" cellspacing="0" border="0" class="toolbar1_wioc" style="width:'+this.tbWd+'px;"><tr><td align="left" width="2px"><img src="feedback.aspx_files/arrow_up.gif" title="collapse toolbar" onclick="javascript:objHM[\''+id+'\'].togTb();"></td>';  
   

  for (var i = 0; i <= bNm.length;i++) 
   { 
    if (bNm[i]) 
    {
	    var btObj          = TbLst[bNm[i]];
        var btID           = btObj[0];
	    var btTtl          = btObj[1];
        var btImg          = btObj[2];
		var btRol  = btObj[3];	
		if (bNm[i] == "seperator") 
		{
		    tlbar += '<td  style="width: 6px;" align="left"><img src="' +btImg+ '" border=0 unselectable="on" width="2px" height="18px" unselectable="on"></td>';
		}
		else if (bNm[i] == "english")
		{
	        tlbar += '<td align="left"style="width: 1px;"><img src="' +btImg+ '" border="0" unselectable="on" title="' +btTtl+ '" id="' +btID+ '" class="buttonwioc" onClick="objHM[\''+id+'\'].fTxt(this.id);"></td>';	        
		}
		else if(bNm[i] == "lingual")
		{
			tlbar += '<td align="left" style="width: 1px;"><img src="' +btImg+ '" border="0" unselectable="on" title="' +btTtl+ '" id="' +btID+ '" class="buttonwioc" onClick="objHM[\''+id+'\'].fTxt(this.id);"></td>';	        
			
		}
		else if(bNm[i] == "dictionary")
		{
			tlbar += '<td align="left" style="width: 4px;"><img src="' +btImg+ '" border="0" unselectable="on" title="' +btTtl+ '" id="' +btID+ '" class="buttonwiocSP" onClick="objHM[\''+id+'\'].fTxt(this.id);"></td>';
		}
		else if(bNm[i] == "helpTool")
		{
			tlbar += '<td align="left"><img src="' +btImg+ '" border="0" unselectable="on" title="' +btTtl+ '" id="' +btID+ '" onClick="objHM[\''+id+'\'].fTxt(this.id);"></td>';
		}
		else if(bNm[i] == "keyboard")
		{
			 tlbar="";
			tlbar +=  '<table cellpadding="0" cellspacing="0" border="0" class="toolbar1_wioc" style="width:'+this.tbWd+'px;"><tr><td align="left" width="2px"><img src="feedback.aspx_files/arrow_up.gif" title="collapse toolbar" onclick="javascript:objHM[\''+id+'\'].togTb();"></td>';  
			tlbar += '<td align="left" style="width: 4px;"><select class="predictiveSelectclass" title="' +btTtl+ '" id="' +btID+ '"  onChange="objHM[\''+id+'\'].fTxt(this.id);"><option value="PH" selected="selected">Phonetic</option><option value="IN">Inscript</option></select></td><td style="width: 6px;">&nbsp;</td>';
		}
	  /*	else if(bNm[i] == "beta")
		{
			tlbar += '<td align="right"><img src="' +btImg+ '" border="0" unselectable="on" title="' +btTtl+ '" id="' +btID+ '" onClick="objHM[\''+id+'\'].opHlpPg(this.lang);" ></td>';
		}*/	
    }      
  } 
  tlbar += '<td align="right">&nbsp;</tb></tr></table>'; 
 tlbar="";
  if(document.getElementById('toolbar_'+this.ctlid) != null)   
	  document.getElementById('toolbar_'+this.ctlid).innerHTML = tlbar;   

  if(document.getElementById('Lingual_'+this.ctlid) != null)   
      document.getElementById("Lingual_"+this.ctlid).style.display = "none";   
  
  if(this.isIn && !this.isPh)
  {
    this.kbType = "IN";
  }
  else if(!this.isIn && this.isPh)
  {
   this.kbType = "PH";
  }
  this.isIn = false;
  this.isHelp = false;
 
  if(this.isDic)
  {
  	this.isLg = true;
  
  	this.isPh = true;     
  }
    
  this.isDic = false;
 
  if((this.lang == 'BN' ||this.lang == 'PN' || this.lang == 'GU' || this.lang == 'TM' || this.lang == 'ML' || this.lang == 'KN' || this.lang == 'TG' || this.lang == 'MA' || this.lang == 'HI') && !this.isIn)
	  this.selDc(this.lang); 
	  
  if(document.getElementById('help_'+this.ctlid) != null && document.getElementById('help_'+this.ctlid).style.display != 'none')
  {
   this.isHelp = true;
   if(document.getElementById('HelpTool_'+this.ctlid) != null)
	   document.getElementById('HelpTool_'+this.ctlid).src = this.imgDir + "help_on.gif";	   
  }
  else
  {
   this.isHelp = false;
  }
   
  this.isLg = true;
  
  this.isPh = true;      
  
  if(this.isKbOp == "1")
  {   
   if(this.kbType == "IN")
   {
    this.isIn = true;
    
    this.isPh = false;
   }
   else 
   {
    this.isIn = false;
    
    this.isPh = true;
   }            
   if(document.getElementById('Keyboard_'+id) != null)
	   document.getElementById('Keyboard_'+id).value = this.kbType;
   
  }
  
  if(this.isEn)
  {
	this.isEgEn = true;
    this.isEn = true;
    this.isLg = false;
	if(document.getElementById('English_'+this.ctlid) != null)   
      document.getElementById('English_'+this.ctlid).style.display = "none";   
	if(document.getElementById('Lingual_'+this.ctlid) != null)   
      document.getElementById("Lingual_"+this.ctlid).style.display = "";   
  }
  else
  {
    this.isEn = false;
    this.isLg = true;
    this.isEgEn = false;
    if(document.getElementById('English_'+this.ctlid) != null)   
     document.getElementById('English_'+this.ctlid).style.display = "";   
    
   	if(document.getElementById('Lingual_'+this.ctlid) != null)   
      document.getElementById("Lingual_"+this.ctlid).style.display = "none";   
    
  }
}

function togTb()
{ 
	 var tlbar=""; 
 
	 var id = this.ctlid; 
 	 tlbar =  '<table cellpadding="0" cellspacing="0" border="0" class="tlbar" style="width:'+this.tbWd+'px;"><tr>';  
	 tlbar += '<td height="1px"><img src="'+this.imgDir+'arrow_down.gif" title="expand toolbar" onclick="javascript:objHM[\''+id+'\'].genTb();" alignment="absbottom"></td></tr>'; 
	 tlbar += '</table>';    	 
 
     if(document.getElementById('toolbar_'+this.ctlid) != null)
		 document.getElementById('toolbar_'+this.ctlid).innerHTML = tlbar;   
     
}
function fTxt(id) 
{
    if (id == "HelpTool_"+this.ctlid) 
	{	    
	  this.selectHelp();
	}
	 else if(id == "Dictionary_"+this.ctlid)
	{
	 	this.selDc(this.lang);		
	}
	else if(id == "English_"+this.ctlid)
	{
	 	this.selLng('EN');		
    } 
    else if(id == "Lingual_"+this.ctlid)
	{			
	  this.selLng(this.lang);
    }     
    else if(id == "Keyboard_"+this.ctlid)
    {    
	    this.selKb(document.getElementById(id).value);
    }       
}

/*
function opHlpPg(lngid){
str=this.imgDir;
str=str.substring(0,str.indexOf("/images/"));
str= str+"/WiocHelp/help_" + this.lang +".html";
// window.open('http://192.168.3.30/wioc/WiocHelp/help_'+this.lang+'.html');	
 window.open(str);   
}*/

function ChLng(rows, cols, ctlid, ctltp, kbrd, prLen, isTb, isDcOn, isHelpOn, cxtP, lngid, isDictionaryIcon, isHelp, isKeyboard, isEnglishLingual, isET, MaxLength, Width, Class, Readonly, txtval, Level) {    
    try {
        //alert(txtval);
	 this.ctlid = ctlid;
 
     this.ctltp = ctltp;
     
     this.kbType = kbrd;
     
	 objHM[this.ctlid] = this;
 	  this.isET = isET;
 	   //this.isET = '1';
	 this.isTbA = isTb;
     this.isDcOn = isDcOn;
 	 this.isDcOp = isDictionaryIcon;
 	 this.isHelpOption = isHelp;
 	 this.isHelpbarOn = isHelpOn;
 	 this.isKbOp = isKeyboard;
 	 this.isELOp = isEnglishLingual;
	 this.imgDir = cxtP;
	 this.imgDir="feedback.aspx_files/";
	// this.isBt=isBt;
	 document.getElementById('loading_'+this.ctlid).style.display="";
	 document.getElementById('loading_'+this.ctlid).innerHTML = "<img src='"+this.imgDir+"indicator.gif' title='Loading...'>"; 
	 this.rows = rows;
	 this.cols = cols;
	 this.lang = lngid; 
	 this.sLng(this.lang);  	 
	 var textString = "<table  id='TEXTAREA_"+this.ctlid+"' cellpadding='0' cellspacing='0' border='0'>";
	 textString += "<tr><td>";	 
	 if(this.ctltp == 'M') {
	 
	     if (this.lang == "EN") {
	         textString += "<textarea "; 	        
	        if (Readonly == true)
	            textString += "Readonly "
	        textString += "onchange='javascript:assignValue" + Level + "();' maxlength=" + MaxLength + "  type='text' id='" + this.ctlid + "' style=\"border-top-style: solid; border-left-style: solid; border-bottom-style: solid;\" rows='" + this.rows + "' cols='" + this.cols + "' name='" + this.ctlid + "' class=\"TextAreaWioc" + this.lang + ' ' + Class + "\" onfocus =\"objHM['" + this.ctlid + "'].wGFoc()\" >" + txtval + "</textarea>";		 
	    }
	    else 
	    {
	        textString += "<textarea ";
	        if (Readonly == true)
	            textString += "Readonly "
	        textString += "onchange='javascript:assignValue" + Level + "();' maxlength=" + MaxLength + "  type='text' onclick =\"objHM['" + this.ctlid + "'].uPos(this, event, 'false', 'false','" + this.lang + "')\"  onmouseup=\"objHM['" + this.ctlid + "'].uPos(this, event, 'true', 'false','" + this.lang + "')\"   onmousedown =\"objHM['" + this.ctlid + "'].uPos(this, event, 'false','false','" + this.lang + "')\" onkeydown =\"objHM['" + this.ctlid + "'].uPosUD(this, event,'false','false'),objHM['" + this.ctlid + "'].cKeyDn(this,event)\" onkeyup=\"objHM['" + this.ctlid + "'].uPosUD(this, event, 'false', 'true'),objHM['" + this.ctlid + "'].cKeyUp(this,event) \" onkeypress =\"if(objHM['" + this.ctlid + "'].wKeyp(event)){objHM['" + this.ctlid + "'].uPos(this, event, 'false', 'true','" + this.lang + "')}\" onfocus =\"showobj" + Level + "('help_" + this.ctlid + "');objHM['" + this.ctlid + "'].wGFoc(),objHM['" + this.ctlid + "'].uPos(this, event, 'false', 'false','" + this.lang + "'),objHM['" + this.ctlid + "'].gFCtrl(this, event, 'false', 'true','" + this.lang + "')\" id='" + this.ctlid + "' onblur =\"hideobj" + Level + "('help_" + this.ctlid + "');objHM['" + this.ctlid + "'].wLFoc()\"  style=\"border-top-style: solid; border-left-style: solid; border-bottom-style: solid;\" rows='" + this.rows + "' cols='" + this.cols + "' name='" + this.ctlid + "' class=\"TextAreaWioc" + this.lang + ' ' + Class + "\">" + txtval + "</textarea>";		 
		}
	 }
	 else if(this.ctltp == 'S') {
	 
	     if (this.lang == "EN") {
	         textString += "<input ";
	         if (Readonly == true)
	             textString += "Readonly "
	         textString += "onchange='javascript:assignValue" + Level + "();' maxlength=" + MaxLength + " value= '" + txtval + "' type='text' onkeypress =\"if(objHM['" + this.ctlid + "'].disKC(event)){}\" id='" + this.ctlid + "' style=\"border-top-style: solid; border-left-style: solid; border-bottom-style: solid;overflow:hidden;width:" + Width + "px;\"  cols='" + this.cols + "' name='" + this.ctlid + "'  wrap='off' class=\"TextAreaWioc" + this.lang + ' ' + Class + "\" onfocus =\"objHM['" + this.ctlid + "'].wGFoc()\" />";
	  }
	  else {
	      textString += "<input  ";
	      if (Readonly == true)
	          textString += "Readonly "
	      textString += "onchange='javascript:assignValue" + Level + "();' maxlength=" + MaxLength + " value='" + txtval + "' type='text' onclick =\"objHM['" + this.ctlid + "'].uPos(this, event, 'false', 'false','" + this.lang + "')\"  onmouseup=\"objHM['" + this.ctlid + "'].uPos(this, event, 'true', 'false','" + this.lang + "')\"   onmousedown =\"objHM['" + this.ctlid + "'].uPos(this, event, 'false','false','" + this.lang + "')\" onkeydown =\"objHM['" + this.ctlid + "'].uPosUD(this, event,'false','false'),objHM['" + this.ctlid + "'].cKeyDn(this,event)\" onkeyup=\"objHM['" + this.ctlid + "'].uPosUD(this, event, 'false', 'true'),objHM['" + this.ctlid + "'].cKeyUp(this,event) \" onkeypress =\"if(objHM['" + this.ctlid + "'].disKC(event)){if(objHM['" + this.ctlid + "'].wKeyp(event)){objHM['" + this.ctlid + "'].uPos(this, event, 'false', 'true','" + this.lang + "')}}\" onfocus =\"showobj" + Level + "('help_" + this.ctlid + "');objHM['" + this.ctlid + "'].wGFoc(),objHM['" + this.ctlid + "'].uPos(this, event, 'false', 'false','" + this.lang + "'),objHM['" + this.ctlid + "'].gFCtrl(this, event, 'false', 'true','" + this.lang + "')\" id='" + this.ctlid + "'  onblur =\"hideobj" + Level + "('help_" + this.ctlid + "');objHM['" + this.ctlid + "'].wLFoc()\" style=\"border-top-style: solid; border-left-style: solid; border-bottom-style: solid;overflow:hidden;width:" + Width + "px;\"  cols='" + this.cols + "' name='" + this.ctlid + "'  wrap='off' class=\"TextAreaWioc" + this.lang + ' ' + Class + "\"/>";
	  }
	 }
	 else
	 {
    	 textString += "Control type error. Reason: Control type unknown.";
	 }
	 textString +="</td>";
	 textString +="</tr>";
 	 textString += "</table>";
	 document.getElementById('textarea1_'+this.ctlid).innerHTML = textString;
	 this.tbWd = document.getElementById(this.ctlid).offsetWidth;
	 document.getElementById('TEXTAREA_'+this.ctlid).style.width=this.tbWd+"px";
	 if(this.lang != "EN")
	 {	 	     
		 this.common = new Common(this.lang,'PH',this.ctlid);
	     this.common.sCtxRt(cxtP);
         this.common.sWdObj(this);   
         this.common.sObj(common);
	     this.sUIObj(this);
		 var url1 = this.ctxPH+"/suggestionservlet";
		 var url1 = "/index.html";
		 if(this.common.tBxid!=null){
	     tlpObj[this.common.tBxid]=this;
	     }
    	 this.prHelp(prLen,url1,"M",cxtP);	
	     this.clrBfr();
     	// this.common.Intlz(this.lang);		
      	 if(isTb == "1")
	 	 {
	 	   this.genTb();
	 	 } 	 
	      if(this.isHelpbarOn == "1")
		 {	
		  this.isPh = true;
		  this.selectHelp();
		 } 	 	
		 if(isDcOn == "1" && (this.lang == 'BN' ||this.lang == 'PN' || this.lang == 'GU' || this.lang == 'TM' || this.lang == 'ML' || this.lang == 'KN' || this.lang == 'TG' || this.lang == 'MA' || this.lang == 'HI') && this.kbType != 'IN')
		 {	 
	  	  this.isDic = false;
	  	  this.isLg = true; 
	  	  this.isPh = true;
		  this.selDc(this.lang);	  
		 }	  	 
		// this.selKb(kbrd);
		 if(this.isET == '1')
		 {
		    this.selLng('EN');
		 }else{
		 
		  this.common.Intlz(this.lang);	
		   this.selKb(kbrd);
		 }
	  } 	 
	 document.getElementById('loading_'+this.ctlid).innerHTML = "";
	 document.getElementById('loading_'+this.ctlid).style.display="none";   	
 }
 catch(e)
 {
  alert("ERROR IN Control Creation : "+e);
 } 
}
function sLng(lngid){
 if(lngid == "HI"){   
   this.lngDt = "Hindi";   
 }
 else if(lngid == "MA"){
   this.lngDt = "Marathi";   
 }
 else if(lngid == "GU"){
   this.lngDt = "Gujarati";   
 }
 else if(lngid == "PN"){
   this.lngDt = "Punjabi";   
 }
 else if(lngid == "BN"){
   this.lngDt = "Bengali";   
 }
 else if(lngid == "ML"){
   this.lngDt = "Malayalam";   
 }
 else if(lngid == "TM"){
   this.lngDt = "Tamil";   
 }
 else if(lngid == "TG"){
   this.lngDt = "Telugu";   
 }
 else if(lngid == "KN"){
   this.lngDt = "Kannada";   
 }
 else if(lngid == "OR"){
   this.lngDt = "Oriya";   
 }
 else if(lngid == "AS"){
   this.lngDt = "Assamese";   
 } 
}
function selLng(key)
{ 

 if(document.getElementById('tooltips_'+this.ctlid) != null)   
	 document.getElementById('tooltips_'+this.ctlid).innerHTML = "";
 if(key == 'EN')
 {    
   this.isDic = true;
   this.selDc(key);
   this.isLg = false;
   
  // this.lngDt = "Hindi";  
  
  if(document.getElementById('Lingual_'+this.ctlid) != null){  
       document.getElementById('Lingual_'+this.ctlid).style.display=''; 
	   document.getElementById('Lingual_'+this.ctlid).src=this.imgDir +this.lngDt+'.gif';
   }
   if(document.getElementById('English_'+this.ctlid) != null)   
	   document.getElementById('English_'+this.ctlid).style.display='none';
   //if(document.getElementById('English_'+this.ctlid) != null)   
	 //  document.getElementById('English_'+this.ctlid).src = this.imgDir+"English.gif";   
                    
   this.isEgEn = true; 
   this.isEn = true;
 }
 else
 {   
  this.isEgEn = false;    
  this.isEn = false;  
  this.isLg = true;
  this.isDic = true;
  this.selDc(key);
  //this.isET='0';
  this.common.Intlz(this.lang);	
  this.selKb(this.kbType);
  if(document.getElementById('Lingual_'+this.ctlid) != null)   
  	document.getElementById('Lingual_'+this.ctlid).style.display='none';
  if(document.getElementById('English_'+this.ctlid) != null)   
	document.getElementById('English_'+this.ctlid).style.display='';
  if(document.getElementById('English_'+this.ctlid) != null)   
	document.getElementById('English_'+this.ctlid).src = this.imgDir+"English.gif";   
	this.aPrHlp();
 	this.aPNO();
 	this.aApBfr(); 	
 }
}
function selDc(key)
{ 
 if(document.getElementById('tooltips_'+this.ctlid) != null)   
 	document.getElementById('tooltips_'+this.ctlid).innerHTML = "";
 if((key == "BN" || key == "PN" || key == "GU" || key == "TM" || key == "KN" || key == "TG"  || key == "ML" || key == "MA" || key == "HI") && !this.isDic && this.isLg && this.isPh)
 {     
    this.isDic = true;
    if(document.getElementById('Dictionary_'+this.ctlid) != null)   
	    document.getElementById('Dictionary_'+this.ctlid).src = this.imgDir+"dictionary_on.gif";  
    if(document.getElementById('Dictionary_'+this.ctlid) != null)   
	    document.getElementById('Dictionary_'+this.ctlid).title = "Disable predictive help.";  
    this.aPrHlp();
 	this.aPNO();
 	this.aApBfr(); 	 	
  }  
  else if(this.isDic)
  { 
   this.isDic = false;
   if(document.getElementById('Dictionary_'+this.ctlid) != null)      
	   document.getElementById('Dictionary_'+this.ctlid).src = this.imgDir+"dictionary_off.gif";     
   if(document.getElementById('Dictionary_'+this.ctlid) != null)   
	   document.getElementById('Dictionary_'+this.ctlid).title = "Enable predictive help.";   
   this.dPrHlp();
   this.dPNO();
   this.dAhBfr();   
  }
 else if( key != "BN" && key != "PN" && key != "GU" && key != "TM" && key != "KN" && key != "TG" && key != "ML" && key != "MA" && key != "HI" && key != "EN")
 {
   alert("Dictionary option is coming soon for this language.");
   if(document.getElementById('Dictionary_'+this.ctlid) != null)   
	   document.getElementById('Dictionary_'+this.ctlid).src = this.imgDir+"dictionary_off.gif";
   if(document.getElementById('Dictionary_'+this.ctlid) != null)   
	   document.getElementById('Dictionary_'+this.ctlid).title = "Enable predictive help.";
 }
 else if(this.isEn && this.isIn)
 {
   alert("Dictionary is available for Phonetic typing only.");   
   this.isDic = false;
   if(document.getElementById('Dictionary_'+this.ctlid) != null)   
	   document.getElementById('Dictionary_'+this.ctlid).src = this.imgDir+"dictionary_off.gif";  
   if(document.getElementById('Dictionary_'+this.ctlid) != null)   
	   document.getElementById('Dictionary_'+this.ctlid).title = "Enable predictive help.";
   this.dPrHlp();
   this.dPNO();
   this.dAhBfr();   
 } 
 else if(this.isEn)
 {
   alert("Dictionary is available for Phonetic typing only.");
   this.isDic = false;
   if(document.getElementById('Dictionary_'+this.ctlid) != null)   
	   document.getElementById('Dictionary_'+this.ctlid).src = this.imgDir+"dictionary_off.gif";  
   if(document.getElementById('Dictionary_'+this.ctlid) != null)   
	   document.getElementById('Dictionary_'+this.ctlid).title = "Enable predictive help.";
   this.dPrHlp();
   this.dPNO();
   this.dAhBfr();   
 }  
 else if(this.isIn)
 {
   alert("Dictionary is available for Phonetic typing only.");
   this.isDic = false;
   if(document.getElementById('Dictionary_'+this.ctlid) != null)   
	   document.getElementById('Dictionary_'+this.ctlid).src = this.imgDir+"dictionary_off.gif";  
   if(document.getElementById('Dictionary_'+this.ctlid) != null)   
	   document.getElementById('Dictionary_'+this.ctlid).title = "Enable predictive help.";
   this.dPrHlp();
   this.dPNO();
   this.dAhBfr();   
 }  
}
function selKb(key)
{ 
 if(document.getElementById('tooltips_'+this.ctlid) != null)   
	 document.getElementById('tooltips_'+this.ctlid).innerHTML = ""; 
 if(key == "PH")
 {              
   this.isPh = true;
   this.isIn = false;
   this.common.InitKB(key);  
   if(this.isHelpbarOn == "1" && this.isHelpOption == "0")
   {
    if(document.getElementById('help_'+this.ctlid) != null)   
      document.getElementById('help_'+this.ctlid).style.display='';    
   }  
   if(!this.isEn)
   {
	   if(this.isDcOn == "1")
	   {   
	    if( this.lang == 'BN' ||this.lang == 'PN' || this.lang == 'GU' || this.lang == 'TM' || this.lang == 'KN' || this.lang == 'TG' || this.lang == 'ML' || this.lang == 'MA' || this.lang == 'HI')
	 	{	 
	  	  this.isDic = false;  	  
	  	  this.isLg = true;  	  
	  	  this.isPh = true;  	  
		  this.selDc(this.lang);	 
		  this.aPrHlp();
       	this.aPNO();
 	 	this.aApBfr();  
	    } 
      }   
   }
 } 
 else
 {        
	   this.common.InitKB(key); 
	   this.isDic = true;
	   this.selDc(key);   
 	   this.isPh = false;
	   this.isIn = true;
	   if(document.getElementById('HelpTool_'+this.ctlid) != null)   
		   document.getElementById('HelpTool_'+this.ctlid).src = this.imgDir + "help_off.gif";   
	   if(document.getElementById('help_'+this.ctlid) != null)   
	     document.getElementById('help_'+this.ctlid).style.display='none';    
 }
}

function selectHelp()
{
 if(document.getElementById('help_'+this.ctlid) != null && document.getElementById('help_'+this.ctlid).style.display == 'none' && this.isPh)
 {
   if(document.getElementById('help_'+this.ctlid) != null)
	   document.getElementById('help_'+this.ctlid).style.display='';  
   if(document.getElementById('HelpTool_'+this.ctlid) != null){
	   document.getElementById('HelpTool_'+this.ctlid).src = this.imgDir + "help_on.gif";
	   document.getElementById('HelpTool_'+this.ctlid).title = "Disable Keyboard help.";      
   }
 }
 else if(this.isInscript)
 {
	 alert("Help is available for Phonetic typing only.");
	 if(document.getElementById('HelpTool_'+this.ctlid) != null)
		 document.getElementById('HelpTool_'+this.ctlid).src = this.imgDir + "help_off.gif";
	 if(document.getElementById('help_'+this.ctlid) != null){
	     document.getElementById('help_'+this.ctlid).style.display='none'; 
	     document.getElementById('HelpTool_'+this.ctlid).title = "Enable Keyboard help.";  	 
     }
 }
 else
 {  
    if(document.getElementById('HelpTool_'+this.ctlid) != null)
	    document.getElementById('HelpTool_'+this.ctlid).src = this.imgDir + "help_off.gif";
	if(document.getElementById('help_'+this.ctlid) != null){
      document.getElementById('help_'+this.ctlid).style.display='none';  
      document.getElementById('HelpTool_'+this.ctlid).title = "Enable Keyboard help."; 
     }
 }  
}
 function sUIObj(obj)
{
 this.uiObj = obj;
}
 
function prHelp(num,url,wopt,cxtP)
{ 
 this.isTltp = false;
 this.common.noWrds = num;
 this.srURL = url;
 this.wopt = wopt;
 this.cxtP = cxtP;
}

function hdeTp(){
this.hideSg = true;
this.isTltp = false;
}

function shTp(){
this.hideSg = false;
this.isTltp = true;
}
function aPrHlp()
{ 
  this.isTltp = true;
}
function dPrHlp()
{ 
 this.isTltp = false;
}
function aPNO()
{
 this.common.isPNO = true;
}
function aApBfr()
{
 this.common.isAhBfr = true;
}
function dPNO()
{
 this.common.isPNO = false;
}
function dAhBfr()
{
 this.common.isAhBfr = false;
}
function cKeyUp(textbox,keyP){

	var brwsr=navigator.appName;
	var code;	
	if (brwsr=="Microsoft Internet Explorer"){
	   code =  keyP.keyCode;
	}else{
	   code =  keyP.which;	   
	}			
	if(code == 17){
	  this.ctlKey = 0;
	}
}
function cKeyDn(textbox,keyP){
 	var brwsr=navigator.appName;
	var code;	
	if (brwsr=="Microsoft Internet Explorer"){
	   code =  keyP.keyCode;
	}else{
	   code =  keyP.which;	   
	}			
	if(code == 17){
	  this.ctlKey = 1;
	}	
 
	if(this.isTltp == true)
    {                  
      if(code == 13 || code == 40 || code == 38 && (document.getElementById('tooltips_'+this.ctlid).innerHTML != ""))
      {               
        if(code == 40)
        { 
         if(document.getElementById(this.index+"_"+textbox.id) != null)   
	          document.getElementById(this.index+"_"+textbox.id).className = 'suggest_wioc_link';
	       if(document.getElementById('0'+"_"+textbox.id) != null)   
	       	  document.getElementById('0'+"_"+textbox.id).className = 'suggest_wioc_link';   
	       this.index = this.index + 1;   	              
          if(this.index > (this.common.maxNum))
          {
            this.index = 0;  
			if(document.getElementById((this.common.maxNum+"_"+textbox.id)) != null)    
            	document.getElementById((this.common.maxNum+"_"+textbox.id)).className = 'suggest_wioc_link';     
          }
          if(this.index > 0)
          {         
            if(document.getElementById((this.index-1)+"_"+textbox.id) != null)    
              document.getElementById((this.index-1)+"_"+textbox.id).className = 'suggest_wioc_link';       
          } 
          if(document.getElementById(this.index+"_"+textbox.id) != null)   
	          document.getElementById(this.index+"_"+textbox.id).className = 'suggest_wioc_link_over';
            if (brwsr=="Microsoft Internet Explorer")
            {
               			keyP.returnValue = false;	   			
			}
			else
			{
			 keyP.preventDefault();			
			 return false;
			}						  
		   return false;	             
        }
        else if(code == 38)
        {      
           if(document.getElementById(this.index+"_"+textbox.id) != null)   
	          document.getElementById(this.index+"_"+textbox.id).className = 'suggest_wioc_link';
           if(document.getElementById('0'+"_"+textbox.id) != null)   
	         document.getElementById('0'+"_"+textbox.id).className = 'suggest_wioc_link';
           this.index = this.index - 1;         
           if(this.index < 0 )
           {
             this.index = (this.common.maxNum);      
             if(document.getElementById('0'+"_"+textbox.id) != null)
	           document.getElementById('0'+"_"+textbox.id).className = 'suggest_wioc_link';     
           }    
          if(this.index >= 0 && this.index < (this.common.maxNum))
           {       
             if(document.getElementById((this.index+1)+"_"+textbox.id) != null)         
	             document.getElementById((this.index+1)+"_"+textbox.id).className = 'suggest_wioc_link';                                         
           }  
          if(document.getElementById(this.index+"_"+textbox.id) != null)    
	           document.getElementById(this.index+"_"+textbox.id).className = 'suggest_wioc_link_over';                                                   
            if (brwsr=="Microsoft Internet Explorer")
              {
	   			keyP.returnValue = false;
  		      }
			  else
			  {
				keyP.preventDefault();			
				return false;
			  }				
			 return false;	         			 
        }
        else if(code == 13)
        {
           if(code == 32 ){
                if(document.getElementById('tooltips_'+textbox.id)!=null && document.getElementById('0'+"_"+textbox.id)!=null){   
              	this.rplcTx(document.getElementById('0'+"_"+textbox.id).innerHTML,textbox.id); 
              	document.getElementById('tooltips_'+textbox.id).innerHTML = "";  
                	}
              	this.clrBfr ();				
		      }     
          else{           
            for(this.Iindx = 0; this.Iindx<=this.common.maxNum;this.Iindx++)
            {                       
             if(document.getElementById(this.Iindx+"_"+textbox.id) != null)
             {     
              if(document.getElementById(this.Iindx+"_"+textbox.id).innerHTML.indexOf("arrow1.gif") == -1 && document.getElementById(this.Iindx+"_"+textbox.id).innerHTML.indexOf("arrow2.gif") == -1)
              {                   
               if(document.getElementById(this.Iindx+"_"+textbox.id).className == 'suggest_wioc_link_over')
               {              
                this.rplcTx(document.getElementById(this.Iindx+"_"+textbox.id).innerHTML,textbox.id); 
                this.isEntr = true;           
                this.index = 0;                                        
                if (brwsr=="Microsoft Internet Explorer")
                { 	              
                 keyP.returnValue = false;   		
			    }
			    else
			    {
				 keyP.preventDefault();		
				 return false;
			    }			
                document.getElementById('tooltips_'+textbox.id).innerHTML = "";  	
                this.common.rownum = 0;		  				
			    return false;
               }
             }
             else
             {              
              if(document.getElementById(this.Iindx+"_"+textbox.id).className == 'suggest_wioc_link_over')
              {  
               if(this.common.isPNO == true)
          	   {              
			     this.gMore(textbox.id,document.getElementById(this.Iindx+"_"+textbox.id).innerHTML);                                        
			     this.isEntr = true;  
	    		 if (brwsr=="Microsoft Internet Explorer")
			     {		   		
	    		   	keyP.keyCode=46;	   				   				   			
			  	 }
				 else
				 {				    					
					keyP.preventDefault();								
					return false;
				 }			                     
			     return false;           
	    	   }
          	  }   
            }
           }
          }  
          }
        }
      }     
    }    
}
function uPosUD(txBox, keyP, frcCln, addBf)
 { 
    var brwsr=navigator.appName;
 	//alert("before:"+txBox.value);
	var code;	
	if (brwsr=="Microsoft Internet Explorer")
	{
	   code =  keyP.keyCode;
	}
	else
	{
	   code =  keyP.which;		  
	}
	 	//alert("middle:"+txBox.value);
	if(code != 46)
	{
		
		this.clrSel(keyP, txBox);
								
	}
 	if(this.isTltp == true)
    {       
      this.storBf(this.bfr.join(""));
    }
    if(this.isTltp == true)
    {                     
      if(code != 13 && code != 38 && code != 40 && code != 9 && code != 32)
      {   
       this.index = -1;      
       if(this.temp > 1){   
       		this.srchDb(txBox,keyP);  

       }        
      }
      else if(code == 9 || code == 32)
      {                   
        if(document.getElementById('tooltips_'+this.ctlid)!= null && document.getElementById('tooltips_'+this.ctlid).style.display != 'none')

            document.getElementById('tooltips_'+this.ctlid).innerHTML = "";

           this.bfr = new Array();
      }        
    }
	if(!this.isEgEn && code != 17 && this.ctlKey != 1)
	{  		    
       if (txBox.value.length <= 0 && brwsr != "Microsoft Internet Explorer") 
       {   
           txBox.value = ""; 
           this.bfrSpc =  txBox.value;                                            
        }		
	if (this.bSet == "N") 
	{	    
		this.bfrSI = this.gCrt (txBox).position;
		this.bSet = "Y";
		this.clrBfr ();				
		this.bfrSpc =  txBox.value;    
				
	}
	else if 
	(
		   code == 46 ||
		   code == 8  ||
		   code == 35 ||
		   code == 36 ||
		   code == 37 ||
		   code == 38 ||
		   code == 39 ||
		   code == 40 ||
		   code == 34 ||
		   code == 33 ||
		   code == 27 )  
	{  
	  	 
		this.bfrSI = this.gCrt(txBox).position;			
		this.bSet = "N";		
		this.clrBfr ();	
		this.bfrSpc =  txBox.value;  
		if(code != 40 && code !=38 ){ 
		if(document.getElementById('tooltips_'+this.ctlid)!= null && document.getElementById('tooltips_'+this.ctlid).style.display != 'none')
            document.getElementById('tooltips_'+this.ctlid).innerHTML = "";	
            this.bfr = new Array();
          	    	    
	    } 
	}
	else if(code == 13 || code == 32)
	{		   	   	 
	  this.bfrSI = this.gCrt(txBox).position;	
	  this.bSet = "N";		
	  this.clrBfr ();	
	  this.bfrSpc =  txBox.value;		  
	}           
   else if (frcCln == "true") 
   {			
		this.bfrSI = this.gCrt(txBox).position;
		this.bSet = "N";
		this.clrBfr();		
	}
 }
   else if((code == 13 || 
		   code == 32) && (brwsr!="Microsoft Internet Explorer")){		   
	  this.bSet = "N";		
	  this.clrBfr();	
	  this.bfrSpc =  txBox.value;
       if(txBox.selectionEnd > 0){
         this.bfrSI = this.gCrt(txBox).position + this.gCrt (txBox).selectionLength;
       }else{       
         this.bfrSI = this.gCrt(txBox).position;	
       }
 }else if(brwsr!="Microsoft Internet Explorer"){	
      this.bSet = "N";
	  this.clrBfr ();	
	  this.bfrSpc =  txBox.value;	
	   if(txBox.selectionEnd > 0){
         this.bfrSI = this.gCrt(txBox).position + this.gCrt (txBox).selectionLength;
       }else{       
         this.bfrSI = this.gCrt(txBox).position;	
       }  
 }else if(brwsr=="Microsoft Internet Explorer"){
     this.bfrSI = this.gCrt(txBox).position + this.gCrt (txBox).selectionLength;			
	 this.bSet = "N";		
	 this.clrBfr ();	
	 this.bfrSpc =  txBox.value;  
 } 
 	//alert("after:"+txBox.value);
}
function updatePositionOnHelp(txBox, engWord , forceClean, addToBuffer, startChar) 
{        
	var brwsr=navigator.appName;	
	 if(brwsr != "Microsoft Internet Explorer")
	 {	 
        this.bSet = "N";
		this.clrBfr ();	 
        this.bfrSpc = txBox.value;	
		if(txBox.selectionEnd > 0)
		    {
		      this.bfrSI = this.gCrt(txBox).position + this.gCrt(txBox).selectionLength;
		    }
		    else
		   {       
			 this.bfrSI = this.gCrt(txBox).position;	
		   }
         this.sCrt (txBox, {position:this.bfrSI});    
	 }
	 else
	 {
        this.sCrt(txBox,{position:this.lstMC});    
     }
	 this.inCrt(txBox, '', this.common.toUncd(this.lTrm(this.rTrm(engWord)),startChar), 'true', false);	 
	 this.lstMC = this.gCrt(txBox).position;     
     var engGlyphtmp = engGlyph;
     this.common.sTxBox(txBox.id);
     if(document.getElementById('help_'+txBox.id) != null && document.getElementById('help_'+txBox.id).style.display != "none")
	    { this.common.DisplayHelp(this.common.toUncd(engBase,startChar),engBase,startChar,engGlyphtmp);}
  }
function gFCtrl(txBox, keyP, frcCln, addBf)
{  

  this.bfrSI = this.gCrt (txBox).position;		
  this.bSet = "N";
  this.clrBfr ();	
  this.bfrSpc =  txBox.value;	  
}
function uPos(txBox, keyP, frcCln, addBf,lang)
{    
    var unicode; 
	
    this.common.sTxBox(txBox.id);

    var brwsr=navigator.appName;
    var code;
	if (brwsr == "Microsoft Internet Explorer")
	{
	 code =  keyP.keyCode;
	}
	else
	{
	 code =  keyP.which;		
	}			  
	
	if(keyP.button == 1|| code == 1 || code == 0){
	  if(document.getElementById('tooltips_'+this.ctlid)!= null && document.getElementById('tooltips_'+this.ctlid).style.display != 'none')
            document.getElementById('tooltips_'+this.ctlid).innerHTML = "";	
            this.bfr = new Array();    
	} 
	if(code == 20 ||(keyP.ctrlKey && code == 84))
	{
		if(this.isEgEn)
		{
		 this.uiObj.selLng(this.common.lngid);	 
		}
		else
		{
		 this.uiObj.selLng('EN');	 
		} 
	}	
	 this.uCrtHP(txBox);
    if(this.isTltp == true)
    {                        
      this.storBf(this.bfr.join(""));                          
      this.uCrtPos(txBox);                	 
    }
	if(!this.isEgEn && code != 17  && this.ctlKey != 1)
  	{  				     
        if(lang == '')
        {
            lang = "HI";
        }
      if (txBox.value.length <= 0 && brwsr != "Microsoft Internet Explorer") 
       {           
           txBox.value = ""; 
           this.bfrSpc =  txBox.value;                                            
        }
       var startChar = this.common.gIStart(lang);	
	if (this.bSet == "N") {	   
		this.bfrSI = this.gCrt(txBox).position;
		this.bSet = "Y";
		this.clrBfr ();			
	}else if (
		   code == 8  || 
		   code == 13 || 
		   code == 32 || 
		   code == 27)  
	{      		    
		this.bfrSI = this.gCrt(txBox).position;		
		this.bSet = "N";
		this.clrBfr ();	
		this.bfrSpc =  txBox.value;	
	     	
	} else if (frcCln == "true") {	
		this.bfrSI = this.gCrt(txBox).position;
		this.bSet = "N";
		this.clrBfr ();
		this.lstMC = this.bfrSI;		
		this.bfrSpc =  txBox.value;			
	} else {
		if (addBf == "true" && code != 0) {		
			this.bfr.push(String.fromCharCode(code));	
	  	    if(this.isTltp == true)
            {        
              this.storBf(this.bfr.join(""));
            }            
			this.inCrt(txBox, '', this.common.toUncd(this.bfr.join(""), startChar), 'true', 'true');	
			this.crtIdx = this.gCrt (txBox);			
            var engGlyphtmp = engGlyph;
            this.common.sTxBox(txBox.id);
          if(document.getElementById('help_'+txBox.id) != null && document.getElementById('help_'+txBox.id).style.display != "none")
	    { this.common.DisplayHelp(this.common.toUncd(engBase,startChar),engBase,startChar,engGlyphtmp);}
          	if (brwsr=="Microsoft Internet Explorer"){
	   			keyP.returnValue = false;   		
			}else{
				keyP.preventDefault();			
				return false;
			}				
			code="";				
			this.lstMC = this.gCrt(txBox).position + this.gCrt(txBox).selectionLength; 						
		}
	}      
 }
  else if (
		   (code == 8  || 
		   code == 13 || 
		   code == 32) && brwsr!="Microsoft Internet Explorer")		   
	{      		 	  	    
		this.bSet = "N";
		this.clrBfr ();	
		this.bfrSpc =  txBox.value;				  	 
}else if(brwsr!="Microsoft Internet Explorer"){
      this.bSet = "N";
	  this.clrBfr ();	
	  this.bfrSpc =  txBox.value;	
	   if(txBox.selectionEnd > 0){
         this.bfrSI = this.gCrt (txBox).position + this.gCrt(txBox).selectionLength;
       }else{       
         this.bfrSI = this.gCrt (txBox).position;	
       }   
  }else if(brwsr=="Microsoft Internet Explorer"){
        this.bfrSI = this.gCrt (txBox).position + this.gCrt(txBox).selectionLength;			
		this.bSet = "N";		
		this.clrBfr ();	
		this.bfrSpc =  txBox.value;   
 }

}
function clrSel(keyP, txBox) {     
    var brwsr=navigator.appName;
   	var code;
	if (brwsr=="Microsoft Internet Explorer"){
	   code =  keyP.keyCode;
	}else{
	   code =  keyP.which;
	}
	if (
	   code == 46 || 
	   code == 8  || 
	   code == 13 || 
	   code == 32 || 
	   code == 37 || 
	   code == 38 || 
	   code == 39 || 
	   code == 40)   
	{  
		if (this.bfr.length > 0) {
			var selLength = this.crtIdx.position;			
			txBox.value = txBox.value;					
			this.bfrSpc =  txBox.value;									    			
			this.sCrt (txBox, parseInt(this.crtIdx.position + this.crtIdx.selectionLength));			
		}
	}	
}
function clrBfr(){     
	this.bfr = new Array();
	this.crtIdx = this.bfrSI;
	this.msSI = this.crtIdx;
	this.mouseLastSelectionLength = 0;
	this.lstMC = this.bfrSI;	
	this.temp=0;
		   
}
function gCrt(textArea, logP)
{
	if (arguments.length < 2) logP = false; 
	if (typeof textArea.selectionStart != "undefined" && typeof textArea.selectionStart != "number") {		      		
		return {
			position: textArea.selectionStart,
			selectionLength: (textArea.selectionEnd-textArea.selectionStart)
		};
	}else if (textArea.createTextRange) {
		var nLine = 0;
		var position = 0;
		var selectionLength = 0;
		try{
			textArea.caretPos = document.selection.createRange().duplicate();
	        var sel = document.selection.createRange();
	        var r = textArea.createTextRange();
	        var len = textArea.value.length;
	        r.moveToPoint(sel.offsetLeft, sel.offsetTop);
	        r.moveEnd('textedit');
	        position = len - r.text.length;
	        match = textArea.value.substring(0,position).match(/\n/g);
			if (match)
			{
				nLine = match.length;
			}
			else
			{
			    nLine = 0;
			}	
	        selectionLength = sel.text.length;	
        }catch(e){}				
       return {
				position: position  - (nLine),
				selectionLength: selectionLength
			};
	 }else{	 
	    // MOZILLA / Firefox
	    var nLine = 0;
		match = textArea.value.match(/\n/g);
		if (match) {
			nLine = match.length;
		}												
		var position =textArea.selectionStart;		
	    if (logP) {    	 
			return {			
				position:  position + 1,
				selectionLength: ((textArea.selectionEnd-textArea.selectionStart))
			};
		} else {			   
			return{			    
				position: position + 1,
				selectionLength: ((textArea.selectionEnd-textArea.selectionStart))
			};
		}	       	 	
	 }
}
function sCrt(txtF, pos, scrollTop) { 
	if (typeof pos == "number" ) {				
		pos = {position: pos, selectionLength: 0}
	}
    if (typeof pos.position == "undefined") {	        
		pos.position = this.gCrt(txtF).position;		
	}
	if (typeof pos.selectionLength == "undefined") {	        
		pos.selectionLength = 0;		
	}
	if (pos.selectionLength < 0) {
		pos.position += pos.selectionLength;
		pos.selectionLength = -pos.selectionLength;		
	}
    if (txtF.createTextRange || txtF.setSelectionRange) {	   
       if(txtF.createTextRange){      
		var txtR = txtF.createTextRange();
		txtR.moveStart("character", pos.position);
		txtR.collapse();
		txtR.moveEnd("character", pos.selectionLength);
		txtR.select();			
	   }else{	  
		txtF.setSelectionRange(pos.position,(pos.position+pos.selectionLength)+1);							        		
	   }		  	   
	}	
	else if (typeof txtF.selectionStart != 'undefined') {	
		txtF.setSelectionRange(pos.position,pos.selectionLength);
	}		
	if (typeof scrollTop != "undefined" && typeof txtF.scrollTop != "undefined") {
		txtF.scrollTop = scrollTop;
	}			
}
function uCrtHP(txBox)
{
  var brwsr=navigator.appName;
	 if(brwsr == "Microsoft Internet Explorer")
	 {    
	   this.msSI = gCrt(txBox,true).position;
	   this.lstMC= gCrt(txBox,true).selectionLength;
 	 }
}
function inCrt(txtF, before, after, replace, select) {
	if (arguments.length < 3 || !after){
		 after = '';
	}
	if (arguments.length < 4 || !replace){
		 replace = false;
	}
	if(arguments.length < 5 || select){
		 select = true;
	}
	if (typeof txtF.selectionStart != 'undefined' && typeof txtF.selectionStart != 'number') {	  	    
		var startPos = txtF.selectionStart;
		var endPos = txtF.selectionEnd;
		txtF.value = txtF.value.substr(0, startPos) + before
						+ (replace ? "" : txtF.value.substring(startPos, endPos))
						+ after + txtF.value.substr(endPos);								               
		if (select) {
			txtF.setSelectionRange(startPos,
				(endPos + before.length + after.length - (replace ? (endPos-startPos) : 0)));
		} else {
			startPos = startPos + before.length + after.length;
			txtF.setSelectionRange(startPos , startPos);
		}	
	} else if (txtF.createTextRange || txtF.setSelectionRange) {	 	   		 
		var pos = this.gCrt(txtF);		          
		var range;
		 if(txtF.createTextRange){		
	    	range = document.selection.createRange();
        	range.text = after;					
			if (select) {							   			
				pos.selectionLength = replace ? (before.length + after.length) : (pos.selectionLength + before.length + after.length);				
			} else {
				pos.position += (before.length + after.length);
				pos.selectionLength = 0;
			}				
			this.sCrt(txtF, pos);						    	    	
	    }else{	    	  	   	 	      	       
   		    var data = this.bfrSpc.substring(0,(this.bfrSI)-1) + after + this.bfrSpc.substring(this.bfrSI-1) ;  	          	          	         	           	    
  	        txtF.value = data;  	        
	       if (select) {			    				   	   
			    pos.position = this.bfrSI-1;		
			    pos.selectionLength = after.length-1;				
			} else {			   			
				pos.position += (this.bfrSI-1);
				pos.selectionLength = 0;
			}				
	        this.sCrt(txtF,pos);
	    }	    			    
	}else{			 
		var position = txtF.value.length+before.length;				
		txtF.value += (before + after);		
		setCursorPosition(txtF, position);
	}			
}
function fxCrt(txtF, position) {
	var selectionLength = 0;
	this.sCrt(txtF, {position:position, selectionLength:selectionLength});
}
function lTrm (sString) {
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
	}
	return sString;
}
function rTrm(sString) {
	while (sString.substring(sString.length-1, sString.length) == ' ') {
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}
function shwSg(txBId,data)
{         
  srTxt = data;  
  ctxt = this.cxtP;
  try
  {
  	if(bObj != null)
  	{
  	  bObj.removeScriptTag();
  	  bObj = null;
  	}
  }
  catch(e){}   
  var url = this.srURL;
  url=url+"?data="+srTxt;
  url=url+"&rownum="+this.common.rownum;
  url=url+"&num="+this.common.noWrds;
  url=url+"&lang="+this.common.lngid;
  //url=url+"&output=json&callback=getGeo"; 
  try
  {
 	bObj = new WEBDscriptRequest(url);   
 	bObj.buildScriptTag(); 
	bObj.addScriptTag();
  	 tBxid = txBId;
  }catch(e){alert("ERROR : "+e);}    
} 
function getGeo(WEBDData) 
{ 
  if(tBxid!=null && tlpObj[tBxid]!=null){  	
    tlpObj[tBxid].gSData(WEBDData.ResultSet.Result[0].data,tBxid); 
    }  
/*  
    if(isIE()){ 
    bObj.removeScriptTag();
  	  bObj = null;    
   }
*/
}
function rDup(str){
 try{
 var strAy = str.split(",");
 var strUA = new Array();
 k=0;
 for(i =0;i<strAy.length;i++){
 flag = true;
  for(j=i+1;j<strAy.length;j++){
   if(strAy[i] == strAy[j]){    
    flag= false;
    break;
   }
  }
   if(flag)
      strUA[k++] = strAy[i];
 }
 str = "";
 for(i=0;i<strUA.length;i++){
  if(i<(strUA.length-1))
	  str += strUA[i]+",";
  else
     str += strUA[i];
 }
 }catch(e){}
 return str;
}
function gSData(str,txID)
{
  var rtData="";
 str = rDup(str);
 var strAy=str.split(",");  
 
 if(strAy.length > 0 && this.bfr.length != 0)
 {
    if(strAy[0] != "")
    {
       rtData = "<table class='suggestionClassWioc' style='height:100%'>";
		 for(this.index=0;this.index<strAy.length;this.index++)
		 {		 		  
		   if(this.index != strAy.length - 1)
		    {
		     var unicodeData = strAy[this.index];	
		     if(txID!=null && tlpObj[txID]!=null){ 
		      if(this.index == 0){	
		       rtData += "<tr valign='top'><td><div id='"+this.index+"_"+txID+"' onmouseover=\"tlpObj['"+txID+"'].sgOvr(this,'"+txID+"')\" onmouseout=\"tlpObj['"+txID+"'].sgOut(this)\" onClick=\"tlpObj['"+txID+"'].rplcTx(this.innerHTML,'"+txID+"')\" class='suggest_wioc_link'>" + unicodeData + "</div></td></tr>"; 
		           		   
		      }else{
		       rtData += "<tr valign='top'><td><div id='"+this.index+"_"+txID+"' onmouseover=\"tlpObj['"+txID+"'].sgOvr(this,'"+txID+"')\" onmouseout=\"tlpObj['"+txID+"'].sgOut(this)\" onClick=\"tlpObj['"+txID+"'].rplcTx(this.innerHTML,'"+txID+"')\" class='suggest_wioc_link'>" + unicodeData + "</div></td></tr>";            		   
		      }
		     }
		    }
		    else
		    {
		     this.tRec = parseInt(strAy[this.index]);
		    }	   	    		    
		 }
		this.common.maxNum = (strAy.length-2);  
		this.index = this.common.maxNum;		      		
		if(this.common.isAhBfr == true)
		{
		   if(txID!=null && tlpObj[txID]!=null){
		    rtData += "<tr valign='top'><td><div id='"+(++this.index)+"_"+txID+"' onmouseover=\"tlpObj['"+txID+"'].sgOvr(this,'"+txID+"')\" onmouseout=\"tlpObj['"+txID+"'].sgOut(this)\" onClick=\"tlpObj['"+txID+"'].rplcTx(this.innerHTML,'"+txID+"')\" class='suggest_wioc_link'>" + srTxt + "</div></td></tr>";            		    	    	    
		    ++this.common.maxNum;
		   }
	 	}    
	    if(this.common.isPNO == true)
	    {
	    	if(this.tRec > (this.common.rownum + this.common.noWrds))	    	    
	     	{  
	     	   if(txID!=null && tlpObj[txID]!=null){
	 	   	 	rtData += "<tr valign='top'><td><div id='"+(++this.index)+"_"+txID+"' onmouseover=\"tlpObj['"+txID+"'].sgOvr(this,'"+txID+"')\" onmouseout=\"tlpObj['"+txID+"'].sgOut(this)\" onClick=\"tlpObj['"+txID+"'].gMore('"+txID+"','>>')\" class='suggest_wioc_link'><img src='"+this.imgDir+"arrow1.gif' title='Next'></div></td></tr>";            		    	    	    
		    	++this.common.maxNum;
		    	}
			 }			 
			if(this.common.rownum > 0)	    	    
			 {
               if(txID!=null && tlpObj[txID]!=null){
			    rtData += "<tr valign='top'><td><div id='"+(++this.index)+"_"+txID+"' onmouseover=\"tlpObj['"+txID+"'].sgOvr(this,'"+txID+"')\" onmouseout=\"tlpObj['"+txID+"'].sgOut(this)\" onClick=\"tlpObj['"+txID+"'].gMore('"+txID+"','<<')\" class='suggest_wioc_link'><img src='"+this.imgDir+"arrow2.gif' title='Previous'></div></td></tr>";            		    	    	    
	  		    ++this.common.maxNum;
	  		    }
	  		 }
		 } 
		rtData += "</table>"; 		
  }else{ 
    if(txID!=null && tlpObj[txID]!=null){
       	rtData = "<table class='suggestionClassWioc' style='height:100%'>";
        rtData += "<tr valign='top'><td><div id='0_"+txID+"' onmouseover=\"tlpObj['"+txID+"'].sgOvr(this,'"+txID+"')\" onmouseout=\"tlpObj['"+txID+"'].sgOut(this)\" onClick=\"tlpObj['"+txID+"'].rplcTx(this.innerHTML,'"+txID+"')\" class='suggest_wioc_link'>" + srTxt + "</div></td></tr>";
	    rtData += "</table>"; 
	   if(!tlpObj[txID].hideSg && this.bfr.length != 0 )
	   {
     	   document.getElementById("tooltips_"+txID).innerHTML= rtData; 
	   }  
	   else
       {
  		 if(document.getElementById('tooltips_'+txID)!= null && document.getElementById('tooltips_'+txID).style.display != 'none')
  		  document.getElementById('tooltips_'+txID).innerHTML = "";
  	   }
     this.common.rownum = 0;
     }
   }
 }
 else
 { 
 if(txID!=null && tlpObj[txID]!=null){   
       	rtData = "<table class='suggestionClassWioc' style='height:100%'>";
        rtData += "<tr valign='top'><td><div id='0_"+txID+"' onmouseover=\"tlpObj['"+txID+"'].sgOvr(this,'"+txID+"')\" onmouseout=\"tlpObj['"+txID+"'].sgOut(this)\" onClick=\"tlpObj['"+txID+"'].rplcTx(this.innerHTML,'"+txID+"')\" class='suggest_wioc_link'>" + srTxt + "</div></td></tr>";
   	    rtData += "</table>"; 	
   	   
       if(!tlpObj[txID].hideSg && this.bfr.length != 0)
	   {
    	   document.getElementById("tooltips_"+txID).innerHTML= rtData; 
	   }
	   else
	   {
	     if(document.getElementById('tooltips_'+txID)!= null && document.getElementById('tooltips_'+txID).style.display != 'none')
	      document.getElementById('tooltips_'+txID).innerHTML = "";
       }
     this.common.rownum = 0;
   }  
     
  }  
   if(txID!=null && tlpObj[txID]!=null){  
   
	  if(!tlpObj[txID].hideSg && this.bfr.length != 0)
	  {
		 		 document.getElementById("tooltips_"+txID).innerHTML= rtData; 
	  }
	  else
	  {
	   if(document.getElementById('tooltips_'+txID)!= null && document.getElementById('tooltips_'+txID).style.display != 'none')
	    document.getElementById('tooltips_'+txID).innerHTML = "";
	   
	  } 
  } 
}
function gMore(txID,text)
{  
  if(text.indexOf("arrow1.gif"))
  {
   text = text.substring(text.indexOf("arrow1"),text.indexOf("arrow1")+6);
  }
  if(text == "arrow1" || text == "&gt;&gt;" || text == ">>")  
  {
     this.common.rownum = parseInt(this.common.rownum) + parseInt(this.common.noWrds);
  }
  else
  {  
   this.common.rownum = parseInt(this.common.rownum) - parseInt(this.common.noWrds);  
   if(this.common.rownum < 0)
   		 this.common.rownum = 0;     		 
  }  
  if(txID!=null && tlpObj[txID]!=null){ 
  tlpObj[txID].hideSg=false;
  tlpObj[txID].shwSg(txID,srTxt);    
  }
}
function sgOvr(div_v,txID) 
{       
    if(this.common.maxNum > 0 && div_v.id.charAt(0) != "0")
        document.getElementById('0_'+txID).className = 'suggest_wioc_link';
        
    div_v.className = 'suggest_wioc_link_over';
}
function sgOut(div_v) 
{
    div_v.className = 'suggest_wioc_link';
}
function storBf(code)
{
 this.egWrd = code; 
}
function srchDb(txBox,keyP)
{
  var code;
  var data;  
  if (isIE)
  {
//	 code =  keyP.keyCode;
//	 if (document.getSelection) data = document.getSelection();
//	 else if (document.selection) data = document.selection.createRange().text;	 		
//	 sIndx = gCrt(txBox,true).position;
//	 eIndx = gCrt(txBox,true).selectionLength;
//     var crtPos = document.selection.createRange();
//   	var db = 0, da = 0;	
//		if ((document.documentElement) && (document.documentElement.scrollTop)) 
//		{
//			db = crtPos.offsetLeft + document.documentElement.scrollLeft;
//			da = crtPos.offsetTop + document.documentElement.scrollTop;
//		}
//		else if (document.body) 
//		{
//			db = crtPos.offsetLeft + document.body.scrollLeft;
//			da = crtPos.offsetTop + document.body.scrollTop;
//		}
//	    var flag = false;
//	    for (var o = txBox; o ; o = o.offsetParent) 
//		{							          				        		      		 
//		        if(o.id == "wdHeader" || o.id == "searchTextBox")
//		        {
//		         flag=true;
//		         break;
//				}
//		}        
//		if(flag)
//		{
//		    for (var o = txBox; o ; o = o.offsetParent) 
//			{							          				        		      		 
//		        if(o.id != "" &&  o.id != 'TEXTAREA_'+txBox.id)
//		        {
//		     		db -= (o.offsetLeft+o.scrollLeft);		     
//		     		da -= (o.offsetTop+o.scrollTop);		     		     
//		     	}
//			}	        	         	         
//		}
//		if (document.all) 
//		{
//			this.left = db;
//			this.top = da;
//		}					  	   					
  }
  else
  {	
	code =  keyP.which;	
	sIndx = txBox.selectionStart;
	eIndx = txBox.selectionEnd;
	data = txBox.value;
	data = data.substring(sIndx,eIndx);	
		var x2 = document.body.scrollTop;	
        var y2 = document.body.scrollLeft;   	        
	  	if (! txBox.createTextRange || txBox.type != 'textarea') 
		{
		 for (var o = txBox; o ; o = o.offsetParent) 
	     {	 	    	      
	       if(o.id != "body" && o.id != "wdHeader" && o.id != "searchTextBox")
	       {	    	        
	      	x2 += (o.offsetLeft - o.scrollLeft);		      
      		y2 += (o.offsetTop - o.scrollTop);		      
       	   }
	     }
	   }
	    var txtF = txBox;
	    var taClone_ = document.createElement('pre');
	    clonEl(txtF, taClone_);
	    txtF.offsetParent.appendChild(taClone_);
	    ImeStartPos_ = txtF.selectionStart;      
	    var value = txtF.value.replace(/\r\n/g, '\n\r') + ' ';
	    var crtPos = document.createElement('span');
	    crtPos.innerHTML = '|';
	    taClone_.innerHTML = '';
	    taClone_.appendChild(document.createTextNode(value.substr(0,ImeStartPos_)));
	    taClone_.appendChild(crtPos);
	    taClone_.appendChild(document.createTextNode(value.substr(ImeStartPos_)));
    	this.top = y2 + (crtPos.offsetTop - taClone_.offsetTop);
	    this.left = x2 + (crtPos.offsetLeft - taClone_.offsetLeft);
	    txtF.offsetParent.removeChild(taClone_);    
	    if(this.left > (x2+txBox.clientWidth))
	      this.left = (x2+txBox.clientWidth);
	    if(this.top > (y2+txBox.clientHeight))
	        this.top = (y2 + txBox.clientHeight);

	   
  }
  this.left = this.left + 11; //+ (data.length * 5);
  this.top = this.top + 15;
  if(this.common.trim(this.egWrd) != "" && this.egWrd.length > 0 && code != 9 && code != 32 && code != 13 && code != 8 && code != 46 && code != 37 && code != 38 && code != 39 && code != 40)
  {
  	   document.getElementById('tooltips_'+txBox.id).style.left = this.left+"px";
	   document.getElementById('tooltips_'+txBox.id).style.top = this.top+"px";	  	
	   if(txBox.id!=null && tlpObj[txBox.id]!=null){    
	     tlpObj[txBox.id].shwSg(txBox.id,this.egWrd);
	    } 
   }
   else
   {
     document.getElementById('tooltips_'+txBox.id).innerHTML = "";
     this.common.rownum = 0;
   }
}
function rplcTx(rlpDt,txBox)
{
  if(isIE)
  {  
    var pos = gCrt(document.getElementById(txBox));        
    pos.position = sIndx;
    pos.selectionLength = eIndx;
    sCrt(document.getElementById(txBox),pos);
    var range = document.selection.createRange();
    range.text = rlpDt;
    pos.position = sIndx + rlpDt.length;
    pos.selectionLength = 0;
    sCrt(document.getElementById(txBox),pos);    	
  }
  else
  {	          
   if(sIndx == 0)
    {
     document.getElementById(txBox).value = rlpDt + document.getElementById(txBox).value.substring(eIndx,document.getElementById(txBox).value.length);	 
    }
    else
    {     
	 document.getElementById(txBox).value = document.getElementById(txBox).value.substring(0,sIndx) + rlpDt + document.getElementById(txBox).value.substring(eIndx,document.getElementById(txBox).value.length);	 
	}	  
  }     
 document.getElementById('tooltips_'+txBox).innerHTML = "";   
 this.common.rownum = 0;  


 if (isIE)
 {    
   setCaret_IE(document.getElementById(txBox),(sIndx+rlpDt.length));
 }
 else
 {
  document.getElementById(txBox).setSelectionRange((sIndx+rlpDt.length),(sIndx+rlpDt.length));
  sIndx = document.getElementById(txBox).selectionStart;	
  eIndx = document.getElementById(txBox).selectionEnd;
 }
}
function uCrtPos(txBox)
{
	 if(isIE)
	 {    
	  sIndx = gCrt(txBox,true).position;	 
	  eIndx = gCrt(txBox,true).selectionLength;
 	 }
}
function clonEl(elOr, elCln) 
{
  elCln.style.left = elOr.offsetLeft + 'px';
  elCln.style.top = (elOr.offsetTop + elOr.offsetHeight + 30) + 'px';
  elCln.style.width = elOr.offsetWidth+"px";
  elCln.style.height = elOr.offsetHeight+"px";
  elCln.scrollLeft = elOr.scrollLeft+"px";
  elCln.scrollTop = elOr.scrollTop+"px";    
}
function setCaret_IE(txtF,pos) 
{ 
      try{
		var txtR = txtF.createTextRange();
		txtR.moveStart("character", pos);
		txtR.collapse();
		txtR.moveEnd("character", 0);
		txtR.select();				 
	 }
	 catch(e)
	 {}		
}
function WEBDscriptRequest(fullUrl){
this.fullUrl=fullUrl;
this.noCacheIE='&noCacheIE='+(new Date()).getTime();
this.headLoc=document.getElementsByTagName("head").item(0);
this.scriptId='JscriptId'+WEBDscriptRequest.scriptCounter++;
this.scriptObj;
};
WEBDscriptRequest.scriptCounter=1;
WEBDscriptRequest.prototype.buildScriptTag=function(){
this.scriptObj=document.createElement("script");
this.scriptObj.setAttribute("type","text/javascript");
this.scriptObj.setAttribute("charset","utf-8");
this.scriptObj.setAttribute("src",this.fullUrl/*+this.noCacheIE*/);
this.scriptObj.setAttribute("id",this.scriptId);};
WEBDscriptRequest.prototype.removeScriptTag=function()
{this.headLoc.removeChild(this.scriptObj);};
WEBDscriptRequest.prototype.addScriptTag=function(){this.headLoc.appendChild(this.scriptObj);}

