//*************************************************************************
//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,'','scrollbars='+scrollbars+',resizable=no,top=10,left=5,width='+x+',height='+y+',status=no,location=no,toolbar=no');
}
 
function fn_Calendar(data)
{ //alert("BB Rulez");
	$('#div_calendario').html('<img src="/portal/images/loading.gif" style="margin-top: 50px;" />');	
	$('#div_calendario').load('/portal/calendar.asp?data=' + escape(data) , function(response, status, xhr) {
		if (status == "error") {
		var msg = 'Errore: ';
		//window.open('/weekly_pharma_news/invio_mail.asp?id_wpn=' + id_wpn + '&classe=' +  escape(classe) + '&step='+ step + '&email_test=' +  escape(email_test))
		alert(msg + xhr.status + ' ' + xhr.statusText);
	}
	});
}


/* 
function open_tabellino(game_id,highlightTeamID,playoffs){
	$.ajax({
		  url: "/portal/boxScore.asp",
		  data: ({
				 "game_id":  game_id,
				 "highlightTeamID":  highlightTeamID,
				 "PO": playoffs
				 }), 
		  success: function(data) {
				//alert(id + '_checklist')
				$('#div_tabellino').html(function() {return data});
		  }
		  }); 
	
	}
	function open_event(dataCal){
	$.ajax({
		  url: "/portal/calendarEvents.asp",
		  data: ({
				 "data":  dataCal
				 }), 
		  success: function(data) {
				//alert(id + '_checklist')
				$('#div_tabellino').html(function() {return data});
		  }
		  }); 
	
	}
*/	
	
function openerLink(url)
{
	parent.location.href = url;
	//this.close();
}
