$(document).ready(function() {

    //RN Widget
    if ($("div.RNWidget").length > 0) {
        InitRNWidget();
    }
    
    $(".platformBox").each(function() {
        $(this).hover(function() {
            $('a > p', this).fadeIn('fast');
            $('.platformBoxHover', this).fadeIn('fast');

        },
		function() {
		    $('a > p', this).fadeOut('fast');
		    $('.platformBoxHover', this).fadeOut('fast');
		})
    });

    $(".platformBoxSml").each(function() {
        $(this).hover(function() {
            $('img', this).fadeOut('fast');
            $('.platformBoxSmlHover', this).fadeIn('fast');

        },
		function() {
		    $('img', this).fadeIn('fast');
		    $('.platformBoxSmlHover', this).fadeOut('fast');
		})
    });

    if ($('#gameList').accordion != null) {
        $('#gameList').accordion({ active: false });
    }

    $('.gamePacks > .packList').width($('.gamePacks').width() - 10);
    $(window).resize(function() {
        $('.gamePacks > .packList').width($('.gamePacks').width() - 10);
    });


    //hover
    $("ul.gList > li:first-child").addClass('defaultGame');
    $("ul.gList > li:first-child > a.gameItem").addClass('gameItemHover');

    $("ul.gList > li").each(function() {

        $(this).hover(function() {
            $('.packList', this).fadeIn("fast");
            $('a.gameItem', this).addClass('gameItemHover');
            $("ul.gList > li:first-child > a.gameItem").removeClass('gameItemHover');
        },
		function() {
		    $('.packList', this).fadeOut("fast");
		    $('a.gameItem', this).removeClass('gameItemHover');
		    $("ul.gList > li:first-child > a.gameItem").addClass('gameItemHover');
		})
    });

    //tabs
    var tabContainers = $('div.tabC > div');
    tabContainers.hide().filter(':first').show();

    $('div.tabC ul.tabNavigation a').click(function() {
        tabContainers.hide();
        tabContainers.filter(this.hash).show();
        $('div.tabC ul.tabNavigation a').removeClass('selected');
        $(this).addClass('selected');
        return false;
    }).filter(':first').click();

    //nav
    if ($('div.infoC').attr("platformID") != null) {
        $("div.packBox a").each(function() {
            var url = $(this).attr("href");
            $(this).attr("href", url + "&pid=" + $('div.infoC').attr("platformID"));
        })
    }

    if ($("div.nav").attr("step") == 3 && $("div.greyHeader").text().length > 0) {
        $("div.nav").html($("div.nav").html() + " / " + $("div.greyHeader").text());
    }

    if ($("a#navPlatform") != null && $("a#navPlatform").length > 0) {
        $("a.backBtn").attr("href", $("a#navPlatform").attr("href"));
    }

    //full size
    if ($("div.leftPart") == null || $("div.leftPart").length == 0) {
        $("div.rightPart").addClass("fullSize");
        $("div.tabC").attr("style", "width:85%")
    }

});

