DY=window.DY||{};
$(document).ready(function(){
//gestione menu
    DY.larghezzaCompleta=$('#menu').width();
    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){


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

	if($('.newsRow').length<1){
		$('#news').hide();
	}

	if($('.cycle').length>0){
	$('.cycle').cycle({
		nowrap:        1
	});
	}
   	$('#fissi a').last().css('border','none'); 
	    
	if($.fancybox){
        $('.thumb').fancybox();
    }
	
	GestisciNewsletter();
});

function GestisciNewsletter(){
	$("#form_newsletter").bind("submit",function(e){
		if(controllaCampi() == true){
			return true;
		}
		else{
			return false;
		}
	});
}  
function controllaMail(email){
	var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
 
	if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) {
		return false;
	}
}
 
function controllaCampi(){
	var nome = document.form_newsletter.nome.value;
	var email = document.form_newsletter.email.value;
	var trattamento1 = document.form_newsletter.privacy1.checked;


	if ((nome == "")) {
		alert("Attenzione!\nIl campo Nome e' obbligatorio.");
		return false;
	}

	else if ((email == "")) {
		alert("Attenzione!\nDevi inserire un indirizzo di posta elettronica.");
		return false;
	}
	else if(controllaMail(email) == false){
		alert("Attenzione!\nInserire un indirizzo email corretto.");
		return false;
	}
	
	else if (!trattamento1) {
		alert("Attenzione!\nDevi acconsentire al trattamento.");
		return false;
	}

 
	return true;
}
	
jQuery(window).load(function(){
    
    //correzione altezze content
    totHeight=$("#box-footer").height()+$("#box-header").height()+$("#divisoria").height()+$('#bottomMiddlePage').height();

});

   



