$(function(){
	$("input").each(function(){
		if($(this).attr('type') == 'submit' || $(this).attr('type') == 'button') {
			$(this).button();
		}
	});
	/*
	// 100% HEIGHT
	var c = $("#wrapper").css('height').split('px');
	c = parseInt(c);
	if(c < 480) {
		$("#wrapper").css({height:"100%",paddingBottom:"10px"});
	}
	*/
	// 100% BODY ON NO SIDEBAR
	if($("#body-right .block").length == 0){
		$("#body-right").css('width','0px');
		$("#body-left").css('width','100%');
	}
	$("textarea").each(function(){
		if(!$(this).hasClass('nowysiwyg')) {
			$(this).ckeditor({
				toolbar : [
					['Source','-','Save','NewPage','Preview','-','Templates'],
					['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
					['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
					['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
					['BidiLtr', 'BidiRtl'],
					'/',
					['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
					['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],
					['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
					['Link','Unlink','Anchor'],
					['Image','MediaEmbed','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
					'/',
					['Styles','Format','Font','FontSize'],
					['TextColor','BGColor'],
					['Maximize', 'ShowBlocks','-','About']
				],
				filebrowserBrowseUrl : '/fm/ajax/browse',
				filebrowserUploadUrl : '/includes/js/files/uploader.php'
			});
		}
	});
	$("ul.sortable-list").sortable({
		placeholder: 'ui-state-highlight',
		stop : function(e) {
			var count = 0;
			$("ul.sortable-list li").each(function(){
				$(this).removeClass('even');
				if(count % 2 == 0) $(this).addClass('even');
				count++;
				$(this).children('input').val(count);
			});
		}
	});
	$("input.date").datepicker({
		changeMonth: true,
		changeYear: true,
		yearRange:'1900:2050'
	});
});
