function roundCorners()  // identify the parent div of the targeted image, then the min width 
{
	/*roundedImages('pagePhoto', 575);         // all pages - page photo
	roundedImages('rightMasterCol2', 150);     // all pages - callouts
	roundedImages('categoryContent', 70);    // category pages only - content
	roundedImages('spotlight', 168);  */       // home page only - spotlight content
	//alert('start');
	var bDivs = $$('div.borderedCorner');
	var rDivs = $$('div.roundedCorner');
	for(i = 0; i < rDivs.length; i++){
		roundedDivs(rDivs[i],false);
	}
	for(var i = 0; i < bDivs.length; i++){
		roundedDivs(bDivs[i],true);
	}
	
	//alert('done');
	
}

function roundedDivs(target, bordered) {
	var content = $(target);
	if(content == null){
		return;
	}
	var h = content.getHeight();
	var wrapper = document.createElement('div');
	wrapper.className = 'cornerWrapper';
	//alert(content.offsetWidth);
	var divWidth = content.offsetWidth;
	wrapper.style.width = divWidth + 'px';

	content.parentNode.replaceChild(wrapper, content);
	var rb = document.createElement('div');
	if(bordered){
		rb.className = 'brb';
	} else {
		rb.className = 'rb';
	}
	
	rb.style.top = (h-11) + "px";
	wrapper.appendChild(rb);
	wrapper.appendChild(content);
}
	
function roundedImages(target, minWidth) { 
 var content = document.getElementById(target);
 if (content == null)
 {
	 return;
 }
 var imgs = content.getElementsByTagName('img');
 for (var i = 0; i < imgs.length; i++) {         // start loop 
   var wrapper = document.createElement('div');  // Create the outer-most div (wrapper)
   wrapper.className = 'wrapper';                // Give it a classname - wrapper
   var imgWidth = imgs[i].width;
   if (imgWidth < minWidth)
   {
	continue;
   }
   wrapper.style.width = imgWidth+'px';           // give wrapper the same width as the current img
   var original = imgs[i];                       // take the next image  
   /* Swap out the original img with our wrapper div (we'll put it back later) */
   if(original.parentNode.tagName.toUpperCase()=='A') original = original.parentNode; // if you link the image this will help the script find the right parent wrapper
   original.parentNode.replaceChild(wrapper, original);
   // IE crash fix - c/o Joshua Paine - http://fairsky.us/home


   /* Create the four other inner nodes and give them classnames */
   var tl = document.createElement('div');
   tl.className = 'tl';
   var br = document.createElement('div');
   br.className = 'br';
   var tr = document.createElement('div');	
   tr.className = 'tr';
   var bl = document.createElement('div');
   bl.className = 'bl';
   /* Glue the nodes back inside the wrapper */
   wrapper.appendChild(tl);
   wrapper.appendChild(tr);
   wrapper.appendChild(bl);
   wrapper.appendChild(br);
   /* And glue the img back in after the divs */
   
   wrapper.appendChild(original);
 }
}
/* Run the function once the page has loaded: */


