function NiftyCheck(){
	if(!document.getElementById || !document.createElement) return(false);
	var b = navigator.userAgent.toLowerCase();
	if(b.indexOf("msie 5") > 0 && b.indexOf("opera") == -1) return(false);
	return(true);
}
/*
hmmm... in ie6, using this on a div with width set in ems is buggy.
*/
function Rounded(selector,bk,color,size) {
	if (! getElementsBySelector(selector)[0]) return(false)
	var i;
	var v = getElementsBySelector(selector);
	var l = v.length;
	for(i = 0; i < l; i++){
		var color = getbgcolor(v[i]) // added 1 jun 05 : db 
		AddTop(v[i],bk,color,size);
		AddBottom(v[i],bk,color,size);
		v[i].style.backgroundColor = 'transparent' // added 2 jun 05 : db 
	}
}

function RoundedTop(selector,bk,color,size) {
	if (! getElementsBySelector(selector)[0]) return(false)
	var i
	var v = getElementsBySelector(selector);
	for(i = 0; i < v.length; i++)
		AddTop(v[i],bk,color,size);
}

function RoundedBottom(selector,bk,color,size){
	if (! getElementsBySelector(selector)[0]) return(false)
	var i;
	var v = getElementsBySelector(selector);
	for(i = 0; i < v.length; i++)
		AddBottom(v[i],bk,color,size);
}

function AddTop(el,bk,color,size){
	var i;
	var d=document.createElement("b");
	var cn="r";
	var lim=4;
	if(size && size=="small"){ cn="rs"; lim=2}
	d.className="rtop";
	d.style.backgroundColor=bk;
	for(i=1;i<=lim;i++){
		var x=document.createElement("b");
		x.className=cn + i;
		x.style.backgroundColor=color;
		d.appendChild(x);
	}
	el.insertBefore(d,el.firstChild);
}

function AddBottom(el,bk,color,size){
	var i;
	var d=document.createElement("b");
	var cn="r";
	var lim=4;
	if(size && size=="small"){ cn="rs"; lim=2}
	d.className="rbottom";
	d.style.backgroundColor=bk;
	for(i=lim;i>0;i--){
	    var x=document.createElement("b");
	    x.className=cn + i;
	    x.style.backgroundColor=color;
	    d.appendChild(x);
	    }
	el.appendChild(d,el.firstChild);
}

function getElementsBySelector(selector){
	var i;
	var s=[];
	var selid="";
	var selclass="";
	var tag=selector;
	var objlist=[];
	if(selector.indexOf(" ")>0){  //descendant selector like "tag#id tag"
		s=selector.split(" ");
		var fs=s[0].split("#");
		if(fs.length==1) return(objlist);
		if(!document.getElementById(fs[1])) return (false)
		return(document.getElementById(fs[1]).getElementsByTagName(s[1]));
	}
	if(selector.indexOf("#")>0){ //id selector like "tag#id"
		s=selector.split("#");
		tag=s[0];
		selid=s[1];
	}
	if(selid!=""){
		objlist.push(document.getElementById(selid));
		return(objlist);
	}
	if(selector.indexOf(".") > 0){  //class selector like "tag.class"
		s = selector.split(".");
		tag = s[0];
		selclass = s[1];
	}
	//if(!document.getElementsByTagName(tag).length > 0) return (false)
	var v = document.getElementsByTagName(tag);  // tag selector like "tag"
	
	if(selclass=="") return(v);
	for(i=0;i<v.length;i++) {
		//if(v[i].className==selclass) { // revised for multiple classes  
		if((' ' + v[i].className + ' ').indexOf(' ' + selclass + ' ') != -1) {
			var x = objlist.push(v[i]);
		}
	}
	return(objlist);
}

function getbgcolor(el) {
	var bgcol = 'auto' // what should the default be? inherit? 
	if (window.getComputedStyle) {
		bgcol = window.getComputedStyle(el,null).getPropertyValue('background-color');
	} else if (document.body.currentStyle) {
		bgcol = el.currentStyle.backgroundColor;
	}
	return bgcol;//el.style.backgroundColor;
}

function niftyinit(){
	if(!NiftyCheck()) return;
	Rounded("div.rcbox");
}

if(typeof ol != "object") { ol = { fa: [window.onload], run: function() {
	for(var i in this.fa) if(typeof this.fa[i] == 'function') this.fa[i]() }}
	window.onload = function() {ol.run() }
}
ol.fa.push(niftyinit)

