$(document).ready(function() {
	/* SITE WIDE */
	$('body').supersleight({shim: '/static/images/png.gif'});
	$('.hide').hide();
	
	$("input[type=file]").filestyle({ 
//	border: 1px solid #cccccc;
		border: '1px solid #cccccc',
		image: '/static/images/input_browse.gif',
		imageheight : 24,
		imagewidth : 74,
		padding: "4px 3px",
		width : 317
	});

	/* FORM VALIDATION */
	$('#nominationForm').submit(function() {
		$(this).find('label.error').remove();
		$('input.error, textarea.error').removeClass('error');
		var errors = false;
		$('input.required, textarea.required').each(function() {
			if ($(this).hasClass('checkbox')) {
				if ($(this).is(':checked')) {} else {
					$(this).next().after('<label class="error">'+$(this).attr('title')+'</label>');
					//$(this).val('');
					errors = true;
				}
			} else {
				if ($(this).val() == '' || $(this).val() == $(this).attr('title')) {
					$(this).after('<label class="error">'+$(this).attr('title')+'</label>');
					$(this).addClass('error');
					//$(this).val('');
					errors = true;
				}
			}
		});
		if(!errors) {
			var email = $('#f_email').val();
			if(!(/^[_A-z0-9-]+((\.|\+)[_A-z0-9-]+)*@[A-z0-9-]+(\.[A-z0-9-]+)*(\.[A-z]{2,4})$/.test(email))) {
				$('#f_email').after('<label class="error">'+$('#f_email').attr('title')+'</label>');
				errors = true;
			}
		}
		if (!errors) {
			return true;
		}
		return false;
	});
	
	$('.find-out-more').html('<a href="#" class="find-out-more toggle">Find out more</a>');
	
	$('.toggle').click(function() {
		$(this).hide();
		$(this).parent().parent().find('.hide').toggle('300');
		return false;
	});
	
	$('.show_terms').click(function() {
		$('.terms').toggle('300');
	});

	$.localScroll();

});
