DY=window.DY||{};
$(document).ready(function(){
    if($.fancybox){
        $("a[rel='lightbox']").fancybox();
    }
    //correzione bordi bianchi menu ultimo e primo
    $('.btnMenu').first().css('borderLeft','2px solid #fff');
    $('.btnMenu').last().css('borderRight','2px solid #fff');

    //gestione menu
    DY.larghezzaCompleta=$('#menu').width();
    DY.numeroBottoni=$('.btnMenu').length;
    DY.larghezaBottoniTotale=0;
    $('.btnMenu').each(function(){
        DY.larghezaBottoniTotale+=$(this).outerWidth(true);
    })
    DY.paddingBottoni=Math.floor((DY.larghezzaCompleta-(DY.larghezaBottoniTotale))/(DY.numeroBottoni)/2);
    DY.paddingBottoni=(DY.larghezzaCompleta-(DY.larghezaBottoniTotale))/(DY.numeroBottoni)/2;
    $('.btnMenu').each(function(index){

        //        if(index==0){
        //            $(this).css({
        //                'paddingLeft':DY.paddingBottoni+'px'
        //            });
        //        }else if (index==(DY.numeroBottoni-1)){
        //            $(this).css({
        //                'paddingRight':DY.paddingBottoni+'px'
        //                });
        //        }else{
        $(this).css({
            'paddingLeft':DY.paddingBottoni+'px',
            'paddingRight':DY.paddingBottoni+'px'
        });
    //        }
    });
    //fine gestione menu

   

    //modifiche bottoni fissi
    $('#fissi a').first().css('borderLeft','none');
    DY.arrayImgFissi=['microHome.jpg','microSitemap.jpg','microContatti.jpg'];
    $('#fissi a').each(function(index){
        if(DY.arrayImgFissi[index]){
            $(this).css('backgroundImage',"url('/stile/img/"+DY.arrayImgFissi[index]+"')");
        }
    });

    //gestione posizionamento immagini sul fondo dei blocchi in home
    $('.contImgCellNov img').each(function(){
       $(this).css('marginTop',($('.contImgCellNov').innerHeight()-$(this).height())+'px');
    });

    $('.imgCatBlk img').each(function(){
       $(this).css('marginTop',($('.imgCatBlk').innerHeight()-$(this).height())+'px');
    });
 

    
    
    $('#getInfo img').attr('align','right');

    /*correzione immagini template home*/
    if($('.interne #template').length>0){
        $('.interne #template').css('backgroundImage',"url('"+$('.interne #template img').attr('src')+"')");
        $('.interne #template img,.interne #template br').remove();
    }

    /*correzione blocchi categorie catalogo*/
    $('.cellaCat:last-child').css('margin-right', '0px');
    $('.cellNovProd:last-child').css('margin-right', '0px');
    /*Slider in home*/
    if($('#prodottiInHome').length>0){
        $("#prodottiInHome").easySlider({
            prevId:'sliderLeftButton',
            nextId:'sliderRightButton',
            controlCreate:false
        });
    }

    

    //correzione posizionamento immagni prodotti allineamento
    $('.prodImgCont a').each(function(){
         $(this).css('marginTop', (($('.prodImgCont').height()-$(this).height()))+'px');
    });
    //correzione posizionamento immagini prodotti in scheda prodotti
    $('.imgCont img').each(function(){
         $(this).css('marginTop', (($('.imgCont').height()-$(this).height()))+'px');
    });


    //effetti mappa
    $('.dovesiamo fieldset').click(function(){
        var link=$(this).children('input[name="linkMappa"]')[0].value;
        $('#mappa>iframe').attr('src',link);
    });

     
   
});



jQuery(window).load(function(){
    //allineamento del blocco per le info con il footer
//    if($('#box-sx').innerHeight()<$('#box-main').innerHeight()){
//        $('#bisInfo').css('marginTop',($('#box-main').innerHeight()-$('#box-sx').innerHeight())+'px');
//    }
    //correzione posizionamento immagni marche n home
    $('.blkMarchiVisual a').each(function(){
         $(this).css('marginTop', ((100-$(this).height())/2)+'px');
    });
     //ciclo sulle marche
     if($('.blkMarchiVisual').length>0){
         $('.blkMarchiVisual').cycle();
     }

   //gestione posizionamento immagini categorie
    $('.imgCatBlk img').each(function(){
       $(this).css('marginTop',($('.imgCatBlk').innerHeight()-$(this).height())+'px');
    });
});

