$(document).ready(function() {

    //Default Action
    $(".tab_content").hide(); //Hide all content
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
    $(".tab_content:first").show(); //Show first tab content
	
    //On Click Event
    $("ul.tabs li").click(function() {
        $("ul.tabs li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tab_content").hide(); //Hide all tab content
        var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active content
        if($($(this).children()[0]).attr('href') == '#tab4'){
            getPlayerCode();
        }
        if ($($(this).children()[0]).attr('href') == '#tab5'){
            $.post("/v2.0/index.php", {
                action: "signout"
            }, function(response){
                if (response.success == 1){
                    WizardParams.channel_user_id = null;
                    location.replace('/v2.0/');
                    
                }else{
                }


            }, "json");
        }

        return false;
    });

    if (WizardParams.channel_user_id == null || WizardParams.media_format == null){


        var pLayer = $('#popup');
        var popWidth = 220;

        pLayer.fadeIn().css({
            'width': Number( popWidth )
        });
        var popMargTop = (pLayer.height() + 80) / 2;
        var popMargLeft = (pLayer.width() + 80) / 2;
        pLayer.css({
            'margin-top' : -popMargTop,
            'margin-left' : -popMargLeft
        });
        $('body').append('<div id="fade"></div>');
        $('#fade').css({
            'filter' : 'alpha(opacity=80)'
        }).fadeIn();

    }



});
