var text_comment_const = "Left comment...";
var new_gallery_comment_id = "#new_gallery_comment";
function gallery_comment_focus(){
    if( $(new_gallery_comment_id).val() == text_comment_const ) {
        $(new_gallery_comment_id).val("");
        $('#comment_button').fadeIn();
    }
}
function gallery_comment_blur() {
    if( $(new_gallery_comment_id).val() == "" ) {
        $(new_gallery_comment_id).val( text_comment_const );
        $('#comment_button').fadeOut();
    } else {

    }
}
function add_gallery_comment( gallery_id ) {
    var comment_text = $(new_gallery_comment_id).val();
    $.post(base_url+'add_gallery_comment', {'gallery_id':gallery_id, 'comment_text':comment_text}, function( data ) {
        if( data.err == 0 ) {
            $(new_gallery_comment_id).val('');
            $('#comments_add_box').after( data.comment );
        }
        $.jGrowl(data.msg);
    },'json');
}
function add_gallery_photo_comment( photo_id ) {
    var comment_text = $(new_gallery_comment_id).val();
    $.post(base_url+'add_gallery_photo_comment', {'photo_id':photo_id, 'comment_text':comment_text}, function( data ) {
        if( data.err == 0 ) {
            $(new_gallery_comment_id).val('');
            $('#comments_add_box').after( data.comment );
        }
        $.jGrowl(data.msg);
    },'json');
}
function user_gallery_photos_comments(gallery_id,page) {
    setAjaxProcess('#gallery_comments');
    $.post(base_url + 'user_gallery_photos_comments',{'gallery_id':gallery_id,'page':page},function( data ){
        $('#gallery_comments').html( data );
    });
}
function user_gallery_image_comments(photo_id,page) {
    setAjaxProcess('#gallery_comments');
    $.post(base_url + 'user_gallery_image_comments',{'photo_id':photo_id,'page':page},function( data ){
        $('#gallery_comments').html( data );
    });
}
function delete_gallery_comment( comment_id ) {
    if( confirm("Delete comment") ) {
        $.post(base_url+'delete_gallery_comment',{'comment_id':comment_id},function( data ){
            $.jGrowl(data.msg);
            if( data.err == 0 ) {
                $('#blog_comment_comment_'+comment_id).fadeOut().remove();
            }
        },'json');
    }
}
function delete_gallery_photo_comment( comment_id ) {
    if( confirm("Delete comment") ) {
        $.post(base_url+'delete_gallery_photo_comment',{'comment_id':comment_id},function( data ){
            $.jGrowl(data.msg);
            if( data.err == 0 ) {
                $('#blog_comment_comment_'+comment_id).fadeOut().remove();
            }
        },'json');
    }
}
/*function deleteBlogComment(id, role) {
    if( confirm("Delete comment ?") ) {
        $.post(base_url+'delete_blog_comment',{"comment_id":id,'role':role},function(){
            $('#blog_comment_comment_'+id).fadeOut(function(){
                $(this).remove();
            })
        });
    }
}
function add_blog_comment( owner_id, blog_id ) {
    var params = {"owner_id":owner_id, "blog_id":blog_id,'comment':$(new_comment_id+blog_id).val()};
    $.post(base_url+'add_blog_comment', params, function( data ) {
        $(new_comment_id+blog_id).val('');
    });
}*/
