var settings = {
    messages            : 'messages',
    notificaVoto			: 'notificaVoto',
    notificaContatto		: 'notifica_rubrica',
    messages_hide_delay : 0.5
};

function init(e)
{
    // check if the messages element exists and is visible,
    // and if so, apply the highlight effect to it
    var messages = $(settings.messages);

    if (messages && messages.visible()) {
        new Effect.Highlight(messages);
    }

    // check if the messages element exists and is visible,
    // and if so, apply the highlight effect to it
    var notifiche = $(settings.notificaVoto);

    if (notifiche && notifiche.visible()) {
        new Effect.Highlight(notifiche);
    }

    // check if the messages element exists and is visible,
    // and if so, apply the highlight effect to it
    var notifica_contatto = $(settings.notificaContatto);

    if (notifica_contatto && notifica_contatto.visible()) {
        new Effect.Highlight(notifica_contatto);
    }

    new SearchSuggestor('search');
}

Event.observe(window, 'load', init);

// casella messaggi standard
function message_write(message)
{
    var messages = $(settings.messages);
    if (!messages)
        return;

    if (message.length == 0) {
        messages.hide();
        return;
    }

    messages.update(message);
    messages.show();
    new Effect.Highlight(messages);
}

function message_clear()
{
    setTimeout("message_write('')", settings.messages_hide_delay * 1000);
}

// effetto notifica a fianco stelle votazione post
function notifica_write(notifica)
{
    var notifiche = $(settings.notificaVoto);
    if (!notifiche)
        return;

    if (notifica.length == 0) {
        notifiche.hide();
        return;
    }

    notifiche.update(notifica);
    notifiche.show();
    new Effect.Highlight(notifiche);
}

function notifica_clear()
{
    setTimeout("notifica_write('')", settings.messages_hide_delay * 1000);
}

// notifica aggiunta contatto in rubrica
function notifica_contatto_write(notifica)
{
    var notifiche = $(settings.notificaContatto);
    if (!notifiche)
        return;

    if (notifica.length == 0) {
        notifiche.hide();
        return;
    }

    notifiche.update(notifica);
    notifiche.show();
    new Effect.Highlight(notifiche);
}

function notifica_contatto_clear()
{
    setTimeout("notifica_contatto_write('')", settings.messages_hide_delay * 1000);
}
