
// autofit <ul>
function sliderAutoWidth() {
	var numOf = $("#content-holder-grafica > li, #content-holder-web > li, #content-holder-3d > li, #content-holder-branding > li").length;
	$("#content-holder-grafica, #content-holder-web, #content-holder-3d, #content-holder-branding").width(numOf * 310);
}

jQuery(document).ready(function($) {

	$("a.anchorLink").anchorAnimate()

	// Setting start page
	if(document.location.hash.length < 1) {
		//document.location = "#home";
		$("a.home.anchorLink").click();
	}
	
	sliderAutoWidth();
	
	// SLIDER
	$("#content-slider, #content-sliderGrafica, #content-slider3d, #content-sliderBranding").slider({
	  change: handleSlider,
	  slide: handleSlider,
	  orientation: 'horizontal',
	  handle: ".ui-slider-handle"
	});
	
	$('div.home').jCarouselLite({//slider for homepage blog posts
		btnNext: '#home-blogposts-nav .next',
		btnPrev: '#home-blogposts-nav .prev',
		easing:'easeInOutExpo',
		vertical: true,
		speed:1000,
		visible:1
	});
	$('#featured-info').jCarouselLite({ //slider for homepage featured section info text
		btnPrev: '#home-featured-nav .prev', 
		btnNext: '#home-featured-nav .next', 
		easing:'easeInOutExpo',
		speed:900,
		vertical:true,
		visible:1
	});
	$('#images').jCarouselLite({ //slider for homepage featured section info text
		btnPrev: '#home-featured-nav .prev', 
		btnNext: '#home-featured-nav .next', 
		easing:'easeInOutExpo',
		speed:900,
		visible:1
	});
	
	$("a.zoom").fancybox({
				'overlayOpacity'	:	0.7,
				'overlayColor'		:	'#FFF',
				'zoomSpeedIn'			: 600,
				'zoomSpeedOut'			: 500,
				'easingIn'				: 'easeOutBack',
				'easingOut'				: 'easeInBack'
			});
		

});

// SLIDER handler
function handleSlider(e, ui)
{
	var maxScroll = $("#content-scroll-web").attr("scrollWidth") - $("#content-scroll-web").width();
	$("#content-scroll-web").attr({scrollLeft: ui.value * (maxScroll / 100) });
	var maxScroll = $("#content-scroll-grafica").attr("scrollWidth") - $("#content-scroll-grafica").width();
	$("#content-scroll-grafica").attr({scrollLeft: ui.value * (maxScroll / 100) });
	var maxScroll = $("#content-scroll-3d").attr("scrollWidth") - $("#content-scroll-3d").width();
	$("#content-scroll-3d").attr({scrollLeft: ui.value * (maxScroll / 100) });
	var maxScroll = $("#content-scroll-branding").attr("scrollWidth") - $("#content-scroll-branding").width();
	$("#content-scroll-branding").attr({scrollLeft: ui.value * (maxScroll / 100) });
}