/**
* Javascript for Blogs
*
* @package js
* @author Tim Carr
* @version 1
* @copyright fish in a bottle 2009
*/ 

$(document).ready(function() {
    // jQuery DatePicker Binding
    if(typeof jQuery.fn.datePicker == 'function') {
        $('.datePicker').datePicker({startDate:'01/01/1996',endDate:'31/12/2020'});
    }
    
    // Delete Blog Entry
    $("form.removeJournal").livequery("click", function (e) {
        var journalID = $("input[@name='journalID']", this).val();

        softConfirm("<p>Do you want to delete this blog entry?</p>", 
                    function(){
                        DoAJAXRequest('BlogsHelper', 'DeleteBlogByID', 'args[]='+journalID, 
                            function(data) {
                                // Hide this item
                                $("#journal_"+journalID).hide('slow');
                                $("#journal_"+journalID).html("");
                                
                                // Show Confirmation
                                softMessage("Blog Entry Deleted. Please wait...");
                                
                                // Reload page
                                window.location = document.location.href;
                            }, 
                            function(data) { 
                                softAlert("An Error Occured", alertOff); 
                            });
                    },
                    alertOff);
    });
});