prepareOnLoad = function() {

    $('#tabs').tabs();

    $(".stabs").bind("click click_handler",
    function() {
        var el = $(this);

        var type = (el.attr("type") == "") ? "tabs": el.attr("type");

        el.parent().find(".tabs").removeClass(type + "_on").addClass(type + "_off");
        el.addClass(type + "_on");

        var subClass = el.find("span:first").attr("data");
        var lnk = el.find("span:first").attr("rel");

        $("." + subClass).hide();
        $("#" + lnk).show();


        $("body").trigger("tabs/selected", {
            tab: el
        })

    });



    $("div.cls_maglie").each(function() {
        var div_maglia = $(this);

        $("table.maglia", div_maglia).map(function(n, i) {
            return n > 0 ? this: null;
        }).hide();

        $("span.maglia", div_maglia).each(function() {
            var maglia = $(this);

            maglia.parents("li:first").bind("click",
            function() {
                $("table.maglia", div_maglia).hide();
                $("table.maglia", div_maglia).map(function() {
                    return $(this).attr("rel") == maglia.attr("rel") ? this: null;
                }).show();
            });
        });
        $("span.maglia:first", div_maglia).parents("li:first").triggerHandler("click");

    });



}
