//*************************************************************************
//funzioni javascript generiche per controllo form
//*************************************************************************
this.str='';

function validamelo(formName,tipo,num,campo,campo2)
{
who=tipo;
num=num;

var nome=eval ("document." + formName + "." + campo);
if (campo2!="") { var nome2=eval ("document." + formName + "." + campo2); }

//************controlla se vuoto*************************
if (tipo=='1') {
if (nome.value==""){ nome.focus(); this.str="Inserire il campo "+campo.toUpperCase(); return false; }else{return true;}}

//******controlla i caratteri contenuti nel campo********
if (tipo=='2') {
if (num==1){Filtro = /[^a-zA-Z\' ]/g;test=0;} //lettere e apice
if (num==2){Filtro = /[^a-zA-Z0-9\'\.\, ]/g;test=0;} //lettere numeri e apice
if (num==3){Filtro = /[^0-9 ]/g;test=0;} //numeri
if (num==4){Filtro = /[^a-zA-Z0-9 ]/g;test=0;} //lettere e numeri
if (num==5){Filtro = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;test=1;}//email
if (num==6){Filtro = /^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/;test=1} //data
if (test){
if (!Filtro.test(nome.value)){nome.focus(); this.str="Verificare il campo "+campo.toUpperCase(); return false; }else{  return true; }
}else{
if (Filtro.test(nome.value)){nome.focus(); this.str="Verificare il campo "+campo.toUpperCase(); return false; }else{return true; }
}
}

//***********controlla che almeno un valore della combo sia selezionato**********
if (tipo=='3') {
num1=nome.value;
if (num1==""){ nome.focus(); this.str="La lista " + campo.toUpperCase() + " deve avere almeno un elemento selezionato"; return false; }else{return true;}}

//***********controlla la lunghezza del campo**********
if (tipo=='4') {
num1=nome.value.length;
if (num1<num){ nome.focus(); this.str="Il campo " + campo.toUpperCase() + " deve essere almeno di " + num + " caratteri"; return false; }else{return true;}}

//*********controlla che due campi siano uguali********
if (tipo=='5') {
if (nome.value!=nome2.value){ nome.value="";nome2.value="";nome.focus(); this.str="Password e conferma Password non corrispondono"; return false;}else{return true;}}
}
//*************************************************************************
//FINE funzioni javascript generiche per controllo form
//*************************************************************************


//---APERTURA POPUP GENERICO
function popup(url, scrollbars, x, y)
{
	window.open(url,'CentroGoldenGoal','scrollbars='+scrollbars+',resizable=no,top=10,left=10,width='+x+',height='+y+',status=no,location=no,toolbar=no');
}


function openGalleryWindow(url) 
{
if (document.all)
		{
			var xMax = screen.width, yMax = screen.height;
		}
else
		{
			if (document.layers)
				{ //alert("IE");
					var xMax = window.outerWidth, yMax = window.outerHeight;
				}
			else
				{ //alert("Firefox");
					var xMax = 800, yMax=600;
				}
		}
var xOffset = 10, yOffset = 10;

var xMax = xMax-200, yMax = yMax-200;
//alert (xMax+'x'+yMax);

popupWin = window.open(url,'new_page','width='+xMax+',height='+yMax+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',scrollbars=yes,toolbars=no,menubar=no,resizable=yes')
}

function pop_calendario(nome_form,nome_campo,valore) 
{
	searchWin = window.open('/portal/datapicker.asp?nome_form='+nome_form+'&nome_campo='+nome_campo+'&valore='+valore,'calendari','scrollbars=no,resizable=no,width=210,height=210,status=no,location=no,toolbar=no,screenX=50,screenY=50,left=300,top=300,alwaysRaised=yes');
}
