﻿function loadComments(id, toggle, sender) {
    if (toggle == true) {
        if ($("#dComments__" + id + ":visible").length == 1) {
            $("#dComments__" + id + "").fadeOut();
        }
        else {
            $("#dComments__" + id + "").fadeIn("slow");
            $("#dComments__" + id + "").load("comments_get.asp?id=" + id);
        }
    }
    else {
        $("#dComments__" + id + "").fadeIn("slow");
        $("#dComments__" + id + "").load("comments_get.asp?id=" + id, function() {
            if (sender != null) {
                slideToAnchor(sender);
            }
        });
    }
}

function RefreshImage(valImageId) {
    var objImage = document.images[valImageId];
    if (objImage == undefined) {
        return;
    }
    var now = new Date();
    objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}

function ClearUserInput(blogId) {
    $('#captchacode' + blogId).val("");
    $('#main' + blogId).val("");
}

function showCommentMessageBar(blogId, cssClass, text) {

    $('#CommentMessageBar' + blogId).attr("class", cssClass);
    $('#CommentMessageBar' + blogId).html(text);
    $('#CommentMessageBar' + blogId).fadeIn();
}

function slideToAnchor(sender) {
    elementClick = $(sender).attr("href");
    destination = $(elementClick).offset().top;
    $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination }, 1100);

    return elementClick.charAt(0) == "#" ? false : true;
}