
$(document).ready(function() {    
    showSubMenu();
    topHeight();
    tabMenu();
    ie6();
});

function ie6() {
    if ($.browser.msie && $.browser.version.substr(0, 1) < 7) {
        $('.topmainM .top-flash').empty();
        $('.topmainM').append("<div class='topPress'><img src='/Files/System/img/topBilder/topPress.jpg'/></div>");
    }
}

function checkUrl() {

    if (window.location.href.toLowerCase().indexOf("/products/casino.aspx") != -1) {
        showPage('1');
    }

    if (window.location.href.toLowerCase().indexOf("/products/bingo.aspx") != -1) {
        showPage('2');
    }

    if (window.location.href.toLowerCase().indexOf("/products/lottery.aspx") != -1) {
        showPage('3');
    }

    if (window.location.href.toLowerCase().indexOf("/products/poker.aspx") != -1) {
        showPage('4');
    }

    if (window.location.href.toLowerCase().indexOf("/products/sports-betting.aspx") != -1) {
        showPage('5');
    }

    if (window.location.href.toLowerCase().indexOf("/products/skill.aspx") != -1) {
        showPage('6');
    }

    if (window.location.href.toLowerCase().indexOf("/products/games.aspx") != -1) {
        showPage('7');
    }
}

jQuery.fn.centerV = function() {
    this.css("position", "absolute");
    this.css("z-index", "300");
    this.css("left", ($(window).width() - this.width()) / 2 + $(window).scrollLeft() + "px");
    return this;
}

function topHeight() {

    $('#topnav-wrap').centerV();
    
    if ($('.topmainM .top-flash').html() != null) {
        $('.topmainM').css({ 'height': '480px' });
    }
    else {
        $('.topmainM').css({ 'height': '365px' });
    }

}

function showSubMenu() {
    $('ul.topNav li:last-child').css({ 'background': 'none' });

    $('ul.topNav li').hover(function() {
        $(this).css({ 'background': '#fff' });
    }, function() {
    $(this).css({ 'background': 'url(Files/System/img/topnav/topnav_divider.png) no-repeat top right' });
    }
    );


    $("ul.topNav li.item").click(function() {
        var buttonWidth = $(this).outerWidth();
        $(this).children('.subNav').css({ 'width': buttonWidth +'px' });
        $(this).children('.subNav').slideDown(200).show();

        $(this).hover(function() {
        }, function() {
            $(this).children('.subNav').slideUp(200);
        });
    });

    $("ul.subNav li").hover(function() {
        $(this).css({ 'background': '#efefef' });
    },
    function() {
        $(this).css({ 'background': '#fff' });
    }
    );
}

function apa(id) {
    var productId = id;

    if (productId == '0') {
        window.location = 'Default.aspx';
    }
    if (productId == '1') {
        window.location = '/Products/Casino.aspx';
    }    
    if (productId == '2') {
        window.location = '/Products/Bingo.aspx';
    }
    if (productId == '3') {
        window.location = '/Products/Lottery.aspx';
    }
    if (productId == '4') {
        window.location = '/Products/Poker.aspx';
    }
    if (productId == '5') {
        window.location = '/Products/Sports-Betting.aspx';
    }    
    if (productId == '6') {
        window.location = '/Products/Skill.aspx';
    }  
    if (productId == '7') {
        window.location = '/Products/Games.aspx';
    }          
}

function showPage(flashId) {

    if (flashId != null) {
        var flashMovie = document.g2VideoContainer7;
        flashMovie.updateFlash(flashId);
    }
}

function tabMenu() {

    $('ul#productNav li').each(function(i) {
        i++;
        i = i - 1;        
        $(this).click(function() {
            $('.contentDiv').hide();
            $('ul#productNav li').removeClass("selected");
            $('ul#productNav li:first').removeClass("tab1-selected");
            $('ul#productNav li:first').addClass("tab1");
            $(this).addClass("selected");
            $('#productNavTabContent' + i).fadeIn(180);
        });        

        $('ul#productNav li:first').click(function() {
            $('.contentDiv').hide();
            $('ul#productNav li').removeClass("selected");
            $(this).addClass("tab1-selected");
            $('#productNavTabContent0').fadeIn(180);
        });
    });

    $('ul#productNav li a span').each(function(i) {

        var obj = $('ul#productNav li a span').eq(i);
        var objChange = $('ul#productNav li a span').parents().find('.product_nav');

        if (obj.html() != null) {
            if (obj.html().length > 12) {
                $(objChange).attr("class", $(objChange).attr('class').replace('product_nav', 'manage_nav'));
            }
            else {
                //alert("nej!");
            }
        }
        i++;
    });
}


	
