﻿// Parametri cookie
var cookieName = 'layoutPos';
var cookieDuration = 365; // days

// Percorso immagini per il tree menu
var subImgOpen = '/templates/centrofiemme/images/list_open.gif';
var subImgClose = '/templates/centrofiemme/images/list_close.gif';

window.addEvent('domready', function() {
    
    // Carico il flash official sponsor
    if ($('offSponsor')) {
        var obj = new Swiff('/templates/centrofiemme/images/banner_cavalese.swf', {
            id: 'officialsponsor',
            width: 176,
            height: 120,
            params: {
                wmode: 'opaque',
                bgcolor: '#ffffff'
            }
        });   
        obj.inject($('offSponsor'));
    }
    
    // Apro il cookie
    var layoutPos = new Hash.Cookie(cookieName, {autoSave: true, duration: cookieDuration, path: '/' });
    layoutPos.load();
    
    // Di default faccio aprire la seconda tab
    if (!layoutPos.get('posTab')) {
        layoutPos.set('posTab', 1);
        layoutPos.load();
    }

    // Gestione tabs inbank, news /////////////////////////////////////////////////////////////////////////////////////////////////////////
    var tabsTop = $$('.tabsTop'); // sono 2
    var boxTop = $$('.boxTop');

    boxTop.setStyles({'opacity':0, 'display':'block'});
    boxTop.set('tween',{duration:400});

    if (tabsTop.length > 0) {
        tabsTop[0].set('index',0);
        tabsTop[1].set('index',1);
        
        // Su explorer 6 è forzato inbank aperto per la gestioen delle immagini
        if (layoutPos.get('posTab') == 1 && !ie6) {
            tabsTop[1].addClass('selected');
            boxTop[1].setStyle('opacity',1);
            layoutPos.set('posTab', 1);
        }
        else { 
            tabsTop[0].addClass('selected');
            boxTop[0].setStyle('opacity',1);
            layoutPos.set('posTab', 0);
        }

        tabsTop.addEvent('click',function(){
            boxTop.tween('opacity',0);
            tabsTop.removeClass('selected');
            this.addClass('selected');
            layoutPos.set('posTab', this.get('index'));
            boxTop[this.get('index')].tween('opacity',1);
        });
    }
    
});

window.addEvent('load', function() {

    // Gestione icone homepage
    $$('.navIcons').addEvent('mouseenter', function(){
	    this.set('tween', { duration: 200});
	    this.tween('margin-top', '-10');																				  
    }).addEvent('mouseleave', function(){
	    this.set('tween', { duration: 300});
	    this.tween('margin-top', '0');
    })

// Chiusura del LOAD
});
