/*||               ROUNDED CORNERS            V2.0 ||*/
/*|||||||||||||||||||||||||||||||||||||||||||||||||||*/
/*||                                               ||*/
/*|| IMPLIMENTATION:                               ||*/
/*||    Simply add this to the element you wish to ||*/
/*||    create add corners to:                     ||*/
/*||            rounded2="#DDD,#003;tl,tr,bl,br"   ||*/
/*||                                               ||*/
/*||    Where: #DDD is the color behind the newly  ||*/
/*||           rounded div element, and #003 is    ||*/
/*||           the background color of the div.    ||*/
/*||           After the semicolon, you can tell   ||*/
/*||           the script which corners to round,  ||*/
/*||           or leave out the semicolon onward   ||*/
/*||           to round all four corners.          ||*/
/*||                                               ||*/
/*|||||||||||||||||||||||||||||||||||||||||||||||||||*/
/*||                                               ||*/
/*|| EXAMPLE:                                      ||*/
/*||       A red div on a black background         ||*/
/*||          with top corners rounded:            ||*/
/*||                                               ||*/
/*||  <div id="ex" rounded2="black,red;tl,tr">     ||*/
/*||       This will be rounded!                   ||*/
/*||   </div>                                      ||*/
/*||                                               ||*/
/*|||||||||||||||||||||||||||||||||||||||||||||||||||*/
/*|||                                             |||*/
/*||     copyright 2007, Jason Miller Design       ||*/
/*|||                                             |||*/
/*|||||||||||||||||||||||||||||||||||||||||||||||||||*/

window.onload = corners2;
function corners2() {
    var elements = new Array();
	var divs = new Array();
    divs = document.getElementsByTagName('div');
    for(var t=0; t<divs.length; t++)
        if(divs[t].getAttribute('rounded2') != null)
            elements[elements.length] = divs[t];
	//here we go:
	if(elements.length > 0) {
		for(i in elements) {
			var div = elements[i];
			var bg, fg;
			var toRound = new Array("tl","tr","bl","br");
			bg = div.getAttribute('rounded2').split(',')[0];
			fg = div.getAttribute('rounded2').split(',')[1];
			if(div.getAttribute('rounded2').indexOf(";") > -1)
				toRound = div.getAttribute('rounded2').split(';')[1].split(',');
			for(w in toRound) {
				c = document.createElement("div");
				c.style.display = "inline";
				c.style.position = "absolute";
				c.style.background = fg;			//yes, opposite
				if(toRound[w].charAt(0)=='t') {c.style.top="0px"; c.style.borderTop="1px solid "+bg; }
				else {c.style.bottom="0px"; c.style.borderBottom="1px solid "+bg; }
				if(toRound[w].charAt(1)=='l') {c.style.left="0px";  c.style.borderLeft="1px solid "+bg; }
				else {c.style.right="0px"; c.style.borderRight="1px solid "+bg; }
				c.style.width = "2px";
				c.style.height = "2px";
				c.style.zIndex = "inherit";
				elements[i].appendChild(c);
			}
		}
		return true;
	}
	else
		return false;
}