var RushField =
{   
	init: function()
	{
		RushField.setupSite();
	},
	
	setupSite: function()
	{
		RushField.smoothScroll();
		RushField.validateRegistration();
		RushField.validateProfile();
	},
	
	smoothScroll: function()
	{
		jQuery('a[href*=#]').click(function()
		{
			if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname)
			{
				var $target = jQuery(this.hash);
				$target = $target.length && $target || jQuery('[name=' + this.hash.slice(1) +']');
				if ($target.length)
				{
					var targetOffset = $target.offset().top - 0;
					jQuery('html,body').animate({scrollTop: targetOffset}, 1000);
					return false;
				}
			}
		});
	},
	
	validateRegistration: function()
	{
		jQuery("#eventRegistration").validate({
			errorLabelContainer: jQuery("#eventRegistration div.error"),
			rules: {
				user_login: {
					required: true,
					minlength: 8
				},
				userpass: {
					required: true,
					minlength: 8
				},
				userpass2: {
					required: true,
					minlength: 8,
					equalTo: "#userpass"
				},
				person_player_firstname: "required",
				person_player_lastname: "required",
				person_dob_month: "required",
				person_dob_day: "required",
				person_dob_year: "required",
				person_address: "required",
				person_city: "required",
				person_state: "required",
				person_zip: "required",
				person_phone_home: "required",
				person_email: "required",
				person_school: "required",
				person_position: "required",
				person_tshirt_size: "required",
				em_medical_insurer: "required",
				em_group: "required",
				em_address: "required",
				em_city: "required",
				em_state: "required",
				em_zip: "required",
				agrTerms: "required"
			},
			messages: {
				user_login: {
					required: "Please fill in the username",
					minlength: "Username must have at least 8 characters"
				},
				user_pass: {
					required: "Please fill in the password",
					minlength: "Password must have at least 8 characters"
				},
				user_pass_2: {
					required: "Please re-type the password",
					minlength: "Re-type password must have at least 8 characters",
					equalTo: "Passwords do not match"
				},
				person_player_firstname: "Please fill in the Player's first name",
				person_player_lastname: "Please fill in the Player's last name",
				person_dob_month: "Please select the bod month",
				person_dob_day: "Please select the bod day",
				person_dob_year: "Please select the bod year",
				person_address: "Please fill in the address",
				person_city: "Please fill in the city",
				person_state: "Please fill in the state",
				person_zip: "Please fill in the ZIP",
				person_phone_home: "Please fill in the home phone",
				person_email: "Please fill in the email",
				person_school: "Please select a school",
				person_position: "Please select a position",
				person_tshirt_size: "Please select a t-shirt size",
				em_medical_insurer: "Please fill in the medical insurer",
				em_group: "Please fill in the medical insurer group",
				em_address: "Please fill in the medical insurer address",
				em_city: "Please fill in the medical insurer city",
				em_state: "Please select the medical insurer state",
				em_zip: "Please fill in the medical insurer zip",
				agrTerms: "You must agree to our terms and conditions"
			}
		});
	},
	
	validateProfile: function()
	{
		jQuery("#userProfile").validate({
			errorLabelContainer: jQuery("#userProfile div.error"),
			rules: {
				person_player_firstname: "required",
				person_player_lastname: "required",
				person_dob_month: "required",
				person_dob_day: "required",
				person_dob_year: "required",
				person_address: "required",
				person_city: "required",
				person_state: "required",
				person_zip: "required",
				person_phone_home: "required",
				person_email: "required",
				person_school: "required",
				person_position: "required",
				person_tshirt_size: "required",
				em_medical_insurer: "required",
				em_group: "required",
				em_address: "required",
				em_city: "required",
				em_state: "required",
				em_zip: "required"
			},
			messages: {
				person_player_firstname: "Please fill in the Player's first name",
				person_player_lastname: "Please fill in the Player's last name",
				person_dob_month: "Please select the bod month",
				person_dob_day: "Please select the bod day",
				person_dob_year: "Please select the bod year",
				person_address: "Please fill in the address",
				person_city: "Please fill in the city",
				person_state: "Please fill in the state",
				person_zip: "Please fill in the ZIP",
				person_phone_home: "Please fill in the home phone",
				person_email: "Please fill in the email",
				person_school: "Please select a school",
				person_position: "Please select a position",
				person_tshirt_size: "Please select a t-shirt size",
				em_medical_insurer: "Please fill in the medical insurer",
				em_group: "Please fill in the medical insurer group",
				em_address: "Please fill in the medical insurer address",
				em_city: "Please fill in the medical insurer city",
				em_state: "Please select the medical insurer state",
				em_zip: "Please fill in the medical insurer zip"
			}
		});
	}
};
jQuery(document).ready(RushField.init);