
/*****************************************************************
** 组件名: SimpleGrid
**			
** 描 述:  Web组件
**..................................................................................................................
** 类 名:  SimpleGrid                    --主类
** 构 造:  SimpleGrid(id,cols,rows,width,height,cellspacing,cellpadding,border)
**            (参数) id                  --注册组件的ID编号(唯一)  
**            (参数) cols               --组件的列数
**            (参数) rows              --组件的最小行数
**            (参数) width             --组件的宽度
**            (参数) height            --组件的高度
**            (参数) cellspacing      --组件的cellspacing
**            (参数) cellpadding      --组件的cellpadding
**            (参数) border            --组件的border

** 方 法:  AddGridItem (aGridItem,align,valign)        --从左到右增加一单元格cell
**            (参数) aGridItem        --单元格cell的内容
**            (参数) align               --单元格cell的align
**            (参数) valign             --单元格cell的valign
**...................................................................................................................	
** 作 者:  仇华华    
** 日 期:  2005-1-1
** 修 改:  
** 日 期:  
** 版 本:
** 示 例:
<完整示例>

</完整示例>

<局部示例>

</局部示例>
*****************************************************************/
function SimpleGrid(id,cols,rows,width,height,cellspacing,cellpadding,border)
{
  if(width==null||width=="") width="";
  if(height==null||height=="") height="";
  if(cellspacing==null||cellspacing=="") cellspacing="";
  if(cellpadding==null||cellpadding=="") cellpadding="";
  if(border==null||border=="") border="0";

  this.Width=width;
  this.Height=height;
  this.Cellspacing=cellspacing;
  this.Cellpadding=cellpadding;
  this.Border=border;

  this.ID=id;
  this.Cols=cols;
  this.Rows=rows;
  this.AddGridItem=SimpleGrid.AddGridItem;
  
  var table = '<table border="' +this.Border+ '"'
            + ' id="SimpleGrid_' +this.ID+ '"'
            + ' cellspacing="' +this.Cellspacing+ '"'
            + ' cellpadding="' +this.Cellpadding+ '"'
            + ' width="' +this.Width+ '"'
            + ' height="' +this.Height+ '">\n';

  for (var x=0; x<this.Rows; x++) {
    table += " <tr>\n";
    for (var y=0; y<this.Cols; y++) {
      table += "  <td></td>\n";
    }
    table += " </tr>\n";
  }
  table += "</table>\n";
  
  document.write(table);
  
   this._ItemCount = "0";  
   this.ItemCount = SimpleGrid.ItemCount;
}

SimpleGrid.ItemCount=function ()
{
   return this._ItemCount;
}

SimpleGrid.AddGridItem=function (aGridItem,align,valign)
{
     if(align==null||align=="") align="center";
     if(valign==null||valign=="") valign="middle";   
     //
     var Number=this._ItemCount; 
     //
     var obj=document.getElementById("SimpleGrid_"+this.ID); 
     var _rows=obj.rows.length ;     
     if(parseInt(Number / this.Cols) +1> _rows)
     {
        obj.insertRow(_rows);
        for(var i=0;i<this.Cols;i++)
        {
          obj.rows[_rows].insertCell(i); 
        }
     }     
     //
     var TB=document.getElementById("SimpleGrid_"+this.ID);
     var r=parseInt(Number / this.Cols);
     var c=parseInt(Number % this.Cols);          
     TB.rows[r].cells[c].innerHTML=aGridItem; 
     TB.rows[r].cells[c].noWrap=true;
     TB.rows[r].cells[c].align=align;
     TB.rows[r].cells[c].vAlign=valign;    
      //  
     var num=this._ItemCount;
     num=parseInt(num)+1;
     this._ItemCount=num;       
}


/*css*/
    document.writeln("<style>");
    document.writeln("a:link, a:visited	{ text-decoration: none; color: #003366 }");
    document.writeln(" a:hover			{ text-decoration: underline }");
    document.writeln(" body			{ 	scrollbar-face-color: #EDEDED;scrollbar-highlight-color: #E6E6E6;scrollbar-shadow-color: #FFFFFF;scrollbar-3dlight-color: #FFFFFF;scrollbar-arrow-color: #7788A0;scrollbar-track-color: #F5F5F5;scrollbar-darkshadow-color: #242930}");         
    document.writeln(" table			{ font-family: Tahoma, Verdana; color: #333333; font-size: 12px }");
    document.writeln(" textarea, input, object	{ font-family: Tahoma, Verdana; font-size: 12px;  color: #000000; font-weight: normal; background-color: #F8F8F8 }");
    document.writeln(" select			{ font-family: Arial; font-size: 11px;  color: #000000; font-weight: normal; background-color: #F8F8F8 }");
    document.writeln(" .nav			{ font-family: Tahoma, Verdana; font-size: 12px; font-weight: bold }");
    document.writeln(" .navtd			{ font-family: Tahoma, Verdana; font-size: 12px; color: #FFFFFF; text-decoration: none }");
    document.writeln(" .header			{ font-family: Tahoma, Verdana; font-size: 11px; color: #333333; font-weight: bold; background-color: #BBC7D7 }");
    document.writeln(" .category		{ font-family: Arial; font-size: 11px; color: #000000 }");
    document.writeln(" .multi			{ font-family: Arial; font-size: 11px; color: #003366; }");
    document.writeln(" .smalltxt		{ font-family: Arial; font-size: 11px }");
    document.writeln(" .mediumtxt		{ font-family: Tahoma, Verdana; font-size: 12px; color: #000000 }");
    document.writeln(" .bold			{ font-weight: bold }");
    document.writeln("</style>");  
//----------------------------------
