DY = window.DY || {};
//$.noConflict();
$(document).ready(function () {
    if ($.fancybox) {
        $("a[rel='lightbox[roadtrip]']").each(function () {
            $(this).attr('rel', 'lightbox');
        });
        $("a[rel='lightbox']").fancybox({
            titlePosition:'inside'
        });
    }


    //gestione men
    $('.menu a').first().css('borderLeftWidth', '0');
    $('.menu a').last().css('borderRightWidth', '0');
    DY.larghezzaCompleta = $('.menu').width();
    DY.numeroBottoni = $('.menu a').length;
    DY.larghezaBottoniTotale = 0;
    $('.menu a').each(function () {
        DY.larghezaBottoniTotale += $(this).outerWidth(true);
    });
    DY.paddingBottoni = Math.floor((DY.larghezzaCompleta - (DY.larghezaBottoniTotale)) / (DY.numeroBottoni) / 2);
    $('.menu a').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
    $('.bloccosingolacategoriahome').each(function () {
        var href = $(this).find('a').attr('href');
        $(this).find('p').first().html('<a href="' + href + '">' + $(this).find('p').html() + '</a>');
    });

    //immagine di template per banner
    if ($('#template').length > 0) {
        $('#template').css('backgroundImage', 'url(' + $('#template>img').first().attr('src') + ')');
        $('#template>img').first().remove();
    }

    //per mappa google in contatti
    if ($('#googleMap').length > 0) {
        var centro = new google.maps.LatLng(45.83546, 10.54430);
        var myOptions = {
            center:centro,
            zoom:14,
            mapTypeId:google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("googleMap"), myOptions);
        var marker = new google.maps.Marker({
            position:centro,
            map:map,
            title:""
        });
    }

});

$(window).load(function(){
    //allineo i componenti laterali
    $('#middle').height($('#box-pagina').height() - ($('#box-header').height() + $('#box-footer').height()));
    $('#box-sx').height($('#middle').innerHeight());
    $('#box-dx').height($('#middle').innerHeight());
});



