function cerca_form_ricerca() {
	cerca_localita();
	cerca_formazione();
}
function getRadioValue(radioObj) {
	if(!radioObj)
	{
 		return "";
 	}
 	var radioLength = radioObj.length;
 	if(radioLength == undefined)
 	{	
 		if(radioObj.checked)
 		{
 			return radioObj.value;
 		}
 		else
 		{
 			return "";
 		}
 	}
 	for(var i = 0; i < radioLength; i++) {
 		if(radioObj[i].checked) {
 			return radioObj[i].value;
 		}
 	}
 	return "";
}
function cerca_localita() {
	strURL = 'localita.php';
	var xmlHttpReq2 = false;
	var self = this;
	// Xhr per Mozilla/Safari/Ie7
	if (window.XMLHttpRequest) {
		self.xmlHttpReq2 = new XMLHttpRequest();
	}
	// per tutte le altre versioni di IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq2 = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq2.open('POST', strURL, true);
	self.xmlHttpReq2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq2.onreadystatechange = function() {
		if (self.xmlHttpReq2.readyState == 4) {
			updatepage_localita(self.xmlHttpReq2.responseText);
		}
		else {
			//updatepage("");
		}
	}
	self.xmlHttpReq2.send(getquerystring_localita());
}
function updatepage_localita(str){
	document.getElementById("localita").innerHTML = str;
}
function getquerystring_localita(carica_tmp) {
// 	var form     = document.forms['form1'];
	qstr='';
	if(document.getElementById("cod_provincia"))
	{
		var cod_provincia = document.getElementById("cod_provincia").value;
		qstr = qstr + '&cod_provincia=' + cod_provincia;
	}
	if(document.getElementById("cod_localita"))
	{
		var cod_localita = document.getElementById("cod_localita").value;
		qstr = qstr + '&cod_localita=' + cod_localita;
		
	}
	return qstr;
}
function cerca_formazione(cont) {
	strURL = 'formazione.php?cerca=1';
	if(cont && cont >0)
		strURL = strURL + '&cont=' + cont;
	var xmlHttpReq = false;
	var self = this;
	// Xhr per Mozilla/Safari/Ie7
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// per tutte le altre versioni di IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			updatepage_risultati(self.xmlHttpReq.responseText);
		}
		else {
			//updatepage("");
		}
	}
	self.xmlHttpReq.send(getquerystring_formazione());
}
function updatepage_risultati(str){
	document.getElementById("risultati").innerHTML = str;
}
function getquerystring_formazione(carica_tmp) {
// 	var form     = document.forms['form1'];
	var form     = document.forms[0];
	qstr='';
	if(document.getElementById("cod_tipologia"))
	{
		var cod_tipologia = getRadioValue(form.cod_tipologia);
		qstr = qstr + '&cod_tipologia=' + cod_tipologia;
	}
	if(document.getElementById("mese"))
	{
		var mese = document.getElementById("mese").value;
		qstr = qstr + '&mese=' + mese;
	}
	if(document.getElementById("anno"))
	{
		var anno = document.getElementById("anno").value;
		qstr = qstr + '&anno=' + anno;
	}
	if(document.getElementById("cod_provincia"))
	{
		var cod_provincia = document.getElementById("cod_provincia").value;
		qstr = qstr + '&cod_provincia=' + cod_provincia;
	}
	if(document.getElementById("cod_localita"))
	{
		var cod_localita = document.getElementById("cod_localita").value;
		qstr = qstr + '&cod_localita=' + cod_localita;
		
	}
	if(document.getElementById("chiave"))
	{
		var chiave = document.getElementById("chiave").value;
		qstr = qstr + '&chiave=' + chiave;
	}
	return qstr;
}