function resizePanel() {

	//get the browser width and height
	width = $(window).width();
	height = $(window).height();

	//get the mask width: width * total of items
	mask_width = width * $('.pagina').length;
		
	//set the dimension	
	$('#wrapper, .pagina').css({width: width, height: height});
	$('#mask').css({width: mask_width, height: height});
	
	//if the item is displayed incorrectly, set it to the corrent pos
	$('#wrapper').scrollTo($('a.selected').attr('href'), 0 );
		
}

  onAfter = function(curr,next,opts) {
	  
     if((opts.currSlide+1)==opts.slideCount)
	 $(".work-lift-down").fadeOut(400); else $(".work-lift-down").fadeIn(400);
	 
	  if(opts.currSlide==0)
	 $(".work-lift-up").fadeOut(400); else $(".work-lift-up").fadeIn(400);
	  
}


$(window).bind("load", function(){
								
$(".js").show();
$("#loader").hide();
});

$(document).ready(function() { 
 

	//get all link with class panel
	$('a.panel').click(function (e) {
		
		prev = $('a.panel.selected').attr("rel"); 
		next = $(this).attr("rel");
        vel = Math.abs(next - prev);         
		if(vel==1) vel=1600;
		else vel= vel * 1600 * 0.6; 
		
		$('a.panel').removeClass('selected');
		$(this).addClass('selected');
		
		if( ($(this).attr('href')=="#servizi") || ($(this).attr('href')=="#web") || ($(this).attr('href')=="#grafica") || ($(this).attr('href')=="#seo") )
		$('a.panel[href*="#servizi"]').addClass('selected');
		
		 
		current = $(this);
		
		
		 
		
		
		
        //scroll it to the destination
		if( ($(this).attr('href')=="#web") || ($(this).attr('href')=="#seo") || ($(this).attr('href')=="#grafica") ){
		$('#wrapper').scrollTo($(this).attr('href'), 1600, {axis:'xy', queue:true} );  e.preventDefault(); 
		} else {
		$('#wrapper').scrollTo($(this).attr('href'), vel, {axis:'yx', queue:true ,onAfter:function(){
																								   
			if( (current.attr('href')=="#portfolio") && ($('.work-loaded').is(':empty')) ){
			$('.work-loaded').empty()
				.html('<img src="img/ajax-loader.gif" class="loading" />')
					.load("elenco_prod.php?cat=7",
						function(){
							$('.work-loaded').trigger("CycleEvent")
						});
		}			   
																								   
																								   } } );	 e.preventDefault();
		}
		
		
		
		
                //cancel the link default behavior
		return false;
	});


	//resize all the items according to the new browser size
	$(window).resize(function () {
		
		//call the resizePanel function
		resizePanel();
	});
	
	
		
 
// Profili

$(".profili").hover(function(){
$(".box-profili").hide();
$("#"+$(this).attr("rel")).show();
}
,function(){});

$(".chiudi-profili").click(function(){
$(".box-profili").hide();
$("#empty-profili").show();

});

 
 
 
 //creazione portfolio
 $('.work-menu li a').live('click', function() {
$('.work-loaded').empty()
	.html('<img src="img/ajax-loader.gif" class="loading" />')
		.load("elenco_prod.php?cat="+$(this).attr("rel"),
			function(){
				$('.work-loaded').trigger("CycleEvent")
			});

});
 
 

 
 /* scroller portfolio */

$('.work-loaded').live("CycleEvent", function(){
$('.work-container').cycle({ 
  	 fx:     'scrollVert', 
	 prev: '.work-lift-up',  
	next: '.work-lift-down',  
	timeout:0, 
	after:onAfter,
   speed: 800
});
$(".ppt").remove();
$(".pp_overlay").remove();
$(".pp_pic_holder").remove();
$("a[rel^='prettyPhoto']").prettyPhoto({theme: 'facebook' });
}); 


$("a[rel^='prettyPhoto']").prettyPhoto({theme: 'facebook' });

$('.work-container').cycle({ 
  	 fx:     'scrollVert', 
	 prev: '.work-lift-up',  
	next: '.work-lift-down',  
	timeout:0, 
	after:onAfter,
   speed: 800
});

  
//hover sulle anteprime portfolio


$(".work-thumb").live("hover",
        function()
        { 
		
		var span=$("span",this);
		//alert(span.css("bottom"));
		//hover off
			if(span.is(':hidden')){
				span.show().stop(true,true).css("bottom","-50px").animate(
				{bottom:"5px"},
				{duration:500} );
				
			 
				
				
			} else {
		//over on	
		//		alert("partito l'on");
		
			span.stop(true,true).hide().css("bottom","-50px") ;
			}
        }
    );
 
 
 
 
 

 
  
	


});