
 	function CheckAjax() 
	{
 		var ajax = assegnaXMLHttpRequest();
  		if(ajax) 
		{
   			// applicativo AJAX
			alert("Funziona con AJAX !");
 		}
  		else
		{
   			// applicativo AJAX
			alert("NON funziona con AJAX !");
 		}
	} 
	
	// funzione per assegnare l'oggetto XMLHttpRequest
	// compatibile con i browsers piu' recenti e diffusi
	function assegnaXMLHttpRequest() 
	{		
		// lista delle variabili locali
		var XHR = null;
	 
		// informazioni sul nome del browser
		browserUtente = navigator.userAgent.toUpperCase();
	
		// browser standard con supporto nativo
		// non importa il tipo di browser
		if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object")
			XHR = new XMLHttpRequest();
	
		// browser Internet Explorer
		// e' necessario filtrare la versione 4
		else if( window.ActiveXObject && browserUtente.indexOf("MSIE 4") < 0) 
		{
	 
		  // la versione 6 di IE ha un nome differente
		  // per il tipo di oggetto ActiveX
		  if(browserUtente.indexOf("MSIE 5") < 0)
		   XHR = new ActiveXObject("Msxml2.XMLHTTP");
		
		  // le versioni 5 e 5.5 invece sfruttano lo stesso nome
		  else
		   XHR = new ActiveXObject("Microsoft.XMLHTTP");
		}		
		return XHR;
	} 	
	
    function new_XHR() 
	{
        var xhr;

        if(!xhr && typeof XMLHttpRequest != 'undefined')
		{
			try
			{
	            xhr = new XMLHttpRequest();
	        }
			catch(E)
			{
                xhr = false;
            }
        }
		else
		{
			try
			{
				xhr = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e)
			{
				try
				{
					xhr = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch(E)
				{
					xhr = false;
				}
			}
		}
        return xhr;
    }
    
    var myxhr;	
    function DoAjaxCall()
	{
		var res="1";
		//alert("111");
		res = MM_validateForm('email','', 'R, isEmail');
		//alert("RES="+res);
		if( res!="")
		{
			// errore
			return;
		}
		//alert("AAA");		myxhr = new_XHR();		//alert("BBB");
		myxhr.onreadystatechange=MyAjaxCallback;
		//alert("000");
		//var line="http://www.operaparrucchieriroma.com/service.php"+"?"+"email="+escape(document.getElementById("email").value);		var line="http://www.ghinea.it/serviceop.php"+"?"+"email="+escape(document.getElementById("email").value);
		//alert("222");
		//alert("LINE="+line);
		myxhr.open('GET', line, true);
		myxhr.setRequestHeader("connection", "Keep-Alive");
		myxhr.send();			
	}

    function DoAjaxReset()
	{
		//alert("Reset");
		if (confirm("Are you sure you want to clear form?")) 
		{
			document.form1.reset();
		}		
	}
	
	
	function MyAjaxCallback()
	{
		var answer, mes, xmlDoc;
		if(myxhr.readyState == 3 && !myxhr.operazioniInLettura) 
		{
		}		
		else if(myxhr.readyState == 4) 
		{
			 answer = myxhr.responseText;			 alert( "La e-mail e' statata inviata corretamente !");
			 //alert("222 Status="+myxhr.status);

		}		
		if(myxhr.readyState==4 && myxhr.status==200)
		{
			answer = myxhr.responseText;
			//alert("Text1="+answer);
			xmlDoc=myxhr.responseXML;			
			if( xmlDoc!=null )
			{
				var testo = myxhr.responseText;
				//alert("Text2="+testo);
				answer=xmlDoc.getElementsByTagName("answer")[0].childNodes[0].nodeValue;
				if( answer=="ok")
				{
					mes = "La e-mail e' statata inviata corretamente !";
					document.form1.reset();
				}
				else
				{
					if( answer=="errore23")
					{
						mes = "Il codice conferma e' stato sbagliato !";
					}
					else
					{
						mes = "C'e' stato un errore.\nAttenzione: la e-mail NON e' statata inviata !";
					}
				}
				alert(mes);
			}
			else
			{
				alert("3");
			}
		}
	}	

    function Azzerra()
	{
		  //document.getElementById("MessagePane").innerHTML = ""; 
	}
	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}
	function MM_validateForm() 
	{ //v4.0
	  var i,p,q,nm,test,num,min,max,errors='', val;
	  args=MM_validateForm.arguments;
	  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]); 
	  //alert("i="+i+"\nval="+args[i]+";"+val+"\n2="+args[i+1]+"\ntest="+test);
		if (val) { nm=val.name; if ((val=val.value)!="") {
		  if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
			if (p<1 || p==(val.length-1)) errors+='- '+nm+' deve contenere un*indirizzo e-mail valido.\n';
		  } else if (test!='R') { ;
		     //num = parseFloat(val);
			//if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
			/*
			if (test.indexOf('inRange') != -1) 
			{ 
				p=test.indexOf(':');
				min=test.substring(8,p); max=test.substring(p+1);
				if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';			  
			} 
			*/
		} } else if (test.charAt(0) == 'R') errors += '- '+nm+' \n'; }
	  } if (errors) alert('I seguenti campi sono obbligatori:\n'+errors);
	  return (errors);
	  //document.MM_returnValue = (errors == '');
	}

