// On-load functions ####################################################################

$(document).ready(function(){
	$('#navigation ul').droppy({speed: 200});
});

// Comments #############################################################################

function loadComments(id){
	$('#comments').load('modules/comments.php?id='+id);
}

function submitComment(id){
	var author = $('#author').val();
	var comment = $('#comment').val();
	
	if (author == '' || comment == '') {
		$('.notification').show();
		$('.notification').fadeOut(8000);
	}
	else {
		$('.notification').hide();
		$.post('modules/comment_save.php?id='+id, $('#comment_form').serializeArray());
		$('#comments ul').append('<li><span class="cmt_author">' + author + ' just posted:</span><p>' + comment + '</p></li>');
		// Clear fields
		$('#author').val('').focus();
		$('#comment').val('');
	}
}

function deleteComment(id){
	$('#cmt'+id).fadeOut(200);
	$.get('modules/comment_delete.php?id='+id);
}

// Email form ###########################################################################

function sendEmail(){
	$('#btn_send').val('Sending...');
	$.post('modules/emailform.php?submit=t', $('#email_form').serializeArray(), function(data){
      $('#emailform').html(data);$('.notification').fadeOut(8000);
	});
}


