jQuery(document).ready(function(){
/* gestione gallery in scheda prodotto */
	var mainImg = jQuery('.main_img',this).children('img');
	var thumb = jQuery('.thumb a',this);
	mainImg.attr('src',jQuery('.thumb a:first',this).attr('href'));
	jQuery('#gallery_prodotto').each(function(){
		thumb.bind('click',function(){
			var href = jQuery(this).attr('href');
			mainImg.fadeOut('normal',function(){
				mainImg.attr('src',href);
				
				mainImg.fadeIn('normal');
			});
			return false;
		});
	});
	
	
	/* stilizzo thumb della gallery prodotto */
	jQuery('#gallery_prodotto .thumb').each(function(i){
		if(((i+1)%5)===0){
			jQuery(this).css({
				paddingRight:'0px'
			}).after('<div class=\'clearer\'>&nbsp;</div>');
		}
		if(((i+1)%5)===1){
			jQuery(this).css({
				paddingLeft:'1px'
			})
		}
	});

	jQuery('#home-banner').innerfade({ speed: 'slow', timeout: 4000, type: 'random', containerheight: '363px' }); 

/* tenere questo commentato fino a che non sarà scritto il plug in definitivo per stilizzare i select */
/*	
	jQuery('#formcontatti_provincia').styleselect({
		hover:'#c89687',
		height: '20px',
		width: '380px'
	});
*/	
	
	jQuery('#formcontatti').children('div').css({position:'absolute'});
	jQuery('#formcontatti').children('div').children('span').css({display:'block'});
	
	jQuery('#formcontatti').each(
		function(){
			
			jQuery('#submit_formcontatti').removeAttr('onclick');
			
			var onclick=function(){
				document.formcontatti.submit();
			}
			
			jQuery('#submit_formcontatti').click(onclick);
			
			if(!jQuery('#formcontatti_n_privacy').attr('checked')){
				
				jQuery('#submit_formcontatti').unbind('click');
				
			}
			
			jQuery('#formcontatti_n_privacy').change(
				function(){
					
					if(!jQuery(this).attr('checked')){
				
						jQuery('#submit_formcontatti').unbind('click');
						
					}
					else{
				
						jQuery('#submit_formcontatti').click(onclick);
						
					}
					
				}
			);
			
		}
	);
	
});


