$(function() {
    renderGrid();
});
function renderPreload() {
    $("#content").ajaxSend(function() {
        $("#preload").show();
    });
    $("#content").ajaxSuccess(function() {
        $("#preload").hide();
    });
}
function renderGrid() {
    $("table.grid tbody tr").each(function() {
        $(this).mouseover(function() {
            $(this).addClass("grid_row_over");
        });
        $(this).mouseout(function() {
            $(this).removeClass("grid_row_over");
        });
        $(this).click(function(sender) {
            if (sender.target.type == "checkbox") {
                // click checkbox
                if (sender.target.checked) {
                    $(this).addClass("grid_row_selected");
                } else {
                    $(this).removeClass("grid_row_selected");
                }
            } else if (!(sender.target instanceof HTMLImageElement)) {
                // chick row
                var chk = $(this).find("input[type=checkbox]");
                chk.attr("checked", !chk.attr("checked"));

                if (chk.attr("checked") == true) {
                    $(this).addClass("grid_row_selected");
                } else {
                    $(this).removeClass("grid_row_selected");
                }
            }
        });
    });
}
function renderPagination() {
    $("p.pagination a").each(function() {
        var href = $(this).attr("href");
        var a = $(this);

        a.attr("href", "#");
        a.attr("lang", href);
        a.click(function() {
            $("#div_grid").load(href);
            return false;
        });
    });
}