﻿
function runCode(code) 
{
    var code=document.getElementById(code).value;//code to be run
    var newwin=window.open('','','');  //popup a new window
    newwin.opener = null            // avoid any changes to the opener window
    newwin.document.write(code);  //populate the code to the popup windwos
    newwin.document.close();
}

function ShowIt()
{
jQuery.blockUI({ message: $('#pnlException') }); 
//alert('9');
}

function InitCustomArray()
{
    var customarray;
    customarray = theBLOG.Ajax.TagAutoComplete().value;
    return customarray;
}

function LoadCalendar()
{
    var today = new Date(); 
    //i don't know why I have to add 1.
    //but it seems to do the right thing
    GetCal(today.getMonth()+1,today.getFullYear ());
}

function GetCal(month, year)
{
    theBLOG.Ajax.LoadCalendar(month, year,GetCal_callback);
}

function GetCal_callback(res)
{
    var divCalendar = document.getElementById('calendar');
    if(divCalendar)
    {
        divCalendar.innerHTML = res.value;
    }
}

function LoadBlogRoll()
{
    theBLOG.Ajax.GetBlogRoll(LoadBlogRoll_callback);
}

function LoadBlogRoll_callback(res)
{
    var divBlogRoll = document.getElementById('divBlogRoll');
    if(divBlogRoll)
    {
        divBlogRoll.innerHTML = res.value;
    }
}


function LoadSiteInfo()
{
    theBLOG.Ajax.GetSiteInfo(LoadSiteInfo_callback);
}

function LoadSiteInfo_callback(res)
{
    var divSiteInfo = document.getElementById('divSiteInfo');
    if(divSiteInfo)
    {
        divSiteInfo.innerHTML = res.value;
    }
}


function LoadQuoteOfTheDay()
{
    theBLOG.Ajax.GetQuoteofTheDay(LoadQuoteOfTheDay_callback);
}

function LoadQuoteOfTheDay_callback(res)
{
    var divQuote = document.getElementById('divQuote');
    if(divQuote)
    {
        divQuote.innerHTML = res.value;
    }
}

function LoadTagCloud()
{
    theBLOG.Ajax.GetTagCloud(LoadTagCloud_callback);
}

function LoadTagCloud_callback(res)
{
    var divTagCloud = document.getElementById('divTagCloud');
    if(divTagCloud)
    {
        divTagCloud.innerHTML = res.value;
    }
}

function loadComments(){
    $.ajax({
        type: "POST",
        url: "/Web/ajaxpro/theBLOG.Ajax,BusinessDomain.ashx",
        data: '{"s":"Michael Schwarz"}',
        beforeSend: function(xhr) {
            xhr.setRequestHeader("X-AjaxPro-Method", "GetCommentList");
        },
        success: function(s) {
            var o = null;
            eval("o = " + s + "*/");
            alert(o);
        }
    }); 
}

function deleteBlogPost(id){
    $.ajax({
        type: "POST",
        url: "/Web/ajaxpro/theBLOG.Ajax,BusinessDomain.ashx",
        data: '{"blogPostID":"' + id + '"}',
        beforeSend: function(xhr) {
            xhr.setRequestHeader("X-AjaxPro-Method", "DeleteBlogPost");
        },
        success: function(s) {
           window.location.reload();
        }
    }); 
}