$(document).ready(function() {		  
			$('#acquisto').ajaxForm();
			$('#articolo a').nyroModal();
			$('#speciale_snowpark a').nyroModal({minWidth: 700, minHeight: 605});
			$('#speciale_snowpark_banner a').nyroModal({minWidth: 700, minHeight: 605});
			// $('#popup_chiarimenti a').nyroModal();
        
        /*$(document).bind("contextmenu",function(e){
        	return false;
        });*/

			/*
			$("#popup_spese_spedizione").tooltip({
    	bodyHandler: function() {
    		return $($(this).attr("href")).html();
    	},
    	showURL: false,
			extraClass: "pretty",
			opacity: 1
    	});
			*/
			
			/*
			$("#popupa_spese_spedizione").click(function(e) {
				e.preventDefault();
				return false;
			});
			*/
			$("#popupa_spese_spedizione").hover(function(e) {
				e.preventDefault();
				$("#contenuto_spese_spedizione").show();
				return false;
			}, function() {
				$("#contenuto_spese_spedizione").hide();
			});
			/*
			$("#popupa_tempi_consegna").click(function(e) {
				e.preventDefault();
				return false;
			});
			*/
			$("#popupa_tempi_consegna").hover(function(e) {
			    e.preventDefault();
				$("#contenuto_tempi_consegna").show();
				return false;
			}, function() {
				$("#contenuto_tempi_consegna").hide();
			});
			/*
			$("#popupa_modalita_pagamento").click(function(e) {
				e.preventDefault();
				return false;
			});
    	*/
			$("#popupa_modalita_pagamento").hover(function(e) {
			    e.preventDefault();
				$("#contenuto_modalita_pagamento").show();
				return false;
			}, function() {
				$("#contenuto_modalita_pagamento").hide();
			});
			/*
			$("#popupa_acquisto_sicuro").click(function(e) {
				e.preventDefault();
				return false;
			});
			*/
			$("#popupa_acquisto_sicuro").hover(function(e) {
			    e.preventDefault();
				$("#contenuto_acquisto_sicuro").show();
				return false;
			}, function() {
				$("#contenuto_acquisto_sicuro").hide();
			});
			
			$('#scelta_taglia a').nyroModal({minWidth: 750, minHeight: 400,resizeable: true, type: 'form'});
			$('#segnalaArticolo a').nyroModal({minWidth: 650, minHeight: 500,resizeable: true, type: 'form'});
			// $('#pulsantePreventivo a').nyroModal({minWidth: 550, minHeight: 400,resizeable: true, type: 'form'});
			

			
			$('#formSegnalaArticolo').submit(function(e) {
			e.preventDefault();
			// if ($("#myValidForm :text").val() != '') {
				$('#formSegnalaArticolo').nyroModalManual();
			// } else {
			//	alert("Enter a value before going to " + $('#myValidForm').attr("action"));
			// }
			return false;
		});

		$("#temporaneo").click(function(e) {
			e.preventDefault(); 	
			// alert('test');
			window.open('borsa.htm', 'self');

		});
		/*
		$("#temporaneo").mouseover(function(e) {
			e.preventDefault(); 	
			alert('test over');
			// window.open('borsa.htm', 'self');

		});
    
		$("#temporaneo").mouseout(function(e) {
			e.preventDefault(); 	
			alert('test out');
			// window.open('borsa.htm', 'self');

		});
		*/
		
		$('#pulsantePreventivo-old').click(function(e) {
			e.preventDefault(); 			
		    
			// alert(this.href);
			var queryString = $('#acquisto').formSerialize();
			// alert(queryString);
			this.href = this.href + "?" +queryString; 
		    var link_preventivo = this.href;
			$('#pulsantePreventivo-old').nyroModalManual({minWidth: 650, minHeight: 450,resizeable: true, type: 'form'});
			// alert(link_preventivo);
			
			// open(link_preventivo);

		});
		
		
		
		
		$("#pulsantePreventivo").click(function() {
			$(this).parent().hide();
			$('.preventivo').show();
			
			return false;
		});
		$("#pulsanteAcquisto").click(function() {
		   var queryString = $('#acquisto').formSerialize();
		   // alert(queryString);
		   
		   if (navigator.userAgent.indexOf('Opera') != -1) {
		   		
		   	   // 20101207 - Exsisto
    		   $("#borsa_contestuale").load("/borsa_contestuale.php?"+ queryString, function(data) {
		   		   // $("#articoliBorsa").html(data);
				   
				   if (data != 0) {
				   $("#elemento_borsa2").html("<div class='ico'><a href='borsa.htm'>la mia borsa (<span id='articoliBorsa'>"+data+"</span>)</a></div>");
				   //$("#borsa_contestuale").html("<a id='link_verso_borsa' href='borsa.htm'>Vai alla borsa ("+data+")</a>");
				   //  $("#link_borsa").html("Vai alla borsaaa ("+data+")");
				   
				   }
				   // Devo differenziare i casi ... in base all'esito dell'ultima operazione ... 
       		       // $("#aggiunto_messaggio").load("../borsa_aggiunto.php",function(data_aggiunto) {
				   
				   $.getJSON('/borsa_aggiunto.php', function (data) {
	    				   		
	    				   		if (data.esito) {
	    				   			$("#aggiunto_messaggio").addClass('mexok');
	    				   			$("#aggiunto_messaggio").removeClass('mexerr');
	    				   		} else {
	    				   			$("#aggiunto_messaggio").removeClass('mexok');
	    				   			$("#aggiunto_messaggio").addClass('mexerr');
	    				   		}
	    				   		
				   				$("#aggiunto_messaggio").html(data.message);
				   				$('#aggiunto').slideDown(); 
				   				
				   				/*if (data.spese > 0) {
				   					$('#spesespedizionelabel').html('spese di spedizione');
				   				} else {
				   					$('#spesespedizionelabel').html('spese di spedizione <u>gratuite</u>');
				   				}*/
				   				
				   });
				   $('#aggiunto a').html('vai alla borsa <span>('+data+')</span>');
				   
    		   });
		   
		   } else {
		   	   // 20101207 - Exsisto	
    		   $("#borsa_contestuale").load("/borsa_contestuale.php?"+ queryString, function(data) {
    		   		   // $("#articoliBorsa").html(data);
    				   
    				   if (data != 0) {
    				   $("#elemento_borsa2").html("<div class='ico'><a href='borsa.htm'>la mia borsa (<span id='articoliBorsa'>"+data+"</span>)</a></div>");
    				   //$("#borsa_contestuale").html("<a id='link_verso_borsa' href='borsa.htm'>Vai alla borsa ("+data+")</a>");
    				   //  $("#link_borsa").html("Vai alla borsaaa ("+data+")");
    				   
    				   }
    				   // Devo differenziare i casi ... in base all'esito dell'ultima operazione ... 
       		       // $("#aggiunto_messaggio").load("../borsa_aggiunto.php",function(data_aggiunto) {
    				   
    				   $.getJSON('/borsa_aggiunto.php', function (data) {
    				   		
    				   		if (data.esito) {
    				   			$("#aggiunto_messaggio").addClass('mexok');
    				   			$("#aggiunto_messaggio").removeClass('mexerr');
    				   		} else {
    				   			$("#aggiunto_messaggio").removeClass('mexok');
    				   			$("#aggiunto_messaggio").addClass('mexerr');
    				   		}
    				   		
			   				$("#aggiunto_messaggio").html(data.message);
			   				$('#aggiunto').slideDown(); 
			   				
			   				/*if (data.spese > 0) {
			   					$('#spesespedizionelabel').html('spese di spedizione');
			   				} else {
			   					$('#spesespedizionelabel').html('spese di spedizione <u>gratuite</u>');
			   				}*/
			   				
    				   });
    				   $('#aggiunto a').html('vai alla borsa <span>('+data+')</span>');
    				   
    		   });		   
		   
		   
		   }
		   
		   return false;
		});
		
		$("#chiudiAggiunto").click(function() {
				$('#aggiunto').toggle(); 		
		});
		
		$("#immagineArticolo0").click(function() {
				$('#immagineArticolo0').toggle(); 		
		});
		
		/*
		$('.tab').find('a.current').hover(
			function(){
				$(this).css('backgroundImage', 'url(../img/tab_current.jpg)'); 
			}, function(){
				$(this).css('backgroundImage', 'url(../img/tab_current.jpg)'); 
			}
		);
		*/
        
        
        
        
        /*
		$("#scheda_informazioni").click(function(e) {
			e.preventDefault();
			
			$("#dettaglio_servizi").hide();
			$("#dettaglio_guida").hide();
			$("#dettaglio_prodotto").show();
			
			$("#scheda_informazioni").addClass("current");
			$("#scheda_guida").removeClass("current");
			$("#scheda_servizi").removeClass("current");
        */
			/*			
			$('.tab').find('a').css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab.jpg' +')');
			$('.tab').find('a.current').css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab_current.jpg' +')');
			
			$('.tab').find('a').hover(
			function(){
			$(this).css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab_hover.jpg' +')'); 
			},
			function(){
			$(this).css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab.jpg' +')'); 
			});
			
			$('.tab').find('a.current').hover(
			function(){
			$(this).css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab_current.jpg' +')'); 
			},
			function(){
			$(this).css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab_current.jpg' +')'); 
			});
			*/
		/*});*/

		/*$("#scheda_guida").click(function(e) {
			e.preventDefault();
			
			$("#dettaglio_prodotto").hide();
			$("#dettaglio_servizi").hide();
			$("#dettaglio_guida").show();
			
			$("#scheda_guida").addClass("current");
			$("#scheda_informazioni").removeClass("current");
			$("#scheda_servizi").removeClass("current");
            */
			/*
			$('.tab').find('a').css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab.jpg' +')');
			$('.tab').find('a.current').css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab_current.jpg' +')');
			
			
			// $("#scheda_servizi a:hover").css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab_hover.jpg' +')'); 
			$('.tab').find('a').hover(
			function(){
			$(this).css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab_hover.jpg' +')'); 
			},
			function(){
			$(this).css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab.jpg' +')'); 
			});
			
			$('.tab').find('a.current').hover(
			function(){
			$(this).css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab_current.jpg' +')'); 
			},
			function(){
			$(this).css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab_current.jpg' +')'); 
			});
			*/
		/*});*/
        /*
		$("#scheda_servizi").click(function(e) {
			e.preventDefault();
			
			$("#dettaglio_guida").hide();
			$("#dettaglio_prodotto").hide();
			$("#dettaglio_servizi").show();
			
			$("#scheda_informazioni").removeClass("current");
			$("#scheda_guida").removeClass("current");
			$("#scheda_servizi").addClass("current");
        */
			/*			
			$('.tab').find('a').css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab.jpg' +')');
			$('.tab').find('a.current').css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab_current.jpg' +')');
			
			// $("#scheda_servizi a:hover").css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab.jpg' +')'); 
			$('.tab').find('a').hover(
			function(){
			$(this).css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab_hover.jpg' +')'); 
			},
			function(){
			$(this).css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab.jpg' +')'); 
			});
			
			$('.tab').find('a.current').hover(
			function(){
			$(this).css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab_current.jpg' +')'); 
			},
			function(){
			$(this).css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab_current.jpg' +')'); 
			});
			*/
		/*});*/
		
        $("#tabInfoProdotto a:first").addClass("current");
        $(".dettaglioInfoProdotto").hide();
        $(".dettaglioInfoProdotto:first").show();
        
        
		$("#tabInfoProdotto a").click(function(e) {
            e.preventDefault();
            
            $("#tabInfoProdotto a").removeClass("current");
            $(this).addClass("current");
            
            $(".dettaglioInfoProdotto").hide();
            $("#"+$(this).attr('rel')).show();
            
        });
        
		
		$('.icoDomanda, .voceGlossario').tooltip({
			showURL: false,
           	track: false
       	});
				

});
