/*SLIDESHOW SU HOMEPAGE*/
function slideSwitch() {
    var $active = $('#slideshow img.active');
		
	if ( $active.attr('data-href') ){
		$active.css('cursor','pointer');
		$active.click(function (){
			var link = $(this).attr('data-href');
			window.location = link;
		})
	} else {
		$active.css('cursor','default');
	}
	
	
    if ( $active.length == 0 ) $active = $('#slideshow img:last');
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow img:first');

    $active.addClass('last-active');
		
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
        	if ( $next.attr('data-href') ){
        		$next.css('cursor','pointer');
        		$next.click(function (){
        			var link = $(this).attr('data-href');
        			window.location = link;
        		})
        	} else {
        		$next.css('cursor','default');
        	}
            $active.removeClass('active last-active');
        });
}

/*FILTRARE PER MARCA*/
function checkMarche(){
	$.ajax({
	  url: 'marche/',
	  success: function(data) {
		$('#marca').html(data);

		$('.sel1').change(function () {
			var chiave= $('option:selected', $(this)).attr('value');
			
			if (chiave){
				$('.prod').hide();
				$('.prod[data-pk='+chiave+']').fadeIn(500);
			} else {
				$('.prod').hide().fadeIn(500);			
			}
		});
		
	  }
	});
}

/*CONTROLLO QUANTITA CARRELLO*/
function checkCart(){
	$.ajaxSetup({ cache: false });
		$.getJSON('/cart/json/', function(data) {
			$('.basket_numero').text(data.qt);
	});
}

