/**
 * jQuery plugin cornerise 
 * Allows rounded corners to be applied to IE
 * @version 0.3
 * @author Ben Boyle <http://inspire.server101.com/ben/>
 * @author Andrew Ramsden <http://irama.org/>
 * @see <http://irama.org/web/dhtml/cornerise/>
 * 
 * @param String whichCorners A string indicating which corners to apply corner to.
 *        Default of null, '' or undefined is the same as '1234' (all corners).
 *        Depending on CSS used, '1' is usually top-left corner, and proceed clockwise till '4' (bottom left).
 *        Any combination of corners can be specified. Example '23' means top-right and bottom-right corners.
 *        Without CSS, corners are added as <span>s which should not affect layout too much.
 * @example <code>$('.rounded').cornerise('13');</code> Will apply a top-left and bottom-right corner to any
 *          element with class="rounded".
 */


(function($) {// start closure

$.fn.cornerise = function(whichCorners) {
	$(this).each(function() {
		$(this).addClass('cornerised');
		applyCorners.apply(this, [whichCorners]);
	});
};

applyCorners = function (whichCorners) {
	
	if (
		typeof whichCorners == 'undefined' ||
		whichCorners == null ||
		whichCorners  == ''
	) {
		whichCorners = '1234';
	}
	
	// apply the specified corners ("p" for "presentation")
	if (whichCorners.indexOf('1') != -1) {
		$(this).prepend('<span class="p p1"></span>');
	}
	if (whichCorners.indexOf('2') != -1) {
		$(this).prepend('<span class="p p2"></span>');
	}
	if (whichCorners.indexOf('3') != -1) {
		$(this).append('<span class="p p3"></span>');
	}
	if (whichCorners.indexOf('4') != -1) {
		$(this).append('<span class="p p4"></span>');
	}
};

})(jQuery); // end closure
