﻿$(function()
{
    $(".tab-title li").first().children().addClass("current");
    $(".tab-content li").first().fadeIn("normal");

    $(".tab-title li").hover(
    function()
    {
        if (!$(".tab-content li").is(":animated"))
        {
            $(".tab-title li").children().removeClass("current");
            $(this).children().addClass("current");
            changeContent();
        }
    },
    function()
    {
    })

    setInterval("actionLoop()", 5000);

})

function actionLoop()
{
    if ($(".tab-title li").last().children().hasClass("current"))
    {
        $(".tab-title li").last().children().removeClass("current");
        $(".tab-title li").first().children().addClass("current");
        changeContent();
    }
    else
    {
        $(".tab-title li .current").parent().addClass("temp");
        $(".tab-title li .current").removeClass("current");
        $(".tab-title .temp").next().children().addClass("current");
        changeContent();
        $(".tab-title .temp").removeClass("temp");
    }
}
function changeContent()
{
    var _index = $(".tab-title li .current").parent().index();
    $(".tab-content li").eq(_index).fadeIn("normal").siblings(".tab-content li").fadeOut("normal");
}
