$('div').eq(0).ready(function() {
	$('.wrapper').hide().delay(100).fadeIn(400);
});

//preloader

  function ajax_request() {
        $(".prefadeIn(2000).loader").fadeTo(1000, 0, function () 
            {$(this).css("display", "none");
         });
  }

//funzioni  

$.each($('.topmenu'), function(){
var cookie = $.cookie(this.id);
if(cookie === null || String(cookie).length < 1) {
$('#' + this.id + '.expandfirst ul:first').show();
}
else {
$('#' + this.id + ' .' + cookie).next().show();
}
});


  jQuery(function( $ ){
    $(document).ready(function(){
    
//preset
    $('#[id*=sub]').hide();

//tutto il resto
   	  $("#news").click(function () {
   	 		$('#subnews').slideDown('slow');
			$('#sublavori').slideUp('slow');
			$.cookie('lavori', 'up');
			$.cookie('news', 'down');			
            return false;           
     	});    	
     
		$('#submenu').click(function () {
			if ($('#subnews').is(":visible")) {
   	  	 		return false;
            	} else {
			}
		});

	  $(".topmenu").click(function () {
			$.cookie('lavori', 'up');
			$.cookie('news', 'up');	
	  });
	  	
   	  $("#lavori").click(function () {                     
			$(this).css("color", "#E2007A");
			$('#sublavori').slideDown('slow');
			$('#subnews').slideUp('slow');
			$.cookie('lavori', 'down');
			$.cookie('news', 'up');	
     	});	
  
  	var lavori = $.cookie('lavori');
    var news = $.cookie('news');
    // Set the user's selection for the left column
    if (lavori == 'down') {
				$('#sublavori').show();
				$('#subnews').hide();
    };
    // Set the user's selection for the right column
    if (news == 'down') {
				$('#subnews').show();
				$('#sublavori').hide();
    };   						
 });
});


