﻿var MilliyetNewComment = function(PageName) {
    this.Host = "http://yorum.milliyet.com.tr/";
    this.CommentPage = PageName || "Comment.aspx";
}
MilliyetNewComment.prototype.NewCommentSendVote =
    function(CommentID, ArticleID, isPositive) {
        var frame = document.getElementById("MilliyetCommentFrame");
        if (frame == null) { 
            frame = document.createElement("IFRAME");
            frame.id = "MilliyetCommentFrame";
            frame.style.width = "100px";
            frame.style.height = "100px";
            document.body.appendChild(frame);
            frame.onload = function() {
                var framea = document.getElementById("MilliyetCommentFrame");

                document.body.removeChild(framea);
            }
        }
        frame.src = this.Host + "d/handler.aspx?iframe=1&hCase=VoteComment&ArticleID=" + ArticleID + "&CommentID=" + CommentID + "&IsPositive=" + isPositive;



    }
    MilliyetNewComment.prototype.SendPositiveVote = function(CommentID, ArticleID) {

        this.NewCommentSendVote(CommentID, ArticleID, 1);
    }
    MilliyetNewComment.prototype.SendNegativeVote = function(CommentID, ArticleID) {
        this.NewCommentSendVote(CommentID, ArticleID, 0);
    }

    MilliyetNewComment.prototype.WriteAnswer = function(CommentID, SourceID, refcid) {
    var url = this.Host + this.CommentPage + "?uid=" + CommentID + "&sid=" + SourceID + "&refcid=" + refcid;
    this.openWindow(url, "WriteAnswer", "width=850,height=650,scrollbars=1");
    }

    MilliyetNewComment.prototype.WriteNewComment = function(UniqueID, SourceID) {
        var url = this.Host + this.CommentPage +"?uid=" + UniqueID + "&sid=" + SourceID;
        this.openWindow(url, "WriteAnswer", "width=850,height=850,scrollbars=1");
    }
    
    MilliyetNewComment.prototype.OpenComment = function(UniqueID, SourceID) {
        var url = this.Host + "Redirect.htm?uid=" + UniqueID + "&sid=" + SourceID;
        this.openWindow(url, "_blank",'',true);
    }
    
    MilliyetNewComment.prototype.openWindow = function(Url, windowName, Properties,replace) {
    window.open(Url, windowName, Properties, replace);
    }

    MilliyetNewComment.prototype.wordCountControl = function(obj, counter, MaxWord) {        
        var words = MaxWord - (obj.value.length);
        var sayac = document.getElementById(counter);
        if (words < 0) {
            obj.value = obj.value.substr(0, MaxWord);
            return false;

        }
        sayac.innerHTML = words;
    }
    var MilliyetComment = new MilliyetNewComment();
    var MilliyetCommentNotLogin = new MilliyetNewComment("CommentV2.aspx");


jQuery.timeago.settings.strings = {
    prefixAgo: "",
    prefixFromNow: "",
    suffixAgo: "önce",
    suffixFromNow: "sonra",
    seconds: "%d saniye",
    minute: "1 dakika",
    minutes: "%d dakika",
    hour: "1 saat",
    hours: "%d saat",
    day: "1 gün",
    days: "%d gün",
    month: "1 ay",
    months: "%d ay",
    year: "1 yıl",
    years: "%d yıl"
};
jQuery(document).ready(function() {
   // jQuery("jtime.timeago").timeago();
});
