﻿/*
JS menu definition
MainNamespace SMALP
Marco Faustinelli - www.faustinelli.net
*/
(function (ns) {
    ns.menu = {
        testFlag: 'SMALP.menu',
        imgDir: '/includes/img_title/',
        pageDir: '/html',
        blinking: false,
        htmlMenu: function (menuObject) {
            var menuRow = $('<tr>').attr('id', menuObject.title.replace(' ', '_') + '-id');
            menuRow.append($('<td>').attr('class', 'smalpleftcolumn').html('\&nbsp;'));
            var menuAnchor = $('<a>').attr('href', SMALP.menu.pageDir + '/' + menuObject.page).attr('class', 'smalpfont').text(menuObject.title);
            if (menuObject.title === 'TEST') menuAnchor.css('color', 'White');
            menuRow.data('menuObject', menuObject);
            menuRow.append($('<td>').attr('class', 'smalpmenucell').append(menuAnchor));
            return menuRow;
        },
        blink: function (menuItemName) {
            this.blinking = !this.blinking;
            var blinkingItem = $('#' + menuItemName.replace(' ', '_') + '-id')
            if (this.blinking) blinkingItem.addClass('blinking');
            else blinkingItem.removeClass('blinking');
        },
        menuVoices: [
            {
                title: 'Chi Siamo',
                page: 'la-storia-del-coro-smalp-fondato-nel-1981.html',
                img: 'Chi_siamo.jpg'
            },
            {
                title: 'News',
                page: 'news-del-coro-smalp.html',
                img: 'News.jpg'
            },
            {
                title: 'Agenda',
                page: 'agenda-del-coro-smalp-calendario-prove-e-appuntamenti.html',
                img: 'Appuntamenti.jpg'
            },
            {
                title: 'Immagini',
                page: 'immagini-del-coro-smalp-fotogallery-pubblica-e-interna.html',
                img: 'Foto.jpg'
            },
            {
                title: 'Repertorio',
                page: 'repertorio-del-coro-smalp-con-mp3-da-ascoltare.html',
                img: 'Repertorio.jpg'
            },
                    {
                        title: 'Video',
                        page: 'video-di-esibizioni-del-coro-smalp.html',
                        img: 'Video.jpg'
                    },
            {
                title: 'Parlano di noi',
                page: 'rassegna-stampa-del-coro-smalp.html',
                img: ''
            },
            {
                title: 'Reclutamento',
                page: 'reclutamento-nuovi-amici-coristi-per-il-coro-smalp.html',
                img: 'Reclu-blink.gif'
            }/*,
            {
                title: 'Contatti',
                page: 'contatta-il-coro-smalp.html',
                img: 'Contatti.jpg'
            }*/,
            {
                title: 'Links',
                page: 'links-con-associazioni-amiche-del-coro-smalp.html',
                img: 'Links.jpg'
            },
            {
                title: 'Riservato',
                page: '../secure/riservato.aspx',
                img: ''
            }
        ]
    };
    // inizializzazione menu
    $(document).ready(function () {
        var menuTable = $('<table>').attr('class', 'menutable smalptable');
        $('#menuHandle').append(menuTable);
        $.each(SMALP.menu.menuVoices, function (index, menuVoice) {
            menuTable.append(SMALP.menu.htmlMenu(menuVoice));
        });
        setInterval('SMALP.menu.blink("Reclutamento")', 2000);
        // alert(SMALP.menu.testFlag);
    })
} (SMALP));
