function emailvalidation(entermail)
{
	// E-mail Validation by Henrik Petersen / NetKontoret
	// Explained at www.echoecho.com/jsforms.htm
	// Please do not remove this line and the two lines above.
	with (entermail)
	{
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		lastpos=value.length-1;
		if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2)
			{
			alert("E-mail inserita non è valida");
			entermail.value = "";
			return false;
			}
		else {
			return true;
		}
	}
}

function ricercaVeloce() {

	if (document.form_ricerca_veloce.idTipo.value == 0) {
		alert("Seleziona una categoria");	
	} else {
		document.form_ricerca_veloce.submit();	
	}
	
}

function getXMLHTTP() { //fuction to return the xml http object
	var xmlhttp=false;	
	try{
		xmlhttp=new XMLHttpRequest();
	}
	catch(e) {		
		try{			
			xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e){
			try{
			req = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e1){
				xmlhttp=false;
			}
		}
	}
	 	
	return xmlhttp;
}

function getMarca(idTipoVeicolo,idMarca) {
	var strURL="trovaMarca.php?idTipoVeicolo="+idTipoVeicolo+"&idMarca="+idMarca;				

	var req = getXMLHTTP();
	
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {						
					document.getElementById('formMarca').innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
			
}