$(function(){
    setPageClickAction();
    
    function setPageClickAction(){    
        $('.paginate').click(function(e){                       
            var d = new Date();           
            url = $(this).attr('href') + '&dummy=' + d.getTime();
            e.preventDefault();          
            $.post(url, {isajax: 'true'},function(data){
                $('#bloghistory').html(data);  
                setPageClickAction();  
            });                            
            return false; 
        });
    }
});

function showAddComment(showdiv){
    switch (showdiv) {
        case 0:
            $('#addCommentLink').show();
            $('#addComment').hide();
        break;
        case 1:
            $('#addCommentLink').hide();
            $('#addComment').show();
            $('#commentSubmitedMessage').hide();
        break;
        case 2:
            $('#addCommentLink').hide();
            $('#addComment').hide();
        break;
    }
}

function postComment() {  
    $.post('global/ajax/blogcommentsuser.php',
        $('#addCommentForm').serialize(true),
        function(data){   
            $('#commentSubmitedMessage').show();
            if (data == 'No Error'){
                $('#commentSubmitedMessage')
                    .html("Your comment has been submited, after comments are approved they will appear on this page.");
                $('#addCommentForm').get(0).reset();    

                showAddComment(0);    
            }
            else{ 
                $('#commentSubmitedMessage').html(data);
            }
    });  
}
