// JavaScript Document
function readyEvents() {
	
	
	
	
	
	
	var validate_entry = $('#afp_entry').validate({
		rules: { 
			email: { 
				required: true, 
				email: true
			},
			phone: {
				required: true,
				phoneUS: true
			}
		}, 
		messages: { 
			// Only change what is needed.
			//first_name: 'This is required, but will not be visible on the website if you use a screen name. ',
		},
		errorClass: 'validateError',
		errorElement: 'span',
		wrapper: 'p',
		errorPlacement: function(error, element) {
			error.appendTo(element.parent('.ctrlHolder')); // adds the message (and wrapper) to after the other elements
			error.addClass('errorField');  // add a class to the wrapper
			element.parent('.ctrlHolder').addClass('error'); // add a class to the element's parent--should be ".ctrlHolder"
			$.fn.colorbox.resize();

		},
		// specifying a submitHandler prevents the default submit, good for the demo 
		submitHandler: function(form) {
			
			entry();
			
		}, 
		// set this class to error-labels to indicate valid fields 
		success: function(label) {
			label.parents('.ctrlHolder').removeClass('error'); // removes .error from .ctrlHolder
			label.parents('.ctrlHolder').children('p.errorField').remove(); // removes the error wrapper and all it contains
		} 
	});
	
	
	$.validator.addMethod('required_group', function(val, el) {
		var $module = $(el).parents('.ctrlHolder');
		return $module.find('.required_group:checked').length;
	}, 'Please rate this item.');
	
	
	
	
	$(".cb_entrylink").colorbox({width:"50%", scrolling: false, inline:true, title:"Enter the contest", href:"#entry_form"});
	
	$("#jc").colorbox({maxHeight:"98%", innerWidth:"800px", inline:true, href:"#jc_large"});
	$("#db").colorbox({maxHeight:"98%", innerWidth:"800px", inline:true, href:"#db_large"});
	$("#jw").colorbox({maxHeight:"98%", innerWidth:"800px", inline:true, href:"#jw_large"});
	$("#jd").colorbox({maxHeight:"98%", innerWidth:"800px", inline:true, href:"#jd_large"});
	$("#dv").colorbox({maxHeight:"98%", innerWidth:"800px", inline:true, href:"#dv_large"});
	$("#rt").colorbox({maxHeight:"98%", innerWidth:"800px", inline:true, href:"#rt_large"});
	$("#hr").colorbox({maxHeight:"98%", innerWidth:"800px", inline:true, href:"#hr_large"});
	$("#nq").colorbox({maxHeight:"98%", innerWidth:"800px", inline:true, href:"#nq_large"});
	$("#jr").colorbox({maxHeight:"98%", innerWidth:"800px", inline:true, href:"#jr_large"});
				
}
