var xmlHttp;
var now = new Date();

function login() {
	xmlHttp=GetXmlHttpObject();
	
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request");
	} 
	
	var url="ajax_tdrive.asp";
	xmlHttp.open("POST",url,true);
	xmlHttp.onreadystatechange=stateChanged ;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp.send('nome=' + escape(document.frmTDrive.nome.value) + '&cognome='  + escape(document.frmTDrive.cognome.value) + '&email=' + escape(document.frmTDrive.email.value) + '&telefono=' + escape(document.frmTDrive.telefono.value) + '&brand=' + escape(document.frmTDrive.brand.value) + '&modello=' + escape(document.frmTDrive.modello.value));
} 

function stateChanged()  { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		var esito = xmlHttp.responseText;
		if (esito=='1') {
			alert('Indirizzo email errato');		
			return false;
		} else {
			if (esito=='3') {
				document.getElementById('TDrive').innerHTML = '<p><span class="grassetti"><b>Grazie per aver richiesto il test drive.</b></span><br><br>Sarai contattato al pił presto per definire il tuo appuntamento.<br>Buona navigazione su <a href="http://www.sava.it">www.sava.it</a><br /></p>';
				tc_log(tdrive_section + + '/test_drive/' + escape(document.frmTDrive.brand.options[document.frmTDrive.brand.selectedIndex].text
) + '/' + escape(document.frmTDrive.modello.options[document.frmTDrive.modello.selectedIndex].text
) + '/completed');
			}
		}
	}
}

function GetXmlHttpObject() { 
	var objXMLHttp=null;
	if (window.XMLHttpRequest) {
		objXMLHttp=new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
}
