
function sendOrder(searchParametersPassed, loginPassed, sessionIdPassed, rightColumnActionPassed, leftColumnActionPassed, showCartFlagPassed, languageIndexPassed) {
   
   //Controllo che sia stata selezionata una modalita' di pagamento
   var typeOfPaymentSelected = false;
   for (i = 0; i < document.cartForm.typeOfPayment.length; i++) {
      if (document.cartForm.typeOfPayment[i].checked == true) {
         typeOfPaymentSelected = true;
      }
   }
   if (!typeOfPaymentSelected) {
      // Se non � stata selezionata una modalit� di pagamento allora avviso l'utente
      alert('You must select a type of payment.\nDevi selezionare un tipo di pagamento.');
   } else {
      // Definisco la variabile che contiene il prezzo di spedizione
      for (i = 0; i < document.cartForm.typeOfPayment.length; i++){
         if (document.cartForm.typeOfPayment[i].checked == true) {
            document.cartForm.selectedShipmentCost.value = document.getElementById("shipmentCost_"+ i).value;
         }
      }
      
      ////////////////////////////////////////////
      loginData = loginPassed + "<;>" + sessionIdPassed;
      document.cartForm.searchParameters.value = decode64(searchParametersPassed);
      //***************************************************************************
      // Costruisco il parametro per forzare il login
      document.cartForm.loginData.value = loginData;
      //***************************************************************************
      document.cartForm.rightColumnAction.value = rightColumnActionPassed;
      document.cartForm.leftColumnAction.value = leftColumnActionPassed;
      //document.form.showCartFlag.value = showCartFlagPassed;
      document.cartForm.cartAction.value = "end-1-";
      document.cartForm.languageIndex.value = languageIndexPassed;
      ////////////////////////////////////////////
      
      /*
      newLocation = "TEST2/start.php?" + document.cartForm.searchParameters.value + "<:>" + loginData + "<:>" + document.cartForm.rightColumnAction.value + "<:>" + document.cartForm.leftColumnAction.value;
      
      document.cartForm.loginData.value = loginData;
      alert(document.cartForm.loginData.value);
      document.cartForm.cartAction.value = "end-1-";
      alert(document.cartForm.cartAction.value);
      */
      
      document.cartForm.submit();
   
   }
   
}


function selectPaymentMode(searchParametersPassed, loginPassed, sessionIdPassed, rightColumnActionPassed, leftColumnActionPassed, showCartFlagPassed, languageIndexPassed) {


//function selectPaymentMode(login, sessionIdPassed) {
   
   if (loginPassed == "") {
      // Se non � un numero allora devo forzare il login
      loginData = document.cartForm.LOGIN.value + "<,>" + document.cartForm.password.value + "<;>" + sessionIdPassed;
   } else {
      
      loginData = loginPassed + "<;>" + sessionIdPassed;
   }
   
   
   ////////////////////////////////////////////
   
   
   //document.form.searchParameters.value = decode64(searchParametersPassed);
   document.cartForm.searchParameters.value = decode64(searchParametersPassed);
   //***************************************************************************
   // Costruisco il parametro per forzare il login
   document.cartForm.loginData.value = loginData;
   //***************************************************************************
   document.cartForm.rightColumnAction.value = rightColumnActionPassed;
   document.cartForm.leftColumnAction.value = leftColumnActionPassed;
   //document.form.showCartFlag.value = showCartFlagPassed;
   document.cartForm.cartAction.value = "spm-1-";
   document.cartForm.languageIndex.value = languageIndexPassed;
   
   document.cartForm.submit();
   
   
   /////////////////////////////////////////////
   
   
}

function showShipmentCosts(methodIndex, shipmentMethodCount) {
   
   
   
   
   
   hideAllShipmentCosts(shipmentMethodCount);
   hideAllTotalCosts(shipmentMethodCount);
   
   document.getElementById('shipmentCostInEuro_' + methodIndex).style.display = "block";
   document.getElementById('shipmentCostInDollar_' + methodIndex).style.display = "block";
   
   
   
   document.getElementById('totalCostInEuro_' + methodIndex).style.display = "block";
   document.getElementById('totalCostInDollar_' + methodIndex).style.display = "block";
   
   
}


function hideAllShipmentCosts(ShipmentCostsCount) {
   
   
   for (i = 0; i < ShipmentCostsCount; i++) {
      //Nascondo i costi in euro
      if (document.getElementById('shipmentCostInEuro_' + i)) {
         //Se esiste l'elemento specificato allora lo nascondo
         document.getElementById('shipmentCostInEuro_' + i).style.display = "none";
         
      }
      
      //Nascondo i costi in dollari
      if (document.getElementById('shipmentCostInDollar_' + i)) {
         //Se esiste l'elemento specificato allora lo nascondo
         document.getElementById('shipmentCostInDollar_' + i).style.display = "none";
         
      }
      
   }
}


function hideAllTotalCosts(ShipmentCostsCount) {
   
   
   for (i = 0; i < ShipmentCostsCount; i++) {
      //Nascondo i costi in euro
      if (document.getElementById('totalCostInEuro_' + i)) {
         //Se esiste l'elemento specificato allora lo nascondo
         document.getElementById('totalCostInEuro_' + i).style.display = "none";
         
      }
      
      //Nascondo i costi in dollari
      if (document.getElementById('totalCostInDollar_' + i)) {
         //Se esiste l'elemento specificato allora lo nascondo
         document.getElementById('totalCostInDollar_' + i).style.display = "none";
         
      }
      
   }
}

function increaseQuantity(searchParameters, userId, session, rightColumnAction, leftColumnAction, cartAction, languageIndex) {
   // Rimuove un articolo dal carrello della spesa
   
   newLocation = "start.php?" + encode64(decode64(searchParameters) + "<:>" + userId + "<;>" + session + "<:>" + rightColumnAction + "<:>" + leftColumnAction + "<:>" + cartAction + "<:>" + languageIndex);
   
   document.location = newLocation;
   
   
}

function decreaseQuantity(searchParameters, userId, session, rightColumnAction, leftColumnAction, cartAction, languageIndex) {
   // Rimuove un articolo dal carrello della spesa
   
   newLocation = "start.php?" + encode64(decode64(searchParameters) + "<:>" + userId + "<;>" + session + "<:>" + rightColumnAction + "<:>" + leftColumnAction + "<:>" + cartAction + "<:>" + languageIndex);
   
   document.location = newLocation;
   
   
}


function changeShipmentCosts() {
   
   
   if (document.cartForm.countrySelect.options[document.cartForm.countrySelect.selectedIndex].value == "italy") {
      //Costi di spedizione
      //document.all.italianShipmentCostsInEuro.style.display = "inline";
      document.getElementById("italianShipmentCostsInEuro").style.display = "block";
      document.getElementById("italianShipmentCostsInDollars").style.display = "block";
      document.getElementById("otherCountryShipmentCostsInEuro").style.display = "none";
      document.getElementById("otherCountryShipmentCostsInDollars").style.display = "none";
      //Costi totali
      document.getElementById("italianTotalCostsInEuro").style.display = "block";
      document.getElementById("italianTotalCostsInDollars").style.display = "block";
      document.getElementById("otherCountryTotalCostsInEuro").style.display = "none";
      document.getElementById("otherCountryTotalCostsInDollars").style.display = "none";
      
   } else {
      //Costi di spedizione
      document.getElementById("italianShipmentCostsInEuro").style.display = "none";
      document.getElementById("italianShipmentCostsInDollars").style.display = "none";
      document.getElementById("otherCountryShipmentCostsInEuro").style.display = "block";
      document.getElementById("otherCountryShipmentCostsInDollars").style.display = "block";
      //Costi totali
      document.getElementById("italianTotalCostsInEuro").style.display = "none";
      document.getElementById("italianTotalCostsInDollars").style.display = "none";
      document.getElementById("otherCountryTotalCostsInEuro").style.display = "block";
      document.getElementById("otherCountryTotalCostsInDollars").style.display = "block";
      
   }
   
}

