$(document).ready(function () {

    $("#search-button").click(function () {
        location.href = "/sok.aspx?search=" + encodeURIComponent($("#search-input input").val());
        return false;
    });

    $("#advsearch-button").click(function () {
        location.href = "/sok.aspx?adv=1&search=" + encodeURIComponent($("#term").val()) + "&scope=" + $("#scope").val() + "&offset=" + $("#offset").val() + "&from=" + $("#from").val() + "&to=" + $("#to").val();
        return false;
    });

    $("#login input").keydown(function (e) {
        if (e.keyCode == 13) {
            $(".login-button").click();
            return false;
        }
    });

    $('#writecomment').click(function () {
        $('#writecomment').hide("fast", function () {
            $('#newcomment').show("slow");
        });
    });

    // Add some spacing to textarticle images. Depends on their alignment
    $('#page').find("img").each(function () {
        
        if ($(this).attr("align") == 'left') {
            $(this).css('paddingRight', '10px');
        }

        else if ($(this).attr("align") == 'right') {
            $(this).css('paddingLeft', '10px');
        }
    });

});