// JavaScript Document
function ArtDel(chiave)
  {
  if(confirm("Attenzione! Si sta per eliminare un articolo dal carrello:\nsi è sicuri di voler proseguire con l' operazione?"))
    {
    document.LISTA.art_del.value=chiave;
    document.LISTA.action="buy_list.php";
    //alert(document.LISTA.art_del.value);
    //alert (document.LISTA.action);
    document.LISTA.submit();
    }
  else return false;
  }

function ArtRefresh(chiave)
  {
  document.LISTA.Aggiorna.value=chiave;
  }

function RefreshChart()
  {
  var IsEmptyQty=CheckEmptyQty();
  if (IsEmptyQty == false) return false;

  document.LISTA.invia.value='modifica';
  document.LISTA.action="buy_list.php";
  document.LISTA.submit();
  return true;
  }

function CheckReg(UserIndex)
  {
  var IsEmptyQty=CheckEmptyQty();
  //alert(IsEmptyQty);
  if (IsEmptyQty == false) return false;

  var UtID=UserIndex;
  if (UtID == 0) 
    {
    var message ='<p align="center">Bisogna essere registrati per effettuare l\' acquisto!</p>';
        message+='<p align="center">Per registrarti <a href="reg_index.php" onclick="HiddenBox()">clicca qui</p>';
    
    document.getElementById('message_text').innerHTML = message;
    ShowBox();
    }
  else GoToNextStep();
  }

function CameBackList(Dest)
  {
  var Target=Dest;
  //document.LISTA.action=Target;
  //document.LISTA.invia.value='continua con gli acquisti';
  location.href=Target;
  //document.LISTA.submit();
  }



function numeralsOnly(evt) 
  {
  evt = (evt) ? evt : event;
  var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :
        ((evt.which) ? evt.which : 0));
  if (charCode > 31 && (charCode < 48 || charCode > 57)) 
    {
    return false;
    }
  if (charCode == 13) return false
  if (charCode == 3 ) return false
  else return true;
  }

function GoToNextStep()
  {
  document.LISTA.action="buy_step_1.php";
  document.LISTA.invia.value='conferma e invia';
  document.LISTA.submit();
  }

function CheckEmptyQty()
  {
  var InputList=document.getElementsByTagName('input');
  for (var A = 0; A < InputList.length ; A++)
    {
    if (InputList[A].getAttribute('verify') == 'empty')
      {      
      if (parseInt(InputList[A].value) <= 0 || String(parseInt(InputList[A].value)) == 'NaN')
        {
        var message ='<p align="center">Impossibile Proseguire con l\'operazione.</p>';
            message+='<p align="center">Prego verificate le quantit&agrave; del vostro carrello!</p>';
        
        document.getElementById('message_text').innerHTML = message;
        ShowBox();
        return false;
        }
      }
    }
  return true;
  }
