/*
	Copyright Code Computerlove Ltd 2009-2010
	Build: 1.0.0.107
	Date: 07/01/2010 09:46:12
*/

/*
	Copyright Code Computerlove Ltd 2009
	Build: 1.0.0.5
	Date: 19/05/2009 12:22:56
*/

(function($j){

	Code.registerNamespace('Website.Pages');
	
	/*
	 * Website.Pages.Homepage
	 */
	Website.Pages.Forms = {
	
		/*
		 * Function: onReady
		 */
		onReady: function(){
			var self = this;
			
			
			self.handleSubmit();
		
		},
		
		handleSubmit: function(){
			var self = this;
				
				/*	This shows the validation summary - needs thinking about as it pushes the form right down and out of sight
				/*	Update in NewsletterSignupForm.aspx and GenericHandler.ashx.cs		
				/*	$j('#aspnetForm').validationAideEnable(jQuery.validationAide.getDefaultValidationRules(), { showSummary:true,summaryMessage:"<p>Please correct the following:</p>"}, null, null, function(){
				*/
				
				$j('#aspnetForm').validationAideEnable(jQuery.validationAide.getDefaultValidationRules(), {showSummary:true, summaryMessage:"<p>Please complete all fields and tick the first 'opt in' box to continue.</p>"}, null, null, function(){
					
					//get form values and store
					var inputString = ('storesignup');
					
					inputString += ('&firstname='+ $j('.js-firstname').val() + '&surname=' + $j('.js-surname').val() + '&company=' + $j('.js-company').val() + '&email=' + $j('.js-email').val() + '&optin=' + $j('.js-optin')[0].checked + '&optinthirdparty=' + $j('.js-optinthirdparty')[0].checked);
					
					Website.Core.contentSource = inputString;
					Website.Core.preloadContent();
					return false;
				});
		}
		
	}
	
	
	$j().ready(function(){
		Website.Pages.Forms.onReady();
	});

})(jQuery);
