var bo_ns_id = 0;
function startIeFix(){
  if(isIE()){
   document.write('<div id="bo_ns_id_' + bo_ns_id + '"><!-- ');
  }
}

function endIeFix(){
 if(isIE()){
    document.write('</div>');
    var theObject = document.getElementById("bo_ns_id_" + bo_ns_id++);
    var theCode = theObject.innerHTML;
    theCode = theCode.substring(4 ,9+theCode.indexOf("</object>"))
    document.write(theCode);
  }
}

function isIE(){
  // only for Win IE 6+
  // But not in Windows 98, Me, NT 4.0, 2000
  var strBrowser = navigator.userAgent.toLowerCase();
  if(strBrowser.indexOf("msie") > -1 && strBrowser.indexOf("mac") < 0){
   if(strBrowser.indexOf("win98") > -1 ||
       strBrowser.indexOf("win 9x 4.90") > -1 ||
       strBrowser.indexOf("winnt4.0") > -1 ||
       strBrowser.indexOf("windows nt 5.0") > -1)
    {
     return false;
    }
    return true;
  }else{
    return false;
  }
}

if( document.compatMode && document.compatMode == "CSS1Compat" ) {
document.onreadystatechange = function fixIE6AbsPos() {
if( !document.body ) { return; }
document.body.style.height = document.documentElement.scrollHeight + 'px';
}
}
/* 
- classes object stores all the class names you want to apply corners to
- assign an array of extensions to the base class name
- these will be inserted inside the base element wrapping from the inside to the outside
- ie. the outermost div will the last one created from the array
*/
var classes = new Object();
classes.clipped = ['br', 'bl', 'tr', 'tl', 'r', 'l', 'b', 't'];
classes['corner-circle'] = ['br', 'bl', 'tr', 'tl', 'bm', 'tm', 'mr', 'ml', 'r', 'l', 'b', 't'];
classes.gilt = ['br', 'bl', 'tr', 'tl', 'r', 'l', 'b', 't'];
classes.lines = ['br', 'bl', 'tr', 'tl', 'b'];

/* without firstLoad, returning to the page would result in repeated and unecessary multiple cornering */
var firstLoad = false;
function setCorners()
	{
	if (firstLoad) { return; }
	firstLoad = true;
	for (i=0;i<document.getElementsByTagName("div").length; i++)
		{
		var className = document.getElementsByTagName("div").item(i).className;
		if (classes[className])
			{
			var inner = document.getElementsByTagName("div").item(i).innerHTML;
			var classArray = classes[className];
			for (var j in classArray)
				{
				inner = divWrap(inner, className + '-' + classArray[j]);
				}
			document.getElementsByTagName("div").item(i).innerHTML = inner;
			}
		}
	}

function divWrap(value, className)
	{
	return '<div class="' + className + '">' + value + '</div>';
	}

window.onload = setCorners;
