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

$(document).ready(function(){
    $('#navigation ul').droppy({speed: 200});
    $('#employment textarea, #employment input, #employment select').focus(function(){ $(this).parents('tr, td').css('background','#f1f1f1'); });
    $('#employment textarea, #employment input, #employment select').blur(function(){ $(this).parents('tr, td').css('background','none'); });
});

// 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);
    });
}



