function submit_guestbook()
{	
	var form_data = $(this).serialize();
	$.ajax({
		type: "POST",
		url: "http://www.buyers-market.net/home/new_comment",
		data: form_data,
		success: function(result)
		{
			$.colorbox.close()
			$(':input', '#new_comment').not('#submit').val('');			
		}
	});
}

$(document).ready(function() {
	//Load new comment
	$('#refresh').click(function(e)
	{
		e.preventDefault();
		var p = {};
		p['valid'] = 1;
	
		$('#comment').load('http://www.buyers-market.net/home/get_comment', p);
	});
	
	
	//New comment pop up
	$("#say_something").colorbox({
		width:"310px", 
		inline:true, 
		href:"#sign_guestbook",
		onClosed:function(){ 
			$('#thank_you').hide();
			$('#new_comment').show();
			$(':input', '#new_comment').not('#submit').val(''); 
			$('#sign_guestbook h3').html('Please sign our guestbook');
		}
	});
	
	//Validate new comment and submit
	$("#new_comment").validate({
		//hide error labels
		errorPlacement: function(error, element) { },
	
		//submit via ajax
		submitHandler: function() 
		{
			var form_data = $("#new_comment").serialize();
			$.ajax({
				type: "POST",
				url: "http://www.buyers-market.net/home/new_comment",
				data: form_data,
				success: function()
				{
					$('#new_comment').fadeOut('fast', function() {
						$('#sign_guestbook h3').html('Thank You!');
						$('#thank_you').fadeIn('fast');
					});			
				}
			});
		}
	});
	
//End document.ready	
});
