var XMLHTTP
var XMLHTTP2
var XMLHTTP3
var XMLHTTP4

function pulisci(str)
{
  k=str.replace(/[\']/g,"`")
  n=k.replace(/[\"]/g,"`")
  return(n)
}

function GetXmlHttpObject()
{
  var XMLHTTP=null;
  try
  {
  // Firefox, Opera 8.0+, Safari
    XMLHTTP=new XMLHttpRequest();
  }
  catch (e)
  {
  // Internet Explorer
  try
    {
      XMLHTTP=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      XMLHTTP=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return XMLHTTP;
}

function showCustomer(str)
{ 
  XMLHTTP=GetXmlHttpObject();
  if (XMLHTTP==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  } 
  var url="ajax.asp";
  url=url+"?id=1&q="+str;
  url=url+"&sid="+Math.random();
  XMLHTTP.onreadystatechange=stateChanged;
  XMLHTTP.open("GET",url,true);
  XMLHTTP.send(null);
}
function popola(ditta)
{ 
  XMLHTTP=GetXmlHttpObject();
  if (XMLHTTP==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  } 
  var url="ajax.asp";
  url=url+"?id=5&ditta="+ditta+"";
  url=url+"&sid="+Math.random();
  XMLHTTP.onreadystatechange=stateChanged3;
  XMLHTTP.open("GET",url,true);
  XMLHTTP.send(null);
}
function insert_dest(stato,ditta)
{
  XMLHTTP=GetXmlHttpObject();
  if (XMLHTTP==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  } 
  var url="ajax.asp";
  url=url+"?id=4&stato="+stato+"&ditta="+ditta+"&referente="+document.getElementById('referente').value+"&indirizzo="+document.getElementById('indirizzo').value+"&cap="+document.getElementById('cap').value+"&citta="+document.getElementById('citta').value+"&provincia="+document.getElementById('provincia').value+"&nazione=IT&telefono="+document.getElementById('telefono').value+"&fax="+document.getElementById('fax').value+'&sid='+Math.random();
  XMLHTTP.onreadystatechange=stateChanged;
  XMLHTTP.open("GET",url,true);
  XMLHTTP.send(null);
  XMLHTTP3=GetXmlHttpObject();
  if (XMLHTTP3==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  } 
  var url="ajax.asp";
  url=url+"?id=5&ditta="+ditta+"";
  url=url+"&sid="+Math.random();
  XMLHTTP3.onreadystatechange=stateChanged4;
  XMLHTTP3.open("GET",url,true);
  XMLHTTP3.send(null);
}

function nuovaDest(stato,ditta)
{ 
  XMLHTTP=GetXmlHttpObject();
  if (XMLHTTP==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  } 
  var url="ajax.asp";
  url=url+"?id=4&stato="+stato+"&ditta="+ditta+"";
  url=url+"&sid="+Math.random();
  XMLHTTP.onreadystatechange=stateChanged;
  XMLHTTP.open("GET",url,true);
  XMLHTTP.send(null);
}

function mostraDitta(str,id_ditta)
{ 
  XMLHTTP=GetXmlHttpObject();
  if (XMLHTTP==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  } 
  var url="ajax.asp";
  url=url+"?id=3&id_ditta="+id_ditta+"&q="+str;
  url=url+"&sid="+Math.random();
  XMLHTTP.onreadystatechange=stateChanged;
  XMLHTTP.open("GET",url,true);
  XMLHTTP.send(null);
}

function testaemail(str)
{ 
  XMLHTTP=GetXmlHttpObject();
  if (XMLHTTP==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  } 
  var url="ajax.asp";
  url=url+"?id=2&q="+str;
  url=url+"&sid="+Math.random();
  //alert("URL "+url);
  XMLHTTP.onreadystatechange=stateChangedQUI; 
  XMLHTTP.open("GET",url,true); 
  XMLHTTP.send(null);
}


function prova()
{
  var form = document.forms['JoinForm'];
  //alert(form['NEmail'].value);
  testaemail(form['NEmail'].value);
	//if(document.getElementById("controllo").innerHTML=="non esiste")
	//{
	//  document.JoinForm.submit();
	//}
}

function stateChangedQUI() 
{
  var field = document.getElementById("controllo");
  if (XMLHTTP.readyState == 4) 
  {
    // Quando pronta, visualizzo la risposta del form
    if(XMLHTTP.responseText=="esiste")
    {
	  field.value = "NO";
	  if(document.getElementById("controllo").value=="NO")
	  {
	    document.getElementById("NEmail").style.borderTop='Thin Solid Red';
	    document.getElementById("NEmail").style.borderLeft='Thin Solid Red';
	    document.getElementById("NEmail").style.borderRight='Thin Solid Red';
	    document.getElementById("NEmail").style.borderBottom='Thin Solid Red';
	    alert("Indirizzo e-mail già presente in archivio");
	  }
    }
    else
    {
	  submitJoinForm("Registra");
    }
  }
  else
  {
    field.value = "WAIT...";
  }

}

function testalogin()
{ 
  XMLHTTP=GetXmlHttpObject();
  if (XMLHTTP==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  } 
  var email,pass;
  var url="ajax.asp";
  email = document.getElementById("email").value;
  pass = document.getElementById("password1").value;
  //alert("email = "+email+"  pass = "+pass);
  url=url+"?id=6&email="+email+'&pass='+pass;
  url=url+"&sid="+Math.random();
  XMLHTTP.onreadystatechange=stateChanged5;
  XMLHTTP.open("GET",url,true);
  XMLHTTP.send(null);
}

function AggiungiCarrello(id,quantita,prezzo)
{
  //var form = document.forms['JoinForm'];
  //alert(form['NEmail'].value);
  //alert("AJAX ID = "+id+"  N = "+n+"  Quantità = "+quantita);
  XMLHTTP=GetXmlHttpObject();
  if (XMLHTTP==null)
  {
    alert ("Your browser does not support AJAX!");
	return;
  } 
  var url="ajax.asp";
  //alert(email+'  '+pass);
  url=url+"?id=10&idart="+id+'&quantita='+quantita+'&prezzo='+prezzo;
  url=url+"&sid="+Math.random();
  //alert(url);
  XMLHTTP.onreadystatechange=stateChanged10;
  XMLHTTP.open("GET",url,true);
  XMLHTTP.send(null);
}

function stateChanged10() 
{ 
  var x,y,top,left;
  if (XMLHTTP.readyState==4)
  { 
    var stringa, K;
	K=document.getElementById("risultato");
	K.innerHTML=XMLHTTP.responseText;
    x=screen.availWidth;
    y=screen.availHeight;
    left=(x/2)-200;
    top=(y/2);
    K.style.left=left+"px";
    K.style.top=top+"px";
    K.style.display="block";
	AggiornaCarrello();
  }
}

function AggiornaCarrello()
{
  //var form = document.forms['JoinForm'];
  //alert(form['NEmail'].value);
  //alert("AJAX ID = "+id+"  N = "+n+"  Quantità = "+quantita);
  XMLHTTP=GetXmlHttpObject();
  if (XMLHTTP==null)
  {
    alert ("Your browser does not support AJAX!");
	return;
  } 
  var url="ajax.asp";
  //alert(email+'  '+pass);
  url=url+"?id=15";
  url=url+"&sid="+Math.random();
  //alert(url);
  XMLHTTP.onreadystatechange=stateChangedAggCarr;
  XMLHTTP.open("GET",url,true);
  XMLHTTP.send(null);
}

function stateChangedAggCarr() 
{ 
  var x,y,top,left;
  if (XMLHTTP.readyState==4)
  { 
    var stringa, K;
	K=document.getElementById("numeroarticoli");
	K.innerHTML=XMLHTTP.responseText;
  }
}

function Carrello()
{
  //var form = document.forms['JoinForm'];
  //alert(form['NEmail'].value);
  //alert("AJAX ID = "+id+"  N = "+n+"  Quantità = "+quantita);
  XMLHTTP=GetXmlHttpObject();
  if (XMLHTTP==null)
  {
    alert ("Your browser does not support AJAX!");
	return;
  } 
  var url="ajax.asp";
  //alert(email+'  '+pass);
  url=url+"?id=11";
  url=url+"&sid="+Math.random();
  //alert(url);
  XMLHTTP.onreadystatechange=stateChanged11;
  XMLHTTP.open("GET",url,true);
  XMLHTTP.send(null);
}

function stateChanged11() 
{ 
  var x,y,top,left;
  if (XMLHTTP.readyState==4)
  { 
    var stringa, K;
	K=document.getElementById("contenuto_carrello");
	K.innerHTML=XMLHTTP.responseText;
	//alert(parti[3]);
	
    x=screen.availWidth;
    y=screen.availHeight;
    left=(x/2)-200;
    top=(y/2)-150;
	K.style.zIndex="99999";
    K.style.left=left+"px";
    K.style.top=top+"px";
    K.style.display="block";
  }
}

function SvuotaCarrello()
{
  //var form = document.forms['JoinForm'];
  //alert(form['NEmail'].value);
  //alert("AJAX ID = "+id+"  N = "+n+"  Quantità = "+quantita);
  XMLHTTP=GetXmlHttpObject();
  if (XMLHTTP==null)
  {
    alert ("Your browser does not support AJAX!");
	return;
  } 
  var url="ajax.asp";
  //alert(email+'  '+pass);
  url=url+"?id=12";
  url=url+"&sid="+Math.random();
  //alert(url);
  XMLHTTP.onreadystatechange=stateChanged12;
  XMLHTTP.open("GET",url,true);
  XMLHTTP.send(null);
}

function stateChanged12() 
{ 
  var x,y,top,left;
  if (XMLHTTP.readyState==4)
  { 
    var stringa,K;
	K=document.getElementById("contenuto_carrello");
	K.innerHTML="<div style=\"font-family:Arial, Helvetica, sans-serif; font-size:10px; padding-left:10px;\">CARRELLO VUOTO</div>";
	//alert(parti[3]);
    K.style.display="none";	//alert(parti[3]);
	AggiornaCarrello();
  }
}

function ModificaCarrello(idart,n,tasto)
{
  //var form = document.forms['JoinForm'];
  //alert(form['NEmail'].value);
  //alert("AJAX ID = "+id+"  N = "+n+"  Quantità = "+quantita);
  XMLHTTP=GetXmlHttpObject();
  if (XMLHTTP==null)
  {
    alert ("Your browser does not support AJAX!");
	return;
  } 
  var url="ajax.asp";
  //alert(email+'  '+pass);

  //alert(url);
  var controllo=0;
  var quantita;
  var errore;
  if (!(validateNumeric(document.getElementById('Qcarr_'+n), 'Quantita'))) {
    controllo=1
	errore=i
  }
  if (!(validateRequiredField(document.getElementById('Qcarr_'+n), 'Quantita'))) {
	controllo=1
	errore=i
  }
  if(document.getElementById('Qcarr_'+n).value<1)
  {
   alert("La Quantità deve essere maggiore di 0");
   controllo=1
   errore=i
  }

	
  quantita = document.getElementById('Qcarr_'+n).value;
  quantita = quantita.replace(",",".");
  quantita = Math.floor(quantita);
  //alert(quantita);				
  if(tasto=='Aggiorna')
  {
    url=url+"?id=13&quantita="+quantita;
  }
  if(tasto=='Elimina')
  {
    url=url+"?id=14";
  }
  url=url+"&idart="+idart+"&sid="+Math.random();
  //alert(url);
  
  if(controllo==0)
  {
	XMLHTTP.onreadystatechange=stateChanged12;
    XMLHTTP.open("GET",url,true);
    XMLHTTP.send(null);
  }

}

function stateChanged12() 
{ 
  var x,y,top,left;
  if (XMLHTTP.readyState==4)
  { 
    var stringa, N,K;
	K=document.getElementById("contenuto_carrello");
	var N = document.getElementById("numeroarticoli");
	N.innerHTML=XMLHTTP.responseText;
	//alert(parti[3]);
    K.style.display="none";	//alert(parti[3]);
	Carrello();
  }
  //Carrello();
}

function SalvaAnagraficaLista()
{ 
  //alert("Ciao a tutti "+document.getElementById("NEmail").value);
  //alert(document.getElementById("spedifatt").checked);
  XMLHTTP=GetXmlHttpObject();
  if (XMLHTTP==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  } 
  var url="ajax.asp";
  //alert(document.getElementById("Tipologia").value);
  var rr = document.getElementById("Tipologia");
							
  for(var i=0; i<rr.length; i++) 
  {
    if(rr[i].checked) 
	{
	  valore = rr[i].value;
	  break;
	}
  }
  
  var form = document.forms['JoinForm'];
  var rr = form['iGender'];
  var sesso;
  for(var i=0; i<rr.length; i++) 
  {
	if(rr[i].checked) 
	{
	  sesso = rr[i].value;
	  break;
	}
  }
  //alert(document.getElementById("iGender").value);
  if(valore==2)
  {
    url=url+"?id=7&varlista=LISTANOZZE&nemail="+document.getElementById("NEmail").value;
	url=url+"&npass="+document.getElementById("NPass").value;
	url=url+"&tipologia="+valore;
	url=url+"&icognome="+pulisci(document.getElementById("iCognome").value);
	url=url+"&inome="+pulisci(document.getElementById("iNome").value);
	url=url+"&igender="+sesso;
	url=url+"&pronas="+document.getElementById("pronas").value;
	url=url+"&comunenascita="+pulisci(document.getElementById("comunenascita").value);
    url=url+"&igiorno="+document.getElementById("iGiorno").value;
	url=url+"&imese="+document.getElementById("iMese").value;
	url=url+"&ianno="+document.getElementById("iAnno").value;
	url=url+"&cod_fisc="+document.getElementById("cod_fisc").value;
	url=url+"&indirizzo="+pulisci(document.getElementById("indirizzo").value);
	url=url+"&cap="+document.getElementById("CAP").value;
	url=url+"&provincia="+document.getElementById("Provincia").value;
	url=url+"&comune="+pulisci(document.getElementById("Comune").value);
	url=url+"&nazione="+document.getElementById("Nazione").value;
	url=url+"&telefono="+document.getElementById("Telefono").value;
	url=url+"&cellulare="+document.getElementById("Cellulare").value;
	url=url+"&spedizione=OK&referente="+pulisci(document.getElementById("referente").value);
	url=url+"&sid="+Math.random();
  }
  else
  {
    url=url+"?id=7&varlista=LISTANOZZE&nemail="+document.getElementById("NEmail").value;
	url=url+"&npass="+document.getElementById("NPass").value;
	url=url+"&tipologia="+valore;
	url=url+"&icognome="+pulisci(document.getElementById("iCognome").value);
	url=url+"&p_iva="+document.getElementById("Partita_IVA").value;
    url=url+"&indirizzo="+pulisci(document.getElementById("indirizzo").value);
	url=url+"&cap="+document.getElementById("CAP").value;
	url=url+"&provincia="+document.getElementById("Provincia").value;
	url=url+"&comune="+pulisci(document.getElementById("Comune").value);
	url=url+"&nazione="+document.getElementById("Nazione").value;
	url=url+"&telefono="+document.getElementById("Telefono").value;
	url=url+"&cellulare="+document.getElementById("Cellulare").value;
	url=url+"&spedizione=OK&referente="+pulisci(document.getElementById("referente").value);
	url=url+"&sid="+Math.random();
  }
  //alert("SalvaAnagrafica "+url);
  XMLHTTP.open("GET",url,false);
  
 //alert(" STATO "+XMLHTTP.onreadystatechange);
  
  XMLHTTP.send(null);
  //alert("Response = "+XMLHTTP.responseText);
  document.getElementById("userid").value=XMLHTTP.responseText;

}

function SalvaRiferimento(ip)
{ 
  XMLHTTP=GetXmlHttpObject();
  if (XMLHTTP==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  } 
  var url="ajax.asp";
  //alert(email+'  '+pass);
  url=url+"?id=9&referente="+pulisci(document.getElementById("referente").value);
  url=url+'&messaggio='+pulisci(document.getElementById("noteconsegna").value);
  url=url+'&ip='+ip;
  url=url+"&sid="+Math.random();
  //alert(url);
  XMLHTTP.onreadystatechange=stateChanged7;
  XMLHTTP.open("GET",url,true);
  XMLHTTP.send(null);
}
function SalvaRiferimentoOrdine(ip)
{ 
  XMLHTTP=GetXmlHttpObject();
  if (XMLHTTP==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  } 
  var url="ajax.asp?id=17";
  //alert(email+'  '+pass);
  //alert("url ="+url);
  if(document.getElementById("referente"))
  {
	param = document.getElementById("referente").value;
	str = pulisci(param);
    url=url+"&referente="+str;
  }
 //alert("url ="+url);
  if(document.getElementById("noteconsegna"))
  {
	param = document.getElementById("noteconsegna").value;
	str = pulisci(param);
    url=url+"&noteconsegna="+str;
  }
  //alert("url ="+url);
  if(document.getElementById("noteregalo"))
  {
	param = document.getElementById("noteregalo").value;
	str = pulisci(param);
    url=url+"&noteregalo="+str;
  }
  //alert("url ="+url);
  url=url+"&ip="+ip+"&sid="+Math.random();
  //alert("url ="+url);
  XMLHTTP.onreadystatechange=stateChanged7;
  XMLHTTP.open("GET",url,true);
  XMLHTTP.send(null);
}
function SalvaAnagrafica()
{ 
  //alert("Ciao a tutti "+document.getElementById("NEmail").value);
  //alert(document.getElementById("spedifatt").checked);
  XMLHTTP=GetXmlHttpObject();
  if (XMLHTTP==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  } 
  var url="ajax.asp";
  //alert(document.getElementById("Tipologia").value);
  var rr = document.getElementById("Tipologia");
							
  for(var i=0; i<rr.length; i++) 
  {
    if(rr[i].checked) 
	{
	  valore = rr[i].value;
	  break;
	}
  }
  
  var form = document.forms['JoinForm'];
  var rr = form['iGender'];
  var sesso;
  for(var i=0; i<rr.length; i++) 
  {
	if(rr[i].checked) 
	{
	  sesso = rr[i].value;
	  break;
	}
  }
  //alert(document.getElementById("iGender").value);
  if(valore==2)
  {
    url=url+"?id=7";
	url=url+"&nemail="+pulisci(document.getElementById("NEmail").value);
	url=url+"&npass="+pulisci(document.getElementById("NPass").value);
	url=url+"&tipologia="+valore;
	url=url+"&icognome="+pulisci(document.getElementById("iCognome").value);
	url=url+"&inome="+pulisci(document.getElementById("iNome").value);
	url=url+"&igender="+sesso;
	url=url+"&pronas="+document.getElementById("pronas").value;
	url=url+"&comunenascita="+document.getElementById("comunenascita").value;
    url=url+"&igiorno="+document.getElementById("iGiorno").value;
	url=url+"&imese="+document.getElementById("iMese").value;
	url=url+"&ianno="+document.getElementById("iAnno").value;
	url=url+"&cod_fisc="+document.getElementById("cod_fisc").value;
	url=url+"&indirizzo="+pulisci(document.getElementById("indirizzo").value);
	url=url+"&cap="+document.getElementById("CAP").value;
	url=url+"&provincia="+document.getElementById("Provincia").value;
	url=url+"&comune="+pulisci(document.getElementById("Comune").value);
	url=url+"&nazione="+document.getElementById("Nazione").value;
	url=url+"&telefono="+document.getElementById("Telefono").value;
	url=url+"&cellulare="+document.getElementById("Cellulare").value;
    if(document.getElementById("spedifatt").checked==false)
	{
	  url=url+"&spedizione=OK&referente="+pulisci(document.getElementById("referente").value);
	  url=url+"&indirizzospedi="+pulisci(document.getElementById("indirizzospedi").value);
	  url=url+"&capspedi="+document.getElementById("capspedi").value;
	  url=url+"&provspedi="+document.getElementById("provspedi").value;
	  url=url+"&comspedi="+pulisci(document.getElementById("comspedi").value);
	  url=url+"&nazspedi="+document.getElementById("nazspedi").value;
	  url=url+"&telspedi="+document.getElementById("telspedi").value;
	}
	url=url+"&sid="+Math.random();
  }
  else
  {
    url=url+"?id=7&nemail="+document.getElementById("NEmail").value;
	url=url+"&npass="+pulisci(document.getElementById("NPass").value);
	url=url+"&tipologia="+valore;
	url=url+"&icognome="+pulisci(document.getElementById("iCognome").value);
	url=url+"&p_iva="+document.getElementById("Partita_IVA").value;
    url=url+"&indirizzo="+pulisci(document.getElementById("indirizzo").value);
	url=url+"&cap="+document.getElementById("CAP").value;
	url=url+"&provincia="+document.getElementById("Provincia").value;
	url=url+"&comune="+pulisci(document.getElementById("Comune").value);
	url=url+"&nazione="+document.getElementById("Nazione").value;
	url=url+"&telefono="+document.getElementById("Telefono").value;
	url=url+"&cellulare="+document.getElementById("Cellulare").value;
    if(document.getElementById("spedifatt").checked==false)
	{
	  url=url+"&spedizione=OK&referente="+pulisci(document.getElementById("referente").value);
	  url=url+"&indirizzospedi="+pulisci(document.getElementById("indirizzospedi").value);
	  url=url+"&capspedi="+document.getElementById("capspedi").value;
	  url=url+"&provspedi="+document.getElementById("provspedi").value;
	  url=url+"&comspedi="+pulisci(document.getElementById("comspedi").value);
	  url=url+"&nazspedi="+document.getElementById("nazspedi").value;
	  url=url+"&telspedi="+document.getElementById("telspedi").value;
	}
	url=url+"&sid="+Math.random();
  }
  //alert("SalvaAnagrafica "+url);  
  //alert("SalvaAnagrafica "+url);
  XMLHTTP.open("GET",url,false);
  
 //alert(" STATO "+XMLHTTP.onreadystatechange);
  
  XMLHTTP.send(null);
  //alert("Response = "+XMLHTTP.responseText);
  document.getElementById("userid").value=XMLHTTP.responseText;
}

function InserisciAlternativa(user)
{ 
  //alert("Ciao a tutti "+document.getElementById("NEmail").value);
  XMLHTTP=GetXmlHttpObject();
  if (XMLHTTP==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  } 
  var url="ajax.asp";
  //alert(document.getElementById("indspedi").value);
  url=url+"?id=8&userid="+user+"&referente="+document.getElementById("referente").value+"&indirizzospedi="+document.getElementById("indirizzospedi").value+"&capspedi="+document.getElementById("capspedi").value+"&provspedi="+document.getElementById("provspedi").value+"&comspedi="+document.getElementById("comspedi").value+"&nazspedi="+document.getElementById("nazspedi").value+"&telspedi="+document.getElementById("telspedi").value;
  url=url+"&sid="+Math.random();
  //alert("Alternativa = "+url);
  XMLHTTP.onreadystatechange=stateChanged7;
  XMLHTTP.open("GET",url,false);
  XMLHTTP.send(null);
}
function EliminaAlternativa(user)
{ 
  //alert("Ciao a tutti "+document.getElementById("NEmail").value);
  XMLHTTP=GetXmlHttpObject();
  if (XMLHTTP==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  } 
  var url="ajax.asp";
  //alert(document.getElementById("indspedi").value);
  url=url+"?id=16&userid="+user;
  url=url+"&sid="+Math.random();
  //alert("Alternativa = "+url);
  XMLHTTP.onreadystatechange=stateChanged7;
  XMLHTTP.open("GET",url,false);
  XMLHTTP.send(null);
}

function stateChanged() 
{ 
  if (XMLHTTP.readyState==4)
  { 
	var R = document.getElementById("txtHint");    
    R.innerHTML = XMLHTTP.responseText;
	document.getElementById("iComune").focus();
  }
}


function stateChanged3() 
{ 
  if (XMLHTTP.readyState==4)
  { 
	var R = document.getElementById("destalt");    
    R.innerHTML = XMLHTTP.responseText;
  }
}
function stateChanged4() 
{ 
  if (XMLHTTP3.readyState==4)
  { 
	var R = document.getElementById("destalt");    
    R.innerHTML = XMLHTTP3.responseText;
  }
}
function stateChanged5() 
{ 
  if (XMLHTTP.readyState==4)
  { 
	var R = document.getElementById("login");    
    //R.innerHTML = XMLHTTP.responseText;
    if(XMLHTTP.responseText=="OK")
	{
	  document.getElementById("tipologin").value="LOGIN";  
	  document.JoinForm.submit();
	}
    if(XMLHTTP.responseText=="PASSWORD ERRATA")
	{
	  R.innerHTML = "Verificare la Password inserita";
	}
	if(XMLHTTP.responseText=="NON ESISTE")
	{
	  R.innerHTML = "Verificare l'indirizzo email inserito";
	}
		
	
  }
}
function stateChanged6() 
{ 
  if (XMLHTTP.readyState==4)
  { 
	var P = document.getElementById("userid"); 
	P.value = XMLHTTP.responseText;
  }
}
function stateChanged8() 
{ 
  if (XMLHTTP.readyState==4)
  { 
	var P = document.getElementById("userid"); 
	P.value = XMLHTTP.responseText;
  }

}
function stateChanged7() 
{ 
  if (XMLHTTP.readyState==4)
  { 
	//var R = document.getElementById("userid");
	var x = XMLHTTP.responseText;
	//document.getElementById("userid").value = x;
	//alert(XMLHTTP.responseText);
    //document.getElementById("userid").value = XMLHTTP.responseText;
  }
}