function initTabs() { $("ul.tabset").each(function () { var btn_h = $(this); var _btn = $(this).find("a.tab"); var _a = _btn.index(_btn.filter(".active:eq(0)")); if (_a == -1) { _a = 0 } _btn.removeClass("active").eq(_a).addClass("active"); _btn.each(function (_i) { this._box = this.href.substr(this.href.indexOf("#") + 1); if (this._box) { this._box = $("#" + this._box); if (_i == _a) { this._box.show() } else { this._box.hide() } } this.onclick = function () { changeTab(_i); return false } }); function changeTab(_ind) { if (_ind != _a) { if (_btn.get(_a)._box) { _btn.get(_a)._box.hide() } if (_btn.get(_ind)._box) { _btn.get(_ind)._box.show() } _btn.eq(_a).removeClass("active"); _btn.eq(_ind).addClass("active"); _a = _ind } } }) } function slideBlock() { $("div.slide-block").each(function () { var hold = $(this); var links = hold.find("> a.open-close"); var box = hold.find("div.block"); var h = box.outerHeight(true); hold.addClass("active"); box.css({ marginTop: -h }); links.click(function () { if (!hold.hasClass("active")) { hold.addClass("active"); box.animate({ marginTop: -h }, 500) } else { hold.removeClass("active"); box.animate({ marginTop: 0 }, 500) } return false }) }) } $(document).ready(function () { initTabs(); slideBlock() });
