﻿
function RefreshHomeJackpotInfo(Amount, Increment) {

    var CallAgain = false;
    var JackpotAmount = Amount;
    var JackpotIncrement = Increment;
    var DisplayTicker = '';
    var PageCulture = $('#PageCulture').val();

    //alert(PageCulture);

    var AfterGetRoomInfo = function (responseText, loadIn, postLoad, extendedData) {
        var result = responseText;
        //alert(result);
        if (result != '') {
            var ObjJSON = parseJSON(result, 'RefreshHomeJackpotInfo');
            if (ObjJSON) {
                if (ObjJSON.status == 'OK') {
                    JackpotAmount = ObjJSON.jackpotamount;
                    JackpotIncrement = ObjJSON.jackpotincrement;
                    JackpotAmount = parseInt(JackpotAmount) + parseInt(JackpotIncrement);
                    //DisplayTicker = insComma(JackpotAmount);
                    JackpotAmount = JackpotAmount / 100;
                    JackpotIncrement = JackpotIncrement / 100;

                    var HostValue = window.location.host.toLowerCase();
                    switch (HostValue) {
                        case 'www.roxypalace.com': { PageCulture = 'en-GB'; break; }
                        case 'www.roxypalace.dk': { PageCulture = 'da-DK'; break; }
                        case 'se.roxypalace.com': { PageCulture = 'sv-SE'; break; }
                        default: { PageCulture = 'sv-SE'; break; }
                    }
                    
                    //alert(PageCulture);

                    if (PageCulture == 'en-GB') {
                        DisplayTicker = num2currency(JackpotAmount, '163');
                    }
                    else if (PageCulture == 'da-DK') {
                        DisplayTicker = num2currency(JackpotAmount, '68,75,75');
                    }
                    else if (PageCulture == "sv-SE") {
                        DisplayTicker = num2currency(JackpotAmount, '8364', 'sv-SE');
                    }
                    else {
                        DisplayTicker = num2currency(JackpotAmount, '8364');
                    }
                    if ($('#CasinoJackpot').length > 0) {
                        $('#CasinoJackpot').html(DisplayTicker);
                    }
                    CallAgain = true;
                }
                else {
                    alert(ObjJSON.errDESC);
                }
            }
        }
        if (CallAgain == true) {
            setTimeout("RefreshHomeJackpotInfo('" + JackpotAmount + "','" + JackpotIncrement + "')", 5000);
        }
    }

    if (Amount == null && Increment == null) {
        var data;
        data = 'action=RefreshHomeJackpot&CurrencyID=null';
        //alert(data);
        ajaxRequest('/desktopmodules/Bluestar.SkinControls/casinoprocess.aspx', data, null, null, AfterGetRoomInfo, null, null);
    }
    else {
        var JackpotValue = parseFloat(JackpotAmount);
        var IncrementValue = parseFloat(JackpotIncrement);

        JackpotValue = JackpotValue + IncrementValue;
        if (PageCulture == 'en-GB') {
            DisplayTicker = num2currency(JackpotAmount, '163');
        }
        else if (PageCulture == 'da-DK') {
            DisplayTicker = num2currency(JackpotAmount, '68,75,75');
        }
        else if (PageCulture == "sv-SE") {
            DisplayTicker = num2currency(JackpotAmount, '8364', 'sv-SE');
        }
        else {
            DisplayTicker = num2currency(JackpotAmount, '8364');
        }
        if ($('#CasinoJackpot').length > 0) {
            $('#CasinoJackpot').html(DisplayTicker);
            setTimeout("RefreshHomeJackpotInfo('" + JackpotValue + "','" + IncrementValue + "')", 1000);
        }
    }

}

var JackpotNum = $('#dnn_CasinoJackpot_JackpotNum').val();
var IncrementNum = $('#dnn_CasinoJackpot_IncrementNum').val();

RefreshHomeJackpotInfo(JackpotNum, IncrementNum);


