self.focus();
function num(obj,a){
	if (isNaN(obj.value) && (obj.value != "") ) {
		obj.value = "";
		a = a + 1
		alert("Il campo deve essere un numero!")
		obj.focus();
	}
	return a;
}
function numo(obj,a){
	replace_str(obj,".","")
	replace_str(obj,",",".")
	if (obj.value == "") {obj.value = "0"}
	if (isNaN(obj.value)) {
		obj.value = "0";
		a = a + 1
		alert("Il campo deve essere un numero!")
		obj.focus();
	}
	replace_str(obj,".",",")
	return a;
}
function email(obj,a){
	flag = 0
	if (obj.value != ""){d = obj.value;b = d.indexOf("@");c = d.indexOf(".",b);if ((b == -1) || (c < b)) {		alert("L\'email non è corretta!")
		a = a + 1
		obj.focus();
}}
return a
}
function c_data(obj,a){
	if ((obj.value != "")) {
	c = obj.value.indexOf("/") + 1
	b = obj.value.indexOf("/",c)
	if (b == -1) {
		alert("Inserire un campo nel formato gg/mm/aa o gg/mm/aaaa.")
		a = a +1;
		obj.focus();
	}
	}
return a
}
function c_ora(obj,a){
	if ((obj.value != "")) {
	c = obj.value.indexOf(":")
	b = obj.value.indexOf(".")
	if ((c == -1)&&(b == -1)) {
		alert("Inserire un campo nel formato hh:mm.")
		a = a +1;
		obj.focus();
	}
	}
return a 
}
function no_vuoto(obj,a){
	if ((obj.value == "")&&(a == 0)) {
		obj.value = "";
		alert("Inserisci un valore!")
		obj.focus();
		a = a + 1
	}
	return a
}
function no_cmb_vuoto(obj,a){
	if (((obj.selectedIndex == -1)||(obj.options[obj.selectedIndex].value == "0"))&&(a == 0)) {
		alert("Seleziona un valore!")
		obj.focus();
		a = a + 1
	}
	return a
}
function viewWin(URL,nome,w,h) {
        displayWin = window.open(URL,nome,"scrollbars=yes,resizable=no,width=" + (w+2) + ",height=" + (h+3) + ",status=yes,location=no,toolbar=no");
}
function getRadioButtonValue(radioGroup){
	for (var i = 0; i < radioGroup.length; i++)
		if (radioGroup[i].checked)
			break;
	if (i < radioGroup.length)
		return radioGroup[i].value;
	else
		return null;
}


 function getCheckBoxValue(obj) {
		var message = ',';
		for (i = 0; i < obj.length; i++) {
		    if (obj[i].checked) {
			message += obj[i].value + ',';
			alert(obj[i].value)
		    }
	        }
		if (message == ',') {
		   message = 0;
		}
		return message;
  }




function replace_str(obj,a,b){
	var posizione, valore
	valore = obj.value
	lunghezza = a.length
	posizione = valore.indexOf(a)
	while(posizione != -1){
		valore = valore.substring(0,posizione) + b + valore.substring((posizione + lunghezza),valore.length)
		posizione = valore.indexOf(a)
	}
	obj.value = valore
}

function vis_data(obj){
	oggettodata = obj
	viewWin2("../inc/calender.htm","calendario",300,250)
}
function viewWin2(URL,nome,w,h) {
        displayWin = window.open(URL,nome,"scrollbars=no,resizable=no,width=" + (w+2) + ",height=" + (h+3) + ",status=no,location=no,toolbar=no");
}
