﻿"use strict";

$(document).ready(function () {
    $("#newComment").validate({
        submitHandler: function (form) {
            var comment = {
                Author : $(form).find("#name").val(),
                Email : $(form).find("#email").val(),
                Website : $(form).find("#website").val(),
                Body : $(form).find("#comment").val()
            };

            $.post(
                    form.action,
                    comment,
                    function (data) {
                        $("UL.comments").prepend(data);
                        form.reset();
                    },
                    "html");
        }
    });
});

(function() {
    
    var links = document.getElementsByTagName('a');
    var query = '?';
    for (var i = 0; i < links.length; i++) {
        if (links[i].href.indexOf('#disqus_thread') >= 0) {
            query += 'url' + i + '=' + encodeURIComponent(links[i].href) + '&';
        }
    }

    document.write('<script charset="utf-8" type="text/javascript" src="http://disqus.com/forums/weiker/get_num_replies.js' + query + '"></' + 'script>');
})();