
notify_on=0;
id_on='';

function checkEvents(second)
{
    new PeriodicalExecuter(checkOTM, second);
    return true;
}

function closeEvents()
{
    if(id_on!="")
    {
        new Effect.Move(id_on,{ x: 0, y: 250, mode: 'relative'});
        notify_on=0;
        setTimeout('closeNotifier()', 3000);
    }
    return false;
}

function closeNotifier()
{
    $('notifier').style.zIndex=-1;
}

function checkOTM()
{
    if(notify_on==0)
    {
        random_num = Math.random();
        new Ajax.Request('/engine_ajax.php?act=notify_otm&user_id='+user_id+'&rand='+random_num, {
            method: 'get',
            onSuccess: function(transport) {
               res = eval(transport.responseText) || "errore";;
               msg=res[0];
               if(msg.response=="full")
               {
                    $(msg.event.otmess_type+"_useract_nick").innerHTML=msg.event.otmess_useract_nick;
                    $(msg.event.otmess_type+"_useract_url").href=msg.event.otmess_useract_url;

                    $('notifier').style.zIndex=2; // abilito div

                    new Effect.Move(msg.event.otmess_type,{ x: 0, y: -250, mode: 'relative'});
                    notify_on=1;
                    id_on=msg.event.otmess_type;
                    setTimeout('closeEvents()', 120000);
                    return false;
               }

            }

        });
    }

}