﻿
    $(document).ready(function() {
        // Tabs
        $('.TabNavigation a').mouseover(function() {
            $(this.hash).siblings(".TabContainer").hide();
            $(this.hash).show();
            $(this).parent("li").siblings().removeClass("TabSelected");
            $(this).parent("li").addClass('TabSelected');
        }).filter(':first').mouseover();
    });
    
    function LoadCommentList(rid, page, size) {
        $.getJSON("/Ajax/LoadCommentList?rootID=" + rid + "&page=" + page + "&size=" + size + "&date=" + new Date(),
		            function(obj) {
                        $.each(obj.List, function(i, n) {
                                n.nV = new Array();
		                $.each(obj.List, function(k, v) {
		                        if (n.ID == v.PID) {
		                            n.nV.push(v);
		                        }
		                    })
		                })
		                $("#CommentList").processTemplate(obj);
		            });
    }

    function SubmitComment(rid) {

        $("#btn_Comment").attr("disabled", "true"); 
        
        $.post('/Ajax/CreateComment',
                   { rootID: rid, title: "", body: $('#txt_Comment').val() },
                   function(obj) {
                       alert(obj);
                   }
               );
    }

    function SubmitReply(rid, txt_Reply, pid) {

        $("#btn_Reply").attr("disabled", "true");

        $.post('/Ajax/CreateReply',
                { rootID: rid, title: "", body: $(txt_Reply).val(), parentID: pid },
                function(obj) {
                    alert(obj);
                }
            );
    }

    function ThumbUpComment(sid, cid) {
        $.post('/Ajax/ThumbUpComment',
                   { siteID: sid, commentID: cid },
                   function(obj) {
                       alert(obj);
                   }
               );
    }

    function ThumbDownComment(sid, cid) {
        $.post('/Ajax/ThumbDownComment',
                   { siteID: sid, commentID: cid },
                   function(obj) {
                       alert(obj);
                   }
               );
    }