function controllo_solo_numeri(b){
    var campo=document.getElementById(b);
    var len=campo.value.length;
		if (!(campo.value.match(/^[0-9]+$/))){
		  campo.value=campo.value.substring(0,campo.value.length-1);
		}
}

function rollover(a){
    document.getElementById(a).src="img/"+a+"b.gif";
}

function rollout(b){
    document.getElementById(b).src="img/"+b+".gif";
}

function aprisottomenu(){
    document.getElementById("vocine").style.display="inline";
}

function sparisci(i){
	  document.getElementById(i).style.display="none";
}

function svuota_div(obj) {
	while(obj.firstChild) obj.removeChild(obj.firstChild);
}

function nuovo_db(f){
      document.getElementById("inviare").disabled=true;
      if(f.email.value=="" || f.password.value=="" || f.nome.value=="" || f.cognome.value==""){
      document.getElementById("inviare").disabled=false;
      return false;
      }
      f.submit();
      return true;
}

function logins(j){
    document.getElementById("inviare").disabled=true;
      if(j.email.value=="" || j.psw.value==""){
      document.getElementById("inviare").disabled=false;
      return false;
      
      }
      j.submit();
      return true;
}


function imposta_destinatario(dati){
  if (dati == "u"){
	    document.getElementById("altri_dati").className = "nascondi";
	    document.getElementById("gesti_avanti").className="appari";
	} else if(dati=="d"){
	    document.getElementById("altri_dati").className = "appari";
	    document.getElementById("gesti_avanti").className="nascondi";
	}
}

function apri_ordine(){
  document.getElementById("modulo_ordine").style.display="none";
  document.getElementById("modulo_normale").style.display="block";
  document.getElementById("modulo_paypal").style.display="none";
  document.getElementById("foto_grande").style.display="none";
  document.getElementById("schedatesto").style.display="none";
  document.getElementById("schedatesto_carrello").style.display="inline";
}

function apri_paypal(){
  document.getElementById("modulo_paypal").style.display="block";
  document.getElementById("modulo_ordine").style.display="none";
  document.getElementById("modulo_normale").style.display="none";
  document.getElementById("foto_grande").style.display="none";
  document.getElementById("schedatesto").style.display="none";
  document.getElementById("schedatesto_carrello").style.display="inline";
}

function controlla_ordine(){
  document.getElementById("notifica_errore").style.display="none";
  var errore=0;
  var campi=new Array("nome","cognome","email1","email2","paese_spedizione");
  for(var r=0;r<campi.length;r++){
    if(document.getElementById(campi[r]).value==""){
      errore++;
    }
  }
  if(errore==0){
    document.getElementById("invia_ordine").disabled=false;
  } else {
    document.getElementById("invia_ordine").disabled=true;
  }
}

function controlla_invio(fo){
    if(document.getElementById("email1").value != document.getElementById("email2").value){
      svuota_div(document.getElementById("notifica_errore"));
      document.getElementById("notifica_errore").appendChild(document.createTextNode("Attenzione. Sono state inserire due mail diverse"));
      document.getElementById("notifica_errore").style.display="block";
      return false;
    } else {
      invia_dati();
    }
}

//############################################### CARRELLO ###########################################

function aggiungi_carrello() {
  if(document.getElementById("piede").value!="" && document.getElementById("colore").value!=""){
    //document.getElementById("ajax-loader1").className="prese";
    var dati_post = "piede=" +
	  encodeURIComponent(document.getElementById("piede").value)+"&colore=" +
	  encodeURIComponent(document.getElementById("colore").value)+"&id_articolo=" +
	  encodeURIComponent(document.getElementById("articolo").value)+"&prezzo=" +
	  encodeURIComponent(document.getElementById("prezzo_vetrina").value);
    req.open('POST','ajax/aggiungi_carrello.php',true);
    req.onreadystatechange =esito_carrello;
    req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	  req.setRequestHeader("Content-length", dati_post.length);
	  req.send(dati_post);
	  } else {
    
    }
  }
                            
    function esito_carrello() {
	   if(req.readyState == 4) {
		  var esito = req.responseText;
		    location.replace('http://www.calzaturebelfiore.com/modelli_scarpe');
	   }
   }
  
function crea_http_req() {
	var req = false;
	if (window.XMLHttpRequest){
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject){
	  req=new ActiveXObject("Microsoft.XMLHTTP")
	}
	 return req;
}

 
var req = crea_http_req();


