﻿var l_basicObject = null;
var l_dataChanged = null;
var l_flagOK = false;
var l_flagDeletingTableQuoteRows = false;
var l_flagStartRequestAgain = false;
// nhung doi tuong chung khoan hay thay doi - HNX - UPCOM
var l_arrayCellChanged = new Array();
var l_arrayCellBasicObjectValue = new Array();
var l_arrayCellChangedClearColor = new Array();
//-------
var l_arrayCellMarketChanged = new Array();
var l_arrayCellMarketChangedClearColor = new Array();
//------------------------------------------
var l_flagClearBackGroundColor;
var l_flagDisplayUpdateData;
//-------
var l_flagUpdateMarketHeaderData;
var l_flagDisplayUpdateMarketData;
var l_flagClearBackGroundColorOfMarketData;
var l_flagIntervalGetPutThroughObject;
var l_flagTimeOutDisplayObjBasicData;
//------------------------------------------
var l_timeServerHour = 0;
var l_timeServerMinute = 0;
var l_timeServerSecond = 0;
//------------------------------------------
var l_objTdTime;
var l_objTdIndex;
var l_objTdChange;
var l_objTdGainersLosers;
var l_objTdTotalMarketVolume;
var l_objTdTotalValue;
var l_objTdTotalMarketVolumePt;
var l_objTdTotalValuePt;
var l_objTdMarketStatus;
var l_objClientID = 0;
var l_objTablePutThrough;
//==============================================
var l_flagRowCreating = false; //aO
var l_flagShowVolumeColor = true;
var l_objHighlightRow = null;
var l_StartRequestTimeOutID = null; //as
var l_ClearBgColorTimeOutID = null; //aN
var l_headerRowCount = 2;
//-------------------------------------------
var l_flagShowPannelOption = false; //aL
var l_flagShowBuyVolume = false; //aB
var l_flagShowSellVolume = false; //aF
var l_flagShowMatchVolume = false; //aF
var l_flagShowBuyOrderCount = false; //aH
var l_flagShowSellOrderCount = false;//aE
var l_flagShowForeignBuy = false; //at
var l_flagShowForeignSell = false; //aG
var l_flagShowCurrentRoom = false; //aw
var l_flagShowHighestPrice = false;
var l_flagShowLowestPrice = false;
var l_flagShowAvrPrice = false;
var l_flagShowSumActionQuantity = false;
//-------------------------------------------
var l_SelectOnPnlOption = "all" //bQ
var l_TypeStockBoard = 0;//cR
var l_scrollInterval = 30; //aJ
var l_lineCount = 20; //aC
var l_waitingTime = 10000; //cc
var l_flagShowSymbolSelectedOnTop = true;//

var screenWidth = "1000"; //ay
var extraColumnString = "0000000"; //bp
var TypeOfCookieName = "HNX_UPCOM"

var l_numberColumnTableQuote = 24; //bY
var l_flagCreateExtraHeaderCells; //aR
var l_SetScrollIntervalID; //bT
var l_WaitingScrollTimeOut; //aT
var l_RowIndexScroll = 1; //aP
var l_divScroll;
var l_flagShowPutThrough = false; //aQ
var l_flagDishplayFloatingHeader = false;//aM
var l_rowID = null; //cp

var l_arraySymbolChecked; //bq
var selectedSymbolList = new Array();
var unselectedSymbolList = new Array();
var oldUnselectedSymbolList;

var l_NumberRowChecked = null; //bu
var l_floatingHeader; 
var latestTime = new Date();
var typedString = "";
//=====================================================================================
// Tao lop Basic Cell
function cls_BasicCellInfo()
{   
   this.cell = null;
   this.data = 0;
   this.className = "";          
};
function cls_CellInfo()
{     
   this.cell = null;   
   this.data = 0;   
   this.dataRealOutOfPicture = 0;
   this.classNameNormal = "";
   this.stockSymbol = ""; //0 - default - 1 - tran - 2 - san - 3 - tham chieu
   this.isPrice = true;   
   this.isSpecial = true;
   this.time = "";  
   this.flagUpDownPicture = false;
   this.typeUpDown = 0; //0 - normal - 1 down - 2 up - 3 cellCeiling - 4 - cellFloor 5 - cellRef;   
   this.EvenOdd = 0; //0 -- Even, 1 -- Odd
};
function cls_basicItemInfo()
{
    this.CeilingPrice = 0;
    this.FloorPrice = 0;
    this.ReferencePrice = 0;
    this.RowIndex = 0;
}
var l_formatWebsiteWords = new clsStockLanguages(); 
//=========================== het = khai = bao ==============================================
function clsStockLanguages()
{
}
function Start()
{   
  StockBoard.Service.StockBoardService.set_defaultUserContext("Default context"); 
  StockBoard.Service.StockBoardService.set_defaultSucceededCallback(OnRequestComplete); 
  StockBoard.Service.StockBoardService.set_defaultFailedCallback(FailedCallback);      
  Initialize();      
  LoadCommon();
}



function FailedCallback(error, userContext, methodName)
{
    window.location.reload(true);
};

function OnRequestComplete(result, userContext, methodName)
{   	
    switch(methodName)
    {
        case "GetStockBoardBasicOject":                
                l_basicObject = eval('(' + result + ')');
                if (l_basicObject != null)
                {                
                    CreateBasicRows(true); 
                }
            break; 
        case "GetPutThroughObject":
            DeletePutThroughTable(l_objTablePutThrough);            
            var v_dataList = eval('(' + result + ')');
            if (v_dataList == null) return;
            if(v_dataList.Items == null) return;                        
            UpdatePutThroughTable(l_objTablePutThrough, v_dataList.Items);            
            break;               
        case "GetChangedObjectCompare":                            
                    l_dataChanged = eval('(' + result + ')');   
                    if (l_dataChanged==null)
                    {            
                        if (l_StartRequestTimeOutID == null)
                        l_StartRequestTimeOutID = self.setTimeout("StartRequest()", l_timeout_requestData); 
                    }
                    else
                    {
                        l_objClientID = l_dataChanged.ClientID;                                         
                        
                        BeginUpdate();              
                        
                        var v_timeServer = l_dataChanged.Time.split(":");  
                        var v_now = new Date();
                        l_timeServerHour = v_timeServer[0] - v_now.getHours(); 
                        l_timeServerMinute  = v_timeServer[1] - v_now.getMinutes();
                        l_timeServerSecond  = v_timeServer[2] - v_now.getSeconds();
                    }                    
            break;            
    }
}

function SetTime()
{
    var v_now = new Date();
    var v_Hour = v_now.getHours() + l_timeServerHour;
    var v_Minute = v_now.getMinutes() + l_timeServerMinute;
    var v_Second = v_now.getSeconds() + l_timeServerSecond;
    v_now = new Date();
    v_now.setHours(v_Hour, v_Minute, v_Second, 0);   
    v_Hour = v_now.getHours();
    v_Minute = v_now.getMinutes();
    v_Second = v_now.getSeconds(); 
    if (v_Hour < 10) v_Hour = "0" + v_Hour; 
    if (v_Minute < 10) v_Minute = "0" + v_Minute;
    if (v_Second < 10) v_Second = "0" + v_Second;
    l_objTdTime.innerHTML =  v_Hour + ":" + v_Minute + ":" + v_Second; 
}

 //************************************************************************************************************************************************************************
//
//  Hàm xet lai client info va yêu cầu dữ liệu
//
//************************************************************************************************************************************************************************
function SetClientInfoAndGetData()
{
   if(l_StartRequestTimeOutID != null)
   {
          clearTimeout(l_StartRequestTimeOutID);
          l_StartRequestTimeOutID = null;        
   }        
   l_flagOK = false;
   l_objClientID = 0;             
   StockBoard.Service.StockBoardService.GetChangedObjectCompare(l_objClientID);
}


//************************************************************************************************************************************************************************
//
//  Hàm yêu cầu dữ liệu
//
//************************************************************************************************************************************************************************
function StartRequest()
{  
   if(l_StartRequestTimeOutID != null)
   {
          clearTimeout(l_StartRequestTimeOutID);
          l_StartRequestTimeOutID = null;        
   }        
   StockBoard.Service.StockBoardService.GetChangedObjectCompare(l_objClientID);
};

function deleteAllRowInTable(mytable)
{  
   for(var i= mytable.rows.length - 1; i > -1; i--)
   {   
       if (i>=2) 
        mytable.deleteRow(i);
   }
   l_flagDeletingTableQuoteRows = false;
}

function CreateBasicRows(pflagStartRequest)
{   
   l_flagRowCreating = true;    
   
   if (l_flagOK==true)  
   {          
       SetClientInfoAndGetData();
   }
   else if (pflagStartRequest==true)
   {
       StartRequest();     
   }   
   
   var v_tableQuote;           
   v_tableQuote = document.getElementById("tableQuote");      
   
   deleteAllRowInTable(v_tableQuote);            
   
   var v_basicItem;
   var v_arrayValue;
   var v_newRow;
   var v_newCell;   
   var v_fontstyle;   
   var v_fontstyle1;   
   var v_cellBasicInfo;       
   var v_iRun = 0;              
   v_fontstyle = "normal";
   v_fontstyle1 = "bold";    
   if(l_basicObject == null || l_basicObject.Items == null)
   return;      
   
   l_arraySymbolChecked = selectedSymbolList;
   oldUnselectedSymbolList = unselectedSymbolList;
   selectedSymbolList = new Array();
   unselectedSymbolList = new Array();
   
   l_arrayCellBasicObjectValue = new Array();       
   l_NumberRowChecked = 0;           
   for(var itemKey in l_basicObject.Items)
   {        
      //-------------------------------------
      unselectedSymbolList.push(itemKey);       
      v_basicItem = l_basicObject.Items[itemKey];
      v_arrayValue = v_basicItem.V.split(";");
      if (v_iRun == 0)
      {
          v_newRow = v_tableQuote.insertRow( - 1);
          v_newRow.style.height = "21px";
          v_newRow.id = "tr" + itemKey;
          
          //v_newRow.onmouseover = OnMouseOverQuote;
          //v_newRow.onmouseout = OnMouseOutQuote;
          //========================================================================================
          //Create newcell      
          
          v_newCell = v_newRow.insertCell( - 1);
          v_newCell.className = "cellCode";
          if(l_TypeStockBoard == 0)
          {
            v_newCell.innerHTML = "<input value=\""+ v_iRun +"\" type=\"checkbox\" id=\"chk"+itemKey+"\" onClick=\"OnRowChecked('"+itemKey+"'); \"/>" + itemKey;
          }
          else
          {         
            v_newCell.innerHTML = "<input value=\""+ v_iRun +"\" type=\"hidden\" id=\"chk"+itemKey+"\" />" + itemKey;
          } 
          v_newCell.style.width = "4.5%";
          v_newCell.style.backgroundColor = backColorSymbol;
          v_newCell.style.fontWeight = v_fontstyle1;
          //======================================
          v_newCell = v_newRow.insertCell( - 1);      
          v_newCell.style.width = "3%";
          v_newCell.innerHTML =  v_arrayValue[0];
          v_newCell.className = "cellCeiling"
          v_newCell.style.backgroundColor = backColor2;
          v_newCell.style.fontWeight = v_fontstyle1;                                 
          //======================================
          v_newCell = v_newRow.insertCell( - 1);
          v_newCell.style.width = "3%";
          v_newCell.innerHTML =  v_arrayValue[1];
          v_newCell.className = "cellFloor"
          v_newCell.style.backgroundColor = backColor2;
          v_newCell.style.fontWeight = v_fontstyle1;                  
          //======================================
          v_newCell = v_newRow.insertCell( - 1);            
          v_newCell.style.width = "3%";
          v_newCell.innerHTML =  v_arrayValue[2];
          v_newCell.className = "cellRef"
          v_newCell.style.backgroundColor = backColor2;
          v_newCell.style.fontWeight = v_fontstyle1;                             
          //====================================== Gia 3
          v_newCell = v_newRow.insertCell( - 1);
          v_newCell.className = "normalPrice";      
          v_newCell.style.width = "3.0%";
          v_newCell.style.backgroundColor = backColor1;
          v_newCell.style.fontWeight = v_fontstyle;
          //====================================== KL3
          v_newCell = v_newRow.insertCell( - 1);
          v_newCell.className = "normalVol";      
          v_newCell.style.width = "3.5%";
          v_newCell.style.backgroundColor = backColorVolume1;
          v_newCell.style.fontWeight = v_fontstyle;
          //====================================== Gia 2
          v_newCell = v_newRow.insertCell( - 1);
          v_newCell.className = "normalPrice";      
          v_newCell.style.width = "3.0%";
          v_newCell.style.backgroundColor = backColor1;
          v_newCell.style.fontWeight = v_fontstyle;
          //====================================== KL2
          v_newCell = v_newRow.insertCell( - 1);
          v_newCell.className = "normalVol";      
          v_newCell.style.width = "3.5%";
          v_newCell.style.backgroundColor = backColorVolume1;
          v_newCell.style.fontWeight = v_fontstyle;
          //====================================== Gia 1
          v_newCell = v_newRow.insertCell( - 1);
          v_newCell.className = "normalPrice";      
          v_newCell.style.width = "3.0%";
          v_newCell.style.backgroundColor = backColor1;
          v_newCell.style.fontWeight = v_fontstyle;
          //====================================== KL1
          v_newCell = v_newRow.insertCell( - 1);
          v_newCell.className = "normalVol";      
          v_newCell.style.width = "3.5%";
          v_newCell.style.backgroundColor = backColorVolume1;
          v_newCell.style.fontWeight = v_fontstyle;
          //====================================== Gia khop lenh
          v_newCell = v_newRow.insertCell( - 1);
          v_newCell.className = "normalMatchingPrice";      
          v_newCell.style.width = "4.5%";
          v_newCell.style.backgroundColor = backColor1Alt;
          v_newCell.style.fontWeight = v_fontstyle;
          //====================================== KL khop lenh
          v_newCell = v_newRow.insertCell( - 1);
          v_newCell.className = "normalMatchingVol";      
          v_newCell.style.width = "3.5%";
          v_newCell.style.backgroundColor = backColorVolume1Alt;
          v_newCell.style.fontWeight = v_fontstyle;       
          //====================================== // +/- TC
          v_newCell = v_newRow.insertCell( - 1);
          v_newCell.className = "normalChange";      
          v_newCell.style.backgroundColor = backColor1Alt;
          v_newCell.style.width = "4.0%";          
          //======================================  // du ban gia 1
          v_newCell = v_newRow.insertCell( - 1);
          v_newCell.className = "normalPrice";      
          v_newCell.style.width = "3.0%";
          v_newCell.style.backgroundColor = backColor1;
          v_newCell.style.fontWeight = v_fontstyle;
          //====================================== //du ban kl1
          v_newCell = v_newRow.insertCell( - 1);
          v_newCell.className = "normalVol";      
          v_newCell.style.width = "3.5%";
          v_newCell.style.backgroundColor = backColorVolume1;
          v_newCell.style.fontWeight = v_fontstyle; 
          //======================================  //du ban gia 2
          v_newCell = v_newRow.insertCell( - 1);
          v_newCell.className = "normalPrice";      
          v_newCell.style.width = "3.0%";
          v_newCell.style.backgroundColor = backColor1;
          v_newCell.style.fontWeight = v_fontstyle;
          //====================================== //du ban kl 2
          v_newCell = v_newRow.insertCell( - 1);
          v_newCell.className = "normalVol";      
          v_newCell.style.width = "3.5%";
          v_newCell.style.backgroundColor = backColorVolume1;
          v_newCell.style.fontWeight = v_fontstyle;
          //====================================== // du ban gia 3
          v_newCell = v_newRow.insertCell( - 1);
          v_newCell.className = "normalPrice";      
          v_newCell.style.width = "3.0%";
          v_newCell.style.backgroundColor = backColor1;
          v_newCell.style.fontWeight = v_fontstyle;
          //====================================== // db kl 3
          v_newCell = v_newRow.insertCell( - 1);
          v_newCell.className = "normalVol";      
          v_newCell.style.width = "3.5%";
          v_newCell.style.backgroundColor = backColorVolume1;
          v_newCell.style.fontWeight = v_fontstyle;
          //====================================== //gia cao nhat
          if (l_flagShowHighestPrice == true)
          {
              v_newCell = v_newRow.insertCell( - 1);
              v_newCell.className = "normalHighLowPrice";      
              v_newCell.style.width = "3.8%";
              v_newCell.style.backgroundColor = backColor1Alt;
              v_newCell.style.fontWeight = v_fontstyle;
          }
          //====================================== //gia thap nhat
          if (l_flagShowLowestPrice == true)
          {
              v_newCell = v_newRow.insertCell( - 1);
              v_newCell.className = "normalHighLowPrice";      
              v_newCell.style.width = "3.8%";
              v_newCell.style.backgroundColor = backColor1Alt;
              v_newCell.style.fontWeight = v_fontstyle;
          }                
          //======================================= 
          //KL mua
          if(l_flagShowBuyVolume  == true)
          {
             v_newCell = v_newRow.insertCell( - 1);
             v_newCell.className = "normalVol";
             v_newCell.style.width = "3.8%";
             v_newCell.style.backgroundColor = backColorVolume1;
             v_newCell.style.fontWeight = v_fontstyle;
          }
          //KL bán
          if(l_flagShowSellVolume == true)
          {
             v_newCell = v_newRow.insertCell( - 1);
             v_newCell.className = "normalVol";
             v_newCell.style.width = "3.8%";
             v_newCell.style.backgroundColor = backColorVolume1;
             v_newCell.style.fontWeight = v_fontstyle;
          }     
          //KL Khop
          if(l_flagShowMatchVolume == true)
          {
             v_newCell = v_newRow.insertCell( - 1);
             v_newCell.className = "normalVol";
             v_newCell.style.width = "3.8%";
             v_newCell.style.backgroundColor = backColorVolume1;
             v_newCell.style.fontWeight = v_fontstyle;
          }     
          // NN mua
          if(l_flagShowForeignBuy == true)
          {
             v_newCell = v_newRow.insertCell( - 1);
             v_newCell.className = "normalVol";
             v_newCell.style.width = "3.8%";
             v_newCell.style.backgroundColor = backColorVolume1Alt;
             v_newCell.style.fontWeight = v_fontstyle;
          }
          // NN bán
          if(l_flagShowForeignSell == true)
          {
             v_newCell = v_newRow.insertCell( - 1);
             v_newCell.className = "normalVol";
             v_newCell.style.width = "3.8%";
             v_newCell.style.backgroundColor = backColorVolume1Alt;
             v_newCell.style.fontWeight = v_fontstyle;
          } 
          v_newCell = v_newRow.insertCell( - 1);
          v_newCell.className = "cellCodeRight";
          v_newCell.innerHTML = itemKey;
          v_newCell.style.width = "3%";
          v_newCell.style.backgroundColor = backColorSymbol;
          v_newCell.style.fontWeight = v_fontstyle1;          
      }
      else 
      {    
            if (v_iRun == 1)
            {
                //hang le
                v_newRow = v_tableQuote.rows[2].cloneNode(true);
                v_tableQuote.rows[2].parentNode.appendChild(v_newRow);
                UpdateOddRowBackColor(v_newRow);                 
            }
            else if (v_iRun % 2 == 0)
            {
                //hang chan
                v_newRow = v_tableQuote.rows[2].cloneNode(true);
                v_tableQuote.rows[2].parentNode.appendChild(v_newRow);                        
            } 
            else 
            {
                //hang le
                v_newRow = v_tableQuote.rows[3].cloneNode(true);
                v_tableQuote.rows[3].parentNode.appendChild(v_newRow);                 
            }                
            v_newRow.id = "tr" + itemKey 
            if(l_TypeStockBoard == 0)
            {
                v_newRow.cells[0].innerHTML = "<input value=\""+ v_iRun +"\" type=\"checkbox\" id=\"chk"+itemKey+"\" onClick=\"OnRowChecked('"+itemKey+"'); \"/>" + itemKey;
            }
            else
            {         
                v_newRow.cells[0].innerHTML = "<input value=\""+ v_iRun +"\" type=\"hidden\" id=\"chk"+itemKey+"\" />" + itemKey;
            }                    
            v_newRow.cells[1].innerHTML = v_arrayValue[0];
            v_newRow.cells[2].innerHTML = v_arrayValue[1];
            v_newRow.cells[3].innerHTML = v_arrayValue[2]; 
            v_newRow.cells[v_newRow.cells.length - 1].innerHTML =  itemKey;
        }                
        //tang bo dem  
        v_iRun = v_iRun + 1;
   }         
   //===========================================       
   l_flagRowCreating = false;     
   FinishCreateBasicRows(); 
   
};

function FinishCreateBasicRows()
{   
   if(l_TypeStockBoard == 0)
   {
      var v_symbol;
      for(var i = 0; i < l_arraySymbolChecked.length; i ++ )
      {
         v_symbol = l_arraySymbolChecked[i];
         var chkSymbol = document.getElementById("chk" + v_symbol);
         if(chkSymbol != null && chkSymbol != "undefined")
         {
            chkSymbol.checked = true;
            OnRowChecked(v_symbol);
         }
      }
   }
   else 
   {
      unselectedSymbolList = oldUnselectedSymbolList;
      selectedSymbolList = l_arraySymbolChecked;
   }   
};

function UpdateOddRowBackColor(pRowOdd)
{                   
          var v_index = 0;  
          pRowOdd.cells[v_index++].style.backgroundColor = backColorSymbolR2;          
          pRowOdd.cells[v_index++].style.backgroundColor = backColor2R2;
          pRowOdd.cells[v_index++].style.backgroundColor = backColor2R2;          
          pRowOdd.cells[v_index++].style.backgroundColor = backColor2R2;          
          //======================================
          pRowOdd.cells[v_index++].style.backgroundColor = backColor1R2;                    
          pRowOdd.cells[v_index++].style.backgroundColor = backColorVolume1R2;                    
          pRowOdd.cells[v_index++].style.backgroundColor = backColor1R2;                    
          pRowOdd.cells[v_index++].style.backgroundColor = backColorVolume1R2;                    
          pRowOdd.cells[v_index++].style.backgroundColor = backColor1R2;                    
          pRowOdd.cells[v_index++].style.backgroundColor = backColorVolume1R2;                                        
          //====================================== Gia, khoi luong khop lenh
          pRowOdd.cells[v_index++].style.backgroundColor = backColor1AltR2;                                                  
          pRowOdd.cells[v_index++].style.backgroundColor = backColorVolume1AltR2                                        
          //====================================== //+/- TC
          pRowOdd.cells[v_index++].style.backgroundColor = backColor1AltR2;                                                            
          //======================================  // du ban gia 1
          pRowOdd.cells[v_index++].style.backgroundColor = backColor1R2;                                                                                          
          //====================================== //du ban kl1
          pRowOdd.cells[v_index++].style.backgroundColor = backColorVolume1R2;                                                                                
          //====================================== 
          pRowOdd.cells[v_index++].style.backgroundColor = backColor1R2;                                                                                
          //====================================== //du ban kl 2
          pRowOdd.cells[v_index++].style.backgroundColor = backColorVolume1R2;                                                                                
          //====================================== // du ban gia 3
          pRowOdd.cells[v_index++].style.backgroundColor = backColor1R2;                                                                                
          //====================================== // db kl 3
          pRowOdd.cells[v_index++].style.backgroundColor = backColorVolume1R2;                                                                                
          //====================================== //gia cao nhat
          if (l_flagShowHighestPrice == true)
          {
              pRowOdd.cells[v_index++].style.backgroundColor = backColor1R2;                                                                                
          }
          //====================================== //gia thap nhat
          if (l_flagShowLowestPrice == true)
          {
              pRowOdd.cells[v_index++].style.backgroundColor = backColor1R2;                                                                                
          }          
          //KL mua
          if(l_flagShowBuyVolume == true)
          {
              pRowOdd.cells[v_index++].style.backgroundColor = backColorVolume1R2;                                                                                             
          }
          //KL bán
          if(l_flagShowSellVolume == true)
          {
            pRowOdd.cells[v_index++].style.backgroundColor = backColorVolume1R2;                                                                                
          }     
          //KL Khớp
          if(l_flagShowMatchVolume == true)
          {
            pRowOdd.cells[v_index++].style.backgroundColor = backColorVolume1R2;                                                                                
          }
          // NN mua
          if(l_flagShowForeignBuy == true)
          {
             pRowOdd.cells[v_index++].style.backgroundColor = backColorVolume1R2;                                                                                
          }
          // NN bán
          if(l_flagShowForeignSell == true)
          {
            pRowOdd.cells[v_index++].style.backgroundColor = backColorVolume1R2;                                                                                
          }
          pRowOdd.cells[v_index++].style.backgroundColor = backColorSymbolR2;                                                                                
}

function BeginUpdate()
{  

   if(l_dataChanged == null && l_basicObject == null)
   return;
   
   if (l_flagDisplayUpdateData != null)      
   {
      clearTimeout(l_flagDisplayUpdateData);      
      l_flagDisplayUpdateData = null; 
   }    
   l_flagDisplayUpdateData = setTimeout("DisplayUpdateData()", 50); 

   if (l_flagClearBackGroundColor != null)      
   {
      clearTimeout(l_flagClearBackGroundColor);   
      l_flagClearBackGroundColor = null;      
   }  
   l_flagClearBackGroundColor = setTimeout("ClearBackGroundColor()", 50);    

   if (l_flagUpdateMarketHeaderData != null)
   {
        clearTimeout(l_flagUpdateMarketHeaderData);         
        l_flagUpdateMarketHeaderData = null;
   }
   l_flagUpdateMarketHeaderData = setTimeout("UpdateMarketHeaderData()", 50);    
   
                 
   var v_arrItemsValue = new Array();
   var cellIndex = 0;
   var v_index = 0;
   var v_changedRow = null;
   var quoteItem = null;   
   var v_chkItem = null;      
   var v_basicItem = null;
   var v_basicValueArray = null;
   var v_basicItemInfo = null;      
   
   for(var item in l_dataChanged.Items)
   {    
      quoteItem = l_dataChanged.Items[item];
      v_arrItemsValue = quoteItem.V.split(";");
      v_changedRow = document.getElementById("tr" + item);  
      v_chkItem = document.getElementById("chk" + item);     
      if(v_changedRow != null)
      {    
            //---------------------------------------------------
            v_basicItem = l_basicObject.Items[item];
            v_basicValueArray = v_basicItem.V.split(";");
            v_basicItemInfo = new cls_basicItemInfo(); 
            v_basicItemInfo.CeilingPrice  = v_basicValueArray[0];
            v_basicItemInfo.FloorPrice = v_basicValueArray[1];  
            v_basicItemInfo.ReferencePrice = v_basicValueArray[2];
            v_basicItemInfo.RowIndex = parseInt(v_chkItem.value);   
            //---------------------------------------------------
            cellIndex = 4;      
            v_index = 0;            
            //======================================================================================================
            //du' mua
            //Gia3           
            UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index++], "normalPrice", true, false, item, v_basicItemInfo);
            //KL3 + KL3ChiTiet
            UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index - 1] + ";" + v_arrItemsValue[v_index++] + ";" + v_arrItemsValue[v_index++], "normalVol", false, false, item, v_basicItemInfo);
            //Gia2
            UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index++], "normalPrice", true, false, item, v_basicItemInfo);
            //KL2
            UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index - 1] + ";" + v_arrItemsValue[v_index++] + ";" + v_arrItemsValue[v_index++], "normalVol", false, false, item, v_basicItemInfo);
            //Gia1
            UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index++], "normalPrice", true, false, item, v_basicItemInfo);
            //Kl1
            UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index - 1] + ";" + v_arrItemsValue[v_index++] + ";" + v_arrItemsValue[v_index++], "normalVol", false, false, item, v_basicItemInfo);
            //Gia khop lenh
            UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index++], "normalMatchingPrice", true, true, item, v_basicItemInfo);
            //KL khop lenh
            UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index++], "normalMatchingVol", false, true, item, v_basicItemInfo);            
            //+/- TC        
            UpdateCellDataImage(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index++], "normalMatchingPrice", true, true, item, v_arrItemsValue[6], v_basicItemInfo);
            //=========================================
            //du ban
            //Gia1
            UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index++], "normalPrice", true, false, item, v_basicItemInfo);
            //Kl1
            UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index - 1] + ";" + v_arrItemsValue[v_index++] + ";" + v_arrItemsValue[v_index++], "normalVol", false, false, item, v_basicItemInfo);
            //Gia2
            UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index++], "normalPrice", true, false, item, v_basicItemInfo);
            //Kl2
            UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index - 1] + ";" + v_arrItemsValue[v_index++] + ";" + v_arrItemsValue[v_index++], "normalVol", false, false, item, v_basicItemInfo);
            //Gia3
            UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index++], "normalPrice", true, false, item, v_basicItemInfo);
            //Kl3
            UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index - 1] + ";" + v_arrItemsValue[v_index++] + ";" + v_arrItemsValue[v_index++], "normalVol", false, false, item, v_basicItemInfo);
            //Cao nhat	
            if (l_flagShowHighestPrice == true)
            {		
			    UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index++], "normalHighLowPrice", true, true, item, v_basicItemInfo);
			}
			else
			{   			    
			    v_index++;
			}
			//Thap nhat
			if (l_flagShowLowestPrice == true)
			{
			    UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index++], "normalHighLowPrice", true, true, item, v_basicItemInfo);
			}
			else 
			{
			    v_index++;
			}			
    	    //=======================================                   
            // KL mua
            if(l_flagShowBuyVolume  == true)
            {
                UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index++], "normalVol", false, true, item, v_basicItemInfo);
            }
            else
            {
                v_index++;
            }
            // KL bán
            if(l_flagShowSellVolume == true)
            {
                UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index++], "normalVol", false, true, item, v_basicItemInfo);
            }
            else
            {
                v_index++;
            }     
            // KL Khop
            if(l_flagShowMatchVolume == true)
            {
                UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index++], "normalVol", false, true, item, v_basicItemInfo);
            }
            else
            {
                v_index++;
            }   
            //nuoc ngoài mua
            if(l_flagShowForeignBuy  == true)
            {               
                UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index++], "normalVol", false, true, item, v_basicItemInfo);
            }
            else
            {
                v_index++;
            }
            //nuoc ngoài ban
            if(l_flagShowForeignSell == true)
            {
                UpdateCellData(v_changedRow.cells[cellIndex++], v_arrItemsValue[v_index++], "normalVol", false, true, item, v_basicItemInfo);
            } 
            else
            {
                v_index++;
            }                                       
        }
    }   
    if (l_StartRequestTimeOutID != null)
    {
        clearTimeout(l_StartRequestTimeOutID);       
        l_StartRequestTimeOutID = null;    
    }   
    l_StartRequestTimeOutID = setTimeout("StartRequest()", l_timeout_requestData);
};


function UpdateCellDataImage(cell, data, className, isPrice, isSpecial, stocksymbol, priceCompare, pBasicItemInfo)
{
     if (l_flagRowCreating == true)
   {
        return;  
   }
   if(data != undefined && data != "")
   {  
      var v_cellInfo = new cls_CellInfo();
      v_cellInfo.cell = cell;     
      v_cellInfo.dataRealOutOfPicture = parseFloat(data);
      v_cellInfo.classNameNormal = className; 
      v_cellInfo.isPrice = isPrice;     
      v_cellInfo.isSpecial = isSpecial;
      v_cellInfo.stockSymbol = stocksymbol; 
      if (pBasicItemInfo.RowIndex % 2 == 0)
      {
         //chan   
         v_cellInfo.EvenOdd = 0;
      }
      else 
      {
        //le
        v_cellInfo.EvenOdd = 1; 
      }
        if(v_cellInfo.dataRealOutOfPicture < 0)
        {
            v_cellInfo.data = data + " <img src=\"images/btdown.gif\" />";
            v_cellInfo.typeUpDown = 1;
        }
        else if(v_cellInfo.dataRealOutOfPicture == 0)
        {
            v_cellInfo.data = data + " <img src=\"images/btnochange.jpg\" />";
            v_cellInfo.typeUpDown = 0;
        }
        else
        {
            v_cellInfo.data = data + " <img src=\"images/btup.gif\" />";
            v_cellInfo.typeUpDown = 2;
        }                                  
        if (v_cellInfo.isPrice == true)
        {                    
            if (priceCompare == pBasicItemInfo.FloorPrice)        
            {                       
                v_cellInfo.data = data + " <b>FL</b>";
            }
            else if (priceCompare == pBasicItemInfo.CeilingPrice)        
            {    
                v_cellInfo.data = data + " <b>CE</b>";                    
            }             
        }       
      v_cellInfo.flagUpDownPicture = true;
      l_arrayCellChanged.push(v_cellInfo);     
   }   
} 

function UpdateCellData(cell, data, className, isPrice, isSpecial, stocksymbol, pBasicItemInfo)
{  
   if (l_flagRowCreating == true)
   {
        return;  
   }
   if(data != undefined && data != "" && data != ";;")
   {  
      var v_cellInfo = new cls_CellInfo();
      
      if (!isPrice && !isSpecial)
      {
        //Added Date: 08/10/2009 09:38:21
        //Added By: hungud        
        //Purpose: isVolume --> insert to anchor <a></a> 
        //Phat hien jscript khac nhau trong header va body (from function Tip javascript)
                
        var v_arr_valvol; 
        
        var v_val_show;
        var v_volume_show;
        var v_volume_detail;  
        
        var v_date;     
        
        var v_strCellID;        
        var v_arr_str;
        
        var v_val_cell_show;
        var v_volume_cell_show;
        var v_volume_cell_detail;  
        
        var v_strTagAmouseover;  
        
        var v_A_val;
        var v_A_vol;
        var v_A_detail;
        
        
        v_arr_valvol = data.split(';');
        
        v_val_show = v_arr_valvol[0];
        v_volume_show = v_arr_valvol[1];
        v_volume_detail = v_arr_valvol[2];   
        
         
          //cell.id = stocksymbol + "_" + v_val_show + "_" + v_volume_show + "_" + v_volume_detail + "_" + v_date.getTime(); 
                 
                
             if (cell!=null && cell.id.length > 0)
             {             
                    v_strCellID = cell.id;
                    v_arr_str = v_strCellID.split('_'); 
                    
                    v_val_cell_show = v_arr_str[1];
                    v_volume_cell_show = v_arr_str[2];
                    v_volume_cell_detail = v_arr_str[3]; 
                    
                    //mot trong truong hop gia ko doi, kl ko doi hoac khoi luong chi tiet ko doi
                    //gia thay doi, nhung kl ko thay doi
                    if (v_val_show != "" && v_volume_show == "" && v_volume_detail=="")
                    {
                        //---> chi update header            
                        v_A_val = v_val_show;                    
                        v_A_detail = v_volume_cell_detail;
                        v_A_vol = v_volume_cell_show;   
                    }
                    else if (v_val_show == "")
                    {
                            v_A_val = v_val_cell_show;
                            //2 truong hop khoi luong thay doi: kl thay doi, hoac chi kl chi tiet thay doi
                            if (v_volume_show != "")
                            {                       
                                v_A_vol = v_volume_show;                               
                                    //----> update kl
                                    if (v_volume_detail != "")
                                    {       
                                        v_A_detail = v_volume_detail;
                                    }
                                    else 
                                    {
                                        v_A_detail = v_volume_cell_detail;                            
                                    }
                            }            
                            else if (v_volume_detail != "")
                            {
                                v_A_vol = v_volume_cell_show;
                                v_A_detail = v_volume_detail;
                            }
                    }
                    else 
                    {
                        v_A_val = v_val_show;
                        v_A_vol = v_volume_show;
                        v_A_detail = v_volume_detail;
                    }   
             }
             else 
             {
                    v_A_val = v_val_show;
                    v_A_vol = v_volume_show;
                    v_A_detail = v_volume_detail;
             }
                //"'" + stocksymbol + " - " +  v_val_show + "'"
                v_strTagAmouseover = "<a onmouseover=\"Tip(popquote(this, '" + v_A_detail + "'), BGCOLOR, '#525152', BORDERCOLOR, '#525152', TITLE, '" + stocksymbol + " - " +  v_A_val + "', CLICKCLOSE, true, FIX, [this, 23, -19]);\">" + v_A_vol + "</a>"; 
                v_cellInfo.data = v_strTagAmouseover;
                v_cellInfo.dataRealOutOfPicture = parseFloat(v_volume_show);
                v_date = new Date();
                cell.id = stocksymbol + "_" + v_A_val + "_" + v_A_vol + "_" + v_A_detail + "_" + v_date.getTime(); 
      }
      else 
      {
         v_cellInfo.dataRealOutOfPicture = parseFloat(data);
         v_cellInfo.data = data; 
      }
      v_cellInfo.cell = cell; 
      v_cellInfo.classNameNormal = className; 
      v_cellInfo.isPrice = isPrice;     
      v_cellInfo.isSpecial = isSpecial;
      v_cellInfo.stockSymbol = stocksymbol;                                                      
      v_cellInfo.flagUpDownPicture = false;
        if (pBasicItemInfo.RowIndex % 2 == 0)
        {
        //chan   
        v_cellInfo.EvenOdd = 0;
        }
        else 
        {
        //le
        v_cellInfo.EvenOdd = 1; 
        }
        if(v_cellInfo.dataRealOutOfPicture == pBasicItemInfo.CeilingPrice)
        {
            v_cellInfo.typeUpDown = 3;
        }
        else if(v_cellInfo.dataRealOutOfPicture == pBasicItemInfo.FloorPrice)
        {
            v_cellInfo.typeUpDown = 4;
        }
        else if(v_cellInfo.dataRealOutOfPicture > pBasicItemInfo.ReferencePrice)
        {
            v_cellInfo.typeUpDown = 2;
        }
        else if(v_cellInfo.dataRealOutOfPicture < pBasicItemInfo.ReferencePrice)
        {
            v_cellInfo.typeUpDown = 1;
        }
        else if (v_cellInfo.dataRealOutOfPicture == pBasicItemInfo.ReferencePrice)
        {
            v_cellInfo.typeUpDown = 5;
        }
        else
        {
            v_cellInfo.typeUpDown = 0;
        }
      l_arrayCellChanged.push(v_cellInfo);     
   }
};

function DisplayUpdateData()
{ 
    //basic row creating
   if (l_flagDisplayUpdateData != null)
   {
        clearTimeout(l_flagDisplayUpdateData); 
        l_flagDisplayUpdateData = null;
   }
   if (l_flagRowCreating == true)
   {         
        l_flagDisplayUpdateData = setTimeout("DisplayUpdateData()", 50);
        return;
   } 
   if (l_arrayCellChanged.length == 0) 
   {
        l_flagDisplayUpdateData = setTimeout("DisplayUpdateData()", 50);    
        return;
   }         
   var v_cellInfo = new cls_CellInfo();             
   for(var i = 0; i < l_arrayCellChanged.length; i ++ )
   {
      v_cellInfo = l_arrayCellChanged[i];                                                    
      l_arrayCellChanged.splice(i,1);            
      if (v_cellInfo.flagUpDownPicture == false)
      {
              //Added Date: 08/10/2009 14:00:39
              //Added By: hungud
              //Purpose: checke cell is null, or its data is different with new data, fill color style  
              if (v_cellInfo.cell.innerHTML != "" && v_cellInfo.data != v_cellInfo.cell.innerHTML)
              {         
                        v_cellInfo.cell.style.backgroundColor = "";            
                        v_cellInfo.cell.className = "CellVolumeChange";                                           
                        if (v_cellInfo.isPrice == true)
                        {       
                                switch(v_cellInfo.typeUpDown)
                                {
                                    case 0:                                         
                                    break;
                                    case 1:
                                        v_cellInfo.cell.className = "CellChangeDown";                    
                                    break;
                                    case 2:
                                        v_cellInfo.cell.className = "CellChangeUp";                    
                                    break;
                                    case 3:                                    
                                    break;
                                    case 4:                                    
                                    break;
                                    case 5:
                                        v_cellInfo.cell.className = "CellChange";                                              
                                    break;
                                }
                        }                    
                        var v_now = new Date();
                        v_cellInfo.time = v_now.getHours() * 60 * 60 + v_now.getMinutes() * 60 + v_now.getSeconds();            
                        l_arrayCellChangedClearColor.push(v_cellInfo);                             
              }
		      else
		      {
		                v_cellInfo.cell.className = v_cellInfo.classNameNormal;                    
                        if (v_cellInfo.isPrice == true)
                        { 
                             switch(v_cellInfo.typeUpDown)
                             {
                                case 0:                                  
                                break;
                                case 1:
                                    if (v_cellInfo.isSpecial == false) 
                                    v_cellInfo.cell.className = "downPrice";
                                    else
                                    v_cellInfo.cell.className = "downPrice2"; 
                                break;
                                case 2:
                                     if (v_cellInfo.isSpecial == false) 
                                    v_cellInfo.cell.className = "upPrice";
                                    else
                                    v_cellInfo.cell.className = "upPrice2";
                                break;
                                case 3:  
                                      if (v_cellInfo.isSpecial == false) 
                                    v_cellInfo.cell.className = "cellCeiling";
                                    else
                                    v_cellInfo.cell.className = "cellCeiling2";                                  
                                break;
                                case 4: 
                                     if (v_cellInfo.isSpecial == false) 
                                    v_cellInfo.cell.className = "cellFloor";
                                    else
                                    v_cellInfo.cell.className = "cellFloor2";                                    
                                break;
                                case 5:  
                                    if (v_cellInfo.isSpecial == false) 
                                    v_cellInfo.cell.className = "cellRef";
                                    else
                                    v_cellInfo.cell.className = "cellRef2";                                 
                                break;
                            }  
                           switch(v_cellInfo.EvenOdd)
                           {
                            case 0:
                                  if (v_cellInfo.isSpecial == false)                                   
                                  v_cellInfo.cell.style.backgroundColor = backColor1;
                                  else 
                                  v_cellInfo.cell.style.backgroundColor = backColor1Alt;
                            break;
                            case 1:
                                 if (v_cellInfo.isSpecial == false)                                   
                                 v_cellInfo.cell.style.backgroundColor = backColor1R2;
                                 else 
                                 v_cellInfo.cell.style.backgroundColor = backColor1AltR2;
                            break;
                           }                          
                     } 
                     else 
                     {     
                          //if is volume                 
                          switch(v_cellInfo.EvenOdd)
                           {
                            case 0:
                                  if (v_cellInfo.isSpecial == false)                                   
                                  v_cellInfo.cell.style.backgroundColor = backColorVolume1;
                                  else 
                                  v_cellInfo.cell.style.backgroundColor = backColorVolume1Alt;
                            break;
                            case 1:
                                 if (v_cellInfo.isSpecial == false)                                   
                                 v_cellInfo.cell.style.backgroundColor = backColorVolume1R2;
                                 else 
                                 v_cellInfo.cell.style.backgroundColor = backColorVolume1AltR2;
                            break;
                           }
                     }                   
              }
      }          
      else 
      {
          //if (v_cellInfo.cell.innerHTML != "" && v_cellInfo.dataRealOutOfPicture != getDataFromInnerHTMLCellPicture(v_cellInfo.cell.innerHTML))
          if (v_cellInfo.cell.innerHTML != "" && v_cellInfo.data != v_cellInfo.cell.innerHTML)
          {               
                v_cellInfo.cell.style.backgroundColor = "";             
                v_cellInfo.cell.className = "CellChange"; 
                switch(v_cellInfo.typeUpDown)
                {                                                  
                    case 1:
                    v_cellInfo.cell.className = "CellChangeDown";                                                             
                    break;
                    case 2:
                    v_cellInfo.cell.className = "CellChangeUp";                                                                                                 
                    break;
                }                                       
                var v_now = new Date();
                v_cellInfo.time = v_now.getHours() * 60 * 60 + v_now.getMinutes() * 60 + v_now.getSeconds();            
                l_arrayCellChangedClearColor.push(v_cellInfo);                             
          }  
          else 
          {
                v_cellInfo.cell.className = v_cellInfo.classNameNormal;                
                 switch(v_cellInfo.typeUpDown)
                {                                                  
                    case 1:
                    v_cellInfo.cell.className = "downPrice2";                                                             
                    break;
                    case 2:
                    v_cellInfo.cell.className = "upPrice2";                                                                                                 
                    break;
                } 
                switch(v_cellInfo.EvenOdd)
                {
                case 0:
                    v_cellInfo.cell.style.backgroundColor = backColor1Alt;
                break;
                case 1:
                    v_cellInfo.cell.style.backgroundColor = backColor1AltR2;
                break;
                }      
          }        
      }
      v_cellInfo.cell.innerHTML = v_cellInfo.data; //data picture to cell     
   }
    if (l_flagDisplayUpdateData != null)
    {
        clearTimeout(l_flagDisplayUpdateData); 
        l_flagDisplayUpdateData = null;
    }
    l_flagDisplayUpdateData = setTimeout("DisplayUpdateData()", 50);    
};

function getDataFromInnerHTMLCellPicture(pInnerText)
{
     var v_text = pInnerText.toString();
     var v_index = v_text.indexOf('<');      
     v_text = v_text.substr(0, v_index);    
     return parseFloat(v_text);
}

function ClearBackGroundColor()
{ 
   if (l_flagClearBackGroundColor != null)
   {
        clearTimeout(l_flagClearBackGroundColor);             
        l_flagClearBackGroundColor = null;
   } 
   if(l_flagRowCreating == true)
   {            
        l_flagClearBackGroundColor = setTimeout("ClearBackGroundColor()", 50);    
        return;  
   }
   if (l_arrayCellChangedClearColor.length == 0)
   {             
        l_flagClearBackGroundColor = setTimeout("ClearBackGroundColor()", 50);    
        return;
   }  
   var v_cellInfo;
   var v_endTime = 0;
   for(var i = 0; i < l_arrayCellChangedClearColor.length; i ++ )
   {
      
      var v_date = new Date();      
      var v_now = v_date.getHours() * 60 * 60 + v_date.getMinutes() * 60 + v_date.getSeconds();
      v_cellInfo = l_arrayCellChangedClearColor[i];              
      v_endTime = v_now - v_cellInfo.time;
      if (v_endTime > l_timeout_clearColor)
       {
         l_arrayCellChangedClearColor.splice(i, 1);
         v_cellInfo.cell.className = v_cellInfo.classNameNormal;                                                                                                                                                
         if (v_cellInfo.flagUpDownPicture == true)
         {
             switch(v_cellInfo.typeUpDown)
            {                                                  
                case 1:
                v_cellInfo.cell.className = "downPrice2";                                                             
                break;
                case 2:
                v_cellInfo.cell.className = "upPrice2";                                                                                                 
                break;
            } 
            switch(v_cellInfo.EvenOdd)
            {
            case 0:
                v_cellInfo.cell.style.backgroundColor = backColor1Alt;
            break;
            case 1:
                v_cellInfo.cell.style.backgroundColor = backColor1AltR2;
            break;
            }      
         }
         else 
         {
            if (v_cellInfo.isPrice == true)
            {                    
                switch(v_cellInfo.typeUpDown)
                {
                case 0:                                  
                break;
                case 1:
                if (v_cellInfo.isSpecial == false) 
                v_cellInfo.cell.className = "downPrice";
                else
                v_cellInfo.cell.className = "downPrice2"; 
                break;
                case 2:
                 if (v_cellInfo.isSpecial == false) 
                v_cellInfo.cell.className = "upPrice";
                else
                v_cellInfo.cell.className = "upPrice2";
                break;
                case 3:  
                  if (v_cellInfo.isSpecial == false) 
                v_cellInfo.cell.className = "cellCeiling";
                else
                v_cellInfo.cell.className = "cellCeiling2";                                  
                break;
                case 4: 
                 if (v_cellInfo.isSpecial == false) 
                v_cellInfo.cell.className = "cellFloor";
                else
                v_cellInfo.cell.className = "cellFloor2";                                    
                break;
                case 5:  
                if (v_cellInfo.isSpecial == false) 
                v_cellInfo.cell.className = "cellRef";
                else
                v_cellInfo.cell.className = "cellRef2";                                 
                break;
                }
                switch(v_cellInfo.EvenOdd)
                {
                case 0:
                if (v_cellInfo.isSpecial == false)                                   
                v_cellInfo.cell.style.backgroundColor = backColor1;
                else 
                v_cellInfo.cell.style.backgroundColor = backColor1Alt;
                break;
                case 1:
                if (v_cellInfo.isSpecial == false)                                   
                v_cellInfo.cell.style.backgroundColor = backColor1R2;
                else 
                v_cellInfo.cell.style.backgroundColor = backColor1AltR2;
                break;
                }             
            } 
            else
            {
              //neu la khoi luong                      
              switch(v_cellInfo.EvenOdd)
               {
                case 0:
                      if (v_cellInfo.isSpecial == false)                                   
                      v_cellInfo.cell.style.backgroundColor = backColorVolume1;
                      else 
                      v_cellInfo.cell.style.backgroundColor = backColorVolume1Alt;
                break;
                case 1:
                     if (v_cellInfo.isSpecial == false)                                   
                     v_cellInfo.cell.style.backgroundColor = backColorVolume1R2;
                     else 
                     v_cellInfo.cell.style.backgroundColor = backColorVolume1AltR2;
                break;
               }
            }
         }       
      }                              
    }   
   if (l_flagClearBackGroundColor != null)
   {
    clearTimeout(l_flagClearBackGroundColor);             
    l_flagClearBackGroundColor = null;
   } 
   l_flagClearBackGroundColor = setTimeout("ClearBackGroundColor()", 50);    
};


function UpdateMarketHeaderData()
{
   if (l_flagRowCreating == true)
   {
        return;  
   }
   var v_TypeUpDownIndex = 0;   
   if(l_dataChanged.Ic != undefined && l_dataChanged.Ic != "")
   {
      if(l_dataChanged.Ic.substr(0, 1) == "-")
      {  
         v_TypeUpDownIndex = 1;
      }
      else if(parseFloat(l_dataChanged.Ic) == 0)
      {              
         v_TypeUpDownIndex = 0;
      }
      else        
      {  
         v_TypeUpDownIndex = 2;
      }
   }
   else 
   {
     var v_tempValue = getDataFromInnerHTMLCellPicture(l_objTdChange.innerHTML);
     if (v_tempValue == 0)
     {
        v_TypeUpDownIndex = 0;
     }
     else if (v_tempValue < 0)
     {
        v_TypeUpDownIndex = 1;
     }
     else if (v_tempValue > 0)
     {
        v_TypeUpDownIndex = 2;
     }
   }
   UpdateCellMarketHeaderData(l_objTdIndex, l_dataChanged.I, "headerInfoValue" , false, true, false, "", v_TypeUpDownIndex);            
   UpdateCellMarketHeaderData(l_objTdChange, l_dataChanged.Ic + "|" + l_dataChanged.Icp, "headerInfoValue" , true, true, false, "", v_TypeUpDownIndex);                              
   UpdateCellMarketHeaderData(l_objTdTotalMarketVolume, l_dataChanged.Tvol, "headerInfoValue", false, false, false,"", v_TypeUpDownIndex); 
   UpdateCellMarketHeaderData(l_objTdTotalValue, l_dataChanged.Tval, "headerInfoValue", false, false, false,"", v_TypeUpDownIndex); 
   UpdateCellMarketHeaderData(l_objTdTotalMarketVolumePt, l_dataChanged.TvolPt, "headerInfoValue", false, false, false,"", v_TypeUpDownIndex); 
   UpdateCellMarketHeaderData(l_objTdTotalValuePt, l_dataChanged.TvalPt, "headerInfoValue", false, false, false,"", v_TypeUpDownIndex); 
   UpdateCellMarketHeaderData(l_objTdMarketStatus, l_dataChanged.TtGd, "headerInfoValue", false, false, false,"", v_TypeUpDownIndex); 
   DisplayUpdateMarketData();
   ClearBackGroundColorOfMarketData();   
}

function UpdateCellMarketHeaderData(cell, data, className, flagUpDownPicture, isPrice, isSpecial, stocksymbol, typeUpDown)
{  
   if (l_flagRowCreating == true)
   {
        return;  
   }
   if(data != undefined && data != "")
   {  
      var v_cellInfo = new cls_CellInfo();                   
      if (flagUpDownPicture == false)
      {
        v_cellInfo.data = data;                        
        v_cellInfo.flagUpDownPicture = false;
      }
      else 
      {
           var v_dataSplit = data.split("|");
           var v_Icp = v_dataSplit[1]; 
           data = v_dataSplit[0];  
           if(data == "undefined" || data == "" || v_Icp == "undefined" || v_Icp == "")  
           {
                return;                
           }            
           if (typeUpDown == 0)
           {
                v_cellInfo.data = data + " <img src=\"images/btnochange.jpg\" />";
           }
           else if (typeUpDown == 1)
           {
                v_cellInfo.data = data + " <img src=\"images/btdown.gif\" />";
           }
           else if (typeUpDown == 2)
           {
                v_cellInfo.data = data + " <img src=\"images/btup.gif\" />";  
           } 
           v_cellInfo.data = v_cellInfo.data + " (" + v_Icp + "%)"; 
           v_cellInfo.flagUpDownPicture = true;
      }  
      v_cellInfo.cell = cell;     
      v_cellInfo.typeUpDown = typeUpDown;       
      v_cellInfo.dataRealOutOfPicture = parseFloat(data);
      v_cellInfo.classNameNormal = className; 
      v_cellInfo.isPrice = isPrice;     
      v_cellInfo.isSpecial = isSpecial;
      v_cellInfo.stockSymbol = stocksymbol;      
      l_arrayCellMarketChanged.push(v_cellInfo);     
   }
};


function DisplayUpdateMarketData()
{
   //basic row creating
    if (l_flagDisplayUpdateMarketData != null)
    {
            clearTimeout(l_flagDisplayUpdateMarketData); 
            l_flagDisplayUpdateMarketData = null;
    }
    if (l_flagRowCreating == true)
    {           
        l_flagDisplayUpdateMarketData = setTimeout("DisplayUpdateMarketData()", 50);
        return;
    } 
    if (l_arrayCellMarketChanged.length == 0) 
    {
        l_flagDisplayUpdateMarketData = setTimeout("DisplayUpdateMarketData()", 50);    
        return;
    }
    if (l_flagDisplayUpdateMarketData != null)
    {
        clearTimeout(l_flagDisplayUpdateMarketData);
        l_flagDisplayUpdateMarketData = null;   
    }      
   var v_cellInfo = new cls_CellInfo();             
   for(var i = 0; i < l_arrayCellMarketChanged.length; i ++ )
   {
          v_cellInfo = l_arrayCellMarketChanged[i];                                                    
          l_arrayCellMarketChanged.splice(i,1); 
          
          if (v_cellInfo.flagUpDownPicture == false)
          {
                     
                if (v_cellInfo.cell.innerHTML != "" && v_cellInfo.data != v_cellInfo.cell.innerHTML)
                {        
                    v_cellInfo.cell.className = "headerInfoValueChange";                                                     
                    if (v_cellInfo.isPrice == true)
                    {
                        switch(v_cellInfo.typeUpDown)
                        {                                                  
                            case 1:
                            v_cellInfo.cell.className = "headerInfoValueDownChange";                                                             
                            break;
                            case 2:
                            v_cellInfo.cell.className = "headerInfoValueUpChange";                                                                                                 
                            break;
                        }                                                               
                    }                                                            
                    var v_now = new Date();
                    v_cellInfo.time = v_now.getHours() * 60 * 60 + v_now.getMinutes() * 60 + v_now.getSeconds();            
                    l_arrayCellMarketChangedClearColor.push(v_cellInfo);                             
                }
                else
                {
                        v_cellInfo.cell.className = v_cellInfo.classNameNormal;                                         
                        if (v_cellInfo.isPrice == true)
                        {
                            switch(v_cellInfo.typeUpDown)
                            {                               
                                case 1:
                                v_cellInfo.cell.className = "headerInfoValueDown";                                                             
                                break;
                                case 2:
                                v_cellInfo.cell.className = "headerInfoValueUp";                                                                                                 
                                break;
                            }                                                               
                        }                                                 
                }   
         } 
         else
         {
                if (v_cellInfo.cell.innerHTML != "" && v_cellInfo.dataRealOutOfPicture != getDataFromInnerHTMLCellPicture(v_cellInfo.cell.innerHTML))
                {        
                    v_cellInfo.cell.className = "headerInfoValueChange";                                                     
                    if (v_cellInfo.isPrice == true)
                    {
                        switch(v_cellInfo.typeUpDown)
                        {                                                  
                            case 1:
                            v_cellInfo.cell.className = "headerInfoValueDownChange";                                                             
                            break;
                            case 2:
                            v_cellInfo.cell.className = "headerInfoValueUpChange";                                                                                                 
                            break;
                        }                                                               
                    }                                                            
                    var v_now = new Date();
                    v_cellInfo.time = v_now.getHours() * 60 * 60 + v_now.getMinutes() * 60 + v_now.getSeconds();            
                    l_arrayCellMarketChangedClearColor.push(v_cellInfo);                             
                }
                else
                {
                        v_cellInfo.cell.className = v_cellInfo.classNameNormal;                                         
                        if (v_cellInfo.isPrice == true)
                        {
                            switch(v_cellInfo.typeUpDown)
                            {                               
                                case 1:
                                v_cellInfo.cell.className = "headerInfoValueDown";                                                             
                                break;
                                case 2:
                                v_cellInfo.cell.className = "headerInfoValueUp";                                                                                                 
                                break;
                            }                                                               
                        }                                                 
                }     
         }            
    v_cellInfo.cell.innerHTML = v_cellInfo.data;      
   }
    if (l_flagDisplayUpdateMarketData != null)
    {
            clearTimeout(l_flagDisplayUpdateMarketData); 
            l_flagDisplayUpdateMarketData = null;
    }
    l_flagDisplayUpdateMarketData = setTimeout("DisplayUpdateMarketData()", 50);     
}

function ClearBackGroundColorOfMarketData()
{ 
   if (l_flagClearBackGroundColorOfMarketData != null)
   {
        clearTimeout(l_flagClearBackGroundColorOfMarketData);             
        l_flagClearBackGroundColorOfMarketData = null; 
   } 
   if(l_flagRowCreating == true)
   {            
        l_flagClearBackGroundColorOfMarketData = setTimeout("ClearBackGroundColorOfMarketData()", 50);    
        return;  
   }
   if (l_arrayCellMarketChangedClearColor.length == 0)
   {             
        l_flagClearBackGroundColorOfMarketData = setTimeout("ClearBackGroundColorOfMarketData()", 50);    
        return;
   } 
   var v_cellInfo;
   var v_endTime = 0;
   for(var i = 0; i < l_arrayCellMarketChangedClearColor.length; i ++ )
   {
      
      var v_date = new Date();      
      var v_now = v_date.getHours() * 60 * 60 + v_date.getMinutes() * 60 + v_date.getSeconds();
      v_cellInfo = l_arrayCellMarketChangedClearColor[i];              
      v_endTime = v_now - v_cellInfo.time;
      if (v_endTime > l_timeout_clearColor)
       {
            l_arrayCellMarketChangedClearColor.splice(i, 1);
            v_cellInfo.cell.className = v_cellInfo.classNameNormal; 
            if (v_cellInfo.isPrice == true)
            {
                 switch(v_cellInfo.typeUpDown)
                  {
                    case 0:
                    v_cellInfo.cell.className = "headerInfoValueUnchange";                         
                    break;                                    
                    case 1:
                    v_cellInfo.cell.className = "headerInfoValueDown";                                                             
                    break;
                    case 2:
                    v_cellInfo.cell.className = "headerInfoValueUp";                                                                                                 
                    break;
                  }                                                               
            }                                        
        }                              
   }   
   if (l_flagClearBackGroundColorOfMarketData != null)
   {
        clearTimeout(l_flagClearBackGroundColorOfMarketData);             
        l_flagClearBackGroundColorOfMarketData = null; 
   }
   l_flagClearBackGroundColorOfMarketData = setTimeout("ClearBackGroundColorOfMarketData()", 50);    
};

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* ham hien thi tat ca chung khoan */
// hien thi chung khoan
function CreatePanelChooseSymbol()
{  
   var theChooseSymbolsTable = document.getElementById("tableChooseSymbols");
   //clear row
   for(var i = theChooseSymbolsTable.rows.length - 1;i >= 0;i -- )   
   theChooseSymbolsTable.deleteRow(i);   
   if(l_basicObject != null && l_basicObject.Items != null)
   {
      var index = 0;
      var chooseSymbolNewRow;
      var chooseSymbolNewCell;
      for(var itemKey in l_basicObject.Items)
      {
         if(index % 15 == 0)
         {
            chooseSymbolNewRow = theChooseSymbolsTable.insertRow( - 1);
         }
         chooseSymbolNewCell = chooseSymbolNewRow.insertCell( - 1);
         chooseSymbolNewCell.id = "tdChoose" + itemKey;         
         chooseSymbolNewCell.className = "cellChooseSymbol";
         chooseSymbolNewCell.innerHTML = "<input type=\"checkbox\" class=\"chkChooseSymbol\" id=\"chkChoose"+itemKey+"\" name=\""+itemKey+"\" onClick=\"G('"+itemKey+"'); \"/><a href=\"javascript : O('"+itemKey+"')\">" + itemKey + "</a>";
         index ++ ;
      }
   }   
};


function togglePanelOption() //l()
{
   if(l_flagShowPannelOption == true)
   {
      HideOption();
   }
   else
   {
      l_flagShowPannelOption = true;
      showPanelOption();
   }
}
;

function HideOption()
{
   var pnlOption = document.getElementById("pnlOption");
   pnlOption.style.display = 'none';
   l_flagShowPannelOption = false;
   var spanOption = document.getElementById("spanOption"); 
   spanOption.innerHTML = "<img src=\"images/tuychon.gif\" onclick=\"togglePanelOption(); \" style=\"pointer : hand; cursor : pointer; \">";  
}
;

function showPanelOption()
{     

  var chkShowHighestPrice = document.getElementById("chkShowHighestPrice");
  var chkShowLowestPrice = document.getElementById("chkShowLowestPrice");  
  var chkShowBuyVolume = document.getElementById("chkShowBuyVolume");
  var chkShowSellVolume = document.getElementById("chkShowSellVolume");  
  var chkShowMatchVolume = document.getElementById("chkShowMatchVolume");
  var chkShowForeignBuy = document.getElementById("chkShowForeignBuy");
  var chkShowForeignSell = document.getElementById("chkShowForeignSell");
  
   
   chkShowHighestPrice.checked = l_flagShowHighestPrice;
   chkShowLowestPrice.checked = l_flagShowLowestPrice;   
   chkShowBuyVolume.checked = l_flagShowBuyVolume;
   chkShowSellVolume.checked = l_flagShowSellVolume;   
   chkShowMatchVolume.checked = l_flagShowMatchVolume;   
   chkShowForeignBuy.checked = l_flagShowForeignBuy;
   chkShowForeignSell.checked = l_flagShowForeignSell;
   
       
   var pnlOption = document.getElementById("pnlOption");
   pnlOption.style.display = 'block';   
   var spanOption = document.getElementById("spanOption");
   spanOption.innerHTML = "<img src=\"images/an.gif\" onclick=\"togglePanelOption(); \" style=\"pointer : hand; cursor : pointer; \">";  
   var screenWidthButtons = document.forms[0].ScreenWidth; 
   var radioButton; 
   for(var i = 0; i < screenWidthButtons.length; i ++ )
   {
      radioButton = screenWidthButtons[i];
      if(radioButton.value == screenWidth)
      {
         radioButton.checked = true;
         break;
      }
   }
   var rbtNormal = document.getElementById("rbtNormal");
   var rbtScrollInfinite = document.getElementById("rbtScrollInfinite");
   var rbtScroll2Directions = document.getElementById("rbtScroll2Directions");
   var txtLineCount = document.getElementById("txtLineCount");
   var txtScrollInterval = document.getElementById("txtScrollInterval");
   var txtWaitingTime = document.getElementById("txtWaitingTime");
      
   if(l_TypeStockBoard == 0)rbtNormal.checked = true;
   else if(l_TypeStockBoard == 1)rbtScrollInfinite.checked = true;
   else rbtScroll2Directions.checked = true;   
   txtLineCount.value = l_lineCount;
   txtScrollInterval.value = l_scrollInterval;
   txtWaitingTime.value = l_waitingTime;
};

function Scroll()
{
   if(l_TypeStockBoard == 0) return;
   else if(l_TypeStockBoard == 1) l_RowIndexScroll = 1;
   var v_tableQuote = document.getElementById("tableQuote");         
   if(l_TypeStockBoard == 1)
   {
      if(l_divScroll.scrollTop >= l_divScroll.scrollHeight - l_divScroll.clientHeight)
      {           
         if(v_tableQuote.rows.length - 2 <= l_lineCount)
         return;         
         var v_replacedRow = v_tableQuote.rows[2];                  
         var v_row;
         for(var i = 0; i < l_lineCount; i ++ )
         {
            var v_row = v_tableQuote.rows[v_tableQuote.rows.length - 1];
            v_replacedRow.parentNode.insertBefore(v_row, v_replacedRow);
            v_replacedRow = v_row;
         }
         l_divScroll.scrollTop = 0;
      }
   }
   else
   {
      if(l_divScroll.scrollTop <= 0 && l_RowIndexScroll == - 1)
      {
         l_RowIndexScroll = 1;
         clearInterval(l_SetScrollIntervalID);
         l_SetScrollIntervalID = null;
         l_WaitingScrollTimeOut = self.setTimeout("WaitingScroll()", l_waitingTime);
         return;
      }
      else if(l_divScroll.scrollTop >= l_divScroll.scrollHeight - l_divScroll.clientHeight && l_RowIndexScroll == 1)
      {
         l_RowIndexScroll = - 1;
         clearInterval(l_SetScrollIntervalID);
         l_SetScrollIntervalID = null;
         l_WaitingScrollTimeOut = self.setTimeout("WaitingScroll()", l_waitingTime);
         return;
      }
   } 
   if (l_TypeStockBoard==1 || l_TypeStockBoard == 2)     
    l_divScroll.scrollTop += l_RowIndexScroll;
   else
   {
       l_RowIndexScroll = l_RowIndexScroll + l_lineCount - 1;
       if (l_RowIndexScroll + 2 > v_tableQuote.length - 1)
       {
            l_RowIndexScroll = 0;
            l_divScroll.scrollTop = 0;
       }
       else
       {
             l_RowIndexScroll = l_RowIndexScroll + l_lineCount - 1;
             if(l_RowIndexScroll + 2 > v_tableQuote.rows.length - 1)
             {
                l_RowIndexScroll = 0;
                l_divScroll.scrollTop = 0;
             }
             else l_divScroll.scrollTop = v_tableQuote.rows[l_RowIndexScroll + 2].offsetTop - 2;
       }
   }
};

function WaitingScroll()
{       
   if (l_WaitingScrollTimeOut !=null)
   clearTimeout(l_WaitingScrollTimeOut);   
   l_WaitingScrollTimeOut = null;   
   if(l_SetScrollIntervalID == null) l_SetScrollIntervalID = self.setInterval("Scroll()", l_scrollInterval);
};

function SetScroll() //L();
{  
   var tableFooter = document.getElementById("tableFooter");
   var tableScrollFooter = document.getElementById("tableScrollFooter");
   var tableFixedHeader = document.getElementById("tableFixedHeader");
   var v_tableQuote = document.getElementById("tableQuote");
   if(l_SetScrollIntervalID != null)
   {
      clearInterval(l_SetScrollIntervalID);
      l_SetScrollIntervalID = null;
   }
   if(l_WaitingScrollTimeOut != null) 
   { 
        clearTimeout(l_WaitingScrollTimeOut);
        l_WaitingScrollTimeOut = null;
   }
   SetLinksVisibility();
   if(l_TypeStockBoard == 0)
   {
      tableFixedHeader.style.display = "none";
      v_tableQuote.rows[0].style.display = "";
      v_tableQuote.rows[1].style.display = "";
      l_divScroll.style.height = "100%";
      tableFooter.style.display = "block";
      tableScrollFooter.style.display = "none";
      l_divScroll.scrollTop = 0;
   }
   else if(l_TypeStockBoard == 1 || l_TypeStockBoard == 2)
   {
      tableFixedHeader.style.display = "block";
      v_tableQuote.rows[0].style.display = "none";
      v_tableQuote.rows[1].style.display = "none";
      tableFooter.style.display = "none";
      tableScrollFooter.style.display = "block";
      l_divScroll.style.height = l_lineCount * 22 + 2 + "px";
      if(l_SetScrollIntervalID == null)
        l_SetScrollIntervalID = self.setInterval("Scroll()", l_scrollInterval);    
   }
};

function SetLinksVisibility()
{
   var tdExchangeLink = document.getElementById("tdExchangeLink");
   var rightLinks = document.getElementById("rightLinks");
   if(l_TypeStockBoard == 0)
   {
      tdExchangeLink.style.visibility = "visible";
      rightLinks.style.visibility = "visible";
   }
   else
   {
      tdExchangeLink.style.visibility = "hidden";
      rightLinks.style.visibility = "hidden";
   }
};

function CreateExtraHeaderCells(tableId)
{
   var v_tmpTable = document.getElementById(tableId);
   if (v_tmpTable.rows.length == 0)
   return;
   var theHeaderRow = v_tmpTable.rows[0];
   var v_flag = false;
   if(theHeaderRow.style.display == "none")
   {
      v_flag = true;
      theHeaderRow.style.display = "block";
   }
   var lastIndex;   
   lastIndex = 7;   
   for(var i = theHeaderRow.cells.length - 1; i >= lastIndex + 1; i -- )
   {
      theHeaderRow.deleteCell(i);
   }   
   var v_rowTemp; 
    if (l_flagShowHighestPrice == true)
   {
      v_rowTemp = theHeaderRow.insertCell( - 1);
      v_rowTemp.innerHTML = l_formatWebsiteWords.HighestPrice;
      v_rowTemp.className = "tableHeader6";
      v_rowTemp.rowSpan = 2;
      l_numberColumnTableQuote ++ ;
   }       
   if (l_flagShowLowestPrice == true)
   {
      v_rowTemp = theHeaderRow.insertCell( - 1);
      v_rowTemp.innerHTML = l_formatWebsiteWords.LowestPrice;
      v_rowTemp.className = "tableHeader6";
      v_rowTemp.rowSpan = 2;
      l_numberColumnTableQuote ++ ;
   }          
   if(l_flagShowBuyVolume == true)
   {
      v_rowTemp = theHeaderRow.insertCell( - 1);
      v_rowTemp.innerHTML = l_formatWebsiteWords.BuyVolume;
      v_rowTemp.className = "tableHeader6";
      v_rowTemp.rowSpan = 2;
      l_numberColumnTableQuote ++ ;
   }
   if(l_flagShowSellVolume == true)
   {
      v_rowTemp = theHeaderRow.insertCell( - 1);
      v_rowTemp.innerHTML = l_formatWebsiteWords.SellVolume;
      v_rowTemp.className = "tableHeader6";
      v_rowTemp.rowSpan = 2;
      l_numberColumnTableQuote ++ ;
   }  
   if(l_flagShowMatchVolume == true)
   {
      v_rowTemp = theHeaderRow.insertCell( - 1);
      v_rowTemp.innerHTML = l_formatWebsiteWords.MatchVolume;
      v_rowTemp.className = "tableHeader6";
      v_rowTemp.rowSpan = 2;
      l_numberColumnTableQuote ++ ;
   }  
   if(l_flagShowForeignBuy == true)
   {
      v_rowTemp = theHeaderRow.insertCell( - 1);
      v_rowTemp.innerHTML = l_formatWebsiteWords.ForeignBuy;
      v_rowTemp.className = "tableHeader8";
      v_rowTemp.rowSpan = 2;
      l_numberColumnTableQuote ++ ;
   }
   if(l_flagShowForeignSell == true)
   {
      v_rowTemp = theHeaderRow.insertCell( - 1);
      v_rowTemp.innerHTML = l_formatWebsiteWords.ForeignSell;
      v_rowTemp.className = "tableHeader8";
      v_rowTemp.rowSpan = 2;
      l_numberColumnTableQuote ++ ;
   }  
    v_rowTemp = theHeaderRow.insertCell( - 1);
    v_rowTemp.innerHTML = l_formatWebsiteWords.mCK;
    v_rowTemp.className = "tableHeader8";
    v_rowTemp.rowSpan = 2;
    l_numberColumnTableQuote ++ ;
    if(v_flag == true)
    theHeaderRow.style.display = "none";  
};

function GetPageTop() //Q()
{
   if(document.documentElement && document.documentElement.scrollTop)return document.documentElement.scrollTop;
   else if(document.body)return document.body.scrollTop;
   else if(window.pageYOffset)return window.pageYOffset;
   else return 0;
};

function OnScroll()
{
   var currentY = GetPageTop();
   var topY = 120;
   if(l_flagShowPannelOption == true)
   {
      var pnlOption = document.getElementById("pnlOption");      
      topY += pnlOption.offsetHeight;
   }
   if(l_flagShowPutThrough == true)
   {
      var pnlPutThrough = document.getElementById("pnlPutThrough");
      topY += pnlPutThrough.offsetHeight;
   }
   if(currentY >= topY && l_TypeStockBoard == 0)
   {
      //hien thi no  
      if(l_flagDishplayFloatingHeader == false)
      {
         l_floatingHeader.style.display = 'block';         
         //add nhung row checked vao no
         //========
         l_flagDishplayFloatingHeader = true;
      }
   }
   else
   {
      //an no          
      if(l_flagDishplayFloatingHeader == true)
      {
         l_floatingHeader.style.display = 'none';
         //xoa nhung row unchecked ra khoi no
         //========
         l_flagDishplayFloatingHeader = false;
      }
   }     
};


//************************************************************************************************************************************************************************
//
//  Hàm dùng để định dạng kích thước bảng....
//
//************************************************************************************************************************************************************************
function SetTableWidth() 
{
   var tableContainer = document.getElementById("tableContainer");
   var tableFloatingHeader = document.getElementById("tableFloatingHeader");
   var tableFixedHeader = document.getElementById("tableFixedHeader");
   var tableScrollFooter = document.getElementById("tableScrollFooter");
   if(screenWidth == "Auto")
   {
      tableContainer.width = "";
      tableFloatingHeader.width = "";
      tableFixedHeader.width = "";
      tableScrollFooter.width = "";
   }
   else
   {
      tableFixedHeader.width = screenWidth;      
      tableContainer.width = screenWidth;      
      tableFloatingHeader.width = screenWidth;
      tableScrollFooter.width = screenWidth;
   }
};

function toggleCheckAll() //A()
{
   var chkDisplayAll = document.getElementById("chkDisplayAll");
   var theChooseSymbolsTable = document.getElementById("tableChooseSymbols");
   var theSelectAllSymbolsTable = document.getElementById("tableSelectSymbols");
   theSelectAllSymbolsTable.disabled = chkDisplayAll.checked;
   theChooseSymbolsTable.disabled = chkDisplayAll.checked;
   var theChooseSymbolsTable = document.getElementById("tableChooseSymbols");
   var theRow;
   var theCell;
   var checkbox;
   if(chkDisplayAll.checked == true)
   {
      for(var i = 0; i < theChooseSymbolsTable.rows.length; i ++ )
      {
         theRow = theChooseSymbolsTable.rows[i];
         for(var j = 0; j < theRow.cells.length; j ++ )
         {
            theCell = theRow.cells[j];
            checkbox = theCell.childNodes[0];
            checkbox.disabled = true;
         }
      }
   }
   else
   {
      for(var i = 0; i < theChooseSymbolsTable.rows.length; i ++ )
      {
         theRow = theChooseSymbolsTable.rows[i];
         for(var j = 0; j < theRow.cells.length; j ++ )
         {
            theCell = theRow.cells[j];
            checkbox = theCell.childNodes[0];
            checkbox.disabled = false;
         }
      }
   }
};

function OnRowChecked(StockSymbol)
{     
   var v_checkbox = document.getElementById("chk" + StockSymbol);
   var v_row = document.getElementById("tr" + StockSymbol);
   var v_tableQuote = document.getElementById("tableQuote");
   //themmoi
   var v_tableFloatingHeader = document.getElementById("tableFloatingHeader");
   //
   var v_cellIndex;
   var v_replacedRow;     
   var replaceRowFloatingHeader;
   if(v_checkbox.checked == true)
   {
      var movedPosition = l_NumberRowChecked + l_headerRowCount;      
      if(l_flagShowSymbolSelectedOnTop == true)
      {        
         v_replacedRow = v_tableQuote.rows[movedPosition];
         v_replacedRow.parentNode.insertBefore(v_row, v_replacedRow); 
         //them moi
         //add vao tableFloatingHeader 
         //nay sinh, neu add vao tableFloatingHeader thi no se ko update duoc data
         //replaceRowFloatingHeader = v_tableFloatingHeader.rows[1];
         //replaceRowFloatingHeader.parentNode.insertBefore(v_row, replaceRowFloatingHeader.nextSibling);
         //
         if(Sys.Browser.name == "Microsoft Internet Explorer")
         {
            if(Sys.Browser.version <= 6)v_checkbox.checked = true;
         }
        selectedSymbolList.push(StockSymbol);        
        for(var i = 0; i < unselectedSymbolList.length; i ++ )
        { 
            if(unselectedSymbolList[i] == StockSymbol)
            {
            unselectedSymbolList.splice(i, 1);
            break;
            }
        }
      }
      l_NumberRowChecked ++;
    }
    else
    {   
        for(var i = 0; i < selectedSymbolList.length; i ++ )
          {
             if(selectedSymbolList[i] == StockSymbol)
             {
                selectedSymbolList.splice(i, 1);
                break;
             }
          }
          var movedPosition = - 1;          
          for(var i = 0; i < unselectedSymbolList.length; i ++ )
          {
             if(unselectedSymbolList[i] > StockSymbol)
             {
                unselectedSymbolList.splice(i, 0, StockSymbol);                
                if(l_flagShowSymbolSelectedOnTop == true)
                   {
                      movedPosition = l_NumberRowChecked + l_headerRowCount + i;
                      v_replacedRow = v_tableQuote.rows[movedPosition];
                      v_replacedRow.parentNode.insertBefore(v_row, v_replacedRow);
                   }                              
                break;
             }
         }
       l_NumberRowChecked --;     
    }        
    createCookie("selectedSymbolList", selectedSymbolList, 1000);
};

//09-10-2008 -01
function ResizeTableHeader(tableId)
{     
   if (l_flagRowCreating == true)  
   {
        return;
   }
   var v_tableQuote = document.getElementById("tableQuote");
   var v_tableResizing = document.getElementById(tableId);
   if(l_TypeStockBoard == 0)
   {
      if(v_tableResizing.tHead.rows[0].cells.length < v_tableQuote.tHead.rows[0].cells.length)return;
      for(var i = 0; i < v_tableQuote.tHead.rows[0].cells.length; i ++ )
      {
         if(v_tableQuote.tHead.rows[0].cells[i].offsetWidth != 0) v_tableResizing.tHead.rows[0].cells[i].width = (v_tableQuote.tHead.rows[0].cells[i].offsetWidth) + 'px';
         else v_tableResizing.tHead.rows[0].cells[i].width = "";
      }
      for(var i = 0; i < v_tableQuote.tHead.rows[1].cells.length;
      i ++ )
      {
         if(v_tableQuote.tHead.rows[1].cells[i].offsetWidth != 0)v_tableResizing.tHead.rows[1].cells[i].width = (v_tableQuote.tHead.rows[1].cells[i].offsetWidth) + 'px';
         else v_tableResizing.tHead.rows[1].cells[i].width = "";
      }
   }
   else
   {
      if(v_tableQuote.rows.length > 2)
      {
         if(v_tableResizing.tHead.rows[0].cells.length - 12 < v_tableQuote.rows[2].cells.length - 23)return;
         v_tableResizing.tHead.rows[0].cells[0].width = (v_tableQuote.rows[2].cells[0].offsetWidth) + 'px';
         for(var i = 1; i < 4; i ++ )
         {
            if(v_tableQuote.rows[2].cells[i].offsetWidth != 0) v_tableResizing.tHead.rows[0].cells[i].width = (v_tableQuote.rows[2].cells[i].offsetWidth) + 'px';
            else v_tableResizing.tHead.rows[0].cells[i].width = "";
         }
         for(var i = 4; i < 12; i ++ )
         {
            if(v_tableQuote.rows[2].cells[i].offsetWidth != 0)v_tableResizing.tHead.rows[1].cells[i - 4].width = (v_tableQuote.rows[2].cells[i].offsetWidth) + 'px';
            else v_tableResizing.tHead.rows[1].cells[i - 4].width = "";
         }
         v_tableResizing.tHead.rows[0].cells[6].width = (v_tableQuote.rows[2].cells[12].offsetWidth) + 'px';         
         v_tableResizing.tHead.rows[0].cells[7].width = (v_tableQuote.rows[2].cells[13].offsetWidth) + 'px';         
         for(var i = 15; i < 19; i ++ )
         {
            if(v_tableQuote.rows[2].cells[i].offsetWidth != 0)v_tableResizing.tHead.rows[1].cells[i - 5].width = (v_tableQuote.rows[2].cells[i].offsetWidth) + 'px';
            else v_tableResizing.tHead.rows[1].cells[i - 5].width = "";
         }
         for(var i = 19; i < v_tableQuote.rows[3].cells.length; i ++ )
         {
            if(v_tableQuote.rows[2].cells[i].offsetWidth != 0)v_tableResizing.tHead.rows[0].cells[i - 11].width = (v_tableQuote.rows[2].cells[i].offsetWidth) + 'px';
            else v_tableResizing.tHead.rows[0].cells[i - 11].width = "";
         }
      }
   }
   if(v_tableQuote.offsetWidth > 0)v_tableResizing.width = v_tableQuote.offsetWidth + 'px';
};

//ham dinh dang du lieu
function LanguageFormat() //T()
{         
    
};

//************************************************************************************************************************************************************************
//
//  Hàm dùng để định dạng ngôn ngữ trên bảng khi có thay đổi như: thêm cột, xóa cột, cho cột chạy....
//
//************************************************************************************************************************************************************************
function Initialize() //R()
{  
     l_formatWebsiteWords.exchangeName = "TRUNG TÂM GIAO DỊCH CHỨNG KHOÁN HÀ NỘI";
     l_formatWebsiteWords.ShowBuyVolume = "Hiển thị Khối lượng mua";
     l_formatWebsiteWords.ShowSellVolume = "Hiển thị Khối lượng bán";
     l_formatWebsiteWords.ShowBuyOrderCount = "Hiển thị Số lệnh mua";
     l_formatWebsiteWords.ShowSellOrderCount = "Hiển thị Số lệnh bán";
     l_formatWebsiteWords.ShowForeignBuy = "Hiển thị Nhà đầu tư nước ngoài mua";
     l_formatWebsiteWords.ShowForeignSell = "Hiển thị Nhà đầu tư nước ngoài bán";
     l_formatWebsiteWords.BuyVolume = "KL mua";
     l_formatWebsiteWords.SellVolume = "KL bán";
     l_formatWebsiteWords.MatchVolume = "KL Khớp";
     l_formatWebsiteWords.BuyOrderCount = "SL mua";
     l_formatWebsiteWords.SellOrderCount = "SL bán";
     l_formatWebsiteWords.ForeignBuy = "NN mua";
     l_formatWebsiteWords.ForeignSell = "NN bán";
     l_formatWebsiteWords.CurrentRoom = "NN room";               
     l_formatWebsiteWords.mCK = "CK";
     l_formatWebsiteWords.HighestPrice = "Cao";
     l_formatWebsiteWords.LowestPrice = "Thấp";
     l_formatWebsiteWords.AvrPrice = "TB";
     l_formatWebsiteWords.SumActionQuantity = "Tổng KL";
     
     l_objTdTime = document.getElementById("tdTime");
     l_objTdIndex = document.getElementById("tdIndex");
     l_objTdChange = document.getElementById("tdChange");
     l_objTdGainersLosers = document.getElementById("tdGainersLosers");
     l_objTdTotalValue  = document.getElementById("tdTotalValue");
     l_objTdTotalMarketVolume  = document.getElementById("tdTotalMarketVolume");
     l_objTdTotalValuePt  = document.getElementById("tdTotalValuePt");
     l_objTdTotalMarketVolumePt  = document.getElementById("tdTotalMarketVolumePt");
     l_objTdMarketStatus  = document.getElementById("tdMarketStatus");
     l_objTablePutThrough = document.getElementById("tablePutThrough");
     
     l_divScroll = document.getElementById("divScroll");
     l_floatingHeader = document.getElementById("floatingHeader");
};


//************************************************************************************************************************************************************************
//
//  Hàm dùng để định dạng ngôn ngữ trên bảng khi có thay đổi như: thêm cột, xóa cột, cho cột chạy....
//
//************************************************************************************************************************************************************************
function LoadCommon() 
{   
      var onTop = readCookie("onTop");
      if(onTop != null)if(onTop == "true") l_flagShowSymbolSelectedOnTop = true;
      else l_flagShowSymbolSelectedOnTop = false;
      
      if(readCookie("extraColString") != null)
      {
          extraColumnString = readCookie("extraColString");
      }
      if(readCookie("screenWidth") != null)
      {
          screenWidth = readCookie("screenWidth");
      }
        if(readCookie("tableType") != null)
        {
        l_TypeStockBoard = readCookie("tableType");
        }      
        if(readCookie("lineCount") != null)
        {
        l_lineCount = parseInt(readCookie("lineCount"));
        }
        if(readCookie("scrollInterval") != null)
        {
        l_scrollInterval = parseInt(readCookie("scrollInterval"));
        }
        if(readCookie("waitingTime") != null)
        {
        l_waitingTime = parseInt(readCookie("waitingTime"));
        } 
        if (readCookie("selectedSymbolList") != null)
        {
            selectedSymbolList = readCookie("selectedSymbolList").split(",");
        }     
  
      SetTableWidth();
      
      if(l_StartRequestTimeOutID != null)
      {
           clearTimeout(l_StartRequestTimeOutID);
           l_StartRequestTimeOutID = null;
      }
      
      GetBasicObject();
    
      l_flagShowHighestPrice = extraColumnString.charAt(0) == '1' ? true : false;
      l_flagShowLowestPrice  = extraColumnString.charAt(1) == '1' ? true : false;
      l_flagShowBuyVolume = extraColumnString.charAt(2) == '1' ? true : false;
      l_flagShowSellVolume = extraColumnString.charAt(3) == '1' ? true : false;      
      l_flagShowMatchVolume = extraColumnString.charAt(4) == '1' ? true : false;            
      l_flagShowForeignBuy = extraColumnString.charAt(5) == '1' ? true : false;
      l_flagShowForeignSell = extraColumnString.charAt(6) == '1' ? true : false;        
    
      l_flagCreateExtraHeaderCells = false;
      CreateExtraHeaderCells("tableQuote");
      CreateExtraHeaderCells("tableFixedHeader");
      CreateExtraHeaderCells("tableFloatingHeader");
      l_flagCreateExtraHeaderCells = true;
    
      SetScroll();  
      ResizeHeader();
      self.setInterval("ResizeHeader()" , 1000);
    
      SetTime();
      self.setInterval("SetTime()", 1000);
    
    if(Sys.Browser.name == "Microsoft Internet Explorer" && Sys.Browser.version <= 6)
    {
      l_floatingHeader.style.position = "absolute";
      self.setInterval("ShowFloatingHeaderIE6()", 300);
    } 
};

//************************************************************************************************************************************************************************
//
//  Hàm xác nhận các lựa chọn (option)....
//
//************************************************************************************************************************************************************************
function OK()
{   

    l_flagOK = true;
    
    var needSetScroll = false;          
    
    var chkShowHighestPrice = document.getElementById("chkShowHighestPrice");   
    var chkShowLowestPrice = document.getElementById("chkShowLowestPrice");       
    var  chkShowBuyVolume = document.getElementById("chkShowBuyVolume");      
    var  chkShowSellVolume = document.getElementById("chkShowSellVolume");                
    var chkShowMatchVolume = document.getElementById("chkShowMatchVolume");
    var chkShowForeignBuy = document.getElementById("chkShowForeignBuy");
    var chkShowForeignSell = document.getElementById("chkShowForeignSell");   
   
      l_flagShowHighestPrice = chkShowHighestPrice.checked;
      l_flagShowLowestPrice = chkShowLowestPrice.checked;      
      l_flagShowBuyVolume = chkShowBuyVolume.checked;
      l_flagShowSellVolume = chkShowSellVolume.checked;
      l_flagShowMatchVolume = chkShowMatchVolume.checked; 
      l_flagShowForeignSell = chkShowForeignSell.checked;      
      l_flagShowForeignBuy = chkShowForeignBuy.checked;      
      
      var tmp_extraColumnString = extraColumnString;   
         
      extraColumnString = "";
      extraColumnString += l_flagShowHighestPrice ? "1" : "0";  
      extraColumnString += l_flagShowLowestPrice ? "1" : "0";  
      extraColumnString += l_flagShowBuyVolume ? "1" : "0";
      extraColumnString += l_flagShowSellVolume ? "1" : "0";
      extraColumnString += l_flagShowMatchVolume ? "1" : "0";        
      extraColumnString += l_flagShowForeignBuy ? "1" : "0";      
      extraColumnString += l_flagShowForeignSell ? "1" : "0";   
   
   var rbtNormal = document.getElementById("rbtNormal");
   var rbtScrollInfinite = document.getElementById("rbtScrollInfinite");
   var rbtScroll2Directions = document.getElementById("rbtScroll2Directions");
   var txtLineCount = document.getElementById("txtLineCount");
   var txtScrollInterval = document.getElementById("txtScrollInterval");
   var txtWaitingTime = document.getElementById("txtWaitingTime");
   var tmp_typeStockB = l_TypeStockBoard;              
            
   if(rbtNormal.checked == true) l_TypeStockBoard = 0;
   else if(rbtScrollInfinite.checked == true)l_TypeStockBoard = 1;
   else l_TypeStockBoard = 2;
      
   if(tmp_typeStockB != l_TypeStockBoard ||  parseInt(txtLineCount.value) != l_lineCount || parseInt(txtScrollInterval.value) != l_scrollInterval || parseInt(txtWaitingTime.value) != l_waitingTime)
   needSetScroll = true;
   
   if (needSetScroll == true)
   {
       l_lineCount = parseInt(txtLineCount.value);
       l_scrollInterval = parseInt(txtScrollInterval.value);
       l_waitingTime = parseInt(txtWaitingTime.value);     
   }
   
   var screenWidthButtons = document.forms[0].ScreenWidth;
   var radioButton;
   for(var i = 0; i < screenWidthButtons.length; i ++ )
   {
      radioButton = screenWidthButtons[i];
      if(radioButton.checked == true)
      {
         screenWidth = radioButton.value;
         break;
      }
   }
  
   SetTableWidth(); 
   
   if (tmp_extraColumnString != extraColumnString || needSetScroll == true)
   {
        
         l_flagCreateExtraHeaderCells = false;
         CreateExtraHeaderCells("tableQuote");
         CreateExtraHeaderCells("tableFixedHeader");
         CreateExtraHeaderCells("tableFloatingHeader");
         l_flagCreateExtraHeaderCells = true;  
                  
         GetBasicObject();
   }
   
   if (needSetScroll == true)    
   {
        SetScroll();
   }
   
   createCookie("onTop", l_flagShowSymbolSelectedOnTop, 1000);      
   createCookie("screenWidth", screenWidth, 1000);      
   createCookie("extraColString", extraColumnString, 1000);
   createCookie("tableType", l_TypeStockBoard , 1000);
   createCookie("lineCount", l_lineCount, 1000);
   createCookie("scrollInterval", l_scrollInterval, 1000);
   createCookie("waitingTime", l_waitingTime, 1000);
   createCookie("selectedSymbolList", selectedSymbolList, 1000);
   HideOption();     
};


//************************************************************************************************************************************************************************
//
//  Hàm tạo cookie
//
//************************************************************************************************************************************************************************
function createCookie(name, value, days)
{
   name = TypeOfCookieName + name;
   if(days)
   {
      var date = new Date();
      date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
      var expires = "; expires=" + date.toGMTString();
   }
   else var expires = "";
   document.cookie = name + "=" + value + expires + "; path=/";
};


//************************************************************************************************************************************************************************
//
//  Hàm đọc cookie
//
//************************************************************************************************************************************************************************
function readCookie(name)
{
   name = TypeOfCookieName + name;
   var nameEQ = name + "=";
   var ca = document.cookie.split(';');
   for(var i = 0; i < ca.length; i ++ )
   {
      var c = ca[i];
      while(c.charAt(0) == ' ')c = c.substring(1, c.length);
      if(c.indexOf(nameEQ) == 0)return c.substring(nameEQ.length, c.length);
   }
   return null;
};

function GetBasicObject()
{     
   if(l_StartRequestTimeOutID != null)
   {
      clearTimeout(l_StartRequestTimeOutID);
      l_StartRequestTimeOutID = null;
   }   
   StockBoard.Service.StockBoardService.GetStockBoardBasicOject();    
};

//************************************************************************************************************************************************************************
//
//  Hàm chỉnh kích thước header của table
//
//************************************************************************************************************************************************************************
function ResizeHeader()
{     
   if(l_flagCreateExtraHeaderCells == true)
   {
      if (l_TypeStockBoard == 0)      
      ResizeTableHeader("tableFloatingHeader");
      else
      ResizeTableHeader("tableFixedHeader");
   }
};

function ShowFloatingHeaderIE6() //ah()
{
   var currentY = GetPageTop();
   var topY = 120;
   if(l_flagShowPannelOption == true)
   {
      var pnlOption = document.getElementById("pnlOption");
      topY += pnlOption.offsetHeight;
   }
   if(l_flagShowPutThrough == true)
   {
      var pnlPutThrough = document.getElementById("pnlPutThrough");
      topY += pnlPutThrough.offsetHeight;
   }
   if(currentY >= topY)
   {
      l_floatingHeader.style.top = currentY;
      if(l_flagDishplayFloatingHeader == false)
      {
         l_floatingHeader.style.display = 'block';
         l_flagDishplayFloatingHeader = true;
      }
   }
   else
   {
      if(l_flagDishplayFloatingHeader == true)
      {
         l_floatingHeader.style.display = 'none';
         l_flagDishplayFloatingHeader = false;
      }
   }
};


//09-10-2008 -05

function ShowPutThrough()
{
   var pnlOption = document.getElementById("pnlPutThrough");
   pnlOption.style.display = 'block';
   l_flagShowPutThrough = true;
   GetPutThroughObject();
   l_flagIntervalGetPutThroughObject = self.setInterval("GetPutThroughObject()", 10 * 1000);
};

function TogglePutThrough()
{
   if(l_flagShowPutThrough == true)HidePutThrough();
   else ShowPutThrough();
};

function HidePutThrough()
{
   var pnlOption = document.getElementById("pnlPutThrough");
   pnlOption.style.display = 'none';
   l_flagShowPutThrough = false;
   self.clearInterval(l_flagIntervalGetPutThroughObject);
   l_flagIntervalGetPutThroughObject = null;
};

function GetPutThroughObject()
{     
   StockBoard.Service.StockBoardService.GetPutThroughObject();
};

function DeletePutThroughTable(pTable)
{
   for(var i = pTable.rows.length - 1; i >= 0; i -- )
   {
      if(i >= 3) pTable.deleteRow(i);
   }
};

function UpdateCellPutThroughTable(cell, data, isPrice, pBasicItemInfo)
{       
    newCell.className = "normalPrice";
    cell.innerHTML = data;
    if (isPrice == true && pBasicItemInfo != null)
    {
         var fdata = parseFloat(data);      
         if(fdata == pBasicItemInfo.CeilingPrice)
         {
            cell.className = "cellCeiling"
         }
         else if(fdata == pBasicItemInfo.FloorPrice)
         {
            cell.className = "cellFloor"
         }
         else if(fdata > pBasicItemInfo.ReferencePrice)
         {
            newCell.className = "upPrice"
         }
         else if(fdata < pBasicItemInfo.ReferencePrice)
         {
            newCell.className = "downPrice"
         }
         else
         {
            newCell.className = "unchangePrice"
         }
    }    
}

function UpdatePutThroughTable(pTable, dataList)
{
   var item;
   var v_newRow;
   var v_newCell;
   var v_Fvalue;
   var v_FArrayValue;
   var v_basicItem;
   var v_basicValueArray;
   var v_basicItemInfo;
   
   for (var iRun = 0; iRun < dataList.length; iRun ++)
   {
      v_Fvalue = dataList[iRun];       
      v_FArrayValue = v_Fvalue.split(";");
      if (l_basicObject != null)
      {
          v_basicItem = l_basicObject.Items[v_FArrayValue[0]];
          v_basicValueArray = v_basicItem.V.split(";");
          v_basicItemInfo = new cls_basicItemInfo(); 
          v_basicItemInfo.CeilingPrice  = v_basicValueArray[0];
          v_basicItemInfo.FloorPrice = v_basicValueArray[1];  
          v_basicItemInfo.ReferencePrice = v_basicValueArray[2];  
      }
      else 
      {
         v_basicItemInfo = null;
      }
      //---------------------------------------------------      
      newRow = pTable.insertRow( - 1);         
      newRow.style.height = "19px";      
      //--------------------------------------
      newCell = newRow.insertCell( - 1);
      newCell.className = "cellCode";   
      newCell.innerHTML = v_FArrayValue[0]; //ma ck
      //--------------------------------------
      //gia chao mua
      newCell = newRow.insertCell( - 1);
      UpdateCellPutThroughTable(newCell, v_FArrayValue[1], true, v_basicItemInfo);       
      //--------------------------------------
      ////kl chao mua
      newCell = newRow.insertCell( - 1);
      newCell.innerHTML = v_FArrayValue[2]; 
      newCell.className = "normalVol";
      //--------------------------------------
      //gia chao ban
      newCell = newRow.insertCell( - 1);            
      UpdateCellPutThroughTable(newCell, v_FArrayValue[3], true, v_basicItemInfo);       
      //--------------------------------------
      //kl chao ban
      newCell = newRow.insertCell( - 1);
      newCell.innerHTML = v_FArrayValue[4]; 
      newCell.className = "normalVol";
   }
};

function KeyPress(e)
{   
   if(window.event)
   {
      keynum = e.keyCode;
   }
   else if(e.which)
   {
      keynum = e.which;
   }
   if(keynum == 13)
   {
      typedString = "";
      return;
   }
   var keychar = String.fromCharCode(keynum);
   var delayTime = new Date() - latestTime;
   latestTime = new Date();
   if(delayTime <= keypressDelayTime)typedString = typedString + keychar;
   else typedString = keychar;
   var g = document.getElementById("tableQuote");
   var row;
   
   typedString = typedString.toUpperCase();
   for(var i = 0; i < g.rows.length; i ++ )
   {
      row = g.rows[i];
      if(row.id.substring(2).indexOf(typedString) == 0)
      {
         if(l_objHighlightRow != null)
         {
            UnHighlight(l_objHighlightRow);
            l_objHighlightRow = null;
         }
         Highlight(row);
         l_objHighlightRow = row;
         var g = document.getElementById("tableQuote");
         window.scrollTo(0, row.offsetTop);
         break;
      }
   }
};

function OnMouseOverQuote()
{
   if(l_flagRowCreating == true) return;
   if(new Date() - latestTime <= 500)return;
   if(l_objHighlightRow != null) UnHighlight(l_objHighlightRow);
   Highlight(this);
   l_objHighlightRow = this;
};

function OnMouseOutQuote()
{
   if(l_flagRowCreating == true) return;
   UnHighlight(this);
};

function Highlight(row)
{
   var cell;
   l_rowID = row.id.substring(2);
   //for(var i = 0; i < row.cells.length; i ++ )
   for(var i = 0; i < 10; i ++ )
   {
      cell = row.cells[i];
      cell.style.backgroundColor = mouseOverBackColor;
   }
};

function UnHighlight(row)
{
   l_rowID = "";
   var symbol = row.id.substring(2);
   var isChecked = false;
   if(l_TypeStockBoard == 0)
   {
      var checkbox = document.getElementById("chk" + symbol);
      if(checkbox == null)return;
      isChecked = checkbox.checked;
   }
   var cell;
   //for(var i = 0; i < row.cells.length; i ++ )
   for(var i = 0; i < 10; i ++ )
   {
      cell = row.cells[i];
      switch(i)
      {
        
         case 0 : //ma chung khoan
         if(l_flagShowSymbolSelectedOnTop == false && isChecked == true) cell.style.backgroundColor = backColorSymbolSelected;
         else if(row.rowIndex % 2 == 0) cell.style.backgroundColor = backColorSymbol;
         else cell.style.backgroundColor = backColorSymbolR2;
         break;
         case 4 :
         case 5 :
         case 6 :
         case 7 :
         case 8 :
         case 9 :
         case 13 :
         case 14 :
         case 15 :
         case 16 :
         case 17 :
         case 18 :
         case 26 :
         case 27 :
         case 28 :
         case 29 :
         case 30 :
         if(l_flagShowSymbolSelectedOnTop == false && isChecked == true)cell.style.backgroundColor = backColor1Selected;
         else if(row.rowIndex % 2 == 0)cell.style.backgroundColor = backColor1;
         else cell.style.backgroundColor = backColor1R2;
         break;
         case 1 :
         case 2 :
         case 3 :
         case 10 :
         case 11 :
         case 12 :
         case 19 :
         case 20 :
         case 21 :
         case 22 :
         case 23 :
         case 24 :
         case 25 :
         if(l_flagShowSymbolSelectedOnTop == false && isChecked == true)cell.style.backgroundColor = backColor2Selected;
         else if(row.rowIndex % 2 == 0)cell.style.backgroundColor = backColor2;
         else cell.style.backgroundColor = backColor2R2;
         break;
         case 21 :        
         break;
         default :
         if(l_flagShowSymbolSelectedOnTop == false && isChecked == true)cell.style.backgroundColor = backColor1SelectedAlt;
         else if(row.rowIndex % 2 == 0)cell.style.backgroundColor = backColor1Alt;
         else cell.style.backgroundColor = backColor1AltR2;
         break;
      }
   }
};


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
//hey --hungud---12-10-2008
function log(message) {    
    if (!log.window_ || log.window_.closed) {
        var win = window.open("", null, "width=400,height=200," +
                              "scrollbars=yes,resizable=yes,status=no," +
                              "location=no,menubar=no,toolbar=no");
        if (!win) return;
        var doc = win.document;
        doc.write("<html><head><title>Debug Log</title></head>" +
                  "<body></body></html>");
        doc.close();
        log.window_ = win;
    }
    var logLine = log.window_.document.createElement("div");
    var v_date = new Date();
    logLine.appendChild(log.window_.document.createTextNode(v_date.getMinutes() + ":" + v_date.getSeconds() + ":" + v_date.getMilliseconds()+":"+ message));       
    log.window_.document.body.appendChild(logLine);
    log.window_.scrollBy(0, 500);     
};