/**
 * @author Dean Peterson
 * @requirements
 * @copyright 2010 Dean Peterson
 * 
 */

$(function(){
    if(!document.console){
        document.console = {};
        document.console.log = function(){};
    }
    
    $("[data-showcase]").each(function(){
        var $showCase = $(this),
            data = $showCase.attr("data-showcase"),
            colors = "ui-color-red ui-color-green ui-color-blue ui-color-yellow ui-color-ltblue",
            colorArray = (function(){
                var string = $.trim(colors),
                    clrArray = string.split(" ");
                return clrArray;
                }()),
            speed = 4500;
        $showCase.addClass(colorArray[0]);
        $showCase.tabs({
            cache: true
        })
        .tabs("disabled")
        .find("ul.ui-tabs-nav li").each(function(index,panel){
            var $this = $(this);
            $this.attr("color",colorArray[index]);
        });
        console.log($.parseJSON(data));
        
        
        $showCase.tabs( "rotate" , speed)
            .tabs({
                show :function(){
                    var $this = $(this),
                        activeColor = $this.find("li.ui-state-active").attr("color");
                    $this.removeClass(colors).addClass(activeColor);
                }
            })
            .tabs("enable")
            .hover(
                function(){
                    $(this).tabs('rotate',0);
                },
                function(){
                    $(this).tabs('rotate',speed);
                }
            );
    });
    
    

});

