function ajaxRequest()
{
	var xmlHttp = false;
	try
	{	xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{	xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{	return false;
			}
		}
	}
	return(xmlHttp);	
}



function number(ruota){

	var sPath = "/includes/numeriFortunati.php?r="+ ruota;

	var sReq = ajaxRequest();
	
	if (!sReq) 
		return(false);

	sReq.open("GET",sPath, true);
	sReq.send(null);

	sReq.onreadystatechange=function(){
	
		// stato della richiesta (Load completato)
	    	if(sReq.readyState==4 ){
			// restituzione senza errori
			if(sReq.status == 200){
			
				try{
					var TXTResponse = sReq.responseText;
					
					aRisultati = TXTResponse.split('_');
					document.getElementById('estratti_vuoto').style.display='none';
					document.getElementById('ruota_scelta').innerHTML=aRisultati[0]+" "+aRisultati[1];

					document.getElementById('estratti_ruota').style.display='block';

				}catch(e){
					//alert(e.description);
					return false;
				}
			}
		}
	}
}


function checkNewsletter(formObj) {
	
	var error = "";

	if ( formObj.nome.value=="" )
		error+="Inserire il proprio nome\n";
	
	if ( formObj.email.value=="" )
		error+="Inserire il proprio indirizzo email per essere ricontattato\n";
		
	if ( formObj.email.value!="" && !/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(formObj.email.value))
		error+="Indirizzo email non valido\n";
                
    if ( !formObj.info.checked)
		error+="E' necessario accettare le nostre politiche sulla privacy\n";
        	
	if ( error!="" ) {
		error = "Si sono verificati i seguenti errori:\n"+error;
		alert (error);
		return false;
	} else {
		return true;
	}
	
}


