$(function() { 
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#002E3C"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#003342"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#002E3C"});
  });
  
  $('select.text-input').css({backgroundColor:"#002E3C"});
  $('select.text-input').focus(function(){
    $(this).css({backgroundColor:"#003342"});
  });
  $('select.text-input').blur(function(){
    $(this).css({backgroundColor:"#002E3C"});
  });
  
  $('textarea.text-input').css({backgroundColor:"#002E3C"});
  $('textarea.text-input').focus(function(){
    $(this).css({backgroundColor:"#003342"});
  });
  $('textarea.text-input').blur(function(){
    $(this).css({backgroundColor:"#002E3C"});
  });

   $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
	
		var organization = $("input#organization").val();
		
	    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();
		
		var start_date = $("input#start_date").val();
		if (start_date == "") {
      		$("label#start_date_error").show();
     		 $("input#start_date").focus();
      	return false;
    	}
		
		var end_date = $("input#end_date").val();
		if (end_date == "") {
      		$("label#end_date_error").show();
     		 $("input#end_date").focus();
      	return false;
    	}
		
		var range = $("select#range").val();
		if (range == "") {
      		$("label#range_error").show();
      		$("select#range").focus();
      	return false;
    	}		
		
		var my_comment = $("textarea#my_comment").val();
		if (my_comment == "") {
      		$("label#my_comment_error").show();
     		$("textarea#my_comment").focus();
      	return false;
   	 	}
		

		
		var dataString = 'organization='+ organization + '&name=' + name + '&email=' + email + '&phone=' + phone + '&start_date=' + start_date + '&end_date=' + end_date + '&range=' + range + '&my_comment=' + my_comment;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "../rfp.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<h2>Thank you for contacting us.</h2>")
        .append("We will get back to you shortly.")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("");
        });
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#organization").select().focus();
});

