

	$(document).ready(function(){
		
		$("#registrazione select#regione").change(function(){				
			if ( $(this).val() != '' ) {
				$("select#provincia").load("_province.php?CodRegione=" + $(this).val());			
			} else {
				$("select#provincia").html("");
			}
		});		
		
		$("#registrazione select#regione").each(function(){			
			if ( $("#CodProvincia").val() != '' ) {		
				$("select#provincia").load("_province.php?CodRegione=" + $(this).val() + "&CodProvincia=" + $("input#CodProvincia").val() );			
			} else if ( $(this).val() != '' ) {
				$("select#provincia").load("_province.php?CodRegione=" + $(this).val());			
			}
		});
		

		$("#registrazione .radio").click(function(){	
			if ( $(this).val() == 'azienda' ) {
				$("fieldset#datiAzienda").show();
			} else {
				$("fieldset#datiAzienda").hide();
				$("fieldset#datiAzienda input").val("");
			}
		});
		
		if ( $("input#utente_tipo_azienda").is(":checked") ) {
			$("fieldset#datiAzienda").show();
		} 
		if ( $("input#utente_tipo_privato").is(":checked") ) {
			$("fieldset#datiAzienda").hide();		
		} 

		$("#carrello .prodotto a.showInfo").click(function(e){
			e.preventDefault();										
			$(this).find("+ .info").slideToggle();
		});
				
		$("#carrello a.confirm").click(function(e){
            e.preventDefault();            
            if (confirm('Eliminare il prodotto dal carrello?')) location.href = $(this).attr("href");
        });
		
		$("select[name=pagamento]").change(function(){
			$(this).parent().submit();
		});
		
		
		$("select[name=corriere]").change(function(){
			$(this).parent().submit();
		});
		
		$("#frmRiepilogoDati input[name=action]").click(function(e){
			e.preventDefault();			
			bool = true;			
			$("#frmRiepilogoDati .required").each(function(){				
			
			
			
			if ( $("input#accetto").is(":checked") ) {				
			} else {
				alert("E' necessario accettare le condizioni di vendita");
				bool = false;					
				return false;
			}
			
			
			
			if ($(this).val() == '') {
				alert("Compila tutti i dati di spedizione");
				bool = false;					
				return false;
			}
			
			
			
				
			});						
			if (bool) $("#frmRiepilogoDati").submit();
		});
		
		$(".addCart").click(function(e){
			e.preventDefault();
			$(this).parents("form").submit();			
		});

		$("#faq #domande a").click(function(e){
			e.preventDefault();			
			n = $(this).attr('href');
						
			$.scrollTo("#faq"+n,800);			
		});
		
		$("#faq .top a").click(function(e){
			e.preventDefault();
			$.scrollTo("#domande",800);
		});
		
	});
		
		
	

