
var myRequest = null;

var CheckCod= false;

var Myform = false;

DizionarioCode	    = new Array();
DizionarioCode.Italiano			= new Array();		
DizionarioCode.Italiano.headers	= "Digita il codice corretto!";

DizionarioCode.Inglese			= new Array();		
DizionarioCode.Inglese.headers	= "Digit the correct code!";

DizionarioCode.Francese			= new Array();		
DizionarioCode.Francese.headers	= "FR - Digita il codice corretto...";

DizionarioCode.Tedesco			= new Array();		
DizionarioCode.Tedesco.headers	= "DE - Digita il codice corretto...";

DizionarioCode.Spagnolo			= new Array();		
DizionarioCode.Spagnolo.headers	= "ES - Digita il codice corretto...";

function CreateXmlHttpReq(handler) {
 
  var agt = navigator.userAgent.toLowerCase();
  var is_ie5 = (agt.indexOf('msie 5') != -1);
  var xmlhttp = null;
 
 try {
 
    xmlhttp = new XMLHttpRequest();
    try {
        
        http_request.overrideMimeType('text/xml');
    } catch(e) { }
    xmlhttp.onload = handler;
    xmlhttp.onerror = handler;
  } catch(e) {
    var control = (is_ie5) ? "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP";
    xmlhttp = new ActiveXObject(control);
    xmlhttp.onreadystatechange = handler;
  }
  
  return xmlhttp;
  
}

function myHandler() {

   
        
    if(myRequest.readyState == 4 && myRequest.status == 200) {
		
		var Response = myRequest.responseText;
		if (Response == 'OK')     { Myform.submit(); }
		else if(Response == 'KO') { Messaggio = DizionarioCode[LinguaPagina].headers; alert(Messaggio); CheckCod=false;  }
		
	}
		
	
	
}




function CheckCode(form) {
	
	Myform=form;
	
	var codice = form.codice.value;
	var r = Math.random();
	
    myRequest = CreateXmlHttpReq(myHandler);
    myRequest.open("GET","spam_check.php?codice="+escape(codice)+"&rand="+escape(r));
    myRequest.send(null);
	
	
	
	return false;
	
	
	
}


