$(document).ready(function(){
	// Validate Form
	$("#newaccount").validate({
		// If form has no errors, continue
 		submitHandler: function(form) {
			var resell = $('input[name=resellerguid]');
			var email = $('input[name=email]');
			var pwd = $('input[name=newpassword]');
			var fname = $('input[name=firstname]');
			var lname = $('input[name=lastname]');
			var pnum = $('input[name=phonenumber]');
			var comp = $('input[name=company]');
			var data = 'resellerguid=' + resell.val() +  '&email=' + email.val() + '&newpassword=' + pwd.val() + '&firstname=' + fname.val() + '&lastname=' + lname.val() + '&phonenumber=' + pnum.val() + '&company=' + comp.val();
			$('#loading').fadeIn('slow');
			$.ajax({ 
				url: "scripts/processNewAcct.php",
				type: "POST",
				data: data,
				cache: false,
				success: function (html) {
					// If the script has no errors, forward to the thank you page
					if (html==1) { 
						window.location = 'thanks.html';
					// If there is errors, stop the loader image and show an error message
					} else {
						$('#loading').fadeOut('slow');
						$('#error').fadeIn('slow');
						
						// Uncomment this if you need to see the results of the cURL operation
						//alert(html);
					}
				}
			});
			return false;
 		}
	});
});
