$.fn.roller = function(open, close, swap){
	var elem = this;
	strOpen = (open == undefined) ? 'Opna' : open;
	strClose = (close == undefined) ? 'Loka' : close;
	doSwap = (swap == undefined || swap == 'true' ) ? true : false;
	
	/* Add the roller button */
	if (undefined !== elem) {
		var boxTitle = elem.find('.boxTitle');
		
		boxTitle.append('<small>'+strOpen+'</small> <a href="#" class="roll"></a>');

		/* Attach the click event to the button */
		boxTitle.live('click', function(){
			var box = $(this).closest('.box');
			var roll = $(this).find('.roll');
			var small = $(this).find('small');

			box.find('.wrapper').slideToggle('slow');
			if (roll.hasClass('minus')) {
				roll.removeClass('minus');
				if (doSwap == true) {
					small.html(strOpen);
				}
			}
			else {
				roll.addClass('minus');
				if (doSwap == true) {
					small.html(strClose);
				}
			}
			return false;
		});
	}
}

$(function(){
	/* Object of the boxes that will be rolled */
	$('.roller', '#grid').roller();
});
