DY=window.DY||{};
$(document).ready(function(){
    if($.fancybox){
        $('a[rel="lightbox[roadtrip]"]').attr('rel','lightbox');
        $("a[rel='lightbox']").fancybox();
    }
	
    $('.btnMenu').last().css('border','none'); 
    if($.fancybox){
        $("a[rel='lightbox']").fancybox();
    }
    var currentPosition = 0;
    var slideWidth = 265;
    var slides = $('.slide');
    var numberOfSlides = slides.length;
    
    $('#box_2_fissi a').last().css('border', 'none');
    $('#box_2_fissi a').last().css('padding', '0');
    $('#box_2_fissi a').last().css('margin', '0');
    
    $('#menu>ul>li ').last().css('border', 'none');
	

	
    // Remove scrollbar in JS
    $('#slidesContainer').css('overflow', 'hidden');

    // Wrap all .slides with #slideInner div
    slides
    .wrapAll('<div id="slideInner"></div>')
    // Float left to display horizontally, readjust .slides width
    .css({
        'float' : 'left',
        'width' : slideWidth
    });

    // Set #slideInner width equal to total width of all slides
    $('#slideInner').css('width', slideWidth * numberOfSlides);

    // Insert controls in the DOM
    $('#slideshow')
    .prepend('<span class="control" id="leftControl">Clicking moves left</span>')
    .append('<span class="control" id="rightControl">Clicking moves right</span>');

    // Hide left arrow control on first load
    manageControls(currentPosition);

    // Create event listeners for .controls clicks
    $('.control')
    .bind('click', function(){
        // Determine new position
        currentPosition = ($(this).attr('id')=='rightControl') ? currentPosition+1 : currentPosition-1;

        // Hide / show controls
        manageControls(currentPosition);
        // Move slideInner using margin-left
        $('#slideInner').animate({
            'marginLeft' : slideWidth*(-currentPosition)
        });
    });


    // manageControls: Hides and Shows controls depending on currentPosition
    function manageControls(position){
        // Hide left arrow if position is first slide
        if(position==0){
            $('#leftControl').hide();
        } else{
            $('#leftControl').show();
        }
        // Hide right arrow if position is last slide
        if(position==numberOfSlides-1){
            $('#rightControl').hide();
        } else{
            $('#rightControl').show();
        }
    }


    //gestione blocchi littleWhite
    var altezza=0;
    $('.blkImgLittle_center').each(function(){
        if(altezza<$(this).height()){
            altezza=$(this).height();
        }
    });
    $('.blkImgLittle_center').css('minHeight',altezza+'px');

    //gestione allineamento link
    $('.blkImgLittle_center').each(function(){
        margine=$(this).find(".blkImgLittle_rightContent").height()-$(this).find(".blkImgLittle_leftContent").height();
        $(this).find('.blkImgLittle_link').css('marginTop',margine+'px');
    });
    
    if($('.allegati').length>0){
        if($('.allegati img').length<1){
            $('.allegati').hide();
        }
    }
    
//gestione menu
DY.larghezzaCompleta=$('#menu').width()-10;
DY.numeroBottoni=$('#menu>ul>li').length;
DY.larghezaBottoniTotale=0;
$('#menu>ul>li').each(function(){
    DY.larghezaBottoniTotale+=$(this).outerWidth(true);
})
DY.paddingBottoni=Math.floor((DY.larghezzaCompleta-(DY.larghezaBottoniTotale))/(DY.numeroBottoni)/2);
$('#menu>ul>li').each(function(index){

    $(this).css({
        'paddingLeft':DY.paddingBottoni+'px',
        'paddingRight':DY.paddingBottoni+'px'
    });
       
});
    
$('.stile_input_box_info').focus(function(){
    if(this.value==this.defaultValue){
        this.value='';
    }
});
$('.stile_input_box_info').blur(function(){
    if(this.value==''){
        this.value=this.defaultValue;
    } 
});
});



