// roundTab object constructor
function roundTab(radius)
{ this.margns = new Array();
  this.fgclrs = new Array();
  this.bgclrs = new Array();
  this.radius=radius;
  this.makeRound  = roundTab_makeRound;
  this.calcWidths = roundTab_calcWidths;
  this.roundTabs =  roundTab_roundTabs;
  this.addColor = roundTab_addColor;
  this.calcWidths();
}
// roundtab methods
function roundTab_addColor( fg, bg )
{ var len = this.fgclrs.length;
  this.fgclrs[len]=fg;
  if( bg ) this.bgclrs[len]=bg;
  else  this.bgclrs[len]=fg;
}
function roundTab_roundTabs( className )
{ var clrMax = this.fgclrs.length;
  var divCnt = 0;
  var allDivs = document.getElementsByTagName( "div" );
  for( var idx = 0; idx < allDivs.length; idx++ )
  { if( allDivs[idx].className == className )
    { var clrIdx = divCnt%clrMax;
      this.makeRound ( allDivs[idx],this.fgclrs[clrIdx],this.bgclrs[clrIdx] );
      divCnt++;
    }
  } 
}
function roundTab_calcWidths()
{ var i;
  for(i=0; i<=this.radius; i++ )
  { var y = this.radius-i;
    var margin = Math.sqrt( Math.pow(this.radius,2)-Math.pow(y,2) );
    this.margns[i]=Math.round(this.radius-margin);
  }
}
function roundTab_makeRound (dv,brdrClr,bckClr)
{ var i;
  var a = dv.innerHTML;
  dv.innerHTML = "";
  var upMargin=this.margns[0]-2;
  var tDv = document.createElement("div");
  tDv.style.marginRight = (upMargin)+"px";
  tDv.style.marginLeft  = (upMargin)+"px";
  tDv.style.marginBottom  = "0px";
  tDv.style.borderWidth = "0px";
  tDv.style.borderBottomWidth = "1px";
  tDv.style.borderColor = brdrClr;
  tDv.style.backgroundColor = bckClr;
  dv.appendChild(tDv);
  
  for(i=1;i<=this.radius;i++)
  { tDv=document.createElement("div");
    tDv.style.marginRight = this.margns[i]+"px";
    tDv.style.marginLeft = this.margns[i]+"px";
    tDv.style.borderWidth = "2px";
    tDv.style.borderTopWidth = "0px";
    tDv.style.borderBottomWidth = "0px";
    tDv.style.borderColor = brdrClr;
    tDv.style.backgroundColor = bckClr;
    img = document.createElement("img");
    img.src="/pg_images/blank.gif";
    tDv.appendChild(img);
    if( i == this.radius )
    { var radialAdjust=Math.round(this.radius/2);
      tDv.style.verticalAlign="text-top";
      tDv.style.paddingBottom=radialAdjust+"px";
      tDv.style.paddingTop="0px";            
      tDv.className="inTab";
    }
    dv.appendChild(tDv);
  }
  tDv.innerHTML=a;
}


