var HD1_urlArray = new Array(3); //for URL's, increase size as necessary
var HD1_banArray = new Array(3); //for banners, increase size as necessary
var HD1_url = "http://www.google.it"; //initial URL
var	HD1_counter = 0;

var HD2_urlArray = new Array(3); //for URL's, increase size as necessary
var HD2_banArray = new Array(3); //for banners, increase size as necessary
var HD2_url = "http://www.google.it"; //initial URL
var	HD2_counter = 0;

var HS1_urlArray = new Array(3); //for URL's, increase size as necessary
var HS1_banArray = new Array(3); //for banners, increase size as necessary
var HS1_url = "http://www.google.it"; //initial URL
var	HS1_counter = 0;

var Tes_urlArray = new Array(3); //for URL's, increase size as necessary
var Tes_banArray = new Array(3); //for banners, increase size as necessary
var Tes_url = "http://www.google.it"; //initial URL
var	Tes_counter = 0;

var Rub_urlArray = new Array(3); //for URL's, increase size as necessary
var Rub_banArray = new Array(3); //for banners, increase size as necessary
var Rub_url = "http://www.google.it"; //initial URL
var	Rub_counter = 0;

function _RS_HD1_caricaarray(ix,a,b) {
	HD1_urlArray[ix] = a;
	HD1_banArray[ix] = b;
	HD1_url = HD1_urlArray[0]; //initial URL
}
function _RS_HD2_caricaarray(ix,a,b) {
	HD2_urlArray[ix] = a;
	HD2_banArray[ix] = b;
	HD2_url = HD2_urlArray[0]; //initial URL
}
function _RS_HS1_caricaarray(ix,a,b) {
	HS1_urlArray[ix] = a;
	HS1_banArray[ix] = b;
	HS1_url = HS1_urlArray[0]; //initial URL
}
function _RS_Tes_caricaarray(ix,a,b) {
	Tes_urlArray[ix] = a;
	Tes_banArray[ix] = b;
	Tes_url = Tes_urlArray[0]; //initial URL
}
function _RS_Rub_caricaarray(ix,a,b) {
	Rub_urlArray[ix] = a;
	Rub_banArray[ix] = b;
	Rub_url = Rub_urlArray[0]; //initial URL
}
function _RS_HD1_changeBanner(HD1_scind){ //banner changer function
	if(HD1_counter > HD1_scind) 
	HD1_counter = 0;
	document.HD1_BanneSponsor.src =  "../../" +HD1_banArray[HD1_counter]; //sets a new banner
	HD1_url = HD1_urlArray[HD1_counter]; //sets a new URL to the banner
	HD1_counter++; //increase the counter for the next banner
}
function _RS_HD2_changeBanner(HD2_scind){ //banner changer function
	if(HD2_counter > HD2_scind) 
	HD2_counter = 0;
	document.HD2_BanneSponsor.src =  "../../" +HD2_banArray[HD2_counter]; //sets a new banner
	HD2_url = HD2_urlArray[HD2_counter]; //sets a new URL to the banner
	HD2_counter++; //increase the counter for the next banner
}
function _RS_HS1_changeBanner(HS1_scind){ //banner changer function
	if(HS1_counter > HS1_scind) 
	HS1_counter = 0;
	document.HS1_BanneSponsor.src =  "../../" +HS1_banArray[HS1_counter]; //sets a new banner
	HS1_url = HS1_urlArray[HS1_counter]; //sets a new URL to the banner
	HS1_counter++; //increase the counter for the next banner
}
function _RS_Tes_changeBanner(Tes_scind){ //banner changer function
	if(Tes_counter > Tes_scind) 
	Tes_counter = 0;
	document.Tes_BanneSponsor.src =  "../../" +Tes_banArray[Tes_counter]; //sets a new banner
	Tes_url = Tes_urlArray[Tes_counter]; //sets a new URL to the banner
	Tes_counter++; //increase the counter for the next banner
}
function _RS_Rub_changeBanner(Rub_scind){ //banner changer function
	if(Rub_counter > Rub_scind) 
	Rub_counter = 0;
	document.Rub_BanneSponsor.src =  "../../../" +Rub_banArray[Rub_counter]; //sets a new banner
	Rub_url = Rub_urlArray[Rub_counter]; //sets a new URL to the banner
	Rub_counter++; //increase the counter for the next banner
}

function aprifinestraCAP(FormIsc,pgm,title)
{	
	indice=0;
	for (i=0; i < document.FormIsc.IDStatoOprovinciaResidenza.length; i++)  { 
		if (document.FormIsc.IDStatoOprovinciaResidenza.options[i].selected){ 
		  	indice = document.FormIsc.IDStatoOprovinciaResidenza.options[i].value
		   	break 
		}
	}
	if(i >0){
		pgm = pgm + "?ID=" + indice
		searchWin = window.open(pgm,'title','scrollbars=no,resizable=yes,width=450,height=260,status=no,location=no,toolbar=no, menubar=no'); setTimeout('searchWin.focus();',250);
	}
	else {		
	alert(" Selezionare una provincia");
	}
}

var PopAttiva=0;
function _RS_apripop(str,posizione)
{ 
  if(PopAttiva) {
 
  	if(!PopAttiva.closed) PopAttiva.close();
}
 L=0;
 PopAttiva = window.open(str,'PopAttiva','scrollbars=yes,resizable=yes,top=0,left='+L+',width=650,height=380,status=no,location=yes,toolbar=no, menubar=no,copyhistory=no'); 
}

var PopFoto=0;
function _RS_apripopfoto(str,posizione)
{
  if(PopFoto) {
 
  	if(!PopFoto.closed) PopFoto.close();
  }
 L=100;
 PopFoto = window.open(str,'PopFoto','scrollbars=yes,resizable=yes,top=100,left='+L+',width=500,height=400,status=no,location=no,toolbar=no, menubar=no,copyhistory=no'); 
}

var PopLeftAttiva=0;
function _RS_apripopLeft(str,posizione)
{
  if(PopLeftAttiva) {
 
  	if(!PopLeftAttiva.closed) PopLeftAttiva.close();
  }
 L=screen.width-700;
 PopLeftAttiva = window.open(str,'PopLeftAttiva','scrollbars=yes,resizable=yes,top=20,left='+L+',width=650,height=380,status=no,location=no,toolbar=no, menubar=no,copyhistory=no'); 
}

var WinAttivaTestata=0;
function _RS_apriwintestata(str)
{
  if(WinAttivaTestata) {
 
  	if(!WinAttivaTestata.closed) WinAttivaTestata.close();
  }
 W=770  +(screen.width-770)/2 ;
 H=screen.height/2 +80;
 L=(screen.width-770)/2 -10 ;
 T=screen.height/2 -150;
 
 WinAttivaTestata = window.open(str,'WinAttivaTestata','scrollbars=yes,resizable=yes,top='+T+',left='+L+',width=770,height='+H+',status=no,location=no,toolbar=no, menubar=no,copyhistory=no'); 
  setTimeout('WinAttivaTestata.focus();',250);
}

var WinAttivaSponsor=0;
function _RS_apriwinsponsor(str)
{
  if(WinAttivaSponsor) {
 
  	if(!WinAttivaSponsor.closed) WinAttivaSponsor.close();
  }
 W=770  +(screen.width-770)/2 ;
 H=screen.height/2 +40;
 L=0;
 T=0;
 
 WinAttivaSponsor = window.open(str,'WinAttivaSponsor','scrollbars=yes,resizable=yes,top='+T+',left='+L+',width=770,height='+H+',status=yes,location=no,toolbar=yes, menubar=yes,copyhistory=no'); 
  setTimeout('WinAttivaSponsor.focus();',250);
}

var WinAttivaRubriche=0;
function _RS_apriwinrubriche(str,posizione,nome)
{
  if(WinAttivaRubriche) {
 
  	if(!WinAttivaRubriche.closed) WinAttivaRubriche.close();
  }
 W=screen.width/2+210;
 H=screen.height/2 +98;
 L=(screen.width-770)/2 +166;
 if(posizione=="left") L=0;
 T=screen.height/2 -176;
 WinAttivaRubriche = window.open(str,'WinAttivaRubriche','scrollbars=yes,resizable=yes,top='+T+',left='+L+',width='+W+',height='+H+',screenX='+L+',screenY='+T+',status=no,location=no,toolbar=no, menubar=no'); 
  setTimeout('WinAttivaRubriche.focus();',250);
}

var WinAttivaRicette=0;
function _RS_apriwinricette(str,posizione,nome)
{
  if(WinAttivaRicette) {
 
  	if(!WinAttivaRicette.closed) WinAttivaRicette.close();
  }
 W=screen.width/2+200;
 H=screen.height/2 +140;
 L=(screen.width-770)/2 +166;
 if(posizione=="left") L=0;
 T=screen.height/2 -176;
 WinAttivaRicette = window.open(str,'WinAttivaRicette','scrollbars=yes,resizable=yes,top='+T+',left='+L+',width='+W+',height='+H+',screenX='+L+',screenY='+T+',status=no,location=no,toolbar=no, menubar=no'); 
  setTimeout('WinAttivaRicette.focus();',250);
}

var WinAttivaTabelle=0;
function _RS_apriwintabelle(str,posizione,nome)
{
  if(WinAttivaRubriche) {
 
  	if(!WinAttivaTabelle.closed) WinAttivaTabelle.close();
  }
 W=screen.width/2+210;
 H=screen.height/2 +98;
 L=(screen.width-770)/2 +166;
 if(posizione=="left") L=0;
 T=screen.height/2 -176;
 WinAttivaTabelle = window.open(str,'WinAttivaTabelle','scrollbars=yes,resizable=yes,top='+T+',left='+L+',width='+W+',height='+H+',screenX='+L+',screenY='+T+',status=no,location=no,toolbar=no, menubar=no'); 
  setTimeout('WinAttivaTabelle.focus();',250);
}

var PopAttivastd=0;
function _RS_apripopstd(nomepgm,W1,HH,T1,L1)
{ 
 if(PopAttivastd) {
  	if(!PopAttivastd.closed) PopAttivastd.close();
  }
 PopAttivastd = window.open(nomepgm,'PopAttivastd','scrollbars=yes,resizable=no,top='+T1+',left='+L1+',width='+W1+',height='+HH+',status=yes,location=no,toolbar=no, menubar=no,copyhistory=no'); 
}


function _RS_CheckLunghezzaCampoRicerca(oForm, oTag, dateString)
{
 /*
   parameters: oForm, oTag, dateString 
   returns: boolean
   
   oForm is the CFForm object.  All ONVALIDATE calls pass this argument.  This function ignores it.
   oTag is the CFForm current tag object.  All ONVALIDATE calls pass this argument.  This function ignores it.
   dateString is the value of the current tag object. 
 
   Returns true if the  lunghezza  del campo passato is  greater or equal than 4
   Returns false if the lunghezza  del campo passato is NOT greater or equal than 4.
*/

//Edit to make sure that length   is greater or egual 4.

	var Campo = new String(dateString);
   	if (Campo.length == 0 || Campo.length >= 4) 
		return true
	else 
	    return false;
}
function  _RS_checkcancel() {
	var Testo = "Premere OK per confermare la cancellazione";
		if (confirm(Testo))
			return true;
		else
			return false;			
}

function  _RS_checkCPForm(_RS_this) {

	pass= _RS_this.newpsw1.value;
   	if ( pass.length < 6  ||  pass.length > 12   || pass.length == 0 ) 
	{ alert ("La prima password deve essere fornita e deve avere minimo 6 e massimo 12 caratteri") ;
	  return false;
	}
	digitcheck = new  Array(62);
	digitcheck[0]='A';
	digitcheck[1]='B';
	digitcheck[2]='C';
	digitcheck[3]='D';
	digitcheck[4]='E';
	digitcheck[5]='F';	
	digitcheck[6]='G';
	digitcheck[7]='H';
	digitcheck[8]='I';
	digitcheck[9]='J';
	digitcheck[10]='K';
	digitcheck[11]='L';	
	digitcheck[12]='M';
	digitcheck[13]='N';
	digitcheck[14]='O';	
	digitcheck[15]='P';
	digitcheck[16]='Q';
	digitcheck[17]='R';
	digitcheck[18]='S';
	digitcheck[19]='T';
	digitcheck[20]='U';	
	digitcheck[21]='V';
	digitcheck[22]='W';
	digitcheck[23]='X';
	digitcheck[24]='Y';
	digitcheck[25]='Z';
	digitcheck[26]='a';
	digitcheck[27]='b';
	digitcheck[28]='c';
	digitcheck[29]='d';
	digitcheck[30]='e';
	digitcheck[31]='f';	
	digitcheck[32]='g';
	digitcheck[33]='h';
	digitcheck[34]='i';
	digitcheck[35]='j';	
	digitcheck[36]='k';
	digitcheck[37]='l';	
	digitcheck[38]='m';
	digitcheck[39]='n';
	digitcheck[40]='o';	
	digitcheck[41]='p';
	digitcheck[42]='q';
	digitcheck[43]='r';
	digitcheck[44]='s';
	digitcheck[45]='t';
	digitcheck[46]='u';	
	digitcheck[47]='v';
	digitcheck[48]='w';
	digitcheck[59]='x';
	digitcheck[50]='y';
	digitcheck[51]='z';
	digitcheck[52]='0';
	digitcheck[53]='1';
	digitcheck[54]='2';
	digitcheck[55]='3';
	digitcheck[56]='4';
	digitcheck[57]='5' ;
	digitcheck[58]='6';
	digitcheck[59]='7';
	digitcheck[60]='8';
	digitcheck[61]='9';
	
	for ( var i1=0; i1 < pass.length; i1++) {
		check=false; 
		for (var i2=0; i2 <=61; i2++) {
			if ( pass.charAt(i1) == digitcheck[i2] ) {
				check=true
				break;
			}
		}
		if (!check){
			alert (" La password deve essere formata solo da lettere e numeri. Quella fornita contiene un carattere illegale alla posizione " +i1 );
			break;
			return false;
		}
	}
   
   	if ( pass != _RS_this.newpsw2.value ) 
	{ alert ("Le due password devono essere uguali") ;
	  return false;
	}
}

function _RS_checkmail(oForm, oTag, dateString) {
   if (dateString == "" || dateString.indexOf ('@', 1) == -1 || 
dateString.indexOf ('.', 3) == -1) 
   {
      return (false);
   } 
   else
   {
      return (true);
   } 
}
function  _RS_checkForumForm(_RS_this)
{
	nomeforum=_RS_this.NickName.value;
   	if ( nomeforum.length < 3 ||  nomeforum.length > 20  || nomeforum.length == 0) 
	{ alert ("Il nome deve  essere fornito e deve avere minimo 3 e massimo 20 caratteri") ;
	  return false;
	}

	oggettoforum=_RS_this.OggettoArgomento.value;
   	if ( oggettoforum.length < 5 ) 
	{ alert ("Il titolo deve  essere fornito e deve avere minimo 5  caratteri") ;
	  return false;
	}

	argomentoforum=_RS_this.TestoArgomento.value;
   	if ( argomentoforum.length == 0) 
	{ alert ("Il testo deve  essere fornito") ;
	  return false;
	}
}

function  _RS_checkISForm(_RS_this)
{
	temp=_RS_this.EMail.value;
	
	if ( temp.length == 0) 
	{ alert ("La e mail  deve essere fornita ");
	  return false;
	}
	str= _RS_this.EMail.value;
	filter= /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	//filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/
	if (!filter.test(str)){
		alert("Fornire un indirizzo email formalmente valido!!");
		return false;
	}
	invalidaddress=new Array()
	invalidaddress[0]="zzhotmail"
	invalidaddress[1]="rocketmail"
	invalidaddress[2]="zdnetmail"
	invalidaddress[3]="zgoogle"
	invalidcheck=0;	
	tempstring=str.split("@")
	tempstring=tempstring[1].split(".")
	for (i=0; i <invalidaddress.length;i++){
		if (tempstring[0]==invalidaddress[i])
		invalidcheck=1
	}
	if (invalidcheck==1){
		alert("Fornire un indirizzo email consentito");
		return false;
	}
	//extend or shorten this list if neccessary

	pass= _RS_this.PasswordRichiesta.value;
   	if ( pass.length < 6  ||  pass.length > 12   || pass.length == 0 ) 
	{ alert ("La password deve essere fornita e deve avere minimo 6 e massimo 12 caratteri") ;
	  return false;
	}
	digitcheck = new  Array(62);
	digitcheck[0]='A';
	digitcheck[1]='B';
	digitcheck[2]='C';
	digitcheck[3]='D';
	digitcheck[4]='E';
	digitcheck[5]='F';	
	digitcheck[6]='G';
	digitcheck[7]='H';
	digitcheck[8]='I';
	digitcheck[9]='J';
	digitcheck[10]='K';
	digitcheck[11]='L';	
	digitcheck[12]='M';
	digitcheck[13]='N';
	digitcheck[14]='O';	
	digitcheck[15]='P';
	digitcheck[16]='Q';
	digitcheck[17]='R';
	digitcheck[18]='S';
	digitcheck[19]='T';
	digitcheck[20]='U';	
	digitcheck[21]='V';
	digitcheck[22]='W';
	digitcheck[23]='X';
	digitcheck[24]='Y';
	digitcheck[25]='Z';
	digitcheck[26]='a';
	digitcheck[27]='b';
	digitcheck[28]='c';
	digitcheck[29]='d';
	digitcheck[30]='e';
	digitcheck[31]='f';	
	digitcheck[32]='g';
	digitcheck[33]='h';
	digitcheck[34]='i';
	digitcheck[35]='j';	
	digitcheck[36]='k';
	digitcheck[37]='l';	
	digitcheck[38]='m';
	digitcheck[39]='n';
	digitcheck[40]='o';	
	digitcheck[41]='p';
	digitcheck[42]='q';
	digitcheck[43]='r';
	digitcheck[44]='s';
	digitcheck[45]='t';
	digitcheck[46]='u';	
	digitcheck[47]='v';
	digitcheck[48]='w';
	digitcheck[59]='x';
	digitcheck[50]='y';
	digitcheck[51]='z';
	digitcheck[52]='0';
	digitcheck[53]='1';
	digitcheck[54]='2';
	digitcheck[55]='3';
	digitcheck[56]='4';
	digitcheck[57]='5' ;
	digitcheck[58]='6';
	digitcheck[59]='7';
	digitcheck[60]='8';
	digitcheck[61]='9';
	
	for ( var i1=0; i1 < pass.length; i1++) {
		check=false; 
		for (var i2=0; i2 <=61; i2++) {
			if ( pass.charAt(i1) == digitcheck[i2] ) {
				check=true
				break;
			}
		}
		if (!check){
			alert (" La password deve essere formata solo da lettere e numeri. Quella fornita contiene un carattere illegale alla posizione " +i1 );
			break;
			return false;
		}
	}

	login=_RS_this.LoginRichiesta.value;

   	if ( login.length < 6 ||  login.length > 20  || login.length == 0) 
	{ alert ("La login deve  essere fornita e deve avere minimo 6 e massimo 20 caratteri") ;
	  return false;
	}

	if  (_RS_this.LoginRichiesta.value == _RS_this.PasswordRichiesta.value)
	{ 
		if (confirm("La login uguale alla password e' sconsigliata. Se confermi la scelta clicca su OK"))
			return true;
		else
			return false;			
	}
	  
	if  (!_RS_hasValue(_RS_this.IDStatoOprovinciaResidenza, "SELECT" ))
	{
		if  (!_RS_onError(_RS_this, _RS_this.IDStatoOprovinciaResidenza, _RS_this.IDStatoOprovinciaResidenza.value, "Scegliere la provincia di residenza."))
		{
			return false;
		}
	}
	
	if  (!_RS_hasValue(_RS_this.IDAreaProfessionale, "SELECT" ))
	{
		if  (!_RS_onError(_RS_this, _RS_this.IDAreaProfessionale, _RS_this.IDAreaProfessionale.value, "Scegliere un'area professionale."))
		{
			return false;
		}
	}
 
	if  (!_RS_hasValue(_RS_this.IDOrigineConoscenzaSito, "SELECT" ))
	{
		if  (!_RS_onError(_RS_this, _RS_this.IDOrigineConoscenzaSito, _RS_this.IDOrigineConoscenzaSito.value, "Scegliere una origine per l'interesse al sito."))
		{
			return false;
		}
	}
	
	if  (!_RS_hasValue(_RS_this.IDTipoInteresseProdotto, "SELECT" ))
	{
		if  (!_RS_onError(_RS_this, _RS_this.IDTipoInteresseProdotto, _RS_this.IDTipoInteresseProdotto.value, "Scegliere un tipo di interesse al prodotto."))
		{
			return false;
		}
	}

	if  (!_RS_hasValue(_RS_this.IDTipoInteresseSito, "SELECT" ))
	{
		if  (!_RS_onError(_RS_this, _RS_this.IDTipoInteresseSito, _RS_this.IDTipoInteresseSito.value, "Scegliere un tipo di interesse al sito."))
		{
			return false;
		}
	}

	return true;
}

function  _RS_checkISFormRid(_RS_this)
{ if (navigator.appName=="Netscape"){ alert()}
	temp=_RS_this.EMail.value;
	
	if ( temp.length == 0) 
	{ alert ("La e mail  deve essere fornita ");
	  return false;
	}
	str= _RS_this.EMail.value;
	filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/
	if (!filter.test(str)){
		alert("Fornire un indirizzo email formalmente valido");
		return false;
	}
	invalidaddress=new Array()
	invalidaddress[0]="zzhotmail"
	invalidaddress[1]="rocketmail"
	invalidaddress[2]="zdnetmail"
	invalidaddress[3]="google"
	invalidcheck=0;	
	tempstring=str.split("@")
	tempstring=tempstring[1].split(".")
	for (i=0; i <invalidaddress.length;i++){
		if (tempstring[0]==invalidaddress[i])
		invalidcheck=1
	}
	if (invalidcheck==1){
		alert("Fornire un indirizzo email consentito");
		return false;
	}
	//extend or shorten this list if neccessary

	pass= _RS_this.PasswordRichiesta.value;
	
   	if ( ( pass.length < 6  ||  pass.length > 12   || pass.length == 0) && _RS_this.LoginRichiesta.value != "ac" ) 
	{ alert ("La password deve essere fornita e deve avere minimo 6 e massimo 12 caratteri") ;
	  return false;
	}
	digitcheck = new  Array(62);
	digitcheck[0]='A';
	digitcheck[1]='B';
	digitcheck[2]='C';
	digitcheck[3]='D';
	digitcheck[4]='E';
	digitcheck[5]='F';	
	digitcheck[6]='G';
	digitcheck[7]='H';
	digitcheck[8]='I';
	digitcheck[9]='J';
	digitcheck[10]='K';
	digitcheck[11]='L';	
	digitcheck[12]='M';
	digitcheck[13]='N';
	digitcheck[14]='O';	
	digitcheck[15]='P';
	digitcheck[16]='Q';
	digitcheck[17]='R';
	digitcheck[18]='S';
	digitcheck[19]='T';
	digitcheck[20]='U';	
	digitcheck[21]='V';
	digitcheck[22]='W';
	digitcheck[23]='X';
	digitcheck[24]='Y';
	digitcheck[25]='Z';
	digitcheck[26]='a';
	digitcheck[27]='b';
	digitcheck[28]='c';
	digitcheck[29]='d';
	digitcheck[30]='e';
	digitcheck[31]='f';	
	digitcheck[32]='g';
	digitcheck[33]='h';
	digitcheck[34]='i';
	digitcheck[35]='j';	
	digitcheck[36]='k';
	digitcheck[37]='l';	
	digitcheck[38]='m';
	digitcheck[39]='n';
	digitcheck[40]='o';	
	digitcheck[41]='p';
	digitcheck[42]='q';
	digitcheck[43]='r';
	digitcheck[44]='s';
	digitcheck[45]='t';
	digitcheck[46]='u';	
	digitcheck[47]='v';
	digitcheck[48]='w';
	digitcheck[59]='x';
	digitcheck[50]='y';
	digitcheck[51]='z';
	digitcheck[52]='0';
	digitcheck[53]='1';
	digitcheck[54]='2';
	digitcheck[55]='3';
	digitcheck[56]='4';
	digitcheck[57]='5' ;
	digitcheck[58]='6';
	digitcheck[59]='7';
	digitcheck[60]='8';
	digitcheck[61]='9';
	
	for ( var i1=0; i1 < pass.length; i1++) {
		check=false; 
		for (var i2=0; i2 <=61; i2++) {
			if ( pass.charAt(i1) == digitcheck[i2] ) {
				check=true
				break;
			}
		}
		if (!check){
			alert (" La password deve essere formata solo da lettere e numeri. Quella fornita contiene un carattere illegale alla posizione " +i1 );
			break;
			return false;
		}
	}

	login=_RS_this.LoginRichiesta.value;

   	if ( (login.length < 6 ||  login.length > 20  || login.length == 0) && _RS_this.LoginRichiesta.value != "ac" ) 
	{ alert ("La login deve  essere fornita e deve avere minimo 6 e massimo 20 caratteri") ;
	  return false;
	}

	if  ((_RS_this.LoginRichiesta.value == _RS_this.PasswordRichiesta.value) && _RS_this.LoginRichiesta.value != "ac" )
	{ 
		if (confirm("La login uguale alla password  e' sconsigliata.\nSe confermi la scelta clicca su OK"))
			return true;
		else
			return false;			
	}
	return true;
}

function _RS_CheckLunghezzaNomeMail(oForm, oTag, dateString)
{
   	if (dateString.length == 0 || dateString.length >= 3) 
		return true
	else 
	    return false;
}

function _RS_CheckLunghezzaCognomeMail(oForm, oTag, dateString)
{
   	if (dateString.length == 0 || dateString.length >= 2) 
		return true
	else 
	    return false;
}

function _RS_CheckLunghezzaIndirizzoMail(oForm, oTag, dateString)
{
   	if (dateString.length == 0 || dateString.length >= 10) 
		return true
	else 
	    return false;
}

function  _RS_checkARform(_RS_this) {
	if (_RS_this.TestoNotizia.value) {
		for (var nc=0; nc < _RS_this.TestoNotizia.value.length; nc++){
		}
	}			
	if  (nc <= 10){ 
		if  (!_RS_onError(_RS_this, _RS_this.TestoNotizia, _RS_this.TestoNotizia.value, "Fornire il testo della notizia, almeno 10 caratteri.Attenzione pulire eventuali caratteri non visibili")) {
		return false;
		}
	}
	return true;
}

function  _RS_checkRIform(_RS_this) {
	if (_RS_this.NoteGenerali.value) {
		for (var nc=0; nc < _RS_this.NoteGenerali.value.length; nc++){
		}
	}			
	if (nc == 0) 
		return true;
	else {
		if (nc <= 10){ 
			if  (!_RS_onError(_RS_this, _RS_this.NoteGenerali, _RS_this.NoteGenerali.value, "Fornire le note generali, almeno 10 caratteri .Attenzione pulire eventuali caratteri non visibili")) {
			return false;
			}
		}
	}
	if (_RS_this.InformazioniNutrizionali.value) {
		for (var nc=0; nc < _RS_this.InformazioniNutrizionali.value.length; nc++){
		}
	}			
	if (nc == 0) 
		return true;
	else {
		if (nc <= 10){ 
			if  (!_RS_onError(_RS_this, _RS_this.InformazioniNutrizionali, _RS_this.InformazioniNutrizionali.value, " Fornire le informazioni nutrizionali, almeno 10 caratteri.Attenzione pulire eventuali caratteri non visibili ")) {
			return false;
			}
		}
	}
	return true;
}

function  _RS_checkFPform(_RS_this) {
	
	if (_RS_this.TestoFase.value) {
		for (var nc=0; nc < _RS_this.TestoFase.value.length; nc++){
		}
	}
	if  (nc <= 10 || _RS_this.TestoFase.value == null  || !_RS_this.TestoFase.value){ 
		alert("Fornire il testo della fase, almeno 10 caratteri.Attenzione pulire eventuali caratteri non visibili ")
		return false;
	}
	return true;
}

function _RS_redirect(URLStr) { location = URLStr; }


function _RS_isitValideDate(oForm, oTag, dateString) 
{
/*
   function isitStartDate 
   parameters: oForm, oTag, dateString 
   returns: boolean
   
   oForm is the CFForm object.  All ONVALIDATE calls pass this argument.  This function ignores it.
   oTag is the CFForm current tag object.  All ONVALIDATE calls pass this argument.  This function ignores it.
   dateString is the value of the current tag object. It should be a date passed as a string in the following
   format: gg/mm/aaaa. This means that months and days require leading zeros!!
 
   Returns true if the date passed is greater or egual than 01/01/2000
   Returns false if the date passed is NOT greater or egual than 01/01/2000
   date.
*/
   if (_RS_checkeurodate(dateString) == false)
      return false;

	var start =new Date()	   
	var startday = new Date(2000,00,01);
    var testdate = new Date(dateString.substring(6,10),
                        dateString.substring(3,5)-1,
                        dateString.substring(0,2));
   if (testdate >= startday)
        return true;
    else
        return false;
}

function _RS_isitStartDate(oForm, oTag, dateString) 
{
/*
   function isitStartDate 
   parameters: oForm, oTag, dateString 
   returns: boolean
   
   oForm is the CFForm object.  All ONVALIDATE calls pass this argument.  This function ignores it.
   oTag is the CFForm current tag object.  All ONVALIDATE calls pass this argument.  This function ignores it.
   dateString is the value of the current tag object. It should be a date passed as a string in the following
   format: gg/mm/aaaa. This means that months and days require leading zeros!!
 
   Returns true if the date passed is greater or egual than 01/01/2000
   Returns false if the date passed is NOT greater or egual than 01/01/2000
   date.
*/
   if (_RS_checkeurodate(dateString) == false)
      return false;

   // Check to make sure the date is zero filled with 4 digit year and therefore 10 characters long.
   if (dateString.length != 10)
		   return false;
		   
    // check to see if the Start Date is a valid actual date
   if (_RS_isitActualDate(oForm, oTag, dateString) == false)
      return false;
	  
	var start =new Date()	   
	var startday = new Date(2000,00,01);
    var testdate = new Date(dateString.substring(6,10),
                        dateString.substring(3,5)-1,
                        dateString.substring(0,2));
   if (testdate >= startday)
        return true;
    else
        return false;
}

function _RS_isitActualDate(oForm, oTag, dateString) {
/*
   function isitActualDate 
   parameters: oForm, oTag, dateString 
   returns: boolean
   
   oForm is the CFForm object.  All ONVALIDATE calls pass this argument.  This function ignores it.
   oTag is the CFForm current tag object.  All ONVALIDATE calls pass this argument.  This function ignores it.
   dateString is the value of the current tag object. It should be a date passed as a string in the following
   format: gg/mm/aaaa. This means that months and days require leading zeros!!
 
   Returns true if the date passed is lesser than today's date
   Returns false if the date passed is lesser or equal than todays
   date.
*/
   if (_RS_checkeurodate(dateString) == false)
      return false;

   // Check to make sure the date is zero filled with 4 digit year and therefore 10 characters long. 
   if (dateString.length != 10)
		   return false;

    var now = new Date();
    var today = new Date(now.getYear(),now.getMonth(),now.getDate());
    var testdate = new Date(dateString.substring(6,10),
                        dateString.substring(3,5)-1,
                        dateString.substring(0,2));

   if (testdate <= now)  
        return true;
    else
        return false;
}
function _RS_isitFutureDate(oForm, oTag, dateString) {
/*
   function isitFutureDate 
   parameters: oForm, oTag, dateString 
   returns: boolean
   
   oForm is the CFForm object.  All ONVALIDATE calls pass this argument.  This function ignores it.
   oTag is the CFForm current tag object.  All ONVALIDATE calls pass this argument.  This function ignores it.
   dateString is the value of the current tag object. It should be a date passed as a string in the following
   format: gg/mm/aaaa. This means that months and days require leading zeros!!
 
   Returns true if the date passed is greater than today's date
   Returns false if the date passed is NOT greater than todays
   date.
*/

   // Check to make sure the date is zero filled with 4 digit year and therefore 10 characters long. 
     if (_RS_checkeurodate(dateString) == false)
      return false;

   
   if (dateString.length != 10)
		   return false;
    var now = new Date();
    var today = new Date(now.getYear(),now.getMonth(),now.getDate());
    var testdate = new Date(dateString.substring(6,10),
                        dateString.substring(3,5)-1,
                        dateString.substring(0,2));
   if (testdate >= today) 
        return true;
    else
        return false;
}

function _RS_validateDateRange(oForm, oTag, dateString)
{
 /*
   parameters: oForm, oTag, dateString 
   returns: boolean
   
   oForm is the CFForm object.  All ONVALIDATE calls pass this argument.  This function ignores it.
   oTag is the CFForm current tag object.  All ONVALIDATE calls pass this argument.  This function ignores it.
   dateString is the value of the current tag object. It should be a date passed as a string in the following
   format: MM/DD/YYYY. This means that months and days require leading zeros!!
 
   Returns true if the date passed is a actual date greater than the start date
   Returns false if the date passed is NOT a actual date greater than start date.
*/

//Edit to make sure that Final date is Later than Start date.
   
     if (_RS_checkeurodate(dateString) == false)
      return false;
	  
	var StartDateString;
	
   //First check to see if the Final Date is a valid actual date
   if (_RS_isitActualDate(oForm, oTag, dateString) == false)
      return false;
	   
   var FinalDate = new Date(dateString.substring(6,10),
                      dateString.substring(3,5)-1,
                      dateString.substring(0,2));
                   
   StartDateString = document.forms(0).item("DemMin").value;
                      
   var StartDate = new Date(StartDateString.substring(6,10),
                      StartDateString.substring(3,5)-1,
                      StartDateString.substring(0,2));
 
    if (StartDate > FinalDate)  
	     return false;
	else
	     return true;
}


function _RS_validateDateArtRange(oForm, oTag, dateString)
{
 /*
   parameters: oForm, oTag, dateString 
   returns: boolean
   
   oForm is the CFForm object.  All ONVALIDATE calls pass this argument.  This function ignores it.
   oTag is the CFForm current tag object.  All ONVALIDATE calls pass this argument.  This function ignores it.
   dateString is the value of the current tag object. It should be a date passed as a string in the following
   format: MM/DD/YYYY. This means that months and days require leading zeros!!
 
   Returns true if the date passed is a actual date greater than the article date
   Returns false if the date passed is NOT a actual date greater than article date.
*/

//Edit to make sure that Final date is Later than article date.

    if (dateString.length == 0)
		   return true;
	
   if (_RS_checkeurodate(dateString) == false)
      return false;
	  
	 var StartString;
	
   
   var FinalDate = new Date(dateString.substring(6,10),
                      dateString.substring(3,5)-1,
                      dateString.substring(0,2));
                   
   StartString = document.forms(1).item("DataEmissioneArticolo").value;
                      
   var StartDate = new Date(StartString.substring(6,10),
                      StartString.substring(3,5)-1,
                      StartString.substring(0,2));
 
    if (StartDate >= FinalDate)  
	     return false;
	else
	     return true;
}

function _RS_validateDateRisRange(oForm, oTag, dateString)
{

    if (dateString.length == 0)
		   return true;
	
   if (_RS_checkeurodate(dateString) == false)
      return false;
	  
	 var StartString;
	
   
   var FinalDate = new Date(dateString.substring(6,10),
                      dateString.substring(3,5)-1,
                      dateString.substring(0,2));
                   
   StartString = document.forms(1).item("DataInizioFerie").value;
                      
   var StartDate = new Date(StartString.substring(6,10),
                      StartString.substring(3,5)-1,
                      StartString.substring(0,2));
 
    if (StartDate >= FinalDate)  
	     return false;
	else
	     return true;
}

function _RS_validateDateSpoRange(oForm, oTag, dateString)
{

    if (dateString.length == 0)
		   return true;
	
   if (_RS_checkeurodate(dateString) == false)
      return false;
	  
	 var StartString;
	
   
   var FinalDate = new Date(dateString.substring(6,10),
                      dateString.substring(3,5)-1,
                      dateString.substring(0,2));
                   
   StartString = document.forms(1).item("DataInizioSponsorizzazione").value;
                      
   var StartDate = new Date(StartString.substring(6,10),
                      StartString.substring(3,5)-1,
                      StartString.substring(0,2));
 
    if (StartDate >= FinalDate)  
	     return false;
	else
	     return true;
}

function _RS_validateMajorAge(oForm, oTag, dateString)
{

    if (dateString.length == 0)
		   return true;
	
   if (_RS_checkeurodate(dateString) == false)
      return false;
	  
	var now = new Date();
	var today = new Date(now.getYear(),now.getMonth(),now.getDate());

   	var BornDate = new Date(dateString.substring(6,10),
                      dateString.substring(3,5)-1,
                      dateString.substring(0,2));

    if ((today -BornDate) <  180000 )  
	     return false;
	else
	     return true;
		 
    if ( (today -BornDate ) >  1000000 )  
	     return false;
	else
	     return true;
}

function _RS_ControlloKcal(oForm, oTag, dateString)
{
   	var CalorieMinime = document.forms(0).item("KalMin").value;
    if (CalorieMinime > dateString)  
	     return false;
	else
	     return true;
}

function  _RS_checkloginform(_RS_this)
{
	if  (!_RS_hasValue(_RS_this.j_username, "TEXT" )) {
		if  (!_RS_onError(_RS_this, _RS_this.j_username, _RS_this.j_username.value, "Fornire la Userid")) {
			return false;
		}
	}
	else {
	if  (!_RS_hasValue(_RS_this.j_password, "PASSWORD" )) 	{
		if  (!_RS_onError(_RS_this, _RS_this.j_password, _RS_this.j_password.value, "Fornire la Password")) {
			return false;
			}
		}
	}
	return true;
}
function  _RS_checksceltaform(_RS_this)
{
	if  (!_RS_hasValue(_RS_this.SelezionePer, "RADIO" )) {
		if  (!_RS_onError(_RS_this, _RS_this.SelezionePer, _RS_this.SelezionePer.value, "Fornire almeno una scelta")) {
			return false;
		}
	}
	return true;
}

var _RS_loaded=0;

function _RS_signalLoad()
{
	_RS_loaded = 1;
}


function _RS_onError(form_object, input_object, object_value, error_message)
{
	alert(error_message);
	return false;	
}


function _RS_hasValue(obj, obj_type)
{
	if (obj_type == "TEXT" || obj_type == "PASSWORD")
	{
		if (obj.value.length == 0) 
	  		return false;
		else 
	  		return true;
	}
	else if (obj_type == "SELECT")
	
	{ 
		for (i=1; i < obj.length; i++)
		{
			if (obj.options[i].selected)
				return true;
		}
	   	return false;	
	}
	else if (obj_type == "SINGLE_VALUE_RADIO" || obj_type == "SINGLE_VALUE_CHECKBOX")
	{
		if (obj.checked)
			return true;
		else
	   		return false;	
	}
	else if (obj_type == "RADIO" || obj_type == "CHECKBOX")
	{
		for (i=0; i < obj.length; i++)
		{
			if (obj[i].checked)
				return true;
		}
	   	return false;	
	}
}


function _RS_checkdate(object_value)
{
	if (object_value.length == 0)
		return true;

	isplit = object_value.indexOf('/');

	if (isplit == -1 || isplit == object_value.length)
		return false;

	sMonth = object_value.substring(0, isplit);

	if (sMonth.length == 0)
		return false;

	isplit = object_value.indexOf('/', isplit + 1);

	if (isplit == -1 || (isplit + 1 ) == object_value.length)
		return false;

	sDay = object_value.substring((sMonth.length + 1), isplit);
	if (sDay.length == 0)
		return false;

	sYear = object_value.substring(isplit + 1);

	if (!_RS_checkinteger(sMonth))
		return false;
	else if (!_RS_checkrange(sMonth, 1, 12))
		return false;
	else if (!_RS_checkinteger(sYear))
		return false;
	else if (!_RS_checkrange(sYear, 0, 9999))
		return false;
	else if (!_RS_checkinteger(sDay))
		return false;
	else if (!_RS_checkday(sYear, sMonth, sDay))
		return false;
	else
		return true;
}


function _RS_checkeurodate(object_value)
{
	if (object_value.length == 0)
		return true;

	isplit = object_value.indexOf('/');

	if (isplit == -1)
		isplit = object_value.indexOf('.');

	if (isplit == -1 || isplit == object_value.length)
		return false;

	sDay = object_value.substring(0, isplit);

	monthSplit = isplit + 1;

	isplit = object_value.indexOf('/', monthSplit);

	if (isplit == -1)
		isplit = object_value.indexOf('.', monthSplit);

	if (isplit == -1 ||  (isplit + 1 )  == object_value.length)
		return false;

	sMonth = object_value.substring((sDay.length + 1), isplit);

	sYear = object_value.substring(isplit + 1);

	if (!_RS_checkinteger(sMonth))
		return false;
	else
	if (!_RS_checkrange(sMonth, 1, 12))
		return false;
	else
	if (!_RS_checkinteger(sYear))
		return false;
	else
	if (!_RS_checkrange(sYear, 0, null))
		return false;
	else
	if (!_RS_checkinteger(sDay))
		return false;
	else
	if (!_RS_checkday(sYear, sMonth, sDay))
		return false;

	else
		return true;
}


function _RS_checkday(checkYear, checkMonth, checkDay)
{	

	maxDay = 31;

	if (checkMonth == 4 || checkMonth == 6 || checkMonth == 9 || checkMonth == 11) maxDay = 30;
	else if (checkMonth == 2)
	{
		if (checkYear % 4 > 0)
			maxDay =28;
		else if (checkYear % 100 == 0 && checkYear % 400 > 0)
			maxDay = 28;
		else
			maxDay = 29;
	}

	return _RS_checkrange(checkDay, 1, maxDay);
}


function _RS_checkinteger(object_value)
{
	if (object_value.length == 0)
		return true;

	var decimal_format = ".";
	var check_char = object_value.indexOf(decimal_format);

	if (check_char == -1)
		return _RS_checknumber(object_value);
	else
		return false;
}


function _RS_numberrange(object_value, min_value, max_value)
{
	if (min_value != null)
	{
		if (object_value < min_value)
			return false;
	}

	if (max_value != null)
	{
		if (object_value > max_value)
			return false;
	}

	return true;
}


function _RS_checknumber(object_value)
{
	if (object_value.length == 0)
		return true;

	var start_format = " .+-0123456789";
	var number_format = " .0123456789";
	var check_char;
	var decimal = false;
	var trailing_blank = false;
	var digits = false;

	check_char = start_format.indexOf(object_value.charAt(0));

	if (check_char == 1)
		decimal = true;
	else if (check_char < 1)
		return false;

	for (var i = 1; i < object_value.length; i++)
	{
		check_char = number_format.indexOf(object_value.charAt(i));
		if (check_char < 0)
			return false;
		else if (check_char == 1)
		{
			if (decimal)
				return false;
			else
				decimal = true;
		}
		else if (check_char == 0)
		{
			if (decimal || digits)	
				trailing_blank = true;
		}
		else if (trailing_blank)
			return false;
		else
			digits = true;
	}	

	return true
}


function _RS_checkrange(object_value, min_value, max_value)
{
	if (object_value.length == 0)
		return true;

	if (!_RS_checknumber(object_value))
		return false;
	else
		return (_RS_numberrange((eval(object_value)), min_value, max_value));

	return true;
}


function _RS_checktime(object_value)
{
	if (object_value.length == 0)
		return true;

	isplit = object_value.indexOf(':');

	if (isplit == -1 || isplit == object_value.length)
		return false;

	sHour = object_value.substring(0, isplit);
	iminute = object_value.indexOf(':', isplit + 1);

	if (iminute == -1 || iminute == object_value.length)
		sMin = object_value.substring((sHour.length + 1));
	else
		sMin = object_value.substring((sHour.length + 1), iminute);

	if (!_RS_checkinteger(sHour))
		return false;
	else if (!_RS_checkrange(sHour, 0, 23))
		return false;

	if (!_RS_checkinteger(sMin))
		return false;
	else
	if (!_RS_checkrange(sMin, 0, 59))
		return false;

	if (iminute != -1)
	{
		sSec = object_value.substring(iminute + 1);

		if (!_RS_checkinteger(sSec))
			return false;
		else if (!_RS_checkrange(sSec, 0, 59))
			return false;	
	}

	return true;
}


function _RS_checkphone(object_value)
{
	if (object_value.length == 0)
		return true;

	if (object_value.length != 12)
		return false;

	if (!_RS_checknumber(object_value.substring(0,3)))
		return false;
	else if (!_RS_numberrange((eval(object_value.substring(0,3))), 100, 1000))
		return false;

	if (object_value.charAt(3) != "-" && object_value.charAt(3) != " ")
		return false

	if (!_RS_checknumber(object_value.substring(4,7)))
		return false;
	else if (!_RS_numberrange((eval(object_value.substring(4,7))), 100, 1000))
		return false;

	if (object_value.charAt(7) != "-" && object_value.charAt(7) != " ")
		return false;

	if (object_value.charAt(8) == "-" || object_value.charAt(8) == "+")
		return false;
	else
		return (_RS_checkinteger(object_value.substring(8,12)));
}


function _RS_checkzip(object_value)
{
	if (object_value.length == 0)
		return true;

	if (object_value.length != 5 && object_value.length != 10)
		return false;

	if (object_value.charAt(0) == "-" || object_value.charAt(0) == "+")
		return false;

	if (!_RS_checkinteger(object_value.substring(0,5)))
		return false;

	if (object_value.length == 5)
		return true;

	if (object_value.charAt(5) != "-" && object_value.charAt(5) != " ")
		return false;

	if (object_value.charAt(6) == "-" || object_value.charAt(6) == "+")
		return false;

	return (_RS_checkinteger(object_value.substring(6,10)));
}


function _RS_checkcreditcard(object_value)
{
	var white_space = " -";
	var creditcard_string="";
	var check_char;

	for (var i = 0; i < object_value.length; i++)
	{
		check_char = white_space.indexOf(object_value.charAt(i));
		if (check_char < 0)
			creditcard_string += object_value.substring(i, (i + 1));
	}	

	if (creditcard_string.length != 16)
		return false;

	if (creditcard_string.charAt(0) == "+")
		return false;

	if (!_RS_checkinteger(creditcard_string))
		return false;

	var doubledigit = creditcard_string.length % 2 == 1 ? false : true;
	var checkdigit = 0;
	var tempdigit;

	for (var ii = 0; i < creditcard_string.length; ii++)
	{
		tempdigit = eval(creditcard_string.charAt(ii));

		if (doubledigit)
		{
			tempdigit *= 2;
			checkdigit += (tempdigit % 10);

			if ((tempdigit / 10) >= 1.0)
				checkdigit++;

			doubledigit = false;
		}
		else
		{
			checkdigit += tempdigit;
			doubledigit = true;
		}
	}	
	return (checkdigit % 10) == 0 ? true : false;
}


function _RS_checkssc(object_value)
{
	var white_space = " -+.";
	var ssc_string="";
	var check_char;

	if (object_value.length == 0)
		return true;

	if (object_value.length != 11)
		return false;

	if (object_value.charAt(3) != "-" && object_value.charAt(3) != " ")
		return false;

	if (object_value.charAt(6) != "-" && object_value.charAt(6) != " ")
		return false;

	for (var i = 0; i < object_value.length; i++)
	{
		check_char = white_space.indexOf(object_value.charAt(i));
		if (check_char < 0)
			ssc_string += object_value.substring(i, (i + 1));
	}

	if (ssc_string.length != 9)
		return false;

	if (!_RS_checkinteger(ssc_string))
		return false;

	return true;
}


function _RS_setFormParam( strFormName, strParamName, strParamValue )
{
	var strObjName = "document." + strFormName + "." + strParamName;
	var obj = eval( strObjName );
	obj.value = strParamValue;
	return true;
}


function _RS_checkregex(object_value, regex)
{
	return regex.test(object_value);
}

