// JavaScript Document

var position = 1;
var elements= 3;


function ppScroll(n) {
	if(n==-1)
		n=((position+1)>elements?1:position+1);
	else {
		//position=n;
		if(n>4) {
			n=1;
			position=4;
		}
		if(n<1) { 
			n=4;
			position=1;
			
		}
	}

	$('#pp'+(position)).fadeOut('slow', function(){
		$('#pp'+n).fadeIn('slow', function(){});		
		position=n;
	});
}

$(document).ready(function() {
	$('#videoHPpp').cycle({
						  timeout:15000, 
					      next:   '#ppright', 
    					  prev:   '#ppleft' 
						
	});


	$(".primopiano").mouseenter(function() {
		$('#videoHPpp').cycle('pause'); 		

	});
	
	$(".primopiano").mouseleave(function() {
		$('#videoHPpp').cycle('resume'); 		
	});
	

	$('#videogiornalecorpo').cycle({
						timeout:8000,
						fx: 'scrollVert',
					    next:   '#videobarradx-ppright', 
    					prev:   '#videobarradx-ppleft'
    					
	});

	$(".immagini").mouseenter(function() {
		$('#videogiornalecorpo').cycle('pause'); 		

	});
	
	$(".immagini").mouseleave(function() {
		$('#videogiornalecorpo').cycle('resume'); 		
	});



	$('#videonewscorpo').cycle({
						timeout:8000,
						fx: 'scrollVert',
					    next:   '#videobarradx-ppright', 
    					prev:   '#videobarradx-ppleft'
    					
	});

	$(".immagini").mouseenter(function() {
		$('#videonewscorpo').cycle('pause'); 		

	});
	
	$(".immagini").mouseleave(function() {
		$('#videonewscorpo').cycle('resume'); 		
	});

	
	function galleryday_initCallback(carousel) { 
	    
	    jQuery('#gallerydaycarousel-next').bind('click', function() {
	    	jQuery('#gallerydaycarousel-prev').show();
	    	jQuery('#gallerydaycarousel-next').show();
	    	carousel.next();
	        return false;
	    });

	    jQuery('#gallerydaycarousel-prev').bind('click', function() {
	    	jQuery('#gallerydaycarousel-prev').show();
	    	jQuery('#gallerydaycarousel-next').show();
	    	carousel.prev();
	        
	        return false;
	    });
	
	}
	
	function galleryday_itemFirstInCallback(carousel, item, idx, state) {
		if(state=='prev')
			jQuery('#gallerydaycarousel-prev').hide();
	};
	function galleryday_itemLastInCallback(carousel, item, idx, state) {

		if(state=='next')
			jQuery('#gallerydaycarousel-next').hide();
	};

	
	jQuery("#gallerydaycarousel").jcarousel({
    	scroll: 4,
    	initCallback: galleryday_initCallback,
    	itemFirstInCallback:  galleryday_itemFirstInCallback,
    	itemLastInCallback:   galleryday_itemLastInCallback,    	
    	buttonNextHTML: null,
    	buttonPrevHTML: null 
    });


	
	
});



 

 

