$(document).ready(function(){ 	$("#addCarrello").click(function () {		var str = $("#carrello-add-form").serialize();			str = str+"&rnd"+Math.random();		$.ajax({ 	    	   type: "POST", 	    	   url: "http://www.pineider.com/cart.do",  	    	   data: str, 	    	   complete: function(val){  			 		/*$("#addCarrello").hide();					$("#qta").hide();					$("#qta-label").hide();*/	    		    var array=val.responseText.split("|");	    		   					setTimeout("$(\"#processandoCarrello\").hide(); $(\"#aggiuntoACarrello\").show();",1000);					if("true" == array[7]) { 						setTimeout("$(\"#addCarrello\").show(); $(\"#aggiuntoACarrello\").hide(); $(\"#remCarrello\").show();",2000);					} else {						setTimeout("$(\"#addCarrello\").show(); $(\"#aggiuntoACarrello\").hide(); $(\"#remCarrello\").show();",2000);						document.getElementById("qta").value = array[8];						if ("eng" == current_language && "string" ==  typeof(current_language))							alert("ATTENTION: The amount requested is not currently available.\nPlease try to buy a smaller amount or contact us.\n\nThanks Staff Pineider");						else							alert("ATTENZIONE: La quantit\340 richiesta non \350 al momento disponibile.\nLa preghiamo di provare ad acquistare una quantit\340 inferiore o a contattarci.\n\nGrazie lo Staff Pineider");												}	 			 		 			 	$("#nitems").html(array[0]);	 			 	$("#totale").html(array[1]);	 			}, 				beforeSend: function(val){ 					$("#addCarrello").hide(); 					$("#processandoCarrello").show(); 			 	} 					     });			});		$(".addCarrelloGrid").click(function () {		var target = $(this).attr("target");		var str = $("#carrello-add-form"+target).serialize();			str = str+"&rnd"+Math.random();		$.ajax({ 	    	   type: "POST", 	    	   url: "http://www.pineider.com/cart.do",  	    	   data: str, 	    	   complete: function(val){ 			 					setTimeout("$(\"#processandoCarrello"+target+"\").hide(); $(\"#aggiuntoACarrello"+target+"\").show();",1000); 					var array=val.responseText.split("|"); 					if("false" == array[7]) { 						setTimeout("$(\"#aggiuntoACarrello"+target+"\").hide(); $(\"#remCarrello"+target+"\").show();",2000);						if ("eng" == current_language && "string" ==  typeof(current_language))							alert("ATTENTION: The amount requested is not currently available.\nPlease try to buy a smaller amount or contact us.\n\nThanks Staff Pineider");						else							alert("ATTENZIONE: La quantit\340 richiesta non \350 al momento disponibile.\nLa preghiamo di provare ad acquistare una quantit\340 inferiore o a contattarci.\n\nGrazie lo Staff Pineider"); 					} else { 						setTimeout("$(\"#addCarrelloGrid"+target+"\").show(); $(\"#aggiuntoACarrello"+target+"\").hide(); $(\"#remCarrello"+target+"\").show();",2000); 					}	 			 	$("#nitems").html(array[0]);	 			 	$("#totale").html(array[1]);	 			}, 				beforeSend: function(val){ 					$("#addCarrelloGrid"+target).hide(); 					$("#processandoCarrello"+target).show(); 			 	} 					     });			});				$("#-remCarrello").click(function () {		var str = $("#carrello-rem-form").serialize();			str = str+"&rnd"+Math.random();				$.ajax({ 	    	   type: "POST", 	    	   url: "http://www.pineider.com/cart.do",  	    	   data: str, 	    	   complete: function(val){ 					$("#addCarrello").show(); 			 		$("#qta").show(); 			 		$("#qta-label").show();										$("#remCarrello").hide(); 			 		var array=val.responseText.split("|"); 	 			 	  $("#nitems").html(array[0]); 	 			 	  $("#totale").html(array[1]);					 		   	   } 	     });			});			$(".slide2_immagine").click(function () {		var str = "act=vnt&variante="+$(this).attr("id")+"&row="+$(this).attr("row");			str = str+"&rnd="+Math.random();				 $.ajax({ 	    	   type: "POST", 	    	   url: "http://www.pineider.com/cart.do",  	    	   data: str, 	    	   complete: function(val){ 			   } 	     });			});			$("#variante_8").change(function () {		var str = $("#form_variante_8").serialize();			str = str+"&act=vnt&rnd="+Math.random();				 $.ajax({ 	    	   type: "POST", 	    	   url: "http://www.pineider.com/cart.do",  	    	   data: str, 	    	   complete: function(val){ 			   } 	     });			});			$("#variante_10").change(function () {		var str = $("#form_variante_10").serialize();			str = str+"&act=vnt&rnd="+Math.random();				 $.ajax({ 	    	   type: "POST", 	    	   url: "http://www.pineider.com/cart.do",  	    	   data: str, 	    	   complete: function(val){ 			   } 	     });			});					$("#addToWhishList").click(function () {		var str = "idProdotto="+$(this).attr("prodotto");		$.ajax({ 	    	   type: "POST", 	    	   url: "http://www.pineider.com/adm/ecommerce/wishlist/add.do",  	    	   data: str, 	    	   complete: function(val){  			 	  $("#addToWhishList").hide(); 			 	  $("#remToWhishList").show(); 			 	} 	     });			});		$("#remToWhishList").click(function () {		var str = "idProdotto="+$(this).attr("prodotto");		$.ajax({ 	    	   type: "POST", 	    	   url: "http://www.pineider.com/adm/ecommerce/wishlist/remove.do",  	    	   data: str, 	    	   complete: function(val){  			 	  $("#addToWhishList").show(); 			 	  $("#remToWhishList").hide(); 			 	} 	     });			});		$(".inputqta").change(function () {		var id = $(this).attr("id");		var qta = $(this).attr("value");		var elem = $(this);		var param = "id="+id+"&qta="+qta+"&act=upd";		$.ajax({ 	    	   type: "POST", 	    	   url: "http://www.pineider.com/cart.do",  	    	   data: param, 	    	   complete: function(val){ 								var array=val.responseText.split("|");					$("#nitems").html(array[0]);	 			 	$("#totale_carrello").html(array[1]);			 			 	$("#totale").html(array[1]);	 			 	$("#partail_"+id).html(array[2]);	 			 	if("false" == array[7]) {	 			 		elem.val(array[8]);	 			 		if ("eng" == current_language && "string" ==  typeof(current_language))							alert("ATTENTION: The amount requested is not currently available.\nPlease try to buy a smaller amount or contact us.\n\nThanks Staff Pineider");						else							alert("ATTENZIONE: La quantit\340 richiesta non \350 al momento disponibile.\nLa preghiamo di provare ad acquistare una quantit\340 inferiore o a contattarci.\n\nGrazie lo Staff Pineider");	 			 	}	 			 			   	   } 	     });				});		$(".remRigaCarrello").click(function () {		var id = $(this).attr("id");		var qta = $(this).attr("value");		var param = "id="+id+"&act=rem";			$.ajax({ 	    	   type: "POST", 	    	   url: "http://www.pineider.com/cart.do",  	    	   data: param, 	    	   complete: function(val){ 					$(".riga_ordine_"+id).remove(); 			 		var array=val.responseText.split("|"); 	 			 	  $("#nitems").html(array[0]); 	 			 	  $("#totale").html(array[1]); 	 			 	  $("#totale_carrello").html(array[1]); 					  var rowCount = $('#main-table tr').length; 					  if(array[0] < 1)   						 window.location = window.location; 				} 	     });			});		$(".remRigaWishlist").click(function () {		var id = $(this).attr("id");		var str= "idProdotto="+$(this).attr("id");		$.ajax({ 	    	   type: "POST", 	    	   url: "http://www.pineider.com/adm/ecommerce/wishlist/remove.do",  	    	   data: str, 	    	   complete: function(val){ 			 	  $("#riga_wishlist_"+id).remove();			 	  $("#pineider-whishlist").effect("bounce", { times:3 }, 300);				  var rowCount = $('#main-table tr').length; 				  if(rowCount < 5) 			 		 window.location = window.location;			 	  			   } 	     });		});	    $('#spese_spedizione').change(function () {    	var str = "id="+$(this).attr("value")+"&act=reg";	;    	$.ajax({ 	    	   type: "POST", 	    	   url: "http://www.pineider.com/cart.do",  	    	   data: str, 	    	   complete: function(val){     			 var array=val.responseText.split("|");    			 $("#totale_carrello_con_spese").html(array[3]);    			 if('true' != array[6]) {    				 window.location = "http://www.pineider.com/"+array[6];    			 }    			     			 if('true' == array[4]) {    				 $("#totale_carrello_con_spese_gratis").html(array[5]);    				 $("#totale_carrello_con_spese_gratis").show();    				 $("#totale_carrello_con_spese").addClass("spese-gratis");    			 } else {    				 $("#totale_carrello_con_spese_gratis").hide();    				 $("#totale_carrello_con_spese").removeClass("spese-gratis");    			 }    		   } 	     });    });        $('#vettore_spedizione').change(function () {    	var str = "id="+$(this).attr("value")+"&act=vct";    	$.ajax({ 	    	   type: "POST", 	    	   url: "http://www.pineider.com/cart.do",  	    	   data: str, 	    	   complete: function(val){     			 var array=val.responseText.split("|");    			 $("#totale_carrello_con_spese").html(array[3]);    			 if('true' == array[4]) {    				 $("#totale_carrello_con_spese_gratis").html(array[5]);    				 $("#totale_carrello_con_spese_gratis").show();    				 $("#totale_carrello_con_spese").addClass("spese-gratis");    			 } else {    				 $("#totale_carrello_con_spese_gratis").hide();    				 $("#totale_carrello_con_spese").removeClass("spese-gratis");    			 }    		   } 	     });    });	    $('#regalo,#button_pagamentokc').click(function () {    	var regalo ="N";    	if($('#regalo:checked').length > 0)     		regalo="S";    	var str = "regalo="+regalo+"&messaggio="+$('#messaggio').attr('value')+"&act=gft";    	var sendForm = $(this).hasClass("bottone_invioform_pagamento");    	$.ajax({ 	    	   type: "POST", 	    	   url: "http://www.pineider.com/cart.do",  	    	   data: str, 	    	   complete: function(val){     			 var array=val.responseText.split("|");    			 $("#totale_carrello_con_spese").html(array[3]);    			 if('true' == array[4]) {    				 $("#totale_carrello_con_spese_gratis").html(array[5]);    				 $("#totale_carrello_con_spese_gratis").show();    				 $("#totale_carrello_con_spese").addClass("spese-gratis");    			 } else {    				 $("#totale_carrello_con_spese_gratis").hide();    				 $("#totale_carrello_con_spese").removeClass("spese-gratis");    			 }    			     			 if(sendForm && control_pagamentokc()) {    				 if('13' == document.getElementById('tipo_pagamento').value) {    					 $('#pagamentokc').attr('action','pagamentopaypal.do');    				 }    				 $('#pagamentokc').submit();    			 }    		  } 	     });    });        $('#regalo_sr,#button_pagamento_sr').click(function () {    	var regalo_sr ="N";    	if($('#regalo_sr:checked').length > 0)     		regalo_sr="S";    	var str = "regalo="+regalo_sr+"&messaggio="+$('#messaggio').attr('value')+"&act=gft";    	var sendForm = $(this).hasClass("bottone_invioform_pagamento");    	$.ajax({ 	    	   type: "POST", 	    	   url: "http://www.pineider.com/cart.do",  	    	   data: str, 	    	   complete: function(val){     			 var array=val.responseText.split("|");    			 $("#totale_carrello_con_spese").html(array[3]);    			 if('true' == array[4]) {    				 $("#totale_carrello_con_spese_gratis").html(array[5]);    				 $("#totale_carrello_con_spese_gratis").show();    				 $("#totale_carrello_con_spese").addClass("spese-gratis");    			 } else {    				 $("#totale_carrello_con_spese_gratis").hide();    				 $("#totale_carrello_con_spese").removeClass("spese-gratis");    			 }    			     			 if(sendForm && control_pagamentokc_sr()) {    				 if('13' == document.getElementById('tipo_pagamento').value) {    					 $('#pagamentokc_sr').attr('action','pagamentopaypal-sr.do');    				 }    				 $('#pagamentokc_sr').submit();    			 }    		  } 	     });    });        $("#-tipo_pagamento").change(function () {    	var str ="act=cts";    	if('3' == document.getElementById('tipo_pagamento').value)     		str = str + "&contrassegno=S";    	else str = str + "&contrassegno=N";    	$.ajax({ 	    	   type: "POST", 	    	   url: "http://www.pineider.com/cart.do",  	    	   data: str, 	    	   complete: function(val){ 	 			 var array=val.responseText.split("|");	 			 $("#totale_carrello_con_spese").html(array[3]);		 			 if('true' == array[4]) {		 				 $("#totale_carrello_con_spese_gratis").html(array[5]);		 				 $("#totale_carrello_con_spese_gratis").show();		 				 $("#totale_carrello_con_spese").addClass("spese-gratis");		 			 } else {		 				 $("#totale_carrello_con_spese_gratis").hide();		 				 $("#totale_carrello_con_spese").removeClass("spese-gratis");		 			 }    			 	 			} 	     });    	      })      .change();});
