﻿var storyID;
function showMain() {
    $("#divSearch").slideUp();
    $("#divStory").slideUp();
    $("#divMain").slideDown();
}
function showSearch() {
    $("#divSearch").slideDown();
    $("#divStory").slideUp();
    $("#divMain").slideUp();
}
function showStory() {
    $("#divSearch").slideUp();
    $("#divStory").slideDown();
    $("#divMain").slideUp();
}
function showInDivSearch(result) {
    $("#divSearch").html(result);
    showSearch();
}
function showInDivStory(result) {
    $("#divStory").html(result);
    showStory();
}
function showInDivComments(result) {
    $("#divComments").html(result);
}
function loader(id) {
    $("#" + id).html("<div style='margin: 20px auto 20px auto; width: 300px; border: solid 1px #DDD; padding: 10px; text-align: center;'><img alt='Loading...' src='images/loader.gif' title='Loading...' /><br />Loading...</div>");
}
function loadStory(id) {
    loader("divStory");
    storyID = id;
    muBlog.webDisplayStory(id, showInDivStory);
}
function showInCalendar(result) {
    $("#divCalendar").html(result);
}
function addComment(IDBlog) {
    document.getElementById("divNewComment").className = "divAdding";
    var username = document.getElementById("txtName").value;
    var comment = document.getElementById("txtComment").value;
    document.getElementById("divNewComment").innerHTML = "<img alt='Adding' src='images/loader.gif' title='Adding...' /> Adding...";
    muBlog.webAddComment(IDBlog, username, comment, showInDivComments);
}
function loadStories(type, input) {
    loader("divSearch");
    muBlog.webDisplayStories(type, input, showInDivSearch);
}
function loadPage(id) {
    loader("divStory");
    muBlog.webDisplayPage(id, showInDivStory);
}
function categoryChange(idCategory) {
    muBlog.webDisplayStories("idblogcat", idCategory, showInDivSearch);
}
function loadCalendar(year, month) {
    muBlog.webDisplayCalendar(year, month, showInCalendar);
}
function loadSearch() {
    loader("divSearch");
    muBlog.webDisplaySearch(document.getElementById("txtSearch").value, showInDivSearch);
}
function slError() {
    $("#divSlError").slideDown();
}
function permalink(IDStory) {
    var permaLinkWin = window.open('permalink.aspx?id=' + IDStory, 'permalinkWindow', 'toolbar=0,location=0,width=569px,height=300px,scrollbars=0');
    permaLinkWin.focus();
}