var el_c = ['rm-sb_top','rm-sb_tl','rm-sb_tr','rm-sb_left','rm-sb_right','rm-sb_bottom','rm-sb_bl','rm-sb_br'];
var el_cache = [];
function createShadedBox( cn ){
	 var c = $(cn);
	 if( !c || !c.parentNode ) return;

	 var bbox = document.createElement('div');
	 bbox.id = bbox.className = "rm-shadedbox";	 
	 for(i=(el_c.length-1);i>=0;i--){
		  var el = document.createElement('div');
		  el.className = el_c[i];
		  el_cache[el_cache.length] = el;
		  bbox.appendChild(el);
	 }
	 c.parentNode.insertBefore(bbox,c);
	 bbox.appendChild(c);	 
	 updateShadedBox(c, bbox);
}

function updateShadedBox(c, bbox){
	if( !c ) return false;
	
	if( !bbox && !(bbox = $("rm-shadedbox"))) return false;
	
   	bbox.style.height = (c.offsetHeight + 34) + 'px';
	bbox.style.width = (c.offsetWidth + 34) + 'px';
   
	var el_array = el_cache;

    for(i=(el_array.length-1);i>=0;i--){
		  if( el_array[i].className == 'rm-sb_left' || el_array[i].className == 'rm-sb_right' ){
		    el_array[i].style.height = c.offsetHeight + 'px';
		  } else if ( el_array[i].className == 'rm-sb_top' || el_array[i].className == 'rm-sb_bottom' ){
		    el_array[i].style.width = c.offsetWidth + 'px';
		  }
	}
}