

/*-----------------------------------------------*/
/*--- VISUALIZZA NASCONDI BOTTONI ---------------*/
/*-----------------------------------------------*/

function VisualizzaTastiOrdine(elemento_menu){
	
	if (elemento_menu == ''){
		
		var ElementoNascosto_1 = document.getElementById("Tasti_Ordine_Def");
		ElementoNascosto_1.style.display = "none";

	}
	
	if (elemento_menu == '1'){

		var ElementoNascosto_1 = document.getElementById("Tasti_Ordine_Def");
		ElementoNascosto_1.style.display = "none";
		ElementoNascosto_1.style.display = "block";

		var ElementoNascosto_2 = document.getElementById("Dati_Password");
		ElementoNascosto_2.style.display = "none";
		ElementoNascosto_2.style.display = "block";

	}
	
	if (elemento_menu == '2'){

		var ElementoNascosto_1 = document.getElementById("Tasti_Ordine_Def");
		ElementoNascosto_1.style.display = "none";
		ElementoNascosto_1.style.display = "block";

		var ElementoNascosto_2 = document.getElementById("Dati_Password");
		ElementoNascosto_2.style.display = "none";

	}
	
}

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/

function AggiungiProdotto(id_prodotto,azione,UrlRedirect){

UrlRedirect = UrlRedirect.replace(/&/g,"|");

	if ( azione == 'Salva' ) {

				quantita = document.getElementById("qta_"+id_prodotto+"_agg").value
				id_misura = document.getElementById("misura_"+id_prodotto+"_agg").value
				
				if (quantita == ''){
					alert("Inserire la quantita' !");
					document.getElementById("qta_"+id_prodotto+"_agg").focus();
					return false;
				}	
														
				if (!IsNumber(quantita)){
					alert("La quantita' non e' corretta!");
					document.getElementById("qta_"+id_prodotto+"_agg").focus();
					return false;
				}
				
				if (quantita < 1){
					alert("La quantita' deve essere maggiore di 0!");
					document.getElementById("qta_"+id_prodotto+"_agg").focus();
					return false;
				}
	
				
				location.href = 'CARRELLO/salva_carrello.asp?id_utente='+document.getElementById("id_utente_accesso").value+'&id_prodotto='+id_prodotto+'&quantita='+quantita+'&id_misura='+id_misura+'&azione='+azione+'&UrlRedirect='+UrlRedirect
	
	}

	if ( azione == 'Cancella' ) {
	
				quantita = document.getElementById("qta_"+id_prodotto+"_agg").value
				id_misura = document.getElementById("misura_"+id_prodotto+"_agg").value
				
				if (quantita == ''){
					alert("Inserire la quantita' !");
					document.getElementById("qta_"+id_prodotto+"_agg").focus();
					return false;
				}	
														
				if (!IsNumber(quantita)){
					alert("La quantita' non e' corretta!");
					document.getElementById("qta_"+id_prodotto+"_agg").focus();
					return false;
				}
				
				if (quantita < 1){
					alert("La quantita' deve essere maggiore di 0!");
					document.getElementById("qta_"+id_prodotto+"_agg").focus();
					return false;
				}

				var agree=confirm("Eliminare articolo ?");

				if (agree == true) {
				
					location.href = 'CARRELLO/salva_carrello.asp?id_utente='+document.getElementById("id_utente_accesso").value+'&id_prodotto='+id_prodotto+'&quantita='+quantita+'&id_misura='+id_misura+'&azione='+azione+'&UrlRedirect='+UrlRedirect
				
				}
	
	}
	
	if ( azione == 'Svuota' ) {
				var agree=confirm("Eliminare gli articoli dal carrello ?");

				if (agree == true) {
					location.href = 'CARRELLO/salva_carrello.asp?id_utente='+document.getElementById("id_utente_accesso").value+'&azione='+azione+'&UrlRedirect='+UrlRedirect
				}
	
	}


}

/*-----------------------------------------------*/
/*--- VISUALIZZA DESTINAZIONE MERCE -------------*/
/*-----------------------------------------------*/

function VisualizzaIndirizzoSpedizione(elemento_menu){

	if (elemento_menu == ''){
		
		var ElementoNascosto_1 = document.getElementById("Destinazione_1");
		ElementoNascosto_1.style.display = "none";

		var ElementoNascosto_2 = document.getElementById("Destinazione_2");
		ElementoNascosto_2.style.display = "none";

	}
	
	if (elemento_menu == '1'){

		var ElementoNascosto_1 = document.getElementById("Destinazione_1");
		ElementoNascosto_1.style.display = "none";
		ElementoNascosto_1.style.display = "block";

		var ElementoNascosto_2 = document.getElementById("Destinazione_2");
		ElementoNascosto_2.style.display = "none";
		ElementoNascosto_2.style.display = "block";

	}
	
	if (elemento_menu == '2'){

		var ElementoNascosto_1 = document.getElementById("Destinazione_1");
		ElementoNascosto_1.style.display = "none";

		var ElementoNascosto_2 = document.getElementById("Destinazione_2");
		ElementoNascosto_2.style.display = "none";
		ElementoNascosto_2.style.display = "block";

	}

}

/*-----------------------------------------------*/
/*-----------------------------------------------*/

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/



function IsNumber(num)
{
   var i = 0;
   var letter;

   while (i < num.length)
   {
      letter = num.charAt(i);

      if ((letter == '0') || (letter == '1') || (letter == '2') ||
          (letter == '3') || (letter == '4') || (letter == '5') ||
          (letter == '6') || (letter == '7') || (letter == '8') ||
          (letter == '9') || (letter == '+') || (letter == '.') ||
          (letter == '/') || (letter == ',') || (letter == ' '))
      {
         i++;
      }
      else
      {
         return false;
      }
   }

   return true;
}
