/** Chat */
function getChatPopupSize()
{
    var h = window.screen.availHeight;
    var w = window.screen.availWidth;
    return w + "x" + h;
}

// Tailles possibles du popup de Chat
appletSizes = new Array();
appletSizes[0] = '752x615';
appletSizes[1] = '950x740';
appletSizes[2] = getChatPopupSize();

// Par défaut, taille adaptée
appletSize = appletSizes[2];

var chatpopup;
function popChat(channel,pseudo)
{
    if (typeof chatpopup != 'undefined' && !chatpopup.closed && !confirm(txtNewPopup)) {
        if (typeof chatpopup.focus != 'undefined')
            chatpopup.focus();
        return false;
    }

    var time = new Date();
    var chatPopupPath = www_path+'chat/chat20080110/popup.php';
    var url = chatPopupPath+'?ts='+time.getTime();

    if(typeof chatBeta != 'undefined') {
      url += '&chatbeta=1';
    }

    if (channel)
    {
      url += '&chan='+channel;
    }
    if (pseudo)
    {
      url += '&query='+pseudo;
    }

    var size = appletSize.split('x');
    var wnd = window.open('','skyChatWindow', 'resizable=yes,location=no,height='+size[1]+',width='+size[0]+', menubar=no,status=no,scrollbars=no,menubar=no');
    try {
        if (!wnd.document.getElementById('skyrockChat'))
        {
            wnd.location = url;
            wnd.focus();
            return true;
        }
        else
        {
            wnd.focus();
            return false;
        }
    } catch (e) {
        if (e instanceof TypeError)
        {
            // on arrive ici si le SM est activé
            wnd.location = url;
            wnd.focus();
            return true;
        }
        wnd.focus();
        return false;
    }
    wnd.focus();
}
