Phx.namespace('Phx.Application.Modules.SelectPlatformExternalLink', new function()
{
    var _getLoggedInCount = function () {
        return ((loggedIn_avz === true)? 1 : 0)+
               ((loggedIn_pvz === true)? 1 : 0)+
               ((loggedIn_svz === true)? 1 : 0);
    };
    
    var _redirectToFirstLoggedInPlatform = function () {
        if(loggedIn_avz) {
            document.location.href = $('#Mod-Link-Selection-avz').attr('href');
            return;
        }
        if(loggedIn_pvz) {
            document.location.href = $('#Mod-Link-Selection-pvz').attr('href');
            return;
        }
        if(loggedIn_svz) {
            document.location.href = $('#Mod-Link-Selection-svz').attr('href');
            return;
        }
    };
    
    var _hideLoggedOutPlatforms = function () {
        if(!loggedIn_avz) {
            $('#Mod-Link-Selection-avz').hide();
        }
        if(!loggedIn_pvz) {
            $('#Mod-Link-Selection-pvz').hide();
        }
        if(!loggedIn_svz) {
            $('#Mod-Link-Selection-svz').hide();
        }
    };
    
    this.init = function()
    {
        var loggedInCount = _getLoggedInCount();
        if(loggedInCount === 0) {
            return;
        }
        if(loggedInCount === 1) {
            _redirectToFirstLoggedInPlatform();
        }
        else {
            _hideLoggedOutPlatforms();
            return;
        }
        
    };    
    
}());