$(document).ready(function (){	
	$('a.external').click(function(){
		window.open(this.href);
		return false;
	});

	$.validator.addMethod('Yes', function(value) {
		return value == 'Yes';
	}, 'Please enter "buga"!');


	$('#freeform').validate({
		highlight: function(element, errorClass) {
			$('#error').fadeIn();
			$(element).addClass('error');
			$('p .error').parent().children('label').css('border', '1px solid #b71342');
		},
		rules: {
			received: 'Yes',
			rules: 'Yes'
		}
	});

	$('.rules #rules').colorbox({
		open: true,
		maxWidth: 700,
		maxHeight: 500
	});
	
	$('form p a, #primary-footer p a').colorbox({
		maxWidth: 700,
		maxHeight: 500
	});
	
	$('label.checkbox').toggle(function(){
		$(this).css({backgroundPosition: "0 -10px"});
		$(this).parent().children('input').val('No');
	}, function(){
		$(this).css({backgroundPosition: "3px 2px"});
		$(this).parent().children('input').val('Yes');
	});
	
	$('label.checkbox-off').toggle(function(){
		$(this).css({backgroundPosition: "3px 2px"});
		$(this).parent().children('input').val('Yes');
	}, function(){
		$(this).css({backgroundPosition: "0 -10px"});
		$(this).parent().children('input').val('No');
	});
	
	$('select').change(function(){
		var date = $(this).val();
		
		if(date == "All"){
			$('li').each(function(){$(this).slideDown('fast');})
		}
		
		else{
			$('li').each(function(){
				var day = $(this).attr('class');
				
				if(date != day){$(this).slideUp('fast');}
				else{$(this).slideDown('fast');}
			});
		}
	});
});