$(function() {
	RegistrationForm.init();
});

var RegistrationForm = {
	ContactAddress: null,
	ContactAddressSame: null,
	ContactAddressDifferent: null,
	SubmitButton: null,
	
	init: function() {
		var cc = this;	
		cc.ContactAddress = $('#ContactAddress');
		cc.ContactAddressSame = $('#RewardRegistrationContactAddressSame');
		cc.ContactAddressDifferent = $('#RewardRegistrationContactAddressDifferent');
		cc.SubmitButton  = $('#RewardRegistrationSubmit');
		
		cc.events();
		cc.validation();
		cc.render();
	},
	events: function() {
		var cc = this;

		cc.ContactAddressSame.click(function(){
			cc.ContactAddress.hide();
		});
		
		cc.ContactAddressDifferent.click(function(){
			cc.ContactAddress.fadeIn();
		});
		
		
	},	
	render: function(url) {
		var cc = this;
		cc.ContactAddress.hide();
	},
	validation: function() {
		var cc = this;
		$("#RewardRegistrationAddForm").validate({
			submitHandler: function(form) {
				var cc = this;
				$('#RewardRegistrationSubmit').fadeOut('fast', function(){
					$('#RewardRegistrationLoading').fadeIn('fast', function(){
						form.submit();
					});
				});
			 },
			errorElement: "div",
			highlight: function(element, errorClass) {
				$(element).fadeOut(function() {
					$(element).fadeIn()
				})
			}
			
		});

		
	}
}