$(function() {
	
	$('#popupBack').css({"opacity":"0.75"});
	
	$('a.emailPost').click(function() {
		$('#popupBack').css({"display":"block","visibility":"visible","opacity":"0.0"});
		$('#popupBack').animate({"opacity":"0.75"});
		$('#popup').fadeIn();
		$('#popupClose').fadeIn();
	});
	
	$('#popupBack').click(function() {
		$(this).hide();
		$('#popup').hide();
	});
	
	$('a.close').click(function() {
		$('#popupBack').hide();
		$('#popup').hide();
	});
	
	
	// These first three lines of code compensate for Javascript being turned on and off. 
	// It simply changes the submit input field from a type of "submit" to a type of "button".
	
	var paraTag = $('input#sendnow').parent('');
	$(paraTag).children('input').remove();
	$(paraTag).append('<input type="button" name="submit" id="sendnow" value="&nbsp;" />');
	
	$('input#sendnow').click(function() {
	
	    var name = $('input#name').val();
	    var email = $('input#email').val();
	    var phone = $('input#phone').val();
	    var message = $('textarea#message').val();
	
	    $.ajax({
	        type: 'post',
	        url: 'http://blog.givemore.com/wp-content/themes/justsell/contactforms/sendEmailContact.php',
	        data: 'name=' + name + '&email=' + email + '&phone=' + phone + '&message=' + message,
	
	        success: function(results) {
	            $('ul#response').fadeIn();
	            $('ul#response').html(results);
	        }
	    }); // end ajax
	});


	
});