
var randomnumber=Math.floor(Math.random()*13)+1


$(document).ready(function(){

	if($('#focusnews').length > 0){	
		$('.focus').css({'background-image':'url(/images/focus_'+randomnumber+'.jpg)'});
		setInterval(function() {
			var randomnumbers=Math.floor(Math.random()*13)+1
			$('.focus').css({'background-image':'url(/images/focus_'+randomnumbers+'.jpg)'});
		}, 10000);

		
		$('#focusnews').append($("div.notizia:first").html());
		$("div.notizia:first").remove();
		$('#focusnews a').hide();
		$(".focus").click(function(){
			document.location = $('#focusnews').children('a').attr('href');
		});
		
		$('.focus').mouseenter(function(){
			$("div.focusfooter").stop().animate({bottom:"0"}, "fast");
		});
		$('.focus').mouseleave(function(){
			$("div.focusfooter").animate({bottom:"-20px"}, "fast");
		});
		$('.focus').css( 'cursor', 'pointer' );

		
		
	}
	
	
	$("div.notizia").mouseenter(function(){
		$(this).children('h2').animate({"color": "#e64135"}, "fast");
		//$(this).children('a').show();
		//$(this).append('<img style="margin:0 0 0 330px;display:block;" src="/images/bgMore.png" />');
		//$("#home").css({'padding':'0 0 7px 0'});
		$(this).animate({backgroundPosition:"100% 100%"}, "600");
	});
	$("div.notizia").mouseleave(function(){
		$(this).children('h2').animate({"color": "#000000"}, "fast");
		//$(this).children('a').hide();
		//$(this).children('img').remove();
		//$("#home").css({'padding':'0 0 30px 0'});
		$(this).animate({backgroundPosition:"150% 100%"}, "fast");
	});
	$("div.notizia").click(function(){
		document.location = $(this).children('a').attr('href');
	});
	
	$("div.notizia > a").hide();
	$('div.notizia').css( 'cursor', 'pointer' );
	
	
	if($('#citazione').length > 0){
		$('#dSide').prepend(	$('#citazione'));		
	}
	
	var area = $('.sideMenu').attr('id');
	if(typeof(area) != 'string')
		area = 'Mhome';
	
	//$('a.'+area).removeClass('hmenu');
	//$('a.'+area).addClass('hmenuSel');
	//$('a.'+area).prepend('<span style="font-size:280%">01</span><br />');
	$('a.'+area).css({'backgroundColor':'#000000','fontSize':'100%'});
	$('a.'+area).delay(200).animate({"height": "40px",'padding':'60px 0 0 0','fontSize':'120%','backgroundColor':'#EF6922'}, 300);
	
	
	$("a.hmenu").mouseenter(function(){
		//$('#navigazione_orizzontale').css({'padding':'0 0 0 0'});
		if(!$(this).hasClass(area))
			$(this).animate({"height": "46px",'padding':'44px 0 0 0','fontSize':'140%'}, "fast");
		
	});
	$("a.hmenu").mouseleave(function(){
		//$('#navigazione_orizzontale').animate({'padding':'0 40px 0 0'});
		if(!$(this).hasClass(area))
			$(this).animate({"height": "40px",'padding':'50px 0 0 0','fontSize':'100%'}, "fast");
	});
	
	$("a.hmenu").css({padding:'50px 0 0 0'});
	//$('#navigazione_orizzontale').css({'padding':'0 40px 0 0'});
	
	
	
	
	$("button, a.button").button();
	/* GESTIONE ERRORI NEI MODULI*/
	$('div.formErrors').dialog({
		autoOpen: true,
		modal: true,
		resizable: false,
		width: 580,
		height: 300,
		title:"Attenzione Errore!",

		buttons: {
			'Riprova': function() {
				$(this).dialog('close');
				//$("#accordion").accordion( "activate" , indexAccordion );
			}
		}

	});	
	
	
	
});

$(window).resize(function(){
});
