/*||             ROUNDED CORNERS              V1.0 ||*/
/*|||||||||||||||||||||||||||||||||||||||||||||||||||*/
/*||                                               ||*/
/*|| IMPLIMENTATION:                               ||*/
/*||    Simply add this to the element you wish to ||*/
/*||    create add corners to:                     ||*/
/*||        rounded="inner,images/**_black.gif"    ||*/
/*||    where 'images/**_black.gif' is the GENERAL ||*/
/*||    path to the corner images. See below.      ||*/
/*||                                               ||*/
/*||                                               ||*/
/*||                   IMPORTANT:                  ||*/
/*||    You _MUST_ save your corner images using a ||*/
/*||    naming convention! Name your images like   ||*/
/*||    this:                                      ||*/
/*||       top left image name: "tl_black"         ||*/
/*||       top right image name: "tr_black"        ||*/
/*||       bottom left image name: "bl_black"      ||*/
/*||       bottom right image name: "br_black"     ||*/
/*||    WHERE: '_black' is some identifier for the ||*/
/*||     set of corner images you have created.    ||*/
/*||    NOTE: file extension does not matter, but  ||*/
/*||     it is best to use transparent gif images. ||*/
/*||                                               ||*/
/*||           PLEASE SEE THE EXAMPLE,             ||*/
/*||               IT WILL CLARIFY                 ||*/
/*||                                               ||*/
/*|||||||||||||||||||||||||||||||||||||||||||||||||||*/
/*||                                               ||*/
/*|| EXAMPLE:                                      ||*/
/*||                                               ||*/
/*||   <div id="example" rounded="inner,**.gif">   ||*/
/*||       This will be rounded!                   ||*/
/*||   </div>                                      ||*/
/*||                                               ||*/
/*||  -Here, the images are in the same folder as  ||*/
/*||      the document to get rounded corners.     ||*/
/*||                                               ||*/
/*||  -The images for this example would be named: ||*/
/*||                                               ||*/
/*||       top left image name:     "tl.gif"       ||*/
/*||       top right image name:    "tr.gif"       ||*/
/*||       bottom left image name:  "bl.gif"       ||*/
/*||       bottom right image name: "br.gif"       ||*/
/*||                                               ||*/
/*|||||||||||||||||||||||||||||||||||||||||||||||||||*/
/*||                                               ||*/
/*|| MAKE YOUR CORNER IMAGES:                      ||*/
/*||   The images you create will be placed INSIDE ||*/
/*||   the new rounded element. That said, the     ||*/
/*||   images should be a transparent round area   ||*/
/*||   on a background that is the same color as   ||*/
/*||   the background over which the new rounded   ||*/
/*||   element will be placed. For example:        ||*/
/*||               Top Left Image:                 ||*/
/*||                                               ||*/
/*||     ################################@ @ @     ||*/
/*||     ##########################@ @ @ @ @ @     ||*/
/*||     ####################@ @ @ @ @ @ @ @ @     ||*/
/*||     ################@ @ @ @ @ @ @ @ @ @ @     ||*/
/*||     ############@ @ @ @ @ @ @ @ @ @ @ @ @     ||*/
/*||     ##########@ @ @ @ @ @ @ @ @ @ @ @ @ @     ||*/
/*||     ########@ @ @ @ @ @ @ @ @ @ @ @ @ @ @     ||*/
/*||     ######@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @     ||*/
/*||     ####@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @     ||*/
/*||     ####@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @     ||*/
/*||     ##@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @     ||*/
/*||     ##@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @     ||*/
/*||     @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @     ||*/
/*||     @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @     ||*/
/*||     @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @     ||*/
/*||                                               ||*/
/*||   # = page background color                   ||*/
/*||   @ = transparent (or div background color)   ||*/
/*||                                               ||*/
/*||   Lastly, the image size will become the      ||*/
/*||   corner radius, 1:1.                         ||*/
/*||                                               ||*/
/*|||||||||||||||||||||||||||||||||||||||||||||||||||*/
/*|||                                             |||*/
/*||     copyright 2007, Jason Miller Design       ||*/
/*|||                                             |||*/
/*|||||||||||||||||||||||||||||||||||||||||||||||||||*/

window.onload = roundedcorners;
var jm_cimages = new Array();

function roundedcorners() {
	//get elements to be rounded:
    var elements = new Array();
	var divs = new Array();
    divs = document.getElementsByTagName('div');
    for(var t=0; t<divs.length; t++)
        if(divs[t].getAttribute('rounded') != null)
            elements[elements.length] = divs[t];
	//here we go:
	if(elements.length > 0) {
		var corners = new Array('tl','tr','bl','br');
		for(var i=0; i<elements.length; i++) {
			style = elements[i].getAttribute('rounded').split(',')[0];
			image = elements[i].getAttribute('rounded').split(',')[1];
			jm_cimages[i] = new Array();
			for(var q=0; q<corners.length; q++) {
				c = document.createElement('div');
				c.setAttribute("class","jasonmiller_rounded_corners--www.jasonmiller.co.nr!");
				c.setAttribute("id","jasonmiller_rounded_corner_"+i+"_"+q);
				c.style.display = "inline";
				c.style.position = "absolute";
				jm_cimages[i][q] = new Image();
				jm_cimages[i][q].src = image.replace('**',corners[q]);
				c.style.background = "url('"+jm_cimages[i][q].src+"')";
				c.style.width = jm_cimages[i][q].width+"px";
				c.style.height = jm_cimages[i][q].height+"px";
				setTimeout("document.getElementById('jasonmiller_rounded_corner_"+i+"_"+q+"').style.width = jm_cimages["+i+"]["+q+"].width+'px';",100);
				setTimeout("document.getElementById('jasonmiller_rounded_corner_"+i+"_"+q+"').style.height = jm_cimages["+i+"]["+q+"].height+'px';",100);
				c.style.zIndex = "0";
				q<2? c.style.top = "0px":c.style.bottom = "0px";
				if(q%2==0)	{ c.style.left = "0px"; c.style.clear = "right"; c.style.align = "left";	}
				else		{ c.style.right = "0px"; c.style.clear = "left"; c.style.align = "right";	}
				elements[i].appendChild(c);
			}
		}
		return true;
	}
	else
		return false;
}