$(function(){
	/* Sliding boxes */
	$('.box h2, .sidebar .box h3').each(function(){
		var  $header = $(this),
			$box = $(this).parent('.box'),
			$bottom = $box.children('.bottom'),
			$collapse = $('<span class="collapse">Collapse/Expand</span>').appendTo($header);
		
		if ($box.hasClass('hide')) {
			$collapse.toggleClass('change');
			$bottom.css({ display: 'none' });
		}
		
		$header.css({
			cursor: 'pointer'
		}).click(function(event){
			if ($(event.target).is('a')) return true;
			
			$collapse.toggleClass('change');
			$bottom.slideToggle();
		});
	});
	
	/* Disappearing messages */
	$('.message').css({ cursor: 'pointer' }).click(function(){ $(this).slideUp(); });
	
	/* Table striping */
	$('tbody tr:odd').addClass('alt');
	
	/* WYSIWYG editor */
	$('.wysiwyg').each(function(){
		var  $this = $(this),
			$remove = $('<span>(<a href="#">remove WYSIWYG editor?</a>)</span>').appendTo($this.siblings('label')).find('a').click(function(){
				$.sMarkUpRemove($this);
				$remove.remove();
				return false;
			}).end();
		
		$this.sMarkUp('html', 300);
	});
	
});