/**
 *
 * Roundbox
 *
 * 2009.01 /mg
 *
 *
 *
 * Adds rounded corners to the specified div(s).
 *
 *
 * Params:		- any jQuery selector that matches one or more divs.
 *
 * Requires:	- 4 corner images (roundbox_tl.*,roundbox_tr.*,roundbox_bl.*,roundbox_br.*)
 *				- jQuery
 *
*/



/* USER CUSTOMIZATION
-------------------------------------------------------------------------------------*/
var boxColour =		"#eaeaea";			// colour of box (should match corner images)
var boxPadding =	"10px 20px";		// box padding
var cornerSize =	"10px";				// size of corners (should match corner images)
var pathToImages =	"roundbox/";		// path to the corner images
var fileExt =		"png";				// file extension of the corner images
//-------------------------------------------------------------------------------------



/* DO NOT MODIFY ANYTHING BELOW THIS LINE (OR DO SO AT YOUR OWN RISK!)
-------------------------------------------------------------------------------------*/
function Roundbox(targets) {

	// Define CSS styles.
	var css_roundbox =			{ padding: boxPadding }
	var css_roundboxContainer =	{ "background-color": boxColour }
	var css_roundboxTop =		{ background: "url('" + pathToImages + "roundbox_tr." + fileExt + "') no-repeat top right" }
	var css_roundboxTopDiv =	{ background: "url('" + pathToImages + "roundbox_tl." + fileExt + "') no-repeat top left"	}
	var css_roundboxBottom =	{ background: "url('" + pathToImages + "roundbox_br." + fileExt + "') no-repeat bottom right" }
	var css_roundboxBottomDiv =	{ background: "url('" + pathToImages + "roundbox_bl." + fileExt + "') no-repeat bottom left" }
	var css_common =			{
									width: "100%",
									height: cornerSize,
									"font-size": "1px"
								}

	// Create elements.
	$(targets).each(function() {
		$(this).css(css_roundbox);
		$(this).wrapAll(
			'<div class="roundbox-container"></div>'
		).before(
			'<div class="roundbox-top"><div></div></div>'
		).after(
			'<div class="roundbox-bottom"><div></div></div>'
		);
	});
	
	// Apply CSS styles.
	$("div.roundbox-container").css(css_roundboxContainer);
	$("div.roundbox-top").css(css_roundboxTop).css(css_common);
	$("div.roundbox-top div").css(css_roundboxTopDiv).css(css_common);
	$("div.roundbox-bottom").css(css_roundboxBottom).css(css_common);
	$("div.roundbox-bottom div").css(css_roundboxBottomDiv).css(css_common);
}
