﻿$(document).ready(function(){
    $("#CommentForm").validationEngine({
        success: success,
		failure : function() {}
	})
});

function ValidateComment() {
    $("#CommentForm").submit();
}

function success() {
    $.ajaxSetup({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        data: "{}",
        dataFilter: function(data) {
            var msg;
            if (typeof (JSON) !== 'undefined' && typeof (JSON.parse) === 'function')
                msg = JSON.parse(data);
            else
                msg = eval('(' + data + ')');

            if (msg.hasOwnProperty('d'))
                return msg.d;
            else
                return msg;
        }
    });

    $.ajax({
        url: "/Comment.aspx/AddComment",
        data: '{"ArticleID":' + $("#ArticleID").val() + ',"UserName":"' + $("#txtCommentName").val() + '","textArea":"' + $("#txtCommentText").val() + '"}',
        success: function(msg) {
        if (msg) {
                //Editöre ekle
                $(".add_comment").html(CommenMSG);
            }
        }
    });
    

}

function ViewPoll(id) {
    $.OpenWindow({
        url: "/Poll.aspx?View=true&PollID="+ id,
        G: 640,
        Y: 480
    });
}


