

$(document).ready(function() {

    // image switch for Stage page
    $('.img-nav a').click(function() {
        $('.img-nav li').removeClass('current');
        var a = $(this);
        var imgNav = a.attr('class');

        $('#dynamic-content > div').each(function() {
            if ($(this).hasClass(imgNav)) {
                $('#dynamic-content div.'+ imgNav ).fadeIn(1000, function() {
                    $(this).removeClass('hidden');
                });
            }
            else {
                $(this).css('display', 'none');
            }
        });

        // image switch for Character Detail pages
        $('.dynamic-content > img').each(function() {

            if ($(this).hasClass(imgNav)) {
                $('.dynamic-content img.'+ imgNav ).fadeIn(1000, function() {

                    $(this).removeClass('hidden');
                });
            }
            else {
                $(this).css('display', 'none');
            }
        });
        a.parent().addClass('current');
    });

    // Virtual console image switch on super metroid hover

    var metroidSwitch = {
        init:function() {

            $('.promo-btns a#super-metroid').mouseover(function () {
                $('.promo-holder.console').addClass('super');
            })

            $('.promo-btns a#super-metroid').mouseout(function () {
                $('.promo-holder.console').removeClass('super');
            })
        }
    };
    metroidSwitch.init();


    /**
     * Promo Nav functionality across the website
     */

    var promoNav = {
        init:function() {

            var navLI = $('#promo-nav ul li');

            navLI.mouseover(function () {

                $(this).siblings().children().removeClass('current');
                $(this).siblings().children('.promo-holder').addClass('hidden');
                if (!$(this).children().hasClass('current')) {
                    $(this).children().addClass('current');
                    $(this).children('.promo-holder').removeClass('hidden');
                }
            });

            navLI.mouseout(function (event) {
                if ($(this).children().hasClass('current')) {
                    $(this).children().removeClass('current');
                    $(this).children('.promo-holder').addClass('hidden');
                }
                else { $(this).sibling().hasClass('live')
                    $(this).children().removeClass('hidden');
                    $(this).children().addClass('current');
                }

            });
        }
    };
    promoNav.init();


    /*
     * Overlay for Buy Now/Buy Now click-thru series
     */

    $("#one").colorbox({   width:"769px",
        height:'391px',
        inline:true,
        href:"#overlay-content .step1"   ,
        title:false
    });
    $("#two").colorbox({   width:"769px",
        height:'442px',
        inline:true,
        href:"#overlay-content .step2",
        title:false
    });
    $("#three").colorbox({   width:"769px",
        height:'527px',
        inline:true,
        href:"#overlay-content .step3",
        title:false
    });

    $("#click").click(function(){
        $('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
        return false;
    });






}); //end of Document Ready


