$(document).ready( function() {
   
// contact form - behaviour and validation
				$('.error').hide();
				$("#contactUs .button").click(function() {
				// validate and process form here
				$('.error').hide();
				var name = $("input#name").val();
				if (name == "") {
				$("label#name_error").show();
				$("input#name").focus();
				return false;
				}
				var email = $("input#email").val();
				if (email == "") {
				$("label#email_error").show();
				$("input#email").focus();
				return false;
				}
				var phone = $("input#phone").val();
				if (phone == "") {
				$("label#phone_error").show();
				$("input#phone").focus();
				return false;
				}
        var subject = $("input#subject").val();
				if (subject == "") {
				$("label#subject_error").show();
				$("input#subject").focus();
				return false;
				}
				var message = $("textarea#message").val();
		  
		    var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&subject=' + subject + '&message=' + message;
  			//alert (dataString);return false;
  			$.ajax({
				type: "POST",
				url: "form-to-email-contact.php",
				data: dataString,
				success: function() {
					$('form.contactForm label, form.contactForm input, form.contactForm textarea').fadeOut();
					$('form.contactForm fieldset').css({padding: "2em 0"}).append("<div id='message'></div>");
					$('#message').html("<h3>Thank you for your submission</h3>")
					.append("<p>Someone will respond to you within two business days</p>")
					.hide()
					.fadeIn(1500, function() {
						$('#message')
					});
    			}
			});
			return false;
		});

// support form - behaviour and validation
				$('.error').hide();
				$("#support .button").click(function() {
				// validate and process form here
				$('.error').hide();
				var name = $("input#name").val();
				if (name == "") {
				$("label#name_error").show();
				$("input#name").focus();
				return false;
				}
				var phone = $("input#phone").val();
				if (phone == "") {
				$("label#phone_error").show();
				$("input#phone").focus();
				return false;
				}
				var license = $("input#license").val();
				if (license == "") {
				$("label#license_error").show();
				$("input#license").focus();
				return false;
				}
				var description = $("textarea#description").val();
		  
		    var dataString = 'name='+ name + '&phone=' + phone + '&license=' + license + '&description=' + description;
  			//alert (dataString);return false;
  			$.ajax({
				type: "POST",
				url: "form-to-email-support.php",
				data: dataString,
				success: function() {
					$('form.contactForm label, form.contactForm input, form.contactForm textarea').fadeOut();
					$('form.contactForm fieldset').css({padding: "2em 0"}).append("<div id='message'></div>");
					$('#message').html("<h3>Thank you for your submission</h3>")
					.append("<p>We are committed to constantly improving everything that we do</p>")
					.hide()
					.fadeIn(1500, function() {
						$('#message')
					});
    			}
			});
			return false;
		});

// zxPico registration form - behaviour and validation
				$('.error').hide();
				$("#zxPico .button").click(function() {
        if($('input#accept:checked').size() == 0){
        alert('Please accept the license agreement');
        return false;
        }
				// validate and process form here
				$('.error').hide();
				var name = $("input#name").val();
				if (name == "") {
				$("label#name_error").show();
				$("input#name").focus();
				return false;
				}
				var phone = $("input#phone").val();
				if (phone == "") {
				$("label#phone_error").show();
				$("input#phone").focus();
				return false;
				}
				var email = $("input#email").val();
				if (email == "") {
				$("label#email_error").show();
				$("input#email").focus();
				return false;
				}
				var title = $("input#title").val();
        var company = $("input#company").val();
        var address1 = $("input#address1").val();
        var address2 = $("input#address2").val();
        var city = $("input#city").val();
        var state = $("input#state").val();
        var country = $("input#country").val();
		  
		    var dataString = 'name='+ name + '&title=' + title + '&company=' + company + '&address1=' + address1 + '&address2=' + address2 + '&city=' + city + '&state=' + state + '&country=' + country + '&phone=' + phone + '&email=' + email;
  			//alert (dataString);return false;
  			$.ajax({
				type: "POST",
				url: "form-to-email-zx-pico.php",
				data: dataString,
				success: function() {
					$('form.contactForm label, form.contactForm input, form.contactForm textarea').fadeOut();
					$('form.contactForm fieldset').not('form.contactForm fieldset.licenseFieldset').css({padding: "2em 0"}).append("<div id='message'></div>");
					$('#message').html("<h3>Thank you for your interest in zxPico</h3>")
					.append("<p>If you haven't received a response within two business days,<br/> please send us a message via 'contact us'</p>")
					.hide()
					.fadeIn(1500, function() {
						$('#message')
					});
    			}
			});
			return false;
		});        
        
        
        
});




