
function setSearchForm(form){
	type = new String(form.assistenza.value);
	if(type == "1"){
		form.contratto.disabled = false;
		form.scaduta.disabled = false;
	}
	else{
		form.contratto.disabled = true;
		form.scaduta.disabled = true;
	}
	return;
}

function checkDate(param,lunghezza_zero){
	indata = new String(param.value);
	if(indata.length == 0){
		if(lunghezza_zero){
			return lunghezza_zero;
		}
		else{
			alert('La data non puņ essere vuota');
			param.select();
			return false;
		}
	}
	
	if(indata.length < 10 || indata.length > 10 || indata.charAt(2) != '/' || indata.charAt(5) != '/'){
		alert('Formato data errato \n Data : gg/mm/aaaa \n es. 01/01/2003');
		param.select();
		return false;
	}

	giorno = new String(indata.substr(0,2));
	mese = new String(indata.substr(3,2));
	anno = new String(indata.substr(6,4));
	if(giorno.charAt(0) == '0'){
		giorno = giorno.charAt(1);
	}
	if(mese.charAt(0) == '0'){
		mese = mese.charAt(1);
	}

	if(isNaN(parseInt(giorno)) ||  parseInt(giorno) == 0 || parseInt(giorno) < 1 || parseInt(giorno) > 31 ||
	   isNaN(parseInt(mese)) ||  parseInt(mese) == 0 || parseInt(mese) < 1 || parseInt(mese) > 12 || 
	   isNaN(parseInt(anno)))
	{
		alert('Formato data errato \n Data : gg/mm/aaaa \n es. 01/01/2003');
		 param.select()
		return false;
	}
	return true;
}
function checkDate_ggmm(param,lunghezza_zero){
	indata = new String(param.value);
	if(indata.length == 0){
		if(lunghezza_zero){
			return lunghezza_zero;
		}
		else{
			alert('La data non puņ essere vuota');
			param.select();
			return false;
		}
	}
	
	if(indata.length < 5 || indata.length > 5 || indata.charAt(2) != '/'){
		alert('Formato data errato \n Data : gg/mm \n es. 25/12');
		param.select();
		return false;
	}

	giorno = new String(indata.substr(0,2));
	mese = new String(indata.substr(3,2));
	if(giorno.charAt(0) == '0'){
		giorno = giorno.charAt(1);
	}
	if(mese.charAt(0) == '0'){
		mese = mese.charAt(1);
	}

	if(isNaN(parseInt(giorno)) ||  parseInt(giorno) == 0 || parseInt(giorno) < 1 || parseInt(giorno) > 31 ||
	   isNaN(parseInt(mese)) ||  parseInt(mese) == 0 || parseInt(mese) < 1 || parseInt(mese) > 12)
	{
		alert('Formato data errato \n Data : gg/mm \n es. 25/12');
		 param.select()
		return false;
	}
	return true;
}

function checkTime(param,lunghezza_zero){
	intime = new String(param.value);
	if(intime.length == 0){
		if(lunghezza_zero){
			return lunghezza_zero;
		}
		else{
			alert('Il campo ora non puņ essere vuoto');
			param.select();
			return false;
		}
	}
	
	if(intime.length < 8 || intime.length > 8 || intime.charAt(2) != ':' || intime.charAt(5) != ':'){
		alert('Formato ora errato \n Ora : hh:mm:ss');
		param.select();
		return false;
	}

	ore = new String(intime.substr(0,2));
	minuti = new String(intime.substr(3,2));
	secondi = new String(intime.substr(6,2));
	if(ore.charAt(0) == '0'){
		ore = ore.charAt(1);
	}
	if(minuti.charAt(0) == '0'){
		minuti = minuti.charAt(1);
	}
	if(secondi.charAt(0) == '0'){
		secondi = secondi.charAt(1);
	}

	if(isNaN(parseInt(ore)) || parseInt(ore) < 0 || parseInt(ore) > 23 ||
	   isNaN(parseInt(minuti)) || parseInt(minuti) < 0 || parseInt(minuti) > 59 || 
	   isNaN(parseInt(secondi)) || parseInt(secondi) < 0 || parseInt(secondi) > 59)
	{
		alert('Formato ora errato \n Ora : hh:mm:ss');
		param.select();
		return false;
	}
	return true;
}


