// JavaScript Document


      $(document).ready(function(){
	
			$('.error').hide();
			
		    $(".lbutton").click(function() {

			var contactLocation = $(this).attr('rel');
			var prefix = contactLocation;
			
				if (contactLocation == 'us') { contactLocation = 'United States'; }
				if (contactLocation == 'bz') { contactLocation = 'Brazil'; }
				if (contactLocation == 'sw') { contactLocation = 'Sweden'; }
				if (contactLocation == 'aus') { contactLocation = 'Austrailia'; }
				if (contactLocation == 'gm') { contactLocation = 'Germany'; }
				if (contactLocation == 'eg') { contactLocation = 'England'; }
		      $('.error').hide();

		  	  var name = $("input#"+prefix+"_name").val();
		  		if (name == "") {
		        $("label#"+prefix+"_name_error").show();
		        $("input#"+prefix+"_name").focus();
		        return false;
		      }
		  		var email = $("input#"+prefix+"_email").val();
		  		if (email == "") {
		        $("label#"+prefix+"_email_error").show();
		        $("input#"+prefix+"_email").focus();
		        return false;
		      }
				
				var phone = $("input#"+prefix+"_phone").val();
				var company = $("input#"+prefix+"_company").val();
				var message = $("textarea#"+prefix+"_message").val();
				
				var subject = $("textarea#"+prefix+"_subject").val();
				
		  		var interested = $("select#"+prefix+"_interested").val();
		  		if (interested == "") {
		        $("label#"+prefix+"_interested_error").show();
		        $("select#"+prefix+"_interested").focus();
		        return false;
		      }
		
			$('.lbutton').attr("disabled", "true"); //disable the button
		
			var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&location=' + contactLocation + '&company=' + company + '&interested=' + interested + '&message=' + message;
			//  alert (dataString);return false;
			  $.ajax({
			    type: "POST",
			    url: "location_process.php",
			    data: dataString,
			    success: function() {
			      $('.theform_message_'+prefix).html("<div id='the_message_"+prefix+"></div>");
			      $('#the_message_'+prefix).html("<h2>Thank you for your interest</h2>")
			      .append("<p>We will be in touch soon.</p>")
			      .hide()
			      .fadeIn(1500, function() {
					$('.lbutton').removeAttr('disabled');  //enable the button
			      });
			    }
			  });
			
			
			  return false;

		    });
		
	


    });

