function newsletter() {	
	$("#overlay").css({"display" : "block"}).animate({opacity: 0.85}, 1000);
	$("#newsletter_block").css({"left" : "50%", "top" : "50%"}).hide().fadeIn(1000);
}

function close_news() {
	$("#overlay").fadeOut(800);
	$("#newsletter_block").fadeOut(800);
}

$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFDDAA"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var name = $("input#name").val();
		if (name == "") {
      $("span#name_error").show();
      $("input#name").focus();
      return false;
    }
		var company = $("input#company").val();
		if (company == "") {
      $("span#company_error").show();
      $("input#company").focus();
      return false;
    }
		var title = $("input#title").val();
		if (title == "") {
      $("span#title_error").show();
      $("input#title").focus();
      return false;
    }
		var address = $("input#address").val();
		var city = $("input#city").val();
		var state = $("select#state").val();
		var zip = $("input#zip").val();
		if (address == "" || city == "" || state == "" || zip == "") {
      $("span#address_error").show();
      $("input#address").focus();
      return false;
    }
		var email = $("input#email").val();
		if (email == "") {
      $("span#email_error").show();
      $("input#email").focus();
      return false;
    }
		var phone = $("input#phone").val();
		if (phone == "") {
      $("span#phone_error").show();
      $("input#phone").focus();
      return false;
    }
		
		var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&company='+ company + '&title=' + title + '&address=' + address + '&city=' + city + '&state=' + state + '&zip=' + zip;
		//alert (dataString);
		//return false;
		
		
		
		$.ajax({
      type: "POST",
      url: "http://www.southeastconnections.com/process.php",
      data: dataString,
      success: function() {
        $('#newsletter_block').html("<div id='message' style='padding:100px 0px 0px 140px;'></div>");
        $('#message').html("<h2>Contact Form Submitted!</h2>")
        .append("<p>We will be in touch soon.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("");
        });
		$("#overlay").animate({opacity: 0.85}, 2000)
					.fadeOut('slow', function() {
				    	$(this).remove();
    				});
		$("#newsletter_block").animate({opacity: 1.0}, 2000)
					.fadeOut('slow', function() {
				    	$(this).remove();
    				});
      }
     });
		
    return false;
	});
});