/*Shadowbox.init({
	overlayOpacity: 0.8
});*/

$(document).ready(function() {	
	
	$("a[rel^='shadowbox']").prettyPhoto({animationSpeed:'slow',theme:'facebook'});
	
	//$('#scroll_pane').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16});
	$('.scroll-pane').jScrollPane();
	
	$('#slideshow').css( {"overflow":"hidden"} );

	$('.home_elenco').cycle({		
		fx:'fade', 
    	timeout: 7000,
		speed: 500,
		prev:   '#prev', 
    	next:   '#next',
		pager: '.pager',
		after: onAfter,
		pagerAnchorBuilder: pagerFactory
	});
	$(".home_elenco li a span").css( {opacity : 0} );
	$(".home_elenco li a")
		.mouseover(function(){
			$("span",this).stop().animate({opacity:"1"}, {duration:200});
		})
		.mouseout(function(){
			$("span",this).stop().animate({opacity:"0"}, {duration:250, complete:function(){
					$("span",this).css({opacity:"0"})
				}})
		})
		
	$("a.roll_imac span.img_up").css( {"display":"block"} );
	//$("a.roll_imac span.txt_zoom").css( {"display":"block"} );
	//$("a.roll_imac:hover span.img_up").css( {opacity : 0} );
	$("span.img_up").css( {opacity : 0} );
	$(".roll_imac")
		.mouseover(function(){
			$(".img_up").stop().animate({opacity:"1"}, {duration:200});
			$(".txt_zoom").stop().animate({bottom:"0"}, {duration:200});
		})
		.mouseout(function(){
			$(".img_up").stop().animate({opacity:"0"}, {duration:250, complete:function(){
					$(".img_up").css({opacity:"0"})
					}})
			$(".txt_zoom").stop().animate({bottom:"-50px"}, {duration:200});
		})
	
	$('#foto_plus_tot').cycle({		
		fx:'fade', 
    	timeout: 0,
		speed: 500,
		prev:   '#prev', 
    	next:   '#next',
		pager: '.pager',
		after: onAfter,
		pagerAnchorBuilder: pagerFactory
	});
	
	function pagerFactory(idx, slide) {       
        return '<li><a href="#"></a></li>';
    };
	
	function onAfter(curr, next, opts) {
		var index = opts.currSlide;
		$('#prev')[index == 0 ? 'hide' : 'show']();
		$('#next')[index == opts.slideCount - 1 ? 'hide' : 'show']();
		
		if(index==0) {
			//$('#prev').css({opacity:"0.5"});
			//$('#foto_plus_tot').cycle(0); 
    		//return false; 
		} else {
			//$('#prev').css({opacity:"1"})
			//return true; 
		}
		if(index == opts.slideCount - 1) {
			//$('#next').css({opacity:"0.5"});
			//$('#foto_plus_tot').cycle(opts.slideCount - 1); 
    		//return false; 
		} else {
			//$('#next').css({opacity:"1"})
			//return true; 
		}
	}
	
	$(".foto_plus a").css( {opacity : 0.5} )
		.mouseover(function(){
			$(this).stop().animate({opacity:"1"}, {duration:200});
		})
		.mouseout(function(){
			$(this).stop().animate({opacity:"0.5"}, {duration:250, complete:function(){
				$(this).css({opacity:"0.5"})
			}})
		})
	
	$('#portfolio_elenco').cycle({		
		fx:'fade', 
    	timeout: 0,
		speed: 500,
		prev:   '#prev', 
    	next:   '#next',
		pager: '.pager',
		after: onAfter,
		pagerAnchorBuilder: pagerFactory
	});
	
	$('.portfolio_elenco li a img').css({marginTop:"0px"});
	$('.portfolio_elenco li a span').css({top:"-40px"});
	$('.portfolio_elenco li a')
		.mouseover(function(){
			$("img",this).stop().animate({marginTop:"20px"}, {duration:500});
			$("span",this).stop().animate({top:"0px"}, {duration:500});
		})
		.mouseout(function(){
			$("img",this).stop().animate({marginTop:"0px"}, {duration:200, complete:function(){
				$(this).css({marginTop:"0px"})
			}});
			$("span",this).stop().animate({top:"-40px"}, {duration:200, complete:function(){
				$(this).css({top:"-40px"})
			}});
		})
	
	$("#menu ul li a")
		.css( {paddingLeft:"15px"} )
		.mouseover(function(){
			$(this).stop().animate({paddingLeft:"30px"}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({paddingLeft:"15px"}, {duration:500, complete:function(){
					$(this).css({paddingLeft:"15px"})
					}})
		})

	$('#menu ul').hide();
	$('#menu ul.menu_open').show();
	var $status = 0 ;	
	$('.logo').click(function() {
		$('#menu ul').slideToggle();
		/*if($status==0) { 
			$("#menu ul").slideDown();
		 	$status = 1;
		} else {
			$("#menu ul").slideUp();
			$status = 0;
		}*/
	})
	
});
