function Delegate(A, B) 
{
    return function() { B.apply(A, arguments); };
}

function TabbedModule(A) {
    this._element = $(A);
    this._element.find(".tabs li a").each(new Delegate(this, function(B, C) {
        C = $(C);
        if (!C.parent("li").hasClass("selected")) {
            this._element.find(C.attr("href")).hide()
        }
        C.click(new Delegate(this, function(D) {
            var E = $(C.parents("ul").find("li.selected a"));
            E.parent("li").removeClass("selected");
            this._element.find(E.attr("href")).hide();
            C.parent("li").addClass("selected");
            this._element.find(C.attr("href")).show();
            D.preventDefault()
        }))
    }))
}
TabbedModule.prototype = {
    _element: null
};

function CompanyViewer(B, D, C, A) {
    this._element = $(B);
    this._direction = D || CompanyViewer.HORIZONTAL;
    this._numCompanies = C || 4;
    this._movement = A || 150;
    if (this._element.children().length > this._numCompanies) {
        this._hideCompanies();
        this._createNavigation();
        this._startSlider();
        this._element.mouseover(new Delegate(this, this._stopSlider));
        this._element.mouseout(new Delegate(this, this._startSlider));
    }
}

CompanyViewer.prototype = { _numCompanies: null, _direction: null, _TIME_PER_COMPANY: 3000, _element: null, _companies: null, _interval: null, _movement: null, _hideCompanies: function() { $.each(this._element.children(), new Delegate(this, function(B, A) { if (B >= this._numCompanies) { $(A).hide(); } })); }, _createNavigation: function() { var A = $("<a class=\"previous-company\"></a>").insertBefore(this._element); var B = $("<a class=\"next-company\"></a>").insertAfter(this._element); A.mouseover(new Delegate(this, this._stopSlider)); A.mouseout(new Delegate(this, this._startSlider)); B.mouseover(new Delegate(this, this._stopSlider)); B.mouseout(new Delegate(this, this._startSlider)); if (this._direction == CompanyViewer.HORIZONTAL) { A.click(new Delegate(this, this._moveRight)); B.click(new Delegate(this, this._moveLeft)); } else { A.click(new Delegate(this, this._moveDown)); B.click(new Delegate(this, this._moveUp)); } }, _startSlider: function() { if (this._interval) { return; } if (this._direction == CompanyViewer.HORIZONTAL) { this._interval = setInterval(new Delegate(this, this._moveLeft), this._TIME_PER_COMPANY); } else { this._interval = setInterval(new Delegate(this, this._moveUp), this._TIME_PER_COMPANY); } }, _moveLeft: function() { var A = this._element.children()[0]; var B = this._element.children()[this._numCompanies]; $(A).animate({ marginLeft: "-" + this._movement + "px" }, 1000, new Delegate(this, function() { $(A).hide().css("margin-left", "").appendTo(this._element); })); $(B).css("margin-right", "-" + this._movement + "px").show().animate({ marginRight: "0px" }, 1000); }, _moveRight: function() { var A = this._element.children()[this._numCompanies - 1]; var B = this._element.children()[this._element.children().length - 1]; $(A).animate({ marginRight: "-" + this._movement + "px" }, 1000, new Delegate(this, function() { $(A).hide().css("margin-right", ""); })); $(B).prependTo(this._element).css("margin-left", "-" + this._movement + "px").show().animate({ marginLeft: "0px" }, 1000); }, _moveUp: function() { var A = this._element.children()[0]; var B = this._element.children()[this._numCompanies]; $(A).animate({ marginTop: "-" + this._movement + "px" }, 1000, new Delegate(this, function() { $(A).hide().css("margin-top", "").appendTo(this._element); })); $(B).css("margin-bottom", "-" + this._movement + "px").show().animate({ marginBottom: "0px" }, 1000); }, _moveDown: function() { var A = this._element.children()[this._numCompanies - 1]; var B = this._element.children()[this._element.children().length - 1]; $(A).animate({ marginBottom: "-" + this._movement + "px" }, 1000, new Delegate(this, function() { $(A).hide().css("margin-bottom", ""); })); $(B).prependTo(this._element).css("margin-top", "-" + this._movement + "px").show().animate({ marginTop: "0px" }, 1000); }, _stopSlider: function() { if (this._interval) { clearInterval(this._interval); } this._interval = null; } };
CompanyViewer.HORIZONTAL = 1;
CompanyViewer.VERTICAL = 2;

$(document).ready(function() {
if (typeof CompanyViewer == "function") {
    new CompanyViewer(".company-viewer .companies");
}
$(".tabbed-module").each(function(A, B) {
    if (typeof TabbedModule == "function") {
        new TabbedModule(B)
    }
});
});