jQuery(function($) {
	fade_texts();
	flash_messages();
	banners();
	
	$('#nav ul').fish();
		
	$('input[type="checkbox"]').filter('[name="check_all"]').toggleCheck(function() {
		$('input[type="checkbox"]').filter($(this).val()).checkAll();
		
	}, function() {
		$('input[type="checkbox"]').filter($(this).val()).unCheckAll();
	});
	
	$('#js-errors').hide();
	$('form#sr').submit(function() {
		if ($('input[name="project_name"]').val() === '') {
			$('#js-errors').show();
			$('input[name="project_name"]').focus();
			if (!$('#js-errors ul li').hasClass('project_name')) {
				$('#js-errors').show();
				var err = $('<li class="project_name no-marker">Please enter a project name</li>');
				$('#js-errors ul').append(err);
				$('[name="project_name"]').blur(function() {
					if ($(this).val() !== '') {
						err.remove();
						if ($('#js-errors ul li').length === 0)
							$('#js-errors').hide();
					}
				});
			}
			$(this).find("input[@type=submit], input[@type=image]").each(function() {
				$(this).removeAttr("disabled");
			});
			return false;
		} else {
			$('#js-errors').hide();
			return true;
		}
	});
	
	$('a[href="#top"]').click(function() {
		window.scrollTo(0, 0);
		return false;
	});

});

$(document).ready(function() {
	$("input[@type=submit], input[@type=image]").each(function() {
		$(this).click(function() {
			this.disabled = true;
			var form = $(this).parents().filter("form:first");
			form.submit();
		});
	});
});