/** 
 *    Common scripts file
 *    @version: 1.0 
 *  @require: jquery
 */
 
var currentPosition = 0; 
var currentVolume = 80;  
var player = null;
var playerReady = false; 

TopUp.addPresets({
    "div.multimediaBox li a.top_up": {
        title: "{alt}",
        type: 'flashvideo',
        readAltText: 1,
        width: 300, 
        height: 30,
        shaded: 1
        },
    "div.photogallery ul li a.top_up": {
        title: "{alt} ({current} di {total})",
        group: "mycarousel",
        readAltText: 1,
        shaded: 1
        },
    "div.videogallery ul li a.top_up": {
        readAltText: 1,
        width: 500, 
        height: 400,
        shaded: 1
        },
    "div.follow ul li.icoMail a.top_up": {
        title: 'Segnala la pagina',
        type: 'iframe',
        width: 400, 
        height: 550,
        layout: 'flatlook',
        resizable: 0
        },
    "#footer div.sisma a.top_up": {
        title: "{alt} ({current} di {total})",
        group: "sisma",
        readAltText: 1,
        shaded: 1
        }
});

$(document).ready(function() {
    //emailProtection('.email'); 
    printButtons('li.icoPrint a');
    goBack('a.back');        
    //loadNavbar('#nav ul.main li.menu-item'); 
    loadCarousel('div.photogallery ul');
    loadCarousel('div.videogallery ul');
});

function loadCarousel(el)
{
    if ($(el).length > 0)
    {
        $(el).jcarousel();
    }
}

function loadNavbar(els)
{
    /*$(els).addEvents({
        'mouseover': function(e){
            e = new Event(e).stop();
            this.addClass('hover');
        },
        'mouseout': function(e){
            e = new Event(e).stop();
            this.removeClass('hover');
        }
    }); */
}

function emailProtection(elClass)
{
    /*
    $each($$(elClass), function(el) {
        var mail = el.get('text').replace('[AT]','@');
        var text = el.get('title') || mail;
        var a = (new Element('a').setProperty('href', 'mailto:' + mail).addClass(elClass.substring(1)).set('text', text)).replaces(el);
    });
    */
}

function printButtons(elClass)
{
    $(elClass).click(function(e){
        e.preventDefault();
        window.print();
    });
}

function goBack(elClass)
{
    $(elClass).click(function(e){
        e.preventDefault();
        window.history.back();
    });
}
