
function checkAnnoDa(){
    var myURI = new URI(decodedURL);
    myURI.setData('timeline_da', document.id('anno_da').get('value'));
    myURI.go();
}

function checkAnnoA(){
    var myURI = new URI(decodedURL);
    myURI.setData('timeline_a', document.id('anno_a').get('value'));
    myURI.go();
    
}

function checkBrand(val){
    var myURI = new URI(decodedURL);
    myURI.setData('id_brand', document.id('filtro_brand').get('value'));
    myURI.go();
}

function checkApprofondimento(val){
    var myURI = new URI(decodedURL);
    myURI.setData('id_approfondimento', document.id('filtro_approfondimento').get('value'));
    myURI.go();
}

function checkEvento(val){
    var myURI = new URI(decodedURL);
    myURI.setData('id_evento', document.id('filtro_evento').get('value'));
    myURI.go();
}


document.addEvent('domready', function(){

    gnt_select_marchio = new brigaSelect({
        id: 'filtro_brand',
        callback: checkBrand,
        additionalId: 'brand_cont'
    });
    
    gnt_select_dal = new brigaSelect({
        id: 'anno_da',
        callback: checkAnnoDa,
        additionalId: 'anno_da_cont'
    });
    
    gnt_anno_a = new brigaSelect({
        id: 'anno_a',
        callback: checkAnnoA,
        additionalId: 'anno_a_cont'
    });
    
    gnt_filtro_approfondimento = new brigaSelect({
        id: 'filtro_approfondimento',
        callback: checkApprofondimento,
        additionalId: 'approfondimento_cont'
    });
    
    gnt_filtro_evento = new brigaSelect({
        id: 'filtro_evento',
        callback: checkEvento,
        additionalId: 'evento_cont'
    });
    
    
    /*
     document.getElements('input.cat_filter').addEvent('click', function(e){
     var Ev = new Event(e);
     var target = Ev.target;
     
     var myURI = new URI(document.location.href);
     
     myURI.setData('id_categoria', target.get('value'));
     
     myURI.setData('id_news', '');
     
     myURI.go();
     
     });
     
     
     document.getElement('select.filtro_brand').addEvent('change', function(ev){
     var event = new Event(ev);
     var target = event.target;
     
     var myURI = new URI(document.location.href);
     
     myURI.setData('id_brand', target.get('value'));
     myURI.setData('id_news', '');
     myURI.go();
     
     });
     document.getElement('select.filtro_approfondimento').addEvent('change', function(ev){
     var event = new Event(ev);
     var target = event.target;
     
     var myURI = new URI(document.location.href);
     
     myURI.setData('id_approfondimento', target.get('value'));
     myURI.setData('id_news', '');
     myURI.go();
     
     });
     
     document.getElement('select.filtro_evento').addEvent('change', function(ev){
     var event = new Event(ev);
     var target = event.target;
     
     var myURI = new URI(document.location.href);
     
     myURI.setData('id_evento', target.get('value'));
     myURI.setData('id_news', '');
     myURI.go();
     
     });
     */
    document.id('btn_form_progetto').addEvent('click', function(ev){
        var myURI = new URI(document.location.href);
        myURI.setData('id_page', 'dettaglio_news');
        myURI.setData('sezione_fe', 'speciale');
        myURI.setData('page', 'fe_std');
        myURI.setData('f_nome', document.id('f_nome_txt').get('value'));
        myURI.go();
    });
    
    
    document.id('f_nome_txt').addEvent('keypress', function(evt){
        if (evt.key == 'enter') {
            var myURI = new URI(document.location.href);
             myURI.setData('id_page', 'dettaglio_news');
        myURI.setData('sezione_fe', 'speciale');
        myURI.setData('page', 'fe_std');
            myURI.setData('f_nome', document.id('f_nome_txt').get('value'));
            myURI.setData('id_news', '');
            myURI.go();
        }
    });
    
    document.getElements('.data_sort').each(function(item, index){
        item.addEvent('click', function(ev){
        
            var event = new Event(ev);
            event.preventDefault();
            var sortDir = 0;
            if (item.hasClass('sel_su')) {
                sortDir = 1;
            }
            else {
                sortDir = 2;
            }
            
            var myURI = new URI(document.location.href);
            
            myURI.setData('sortField', 'anno');
            myURI.setData('sortDir', sortDir);
            myURI.setData('id_news', '');
            myURI.go();
        });
    });
    
    /* 
     
     document.getElement('.anno_da').addEvent('change', function(ev){
     var event = new Event(ev);
     var target = event.target;
     var myURI = new URI(document.location.href);
     
     myURI.setData('timeline_da', target.get('value'));
     myURI.setData('id_news', '');
     myURI.go();
     
     });
     document.getElement('.anno_a').addEvent('change', function(ev){
     var event = new Event(ev);
     var target = event.target;
     var myURI = new URI(document.location.href);
     
     myURI.setData('timeline_a', target.get('value'));
     myURI.setData('id_news', '');
     myURI.go();
     
     });
     */
});

