var $j = jQuery.noConflict();

(function ($j) {
    $j.fn.heightAdjust = function (row, child) {
        this.each(function () {
            var elems = $j(child, this);
            var nelems = elems.length;
            var heights = new Array(nelems);
            var setHeight = function () {
                for (var i = 0; i < nelems; i++) {
                    elems[i].style.height = "";
                    heights[i] = $j(elems[i]).height();
                }
                var max = 0;
                for (var i = 0; i < nelems; i++) {
                    if (0 == i % row) {
                        max = Math.max.apply(Math, heights.slice(i, i + row));
                    }
                    heights[i] = max;
                }
                for (var i = 0; i < nelems; i++) {
                    elems[i].style.height = heights[i] + "px";
                }
            }
            setHeight();
            if ($j("#font-checker").length == 0) {
                $j("body").append('<div id="font-checker" style="position:absolute;left:-9999px;top:0;">&nbsp;</div>');
            }
            var baseSize = $j("#font-checker").height();
            var checkSize = 0;
            setInterval(function () {
                checkSize = $j("#font-checker").height();
                if (baseSize !== checkSize) {
                    setHeight();
                    baseSize = checkSize;
                }
            }, 1000);
        });

    }
})(jQuery);

(function ($j) {
    $j.fn.rollover = function () {
        var elems = this;
        var nelems = elems.length;
        var off = "_off";
        var on = "_on";
        var preLoadImg = new Object();
        for (var i = 0; i < nelems; i++) {
            preLoadImg[elems[i]] = new Image();
            preLoadImg[elems[i]].src = elems[i].src.replace(off, on);
            elems[i].onmouseover = function () {
                this.src = this.src.replace(off, on);
            }
            elems[i].onmouseout = function () {
                this.src = this.src.replace(on, off);
            }
        }
    }
})(jQuery);

$j.event.add(window, "load", function(){
    $j("ul.link-01", "div.layout-relation").heightAdjust(4, "li");
	$j("ul.list-04").heightAdjust(3, "li");
	$j("ul.triple li").heightAdjust(3, "li");
});

$j(function () {
    if ($j("img[src *= '_off.'], input[src *= '_off.']")) {
        $j("img[src *= '_off.'], input[src *= '_off.']").rollover();
    };
    if ($j("table.table-01, table.table-02, table.table-03")) {
        $j("table.table-01, table.table-02, table.table-03").each(function () {
            $j("tr:nth-child(2n+1)", this).addClass("odd");
        });
    }

});
