﻿
//launch the lobby
function OpenLobby(GCode)
 {

     var ul, curr, vt, ulLang, site, e;
     ul = document.getElementById("txtLanguage").value;
     curr = document.getElementById("homeCurrencyHolder").value.toUpperCase();
     vt = document.getElementById("txtVT").value;
     site = document.getElementById("currentSite").value;
     e = "";

     if (site.indexOf("dev.") != -1) {

         e = "dev.";

     } else if (site.indexOf("qa.") != -1) {

         e = "qa.";

     } else if (site.indexOf("st.") != -1) {

         e = "st.";
     }
    
     
    ulLang = getThreeCharLang(ul)


    var url = 'https://secure.' + e + 'neogames-tech.com/ScratchCards/lobby.aspx?' + 'CSI=70&LNG=' + ulLang + '&CUR=' + curr + '&BD=info.' + e + 'safariscratch.com&SDN=' + e + 'safariscratch.com&PAR=' + vt + '&AFI=&AR=&RegistrationMode=&BO=&PRD=&GID=' + GCode;
    var winName = '';
    var urlParms = "resizable=yes,left=0,top=0,width=" +
    (window.screen.width - 8) + ",height=" +
    (window.screen.height - (window.screen.height > 600 ? 70 : 50));
    window.open(url, winName, urlParms);
}

// Launch Chat
function launchChat()
{
    var ul, curr, vt, ulLang;
    ul = document.getElementById("txtLanguage").value;
    //curr = document.getElementById("txtCurrency").value;
    curr = document.getElementById("homeCurrencyHolder").value;
    vt = document.getElementById("txtVT").value;

    ulLang = getThreeCharLang(ul)

    var url = 'https://server.iad.liveperson.net/hc/15712222/?cmd=file&amp;file=visitorWantsToChat&amp;site=15712222&VISITORVAR!Brand=safariscratch.com&amp;VISITORVAR!Username=-&VISITORVAR!PlayMode=WebSite&amp;SESSIONVAR!Language=' + ulLang + '&amp;SESSIONVAR!Currency=' + curr + '&amp;referrer=http://www.safariscratch.com&CurrencyCode=' + curr + '&amp;LanguageCode=' + ul
    var winName = '';
    var urlParms = "resizable=no,left=0,top=0,width=150,height=550" +
    window.open(url, winName, urlParms);
}

// get the three character language code for Neo Games
function getThreeCharLang(ul) {
   
    switch (ul) {
        case "en":
            ul = "ENG"
            break;
        case "fr":
            ul = "FRE"
            break;
        case "de":
            ul = "GER"
            break;
        case "es":
            ul = "SPA"
            break;
        case "it":
            ul = "ITA"
            break;
        case "nl":
            ul = "DUT"
            break;
        case "pt":
            ul = "POR"
            break;
        case "pt-br":
            ul = "BRA"
            break;
        case "sv":
            ul = "SWE"
            break;
        case "no":
            ul = "NOR"
            break;
        case "da":
            ul = "DAN"
            break;
        case "fi":
            ul = "FIN"
            break;
        case "el":
            ul = "GRE"
            break;
        default:
            ul = "ENG"
       
    }

    return ul

}


$(document).ready(function() {

    SetCurrency("eur");

    var langDropDown = $("#currentLanguage").val()


    if (langDropDown == "sv") {

        SetCurrency("sek");

    } else {

        SetCurrency("eur");

    }


});

function SetCurrency( Item ) {

    $('.homeOfferTextHolder').attr('id', Item + 'OfferText');
    $('#homeCurrencyHolder').val(Item);
    $("#dropDownCurrency option[value='" + $("#homeCurrencyHolder").val() + "']").attr('selected', 'selected');

}






