var wObj = new Array();
var wUIObj = new Array();
function WEBDWIOCLITE()
{  
  this.ctxpth = "";
  this.key = ""; 
  this.rows = "1";
  this.cols = "1"; 
  this.divid = "";  
  this.ctlid = ""; 
  this.ctltp = "P"; 
  this.wopt= "M"
  this.lngid = 'HI'; 
  this.plen = '6';  
  this.istb = '1'; 
  this.isdic = '1'; 
  this.isbeta = '1';
  
 this.ishelpon = '1'; 
 this.kbtyp = '0'; 
 this.isdIc = '1'; 
 this.ishelp = '1'; 
 this.iskb = '1';  
 this.isegL = '1'; 
 this.ermsg = "";
 this.isegT ='0';
 this.generateControlWEBD = generateControlWEBD;
 this.drwC = drwC;
 this.sEI = sEI;
 this.sKbI = sKbI;
 this.sHI = sHI;
 this.sDicI = sDicI;
 this.sBI = sBI;
 this.sKbTyp = sKbTyp;
 this.sSbOn = sSbOn;
 this.sHpOn = sHpOn ;
 this.sDcOn = sDcOn;
 this.sTbEn = sTbEn;
 this.sPdLen = sPdLen;
 this.sNoSg = sNoSg;
 this.sEgTOn = sEgTOn;
 this.sCtlW = sCtlW;
 this.sCol = sCol;
 this.sRow = sRow;    
 this.popC = popC;
 this.sCtx=sCtx;
}
function generateControlWEBD(rows, cols, divid, id, num, lngid, wopt, MaxLength, Width, Class, Readonly, Level)
{
 wObj[id] = this; 
 this.rows = rows;
 this.cols = cols;
 this.divid = divid;
 this.ctlid = id;
 this.plen = num;
 this.lngid = lngid;
 this.wopt = wopt;
 
// try
//   {
//       
//        _wiocliteControlSetProperties(this);
//   }
//   catch(e)
//   {
       this.drwC(MaxLength, Width, Class, Readonly, document.getElementById(id).value, Level);
   //}
}

function getControl(WEBDData)
{  
 var string = WEBDData.ResultSet.Result[0].data; 
 var sArr = string.split("~");
 if(sArr.length > 10)
 {
  id = sArr[10];
 }
 wObj[id].popC(string);
}

function popC(string)
{ 
 var sArr = string.split("~");
 if(sArr.length > 1)
 {
  if(sArr[0] == "1")
  {     
   this.lngid = sArr[1];
   this.ctltp = sArr[2];
   this.wopt = sArr[3];
   this.version = sArr[4];
   this.rows = sArr[5];
   this.cols = sArr[6];
   this.ctxpth = sArr[7];
   this.divid = sArr[9];
   this.ctlid = sArr[10];
   this.plen = sArr[11];            
   
   try
   {
    _wiocliteControlSetProperties(this);
   }
   catch(e)
   {
    this.drwC();
   }
  }
  else
  {
    document.getElementById(sArr[2]).innerHTML = sArr[1];
    this.ermsg = sArr[1];
  }
 }
}

function drwC(MaxLength, Width, Class, Readonly, txtval, Level)
{
 if(this.ermsg == "")
 {
   if(this.kbtyp == "0")
   {
    this.kbtyp = "PH";
   }
   else if(this.kbtyp == "1")
   {
    this.kbtyp = "IN";
   }         
   var HTMLCode ="";

   HTMLCode += "<div align='left' id='loading_"+this.ctlid+"' STYLE='position:relative;'></div>";
   
   HTMLCode += "<div align='left' id='tooltips_"+this.ctlid+"' STYLE='position:absolute;left:170px;top:130px;color:black;z-index:2000' class='tooltips_wioc'></div>";  
   
   if(this.istb == "1")
   {
	   HTMLCode += "<div align='left' id='toolbar_"+this.ctlid+"' STYLE='align:left;position:relative;color:black;display:none;'></div>";      
   }
   
   HTMLCode += "<div align='left' id ='textarea1_"+this.ctlid+"'></div>";  
    
   HTMLCode +="<div id ='help_"+this.ctlid+"' STYLE='align:center;display:none;position:static;'></div>"; 
   
    document.getElementById(this.divid).innerHTML = HTMLCode;

    var webd = new WCtrlUI();  
   wUIObj[this.ctlid]= webd;
   webd.ChLng(this.rows, this.cols, this.ctlid, this.wopt, this.kbtyp, this.plen, this.istb, this.isdic, this.ishelpon, this.ctxpth, this.lngid, this.isdIc, this.ishelp, this.iskb, this.isegL, this.isegT, MaxLength, Width, Class, Readonly, txtval, Level);
      document.getElementById("help_"+this.ctlid).style.width = webd.tbWd+"px";  
  
       
   try
   {
       	_wiocliteControlLoaded(this.ctlid);
   }
   catch(e){}         
 }
 else
 {
  alert("Error: "+this.ermsg);
 }
}
function sRow(row)
{
 this.rows = sRow
}

function sCol(col)
{
 this.cols = col;
}

function sCtlW(wrap)
{
 this.wopt = wrap;
}
  

function sNoSg(length)
{
 this.plen = length;  
}  

function sPdLen(length)
{
 this.plen = length;  
}

function sTbEn(flag)
{
 if(flag)
 {
  this.istb = '1'; 
 }
 else
 {
  this.istb = '0'; 
 }
}  
  
function sDcOn(flag)
{
 if(flag)
 {
  this.isdic = '1'; 
 }
 else
 {
  this.isdic = '0'; 
 }
}
 
function sHpOn(flag)
{
 if(flag)
 {
  this.ishelpon = '1'; 
 }
 else
 {
  this.ishelpon = '0'; 
 }
} 
  
function sSbOn(flag)
{
}
  
function sKbTyp(keyboard)
{
 this.kbtyp = keyboard; 
}

function sBI(flag)
{
} 
  
function sDicI(flag)
{
 if(flag)
 {
  this.isdIc = '1'; 
 }
 else
 {
  this.isdIc = '0'; 
 }
}
  
function sHI(flag)
{
 if(flag)
 {
  this.ishelp = '1'; 
 }
 else
 {
 this.ishelp = '0'; 
 }
}
  
function sKbI(flag)
{
 if(flag)
 {
  this.iskb = '1';  
 }
 else
 {
  this.iskb = '0';  
 }
}  

function sEI(flag)
{
 if(flag)
 {
  this.isegL = '1'; 
 }
 else
 {
  this.isegL = '0'; 
 }
}    

function sEgTOn(flag)
{

 if(flag)
 {
  this.isegT = '1'; 
 }
 else
 {
  this.isegT = '0'; 
 }
}  

function sCtx(ctx)
{
this.ctxpth=ctx;
}

function setBetaImageAvailable(flag)
{
 if(flag)
 {
  this.isbeta = '1'; 
 }
 else
 {
  this.isbeta = '0'; 
 }
} 

function hideSuggestions(id)
{
 if(document.getElementById('tooltips_'+id)!= null && document.getElementById('tooltips_'+id).style.display != 'none')
   document.getElementById('tooltips_'+id).innerHTML = "";
} 

function toggleLanguage(ctlid)
{ 
 try{
    if(wUIObj[ctlid].isEn){
	 wUIObj[ctlid].selLng(wUIObj[ctlid].lang);	
	 if(wObj[ctlid].isdic == '1'){
	  wUIObj[ctlid].selDc(wUIObj[ctlid].lang);
	  }
	 return true;
	}else{
	 wUIObj[ctlid].selLng('EN');
	 return false;
	}
 }catch(e){
 	alert("Error: toggleLanguage method Reason "+e);
 }
}

