// JavaScript 1.2 Document
/*
	Libreria funzioni controllo ausiliarie:
		Versione 1.0
		Ultima modifica/revisione: 09/05/2007.
		Ultima modifica: 18/03/2004.		
		Autore: Baket, Leonardo, Antonio
*/

var msgChkBool = 'Necessario spuntare la casella';
var elNum = 6;			// Numero di elementi minimi
var firstEl = 3;		// primo elemento utile

function fldCheckBool(fld, fldName) {
	if ( !fld.checked ) {
		alert(fldName + ': ' + msgChkBool);
		fld.focus();
		return false;	
	}
	return true;
}

var msgChkCombo = 'Selezionare un valore non nullo';

function fldCheckCombo(fld, fldName) {
	var str='';
	if (fld && (fld.selectedIndex >= 0))
		str = fld.options[fld.selectedIndex].value;	
	if (str=='') {
		alert(fldName + ': ' + msgChkCombo);
		fld.focus();
		return false;		
	}	
	return true;	
}

function getPath() {
	var path = '';
	var url = document.URL;
	var i;
		
	tmp = url.split('/');

	
	if (tmp.length > elNum) {
		for (i=firstEl; i < (tmp.length-elNum) + firstEl;i++)
			path = path + '/' + tmp[i];		
	}
	if(path!='')
		path = path + '/';
	
	
	return path;
	
}

/* Author: Laura 
   Date: 16-09-2009
   Controllo per i radiobutton
*/
var msgRadio = 'Scegliere una opzione';
function fldRadio(fld, fldName) {
	var radiofld = false;
	for(var i=0; i<fld.length; i++) {
	  if(fld[i].checked) {
		radiofld = true;
		break;
	  }
	}
	if(!radiofld) {
	  alert(fldName + ': ' + msgRadio);
	  return false;
	}
	return true;
}
