﻿function openW(win,title,h,w,scroll) {
var x;
var y;
var param;
x = screen.width / 2 - w / 2;
y = screen.height / 2 - (h / 2+20);
param = "width="+w+",height="+h+",left="+x+",top="+y+",scrollbars="+scroll+",toolbar=0,location=0,directories=0,menuBar=0,resizable=0";
windowDoPop=window.open(win,title,param);
windowDoPop.focus();
}
function openWlato(win,title,h,w,scroll) {
var x;
var y;
var param;
x = 5;
y = screen.height / 2 - (h / 2+20);
param = "width="+w+",height="+h+",left="+x+",top="+y+",scrollbars="+scroll+",toolbar=0,location=0,directories=0,menuBar=0,resizable=0";
windowDoPop=window.open(win,title,param);
windowDoPop.focus();
}

function validate_file(theForm){
	if (theForm.MyFile.value == "" || theForm.MyFile.value.length < 5){
		alert("Il campo File e' vuoto.");
		theForm.MyFile.focus();
		return false;
	}
return true;
}
function validate_login(theForm){
	if (theForm.nominativo.value == "" || theForm.nominativo.value.length < 2){
		alert("Il campo Nominativo e' vuoto.");
		theForm.nominativo.focus();
		return false;
	}
	if (theForm.user.value == "" || theForm.user.value.length < 5){
		alert("Il campo User e' vuoto o ha meno di 5 caratteri.");
		theForm.user.focus();
		return false;
	}
	if (theForm.password.value == "" || theForm.password.value.length < 5){
		alert("Il campo Password e' vuoto o ha meno di 5 caratteri.");
		theForm.password.focus();
		return false;
	}
return true;
}
function validate_articoli(theForm){
	if (theForm.tipo_articoli.value == 0){
		alert("Il campo tipologia non e' selezionato.");
		theForm.tipo_articoli.focus();
		return false;
	}
	valore = theForm.date3.value
	primacoppia = valore.substr(0,2)
	secondacoppia = valore.substr(3,2)
	quadrupla = valore.substr(6,4)
	numero = parseInt('1' + primacoppia)-100
	numero1 = parseInt('1' + secondacoppia)-100
	numero2 = parseInt(quadrupla)
	primoslash = valore.substr(2,1)
	secondoslash = valore.substr(5,1)
	//alert(valore + ' - ' + primacoppia + ' ' + secondacoppia + ' ' + quadrupla)
	//alert(valore + ' - ' + numero + ' ' + numero1 + ' ' + numero2)
	primalunghezza = primacoppia.length
	secondalunghezza = secondacoppia.length
	terzalunghezza = quadrupla.length
	if ((primalunghezza=2)&&(primoslash=="/")&&(numero>=1)&&(numero<=31)&&(secondalunghezza=2)&&(secondoslash=="/")&&(numero1>=1)&&(numero1<=12)&&(quadrupla=4)&&(numero2>=1700)&&(numero2<=2200))
	{
	}
	else
	{
		alert("Il campo data non segue il formato indicato.");
		theForm.date3.focus();
		return false;
	}
	if (theForm.titolo_articoli.value == ""){
		alert("Il campo titolo non e' selezionato.");
		theForm.titolo_articoli.focus();
		return false;
	}
return true;
}

function validate_cat_convenzioni(theForm){
	if (theForm.catnome.value == "" || theForm.catnome.value.length < 2){
		alert("Il campo Categoria e' vuoto.");
		theForm.catnome.focus();
		return false;
	}
return true;
}
function soloNumPoint(obj_soloNumPoint) {
  v_soloNumPoint = obj_soloNumPoint.value.replace(/[^0-9\.\-]/g,"");
  obj_soloNumPoint.value = v_soloNumPoint;
}

