// VARS (GLOBAL, from the outside)
var WEB_APPLICATION_NAME = "mobbeel";
var USER_AGENT_LANGUAGE = (navigator.language || navigator.systemLanguage || navigator.userLanguage || 'en').substr(0, 2).toLowerCase();

function changeLanguage(languageToChange) {

    // Taking current location
    var currentLocation = new String(window.location);

    var languageChanged = '';

    // Finding out the language to change and the changed language
    if (languageToChange == 'en') {
        languageChanged = 'es';
    } else {
        languageChanged = 'en';
    }
    /* Checking if it's in in incoming language already. If yes, do nothing. If not, changing it for the new one*/
    if (currentLocation.indexOf('/' + languageChanged + '/') > 0 || currentLocation.indexOf('/' + languageToChange + '/') > 0) {
        var newLocation = currentLocation.replace('/' + languageChanged + '/', '/' + languageToChange + '/');
        location.href = newLocation;
    } else {
        // We have the original url system (without i18n). So, substitute url with the localized one
        var newLocation = new String(currentLocation.replace(WEB_APPLICATION_NAME,languageToChange + '/' + WEB_APPLICATION_NAME));
        location.href = newLocation;
    }
}

function initializeSlide() {
    $(".rack-design").showcase({
    width: "600px",
    height: "375px",
    animation: { type: "fade", interval: 3500, speed: 1000 },
    navigator: { item: { width: "64px", height: "48px" },
    showMiniature: true,
    autoHide: true }
    });
}

function initializeMenu (animationSpeed) {

    $('#menu_list li')
        .mouseover(function(){
            $(this).stop().animate({backgroundPosition:"0 15px",opacity:"1.0"}, {duration:animationSpeed});
    })
    .mouseout(function(){
        $(this).stop().animate({backgroundPosition:"0 30px",opacity:"0.8"}, {duration:animationSpeed, complete:function() {
        }})
    })

}

