//tab effects

var TabbedContent = {
    init: function () {
        $(".tab_item").click(function () {

            var background = $(this).parent().find(".moving_bg");

            $(background).stop().animate({
                left: $(this).position()['left']
            }, {
                duration: 300
            });

            TabbedContent.slideContent($(this));

        });

        var position = 1;
        var panelheight = $("#contentBox").find(".tabbed_content").find(".slide_content").find(".tabslider div.tab_div:nth-child(" + position + ")").height();


        ($("#contentBox").find(".tabbed_content").find(".slide_content")).height(panelheight);
    },

    slideContent: function (obj) {

        var margin = $(obj).parent().parent().find(".slide_content").width();
        margin = margin * ($(obj).prevAll().size() - 1);
        margin = margin * -1;

        $(obj).parent().parent().find(".tabslider").stop().animate({
            marginLeft: margin + "px"
        }, {
            duration: 300
        });

        var position = $(obj).prevAll().size();
        var panelheight = $(obj).parent().parent().find(".slide_content").find(".tabslider div.tab_div:nth-child(" + position + ")").height();

        ($(obj).parent().parent().find(".slide_content")).animate({ 'height': panelheight }, { queue: false, duration: 300 });

    }
}

$(document).ready(function() {
	TabbedContent.init();
});
