﻿function Postit()
{
    var cat = $get('ctl00_c_addpost1_catDropDown').value;
    var title = $get('ctl00_c_addpost1_titletext').value;
    var desc = $get('ctl00_c_addpost1_descText').value;
    var pid = $get('ctl00_c_addpost1_pid').value;
    if(cat != '0' && title != '' && desc != '')
    {
        MainWebservice.PostBlog(pid,cat,title,desc,ONS_Postit);
    }
}
function ONS_Postit(retval)
{
    if(retval == 't')
    {
        window.location="postlist.aspx";
    }
    else
    {
        alert('Posting Failed');
        $get('ctl00_c_addpost1_catDropDown').value = '0';
        $get('ctl00_c_addpost1_titletext').value = '';
        $get('ctl00_c_addpost1_descText').value = '';
    }
}

function DeletePost(cid)
{
    var cat = $get('ctl00_c_postlist1_catDropDown').value;
    MainWebservice.DeletePost(cid,cat,ONS_DeletePost);
}
function ONS_DeletePost(retval)
{
    if(retval != "f")
        $get('ctl00_c_postlist1_postListDiv').innerHTML = retval;
    else
        alert('Deletion Failed');
}

function ShowAddCommentBox()
{
    $get('addCmtTbl').style.display = 'block';
    $get('showaddcommentbtn').style.display = 'none';
}
function CancelComment()
{
    $get('addCmtTbl').style.display = 'none';
    $get('showaddcommentbtn').style.display = 'block';
}
function AddComment()
{
    var cmt = $get('cmtText').value;
    var pid = $get('ctl00_c_addcommentadmin1_pid').value;
    MainWebservice.AddComment(pid,cmt,ONS_AddComment);
}
function ONS_AddComment(retval)
{
    CancelComment();
    $get('ctl00_c_addcommentadmin1_cmtList').innerHTML = retval;
}
function ApproveOrDisapproveComment(cmtid,obj)
{
    if(obj.value == 'Approve')
        obj.value = 'Disapprove';
    else
        obj.value = 'Approve';
    MainWebservice.ApproveOrDisapproveComment(cmtid);
}

function DeleteComment(cmtid)
{
    var pid = $get('ctl00_c_addcommentadmin1_pid').value;
    MainWebservice.DeleteComment(pid,cmtid,ONS_AddComment);
}

function FilterPostList(val)
{
    MainWebservice.FilterPostList(val,ONS_FilterPostList);
}

function ONS_FilterPostList(retval)
{
    $get('ctl00_c_postlist1_postListDiv').innerHTML = retval;
}
