$(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;
		});

		// Controllo per opera .... 
		if (navigator.userAgent.indexOf('Opera') != -1) {

		        $("#borsa_contestuale").load("../borsa_contestuale.php",function(data) {
    			 if (data != 0) {
    			 $("#borsa_contestuale").html("<a href='borsa.htm' id='link_borsa'>Vai alla borsa ("+data+")</a>");
    			 } else {
    			 $("#borsa_contestuale").html("");
    			 }
    		});
		
		
    } else {		
    		
				$("#borsa_contestuale").load("borsa_contestuale.php",function(data) {
    			 if (data != 0) {
    			 $("#borsa_contestuale").html("<a href='borsa.htm' id='link_borsa'>Vai alla borsa ("+data+")</a>");
    			 } else {
    			 $("#borsa_contestuale").html("");
    			 }
    		});
		
		
		}
		

		$("#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 a').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 a').nyroModalManual({minWidth: 650, minHeight: 450,resizeable: true, type: 'form'});
			// alert(link_preventivo);
			
			// open(link_preventivo);

		});
		
		
		
		
		// $("#pulsantePreventivo").click(function() {
		// });
		$("#pulsanteAcquisto").click(function() {
		   var queryString = $('#acquisto').formSerialize();
		   // alert(queryString);
		   
		   if (navigator.userAgent.indexOf('Opera') != -1) {
		   
    		   $("#borsa_contestuale").load("../borsa_contestuale.php?"+ queryString, function(data) {
    		   		   // $("#articoliBorsa").html(data);
    				   
    				   if (data != 0) {
    				   $("#elemento_borsa").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) {
    				   
    				   $("#aggiunto_messaggio").load("../borsa_aggiunto.php",function(data_aggiunto) {
    				   				$("#aggiunto_messaggio").html(data_aggiunto);
    				   				$('#aggiunto').toggle(); 
    				   });
    				   
    		   });
		   
		   } else {
		   
    		   $("#borsa_contestuale").load("borsa_contestuale.php?"+ queryString, function(data) {
    		   		   // $("#articoliBorsa").html(data);
    				   
    				   if (data != 0) {
    				   $("#elemento_borsa").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) {
    				   
    				   $("#aggiunto_messaggio").load("borsa_aggiunto.php",function(data_aggiunto) {
    				   				$("#aggiunto_messaggio").html(data_aggiunto);
    				   				$('#aggiunto').toggle(); 
    				   });
    				   
    		   });		   
		   
		   
		   }
		   
		   
		});
		
		$("#chiudiAggiunto").click(function() {
				$('#aggiunto').toggle(); 		
		});
		
		$("#immagineArticolo0").click(function() {
				$('#immagineArticolo0').toggle(); 		
		});
		
		$('.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_informazioni").click(function(e) {
			e.preventDefault(); 		
			$("#dettaglio_servizi").hide();
			$("#dettaglio_guida").hide();
			$("#dettaglio_prodotto").show();
			$("#scheda_informazioni").addClass("current");
			// $("#scheda_informazioni a:hover").css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab.jpg' +')'); 
			 			
			$("#scheda_guida").removeClass("current");
			// $("#scheda_guida a:hover").css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab_hover.jpg' +')'); 
			
			$("#scheda_servizi").removeClass("current");
			// $("#scheda_servizi a:hover").css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab_hover.jpg' +')'); 
		
		    $('.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_guida a:hover").css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab.jpg' +')'); 
			$("#scheda_informazioni").removeClass("current");
			// $("#scheda_informazioni a:hover").css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab_hover.jpg' +')'); 
			
			$("#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_informazioni a:hover").css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab_hover.jpg' +')'); 
			$("#scheda_guida").removeClass("current");
			// $("#scheda_guida a:hover").css('backgroundImage','url(' + 'http://www.maxisport.com/nuovo/img/tab_hover.jpg' +')'); 
			
			$("#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' +')'); 
        });
				
		});
		
		
		
		$('.icoDomanda, .voceGlossario').tooltip({
			showURL: false,
           	track: false
       	});
				

});