function RoundCornersByID (ID, Radius)
{
// -----------------------
var SourceDiv;
var Border;
var NewDiv;
var Index;
var DistOuter;
var DistInner;
var Margin;
var Width;
var NewElem;
// -----------------------
SourceDiv = document.getElementById(ID);
// -----------------------
if (SourceDiv.currentStyle)
{
Border    = parseInt (SourceDiv.currentStyle.borderWidth);
}
else if (window.getComputedStyle)
{
Border    = parseInt (window.getComputedStyle(SourceDiv, null).getPropertyValue('border-top-width'));
}
else
{
Border    = 0;
}
// -----------------------
SourceDiv.style.padding = '0px';
SourceDiv.style.borderStyle = 'none';
SourceDiv.style.backgroundColor = 'transparent';
// -----------------------
NewDiv = document.createElement('div');
NewDiv.id = 'Container_Ignore';
NewDiv.className = SourceDiv.className;
NewDiv.style.width = 'auto';
NewDiv.style.height = 'auto';
NewDiv.style.margin = '0px';
NewDiv.style.borderTopStyle = 'none';
NewDiv.style.borderBottomStyle = 'none';
// -----------------------
NewDiv.innerHTML = SourceDiv.innerHTML;
SourceDiv.innerHTML = '';
// -----------------------
for (Index = 0; Index < Radius; Index++)
{
DistOuter = Math.round (Math.sqrt( Math.pow(Radius, 2) - Math.pow(Radius - Index, 2) ) );
if (Math.pow(Radius - Border, 2) - Math.pow(Radius - Index, 2) >= 0)
{
DistInner = Math.round (Math.sqrt( Math.pow(Radius - Border, 2) - Math.pow(Radius - Index, 2) ) );
}
else
{
DistInner = 0;
}
if (DistInner < 0)
{
DistInner = 0;
}
Margin = Radius - DistOuter + 1;
Width = DistOuter - DistInner;
NewElem = document.createElement('b');
NewElem.innerHTML = '';
NewElem.innerText = '';
NewElem.className = SourceDiv.className;
NewElem.style.display = 'block';
NewElem.style.height = '1px';
NewElem.style.width = 'auto';
NewElem.style.lineHeight = '0px';
NewElem.style.padding = '0px';
NewElem.style.fontSize = '0px';
NewElem.style.overflow = 'hidden';
NewElem.style.margin = '0px ' + Margin + 'px';
NewElem.style.borderTopWidth = '1px';
NewElem.style.borderLeftWidth = Width + 'px';
NewElem.style.borderRightWidth = Width + 'px';
NewElem.style.borderBottomStyle = 'none';
if (Index < Border)
{
NewElem.style.borderLeftStyle = 'none';
NewElem.style.borderRightStyle = 'none';
NewElem.style.height = '0px';
}
else
{
NewElem.style.borderTopStyle = 'none';
}
SourceDiv.appendChild (NewElem);
}
// -----------------------
SourceDiv.appendChild (NewDiv);
// -----------------------
for (Index = Radius - 1; Index >= 0; Index--)
{
DistOuter = Math.round (Math.sqrt( Math.pow(Radius, 2) - Math.pow(Radius - Index, 2) ) );
if (Math.pow(Radius - Border, 2) - Math.pow(Radius - Index, 2) >= 0)
{
DistInner = Math.round (Math.sqrt( Math.pow(Radius - Border, 2) - Math.pow(Radius - Index, 2) ) );
}
else
{
DistInner = 0;
}
if (DistInner < 0)
{
DistInner = 0;
}
Margin = Radius - DistOuter + 1;
Width = DistOuter - DistInner;
NewElem = document.createElement('b');
NewElem.innerHTML = '';
NewElem.innerText = '';
NewElem.className = SourceDiv.className;
NewElem.style.display = 'block';
NewElem.style.height = '1px';
NewElem.style.width = 'auto';
NewElem.style.lineHeight = '0px';
NewElem.style.padding = '0px';
NewElem.style.fontSize = '0px';
NewElem.style.overflow = 'hidden';
NewElem.style.margin = '0px ' + Margin + 'px';
NewElem.style.borderTopWidth = '1px';
NewElem.style.borderLeftWidth = Width + 'px';
NewElem.style.borderRightWidth = Width + 'px';
NewElem.style.borderBottomStyle = 'none';
if (Index < Border)
{
NewElem.style.borderLeftStyle = 'none';
NewElem.style.borderRightStyle = 'none';
NewElem.style.height = '0px';
}
else
{
NewElem.style.borderTopStyle = 'none';
}
SourceDiv.appendChild (NewElem);
}
}
var RoundCornersIDCount = 0;
function RoundCornersByClass (Class, Radius)
{
var Index;
var DivList;
DivList = document.getElementsByTagName('div');
for (Index = 0; Index < DivList.length; Index++)
{
if ((DivList[Index].className == Class) &&
(DivList[Index].id != 'Container_Ignore'))
{
if (DivList[Index].id == '')
{
RoundCornersIDCount++;
DivList[Index].id = 'RoundCornersDiv_' + RoundCornersIDCount;
}
RoundCornersByID(DivList[Index].id, Radius);
}
}
}
