$(document).ready(function(){
	tabs = $(".tabbed .tab li");
	$(".tabbed .tab li").click(function(){
		// underline tab
		$(this).siblings().css("border-bottom", "1px solid #ccc");
		$(this).css("border-bottom", "1px solid white");
		// show body
		idx = $(".tabbed .tab li").index(this);
		$(".tabbed .body li").css("display", "none");
		$(".tabbed .body li").eq(idx).css("display", "block");
		
	});

    $('textarea[maxlength]').keyup(function(){
		var max = parseInt($(this).attr('maxlength'));
		if($(this).val().length > max){
			$(this).val($(this).val().substr(0, $(this).attr('maxlength')));
		}
		$(this).parent().find('.charsRemaining').html('You have ' + (max - $(this).val().length) + ' characters remaining');
	});
});
tinyMCE.init({
	theme : "advanced",
	skin : "o2k7",
	mode : "specific_textareas",
	editor_selector : "content_summary",
	plugins : "paste",
	paste_auto_cleanup_on_paste : true,
	content_css : "/resources/css/content.css",
	
	theme_advanced_buttons1 : "bold,italic,underline,|,link,unlink",
	theme_advanced_buttons2 : "",
	theme_advanced_buttons3 : "",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
});
tinyMCE.init({
	mode : "specific_textareas",
	editor_selector : "comment_body",
	theme : "advanced",
	skin : "o2k7",
	plugins : "paste",
	paste_auto_cleanup_on_paste : true,
	paste_remove_styles : true,
	content_css : "/resources/css/content.css",
	
	theme_advanced_buttons1 : "bold,italic,underline,|,link,unlink,|,bullist,numlist,|,outdent,indent",
	theme_advanced_buttons2 : "",
	theme_advanced_buttons3 : "",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
});
tinyMCE.init({
	theme : "advanced",
	skin : "o2k7",
	mode : "specific_textareas",
	editor_selector : "mceEditor",
	plugins : "table,advhr,preview,media,paste,nonbreaking,xhtmlxtras",
	paste_auto_cleanup_on_paste : true,
	content_css : "/resources/css/content.css",
	
	theme_advanced_buttons1 : "cut,copy,paste,cleanup,|,bullist,numlist,|,outdent,indent,|,bold,italic,underline,strikethrough,|,removeformat,|,justifyleft,justifycenter,justifyright,justifyfull,|,blockquote,|,preview,|,charmap",
	theme_advanced_buttons2 : "undo,redo,|,link,unlink,|,tablecontrols,visualaid,|,sub,sup,|,hr,advhr",
	theme_advanced_buttons3 : "",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
});