function CambiaLingua(lingua){
	var PAGINA = document.URL;
	if("ITA"==lingua ){
		var Adress = PAGINA.toLowerCase().replace(/ita/, "ENG");
	}else{
		var Adress = PAGINA.toLowerCase().replace(/eng/, "ITA");
	}
	//document.write(Adress);
	location.href=Adress;
}
function checkSelect(name,valore){
	//alert(document.getElementById(name).options[1].value);
	var controllo=false;
		for (var idx=0;idx<document.getElementById(name).options.length;idx++) {
			if (valore==document.getElementById(name).options[idx].value) {
				//alert(document.getElementById(name).options[idx].value);
				document.getElementById(name).selectedIndex=idx;
				document.getElementById(name).options[idx].selected=true;
				controllo=true;
			}
		}
		if( false==controllo ){
			document.getElementById(name).options[document.getElementById(name).options.length] = new Option(valore,valore);
			document.getElementById(name).options[document.getElementById(name).options.length-1].selected=true;
		}
	}


	function checkRadio(name,valore){
		//alert(document.getElementById(name).options[1].value);
		//alert(valore);

		var frm=document.volontari;
		var radio=frm[name];
		//if("PATENTE"==name){
		//	alert(valore);
		//}
		if(valore.toUpperCase() == "TRUE"){
			radio[0].checked=true;
		}else{
			radio[1].checked=true;
		}
		//document.getElementById(name).checked=true;	
	}
	function checkValueRadio(name,valore){
		//alert(document.getElementById(name).options[1].value);
		//alert(valore);

		var frm=document.volontari;
		var radio=frm[name];
		//if("PATENTE"==name){
		//	alert(valore);
		//}
		for(i=0;i<3;i++){
		//alert(radio[i].value+" --- "+valore);
			if(radio[i].value == valore  ){
			//alert(radio[i].value+" --- "+valore);
				radio[i].checked=true; 
			}
		}
		//document.getElementById(name).checked=true;	
	}
	
	function checkCB(name,valore){
			if("True" == valore){
				document.getElementById(name).checked=true;
			}
		}

	function checkBButton(name,valore){
		//alert(valore);
		document.getElementById(name+valore).checked=true;
	}	
	function checkBIter(name,valore){
		var frm=document.volontari;
		var radio=frm[name];
		if(valore=="POMERIGGIO"){
			radio[0].checked=true;
		}
		if(valore=="SERALE"){
			radio[1].checked=true;
		}	
		if(valore=="WEEK-END"){
			radio[2].checked=true;
		}	
	}
	



function displayage(yr, mon, day, unit, decimal, round){
var one_day=1000*60*60*24
var one_month=1000*60*60*24*30
var one_year=1000*60*60*24*30*12
today=new Date()
var pastdate=new Date(yr, mon-1, day)

var countunit=unit
var decimals=decimal
var rounding=round

finalunit=(countunit=="giorni")? one_day : (countunit=="mesi")? one_month : one_year
decimals=(decimals<=0)? 1 : decimals*10

if (unit!="anni"){
if (rounding=="rounddown")
document.write(Math.floor((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals+" "+countunit)
else
document.write(Math.ceil((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals+" "+countunit)
}
else{
yearspast=today.getFullYear()-yr-1
tail=(today.getMonth()>mon-1 || today.getMonth()==mon-1 && today.getDate()>=day)? 1 : 0
pastdate.setFullYear(today.getFullYear())
pastdate2=new Date(today.getFullYear()-1, mon-1, day)
tail=(tail==1)? tail+Math.floor((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals : Math.floor((today.getTime()-pastdate2.getTime())/(finalunit)*decimals)/decimals
document.write(yearspast+tail+" "+countunit)
}
}


	
