/* Author: Paolo Stefan / Tomas de Zanetti

*/

$.fn.showdelay = function(){
	var delay = 0;
	return this.each(function(){
	$(this).delay(delay).fadeIn(350);
	delay += 150;
	});
};

// Menu rollover effect
$(document).ready( function(){
	//$('#menu .rollover').hide();
	$('#menu li').hover( 
		function(){	
			$('.rollover',this).fadeIn();	
			console.log('rollover');
		},
		function(){
			$('.rollover',this).fadeOut();	
			console.log('rollout');
			//$('.rollover',this).fadeOut();	
		}
	);
	
	
	chiuso=true;
	$('.focus_puls_iscrizione').click(function() {
		if(chiuso==true){
	  		$('.puls_iscrizione').animate({height: "200px"}, 800, function() { chiuso=false; });
		}else{
			$('.puls_iscrizione').animate({height: "17px"}, 800, function() { chiuso=true; });
		}
	});
	
	
	
	
	

	
	
	
	
	
	
	
	
	
} );


// Filters
var names = ['tipologia','combustibile','diffusione','design','finiture','marchio'];

// Send an AJAX request to the query script
function filtersQuery(){
	
	var querystr = [];
	
	for( var i in names ){
		var s = $("[name='" + names[i] + "']").serialize();
		if( s!='' ) { querystr.push(s); }
	}
	
	querystr = querystr.join('&');
	
	$('#contents').fadeOut('slow',
						   
		function(){
			$('#contents').empty().show().load('query.php?'+querystr); 
		}
	);
	
}

function filtersSetup(){
	
	for( var i in names ){
		$("[name='" + names[i] + "']").click(function(){
			filtersQuery();
		});
	}
}

// Check/uncheck all filter checkboxes in a group, sending the query.
function tickAll( name, checked ){
	
	var sel = $("[name='"+name+"']");
	
	if( checked ){ sel.attr('checked',true); }
	else{ sel.removeAttr('checked');}	
	
	filtersQuery();
}

// Prodotti
function swapPic( picpath ){
	$('#largepic').fadeOut('slow',function(){
		$('#largepic').html('<img src="'+picpath+'" alt="" />').fadeIn();
	} );
}















