DY=window.DY||{};
$(document).ready(function(){
    if($.fancybox){
        $("a[rel='lightbox']").fancybox();
    }

   /* if( $("#slider").length){
//        $("#slider").easySlider({
//            orientation:'horizontal'
//        });
        $('#slider').infiniteSlider();
    }*/
	
	    //allineamento delle immagini all'interno della slide'
   /* $('#slideProds a').each(function(){
        $(this).css({
            'marginTop':((200-$(this).height())/2)+'px'
        });
    });*/

    if($('#slideProds').length>0){

        $('#slideProds').infiniteSlider({
            movimento:100,
            movimentoRapido:100,
            prevText:'',
            nextText:'',
			automazione:false
        });

         
    }
    //gestione menu

    DY.larghezzaCompleta=$('#menu #contenutiMenu').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);	
    $('.btnMenu').each(function(index){

        $(this).css({
            'paddingLeft':DY.paddingBottoni+'px',
            'paddingRight':DY.paddingBottoni+'px'
        });
        
    });
    //fine gestione menu
    //gestione menu
    DY.larghezzaCompleta=$('#prodotti').width();
    DY.numeroBottoni=3
    DY.larghezaBottoniTotale=$('.blk_prodotto').outerWidth(true)*3
    DY.paddingBottoni=Math.floor((DY.larghezzaCompleta-(DY.larghezaBottoniTotale))/(DY.numeroBottoni-1)/2);
    
    $('.prodRow').each(function(){
        $(this).children('.blk_prodotto').each(function(index){
            if(index==0){
                $(this).css({
            
                    'marginRight':DY.paddingBottoni+'px'
                });
            }else        if(index==DY.numeroBottoni-1){
                $(this).css({
                    'marginLeft':DY.paddingBottoni+'px'
            
                });
            }else {
       
                $(this).css({
                    'marginLeft':DY.paddingBottoni+'px',
                    'marginRight':DY.paddingBottoni+'px'
                });
            }
        
        });
    });


    //gestione click su ricerca
    $('#cerca input').focus(function(){
        if(this.value==this.defaultValue){
            this.value='';
        }
    });
    $('#cerca input').blur(function(){
        if(this.value==''){
            this.value=this.defaultValue;
        }
    });
//    $('#cerca input').bind('keypress',  function(e){
//        var code = (e.keyCode ? e.keyCode : e.which);
//        if(code == 13) { //Enter keycode
//            console.debug('ok');
//
//        }
//    });
   

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


    /*Ciclo template*/
    //    if($('#imgTemplate img').length>1){
    //        $('#imgTemplate').cycle();
    //    }



    if($(".jqzoom").length > 0){
        $('.miniImgProd a').each(function(){
            $(this).attr('rel','lightbox').addClass('jqzoom');//.attr('href',$(this).children('img').attr('src'));
        });
        $(".jqzoom").fancybox();
    }

    //if($(".jqzoom").length > 0){
    //    $(".jqzoom").jqzoom();
    //}

    if($(".imgfinitura").length > 0){
        $('.imgfinitura>img + div>div:empty').parent().remove();
        $('.imgfinitura>img').tooltip({
            tipClass:'tipFiniture'
        }).dynamic({
            bottom: {
                direction: 'down',
                bounce: true
            }
        });
    }


    $('.immagine_prodotto img').each(function(){
        $(this).css('marginLeft',($('.immagine_prodotto').width()-$(this).width())/2+'px');
    });


    $('#box-middle').css('minHeight',($(window).height()-($('#box-header').outerHeight(true)+$('#box-footer').outerHeight(true)))+'px');

    $('#box-sx').css('minHeight',$('#box-middle').height());


});


