function OpenLoginWin() {
	if (!(area_ris = open("./entra.php","","menubar=no,status=no,scrollbars=no,width=220,height=170"))) {
		alert("ATTENZIONE\n\nIl tuo browser non permette l'apertura di finestre popup.\nE' necessario disattivare quest'opzione per poter accedere all'area riservata.");
	} else {
		area_ris.moveTo(400,330);
	}
}
function Chk_Form() {
	var n, err;
	n = document.form_login.elements;
	for (i=0;i<n.length;i++) {
		if (n[i].value == "") {
			err = 1;
		}
	}
	if (err == 1) {
		alert("ATTENZIONE\n\nRiempire entrambi i campi.");
		return false;
	} else {
		document.form_login.submit();
	}
}
function Chk_Form_Info() {
var i, n, err;
	n = document.mod_info.elements;
	// var RegEx = new RegExp("^\s*$","g");
	for (i=0;i<n.length;i++) {
		var valore = new String();
		//  || RegEx.test(valore)
		valore = n[i].value;
		if (valore == "") {
				err = 1;
		}
	}
	if (err == 1) {
		alert("ATTENZIONE\n\nRiempire tutti i campi.");
		return false;
	} else if (document.mod_info.inf_priv.checked == false) {
		alert("ATTENZIONE\n\nE\' necessario accettare l\'informativa sulla privacy.");
		return false;
	} else {
		document.mod_info.submit();
	}
}
function Chk_Form_Inv() {
	var err_prezzo = 0;
	var err_periodo = 0;
	var RegEx_prezzo = /^[0-9]{1,3}(,|\.)[0-9]{1,2}$/;
	var RegEx_data = /^[0-9]{1,2}\.[0-9]{1,2}\s-\s[0-9]{1,2}\.[0-9]{1,2}$/;
	var n = document.form_inv.elements;
	for (var i=0;i<n.length;i++) {
		var nome = new String(n[i].name);
		if (nome.substr(0,1) == "P") {
			if ((n[i].value != "" && n[i].value != "-") && !RegEx_data.test(n[i].value)) {
				err_periodo = 1;
				n[i].style.background = '#FFFF00';
			} else n[i].style.background = '#FFFFFF';
		}
		if (nome.substr(1,1) == "B") {
			if ((n[i].value != "" && n[i].value != "-") && !RegEx_prezzo.test(n[i].value)) {
				err_prezzo = 1;
				n[i].style.background = '#FFFF00';
			} else n[i].style.background = '#FFFFFF';
		}
	}
	if (err_prezzo != 1 && err_periodo != 1) {
		document.form_inv.action = "./action.php?a=prezzi_inv";
		document.form_inv.submit();
	} else {
		alert("ATTENZIONE\n\nI valori evidenziati non sono nel formato corretto.");
		return false;
	}
}

function Chk_Form_Est() {
	var err_prezzo = 0;
	var err_periodo = 0;
	var RegEx_prezzo = /^[0-9]{1,3}(,|\.)[0-9]{1,2}$/;
	var RegEx_data = /^[0-9]{1,2}\.[0-9]{1,2}\s-\s[0-9]{1,2}\.[0-9]{1,2}$/;
	var n = document.form_est.elements;
	for (var i=0;i<n.length;i++) {
		var nome = new String(n[i].name);
		if (nome.substr(0,1) == "P") {
			if ((n[i].value != "" && n[i].value != "-") && !RegEx_data.test(n[i].value)) {
				err_periodo = 1;
				n[i].style.background = '#FFFF00';
			} else n[i].style.background = '#FFFFFF';
		}
		if (nome.substr(1,1) == "B") {
			if ((n[i].value != "" && n[i].value != "-") && !RegEx_prezzo.test(n[i].value)) {
				err_prezzo = 1;
				n[i].style.background = '#FFFF00';
			} else n[i].style.background = '#FFFFFF';
		}
	}
	if (err_prezzo != 1 && err_periodo != 1) {
		document.form_est.action = "./action.php?a=prezzi_est";
		document.form_est.submit();
	} else {
		alert("ATTENZIONE\n\nI valori evidenziati non sono nel formato corretto.");
		return false;
	}
}
function Change_BG(IDfield) {
	var d = document.getElementById(IDfield).style.background;
    if (d.substr(0,16) == 'rgb(255, 255, 0)') {
		document.getElementById(IDfield).style.background = '#FFFFFF';
        return true;
	} else return false;
}