function chkcli(){
	var cognome=document.getElementsByName('cognome');
	var nome=document.getElementsByName('nome');
	var telefono=document.getElementsByName('telefono');
	var errors="";
	if(cognome[0].value == '')
		errors+='Inserisci il cognome.\n';
	if(nome[0].value == '')
		errors+='Inserisci il nome.\n';
// 	var espressione = new RegExp("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+[\.]([a-z0-9-]+)*([a-z]{2,3})$");
// 	var stringa = document.insClienti.mail.value;
// 	if(!espressione.test(stringa))
// 		errors+='Inserisci una mail valida\n';
	var espressione = /^[0-9-]+$/;
	var stringa = document.insClienti.telefono.value;
	if(!espressione.test(stringa) && stringa!="")
		errors+='Inserisci un numero di telefono valido';
	if(errors!=""){
		alert(errors);
		document.insClienti.ok.value="error";
		return false;
	}
}

function chkrqs(){
	var cliente=document.getElementsByName('idCliente');
	var tipologia=document.insReq.tipologia;
	var catalogazione=document.insReq.catalogazione;
	var provincia=document.insReq.provincia;
	var comune=document.insReq.comune;
	var zona=document.insReq.zona;
	var prezzo=document.getElementsByName('prezzo');
	var errors="";
	if(cliente[0].value == '')
		errors+='Inserisci un ID cliente.\n';
	if(tipologia.options[tipologia.selectedIndex].value == '')
		errors+='Inserisci una tipologia.\n';
	if(catalogazione.options[catalogazione.selectedIndex].value == '')
		errors+='Inserisci una catalogazione.\n';
	if(provincia.options[provincia.selectedIndex].value == '')
		errors+='Seleziona la provincia.\n';
	if(comune.options[comune.selectedIndex].value == '')
		errors+='Seleziona il comune.\n';
	if(errors!=""){
		alert(errors);
		document.insReq.ok.value="error";
		return false;
	}
}

function getXmlHttpRequest(){
	//crea istanza httprequest
	var httpRequest=null;
	try{
		httpRequest=new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e){
		try{
			httpRequest=new ActiveXObject("Microsoft.XMLHTTP");
		}catch(e){
			httpRequest=null;
		}
	}
	if(!httpRequest&&typeof XMLHttpRequest!="undefined"){
		httpRequest=new XMLHttpRequest();
	}
	return httpRequest;
}

function updateDiv(id, url){
	//aggiorna un elemento html
	var req=getXmlHttpRequest();
	req.open("GET",url,true);
	req.onreadystatechange=function(){
		if (req.readyState==4 || req.readyState=="complete"){
			if (req.status==200){
				var el=document.getElementById(id);
				el.innerHTML=req.responseText;
			}
		}
	}
	req.send(null);
}

function addImage(testo){
	imgList.TypeHtml({
		speed : 'medium',
		wait_time : 0,
		html_text : testo
	});
}