// JavaScript Document

  $(document).ready(function(){
		var hash = window.location.hash.replace('#', '');
		var currentTab = $('ul.nav a')
							.bind('click', showTab)
							.filter('a[rel=' + hash + ']');
		if (currentTab.size() == 0) {
			currentTab = $('ul.nav a:first');
		}
		if(currentTab.get(0)) showTab.apply(currentTab.get(0));
	/* 
	$(".home#slider").easySlider({
		auto: false,
		continuous: true
	});*/
	$('.home#slider').cycle({ 
    fx:     'fade', 
    speed:  'fast', 
    timeout: 5000, 
    next:   '#nextBtn', 
    prev:   '#prevBtn' 
	});
	
	$('.home#slider img').click(function(){
		document.location.href = $(this).attr("longdesc");
	});
	ulW = 0;
	$('#divscroll li').each(function() {
				var obj = $(this);
				ulW+=30+obj.width();
	});
	$("#divscroll ul").css('width',ulW);
	$('#divscroll').autoscroll(AUTOSCROLL_X);	
	
		$("a[rel^='prettyPhoto']").prettyPhoto({
			/* fast/slow/normal */
			animationSpeed: 'fast', 
			/* padding for each side of the picture */
			padding: 40, 
			/* Value betwee 0 and 1 */
			opacity: 0.45, 
			/* true/false */
			showTitle: true,
			/* true/false */
			allowresize: true,
			/* The separator for the gallery counter 1 "of" 2 */
			counter_separator_label: '/', 
			/* light_rounded / dark_rounded / light_square / dark_square */
			theme: 'light_rounded', 
			callback: function(){
				$('#blocco_carrello').load('../../response.php');
				//window.location.reload();
			}
		});
});

var showTab = function(e) {
		var tabIndex = $('ul.nav a')
							.removeClass('active')
							.index(this);
		$(this)
			.addClass('active')
			.blur();
		$('div.tab')
			.hide()
			.eq(tabIndex)
			.show();
};


