var winRef=null;


function checkWindowExist_notify(user, room, serverH, sex, serverPHP)
{
    var url="/chat/chat.html";
    var paramTmp = '?usernameH=' + user + '&passwordH=l2l&serverH='+serverH+'&serverPHP='+serverPHP+'&roomServerH=conference&roomNameH=' + room + '&roomColorH=' + sex +'&portServerH=5222&logView=0';

    if(winRef != null)
    {
       if(winRef.closed)
       {
            winRef = window.open(url + paramTmp, "testWindow","width=555,height=505,menubar=no,location=no,scrollbars=no,status=no,resizable=no,toolbar=no");
       }
       else
       {
         var flashmovie = winRef.document.chat;
	 winRef.focus();
         flashmovie.sendToSwf(room);//metodo flash da richiamare con passaggio di parametri
       }
    }
    else
    {
        winRef = window.open(url + paramTmp, "testWindow","width=555,height=505,menubar=no,location=no,scrollbars=no,status=no,resizable=no,toolbar=no");
    }
      closeEvents();
}


function checkWindowExist(url, user, pwd, server, serverPHP, roomServer, room,user_nick,user_nick_rcpt,user_nick_rcpt_sex,portServer,logView){
    var paramTmp = '?usernameH=' + user + '&passwordH=' + pwd + '&serverH=' +server + '&serverPHP=' +serverPHP + '&roomServerH=' + roomServer + '&roomNameH=' + room + '&roomColorH=' + user_nick_rcpt_sex + '&portServerH='+portServer + '&logView='+logView;
    if(winRef != null && winRef != "")
    {
       if(winRef.closed)
       {
            winRef = window.open(url + paramTmp, "testWindow","width=555,height=505,menubar=no,location=no,scrollbars=no,status=no,resizable=no,toolbar=no");
       }
       else
       {
         var flashmovie = winRef.document.chat;
	 winRef.focus();
         flashmovie.sendToSwf(room);//metodo flash da richiamare con passaggio di parametri
       }

        new Ajax.Request('/engine_ajax.php?act=set_otm_chat&user_nick='+user_nick+'&user_nick_rcpt='+user_nick_rcpt+'&room='+room,
            {
                method:'get',
                onSuccess: function(transport){
                    response = eval(transport.responseText) || "errore";
                },
                onFailure: function(){ alert('Error set notify!') }
            });


    }
    else
    {
        winRef = window.open(url + paramTmp, "testWindow","width=555,height=505,menubar=no,location=no,scrollbars=no,status=no,resizable=no,toolbar=no");

        new Ajax.Request('/engine_ajax.php?act=set_otm_chat&user_nick='+user_nick+'&user_nick_rcpt='+user_nick_rcpt+'&room='+room,
        {
            method:'get',
            onSuccess: function(transport){
              response = eval(transport.responseText) || "errore";
            },
            onFailure: function(){ alert('Error set notify!') }
        });
    }
}

