	/*--------------------------------------------------------------------------
	* Copyright 2008 Mark. Sydney :: www.marksydney.com :: All Rights Reserved *
	 	                          __             
		 /'\_/`\                 /\ \            
		/\      \    __      _ __\ \ \/'\        
		\ \ \__\ \  /'__`\  /\`'__\ \ , <       
		 \ \ \_/\ \/\ \L\.\_\ \ \/ \ \ \\`\   __ 
		  \ \_\\ \_\ \__/.\_\\ \_\  \ \_\ \_\/\_\
		   \/_/ \/_/\/__/\/_/ \/_/   \/_/\/_/\/_/
	
	* Author: Nathan Winch
	* Project: Optus - optusbefirst (iPAD)
	--------------------------------------------------------------------------*/
	
	jQuery(function($){				
		var validator = $("#form_registration").validate({
			rules: {
				'registration[firstname]':		{ required:true },
				'registration[lastname]':			{ required:true },
				'registration[email]':				{ required:true, email:true },
				'registration[postcode]':			{ required:true, digits:true },
				'registration[mobile]':				{ required:false, digits:true }
			},
			groups: {
			    phones: "registration_answer4_1 registration_answer4_2"
			},
			messages: {
				'registration[firstname]':		{ required:'First Name is required' },
				'registration[lastname]':		{ required:'Last Name is required' },
				'registration[email]':			{ required:'Email is required', email:'Email must be a valid format' },
				'registration[postcode]':		{ required:'Postcode is required', digits:'Postcode can only be digits' },
				'registration[mobile]':			{ digits:'Mobile can only be digits' }
			},
			errorLabelContainer: "#errorBox",
			wrapper: "li"
		});
		
		/** Nathan :: Custom method for checking at least 1 checkbox has been checked. */
		jQuery.validator.addMethod('phones', function() {
			if ($('#form_registration .phones:checked').length >= 1) return true;
			else return false;
		}, "Please choose what you are interested in");
		
		jQuery.validator.addClassRules('phones', {
	        'phones' : true
		});
	});
