$(function() {

  $('.error').hide();

  $('input.text-input').css({backgroundColor:"#303030"});

  $('input.text-input').focus(function(){

    $(this).css({backgroundColor:"#606060"});

  });

  $('input.text-input').blur(function(){

    $(this).css({backgroundColor:"#303030"});

  });



  $(".button").click(function() {

		// validate and process form

		// first hide any error messages

    $('.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 elocation = $("input#elocation").val();

		if (elocation== "") {

      $("label#elocation_error").show();

      $("input#elocation").focus();

      return false;

    }	

	var edate = $("input#edate").val();

		if (edate == "") {

      $("label#edate_error").show();

      $("input#edate").focus();

      return false;

    }

	

	var message = $("input#message").value;

	var message = document.getElementById('message').value;

		

		var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&elocation=' + elocation +'&edate=' + edate + '&message=' + message;

		//alert (dataString);

		

		$.ajax({

      type: "POST",

      url: "bin/process.php",

      data: dataString,

	  error: function(e){

        alert("error:" + e);

    }, 

      success: function() 

	  {

		$("#user_name").html('<span style="color: #cea52f;" id="user_name">' + name + '</span>');		

		$("#contact_form").hide();

		$('#contact_form_reply').fadeIn(2000);

      

      }

     });

    return false;

	});

});

runOnLoad(function(){

  $("input#name").select().focus();

});


