// multi 27/12/2009 per riassumere le varie routines chirologia-naturagallura-ubn
// attenzione al path da personalizzare per raggiungere le images in photo, graph ecc
// bisogna togliere i .submit inutili
// bisogna puntare sul sicuro per i campi eliminando i != null e estraendo form con rispettivi campi con estrattori
//var immpagg = '/NGALL/images/pagine/';    			// immagini animate relative alle pagine (in genere /images/) PROVA
//var immgall = '/NGALL/images/galleria/';				// immagini animate relative alla galleria (in genere /public/) PROVA
var immpagg = '/images/pagine/';    			// immagini animate relative alle pagine (in genere /images/) PRODUZIONE
var immgall = '/images/galleria/';				// immagini animate relative alla galleria (in genere /public/) PRODUZIONE
var perman = 3000;
var dissolv = 3;
var PresentSpeed = 10000;
var t;
var p;
var r = 0;
var j = 0;
var preLoad = new Array();
var pref;
var suff;
var nfot;
var cifre;
var strl;
var libr;
//
man=navigator.appName;
ver=navigator.appVersion;
var OP = (man.indexOf('Opera')>=0 && ver.indexOf('9.')>=0);
var NS = (man.indexOf('Netscape')>=0 && ver.indexOf('5.')>=0);
var N4 = (man.indexOf('Netscape')>=0 && ver.indexOf('4.')>=0);
var IE = (man.indexOf('Microsoft')>=0 && ver.indexOf('4.')>=0);
if (NS) {N4 = false};
// Safari è riconosciuto come NS avendo man=Netscape e ver=5.
// test specifico per Safari
// var SF = (man.indexOf('Netscape')>=0 && ver.indexOf('Safari')>=0);
// con Safari il cambio immagini funziona ed è possibile aggiungere SF così: if (IE || NS || OP || SF)  
//
// alert('OP-NS-N4-IE: '+OP+NS+N4+IE+'| nome: '+man+'| version: '+ver);
//
if (document.URL.substring(0,4) == "file") {
	pref = document.URL.substring(document.URL.lastIndexOf("\\")+1,document.URL.lastIndexOf("\\")+4);
} 
else {
	pref = document.URL.substring(document.URL.lastIndexOf("/")+1,document.URL.lastIndexOf("/")+4);
}
if (pref == "")  {
	pref = "ind";
}
/* eventuale differenza fra index.asp e altre pagine (per prove locali) fra 'images/' e '../images/ */  
if (pref == "ind") {
	libr = immpagg;
} 
else {
	libr = immpagg;
}
function foto(l,m,dir)
{
	if (dir != null) {
		dir = dir + '/'
	}	 
	if (isNaN(l))	{
		return;
	}
	if (l <= 1)	{
	return;
	}
	p = l;
	if (m == null)	{
		suff = "";
	}
	else {
		pref = '';
		suff = m;
		libr = immgall + [dir];
	}
	for (i = 0; i < p; i++) {
		nfot = i+1;
		cifre = 2;
		strl = "00000" + nfot;
		nfot = strl.substr(strl.length-cifre,strl.length);
		preLoad[i] = new Image();
  	preLoad[i].src = libr+pref+suff+nfot+'.jpg';
  }
	pres();
}
function graf(l,m,dir)
{
	if (dir != null) {
		dir = dir + '/'
	}	 
	if (isNaN(l))	{
		return;
	}
	if (l <= 1)	{
	return;
	}
	p = l;
	if (m == null)	{
		suff = "";
	}
	else {
		pref = '';
		suff = m;
		libr = immgall + [dir];
	}
	for (i = 0; i < p; i++) {
		nfot = i+1;
		cifre = 2;
		strl = "00000" + nfot;
		nfot = strl.substr(strl.length-cifre,strl.length);
		preLoad[i] = new Image();
  	preLoad[i].src = libr+pref+suff+nfot+'.gif';
  }
	pres();
}
function fototim(l,m,dir)
{
	if (dir != null) {
		dir = dir + '/'
	}	 
	if (isNaN(l))	{
		return;
	}
	if (l <= 1)	{
	return;
	}
	p = l;
	if (m == null) {
		suff = "";
	}
	else {
		pref = '';
		suff = m;
		libr = immgall + [dir];
	}
	for (i = 0; i < p; i++) {
		nfot = i+1;
		cifre = 2;
		strl = "00000" + nfot;
		nfot = strl.substr(strl.length-cifre,strl.length);
		preLoad[i] = new Image();
  	preLoad[i].src = libr+pref+suff+nfot+'.jpg';
  }
	prestim();
}
function pres(){ 
	if (IE) {
		document.images.fig.style.filter="blendTrans(duration=dissolv)";
		document.images.fig.filters.blendTrans.Apply();
  	}
  if (IE || NS || OP) document.images.fig.src = preLoad[j].src;
  if (N4) document.layers['content'].document.images['fig'].src = preLoad[j].src;
  if (IE){
			document.images.fig.filters.blendTrans.Play();
  	}
  j = j + 1;
  if (j > (p-1)) {
  	j=0;
   }
  t = setTimeout('pres()', perman);
}
function prestim(){
	if (IE) {
		document.images.fig.style.filter="blendTrans(duration=dissolv)";
		document.images.fig.filters.blendTrans.Apply();
  	}
  if (IE || NS || OP) document.images.fig.src = preLoad[j].src;
  if (N4) document.layers['content'].document.images['fig'].src = preLoad[j].src;
  if (IE){
			document.images.fig.filters.blendTrans.Play();
  	}
  j = j + 1;
  if (j > (p-1)) {
  	j=0;
  	r = r + 1;
  }
  if (r >= 3) avanza();
  t = setTimeout('prestim()', perman);
}                                                                                                                                                                                                                                                                                                                            
function avanza(){
t = setTimeout('automa()', PresentSpeed);
}
function automa(){
   document.forms['mio_formC'].submit();
}
function invio_modulo()
{
/*if (document.mio_form.keywords.value.length < 4)
  {
   document.mio_form.keywords.focus();
   return;
   };
 document.mio_form.keywords.focus();
 document.mio_form.submit(); */
document.getElementById("mio_form").submit();
}
function clik(immis,dir)
{  
	if (dir != null) {
		dir = dir + '/'
	}	 
	if ([immis].toString().length >4)
	{	oF=new Array();
		oF[1]='';oF[2]='';oF[3]='';oF[4]='';oF[5]='';oF[6]='';oF[7]='';oF[8]='';oF[9]='';
		oF[10]='';oF[11]='';oF[12]='';oF[13]='';oF[14]='';oF[15]='';	
  	for(var i=1; i <16; i++)
   	{ cked = '';deft = '';scelta = '';
   		for(var j=1; j <6; j++)
   		{ campo = "R" + ("00" + i.toString()).substr(("00" + i.toString()).length-2,2) + j;
				if (document.getElementById([campo]) != null)
				{	if (document.getElementById([campo]).value.substr(7,1) == "*") {deft = j;};
	   			if (document.getElementById([campo]).checked)	{cked = j;};
	   			segno = document.getElementById([campo]).value.substr(0,2);
	   			condiz = document.getElementById([campo]).value.substr(5,2)-0;
   			};
 			};
 			if (cked == '') {scelta = deft;} else {scelta = cked;};
   		if (scelta != '')
   		{ oF[i] = scelta.toString();
   			if (condiz != 0) {oF[i] = oF[condiz] + oF[i];}; 
   			livnum = ("00" + i.toString()).substr(("00" + i.toString()).length-2,2);
   			ident = "Liv" + livnum;
				document.getElementById([ident]).src = immgall + [dir] + segno + livnum + oF[i] + ".gif";
   		};   	    	 	
		};
	}
	else
	{	for(var i=1; i <16; i++)
  	{ campo = "T" + ("00" + i.toString()).substr(("00" + i.toString()).length-2,2);
			if (document.getElementById([campo]) != null)
			{	if (i != (([immis].toString().substr(2,2))-0))
  			{ ident = "Liv" + ("00" + i.toString()).substr(("00" + i.toString()).length-2,2);
				document.getElementById([ident]).src = immgall + [dir] + "vuoto.gif";
				};
	  	};
		};
		ident = "Liv" + ([immis].toString().substr(2,2));
		document.getElementById([ident]).src = immgall + [dir] + [immis] + ".gif";
	};
}
function invio_moduloC()
{	document.redval = false;
	for(var i=1; i <16; i++)
 	{ campo = "R" + ("00" + i.toString()).substr(("00" + i.toString()).length-2,2);
		if (document.getElementById([campo]) != null)
		{	if (ripri([i])) {return;};
		};
		campo = "T" + ("00" + i.toString()).substr(("00" + i.toString()).length-2,2);
		if (document.getElementById([campo]) != null)
		{	if (ripri([i])) {return;};
			if (abbl([campo])) {return;};
		};
	}; 
   for(var i=1; i <16; i++)
   {
   	// trattazione dell'n° R
   	cked = '';
   	esis = '';
   	for(var j=1; j <6; j++)
   	{ campo = "R" + ("00" + i.toString()).substr(("00" + i.toString()).length-2,2) + j;
			if (document.getElementById([campo]) != null)
   		{	esis = j;
   			if (document.getElementById([campo]).checked)
   			{	cked = j;
   			};
   		};
 		};
 		if (esis != '')
   	{	if (cked == '')
   		{	alert("Scelta per <<" + document.getElementById("L" + i).innerHTML + ">> non effettuata!");
				document.getElementById("L" + i).style.background = '#FF6B6B'
 		 		return;
 		 	};
   	};
   	// trattazione dell'n° T
   	campo = "T" + ("00" + i.toString()).substr(("00" + i.toString()).length-2,2);
		if (document.getElementById([campo]) != null)
		{	if (check([campo],[i]))
			{	return;
			};
  	};
	};
	//document.getElementById("mio_formC").submit();
	document.redval = true;
}
function invio_moduloN()
{
clear('Anno','#FFFFFF');
clear('Numero','#FFFFFF');
clear('Autore','#FFFFFF');
clear('Articolo','#FFFFFF');
if ((document.getElementById(['Numero']).value.length == 0) && (document.getElementById(["Anno"]).value.length == 0) && (document.getElementById(["Autore"]).value.length == 0) && (document.getElementById(["Articolo"]).value.length == 0)) 
  { alert("Immettere almeno uno degli elementi per poter effettuare la ricerca!");
   	return;}
if ((document.getElementById(['Anno']).value.length > 0) && (isNaN(parseFloat(document.getElementById(["Anno"]).value.replace(/,/gi,".")))))
  { alert("Immesso per Anno Pubblicazione un valore non numerico!");
 		evid('Anno','#9FFFC8');
   	return;}
if ((document.getElementById(['Anno']).value.length > 0) && (document.getElementById(["Anno"]).value < 1980)) 
  { alert("Immesso per Anno Pubblicazione (di 4 cifre) un valore troppo piccolo!");
 		evid('Anno','#9FFFC8');
   	return;} 
if ((document.getElementById(['Anno']).value.length > 0) && (document.getElementById(["Anno"]).value > 2050)) 
  { alert("Immesso per Anno Pubblicazione (di 4 cifre) un valore troppo grande!");
 		evid('Anno','#9FFFC8');
   	return;}    	
if ((document.getElementById(['Numero']).value.length > 0) && (isNaN(parseFloat(document.getElementById(["Numero"]).value.replace(/,/gi,"."))))) 
  { alert("Immesso per Numero Rivista un valore non numerico!");
 		evid('Numero','#9FFFC8');
   	return;}   	
if ((document.getElementById(['Numero']).value.length > 0) && (document.getElementById(["Numero"]).value < 1)) 
  { alert("Immesso per Numero Rivista un valore troppo piccolo!");
 		evid('Numero','#9FFFC8');
   	return;} 
if ((document.getElementById(['Numero']).value.length > 0) && (document.getElementById(["Numero"]).value > 9)) 
  { alert("Immesso per Numero Rivista un valore troppo grande!");
 		evid('Numero','#9FFFC8');
   	return;} 
if ((document.getElementById(['Articolo']).value.length > 0) && (document.getElementById(["Articolo"]).value.length > 0) && (document.getElementById(["Articolo"]).value.length < 3))
  { alert("Immesso per Titolo Articolo un dato non significativo per la ricerca!");
 		evid('Articolo','#9FFFC8');
   	return;}
if ((document.getElementById(['Autore']).value.length > 0) && (document.getElementById(["Autore"]).value.length > 0) && (document.getElementById(["Autore"]).value.length < 3))
  { alert("Immesso per Autore Articolo un dato non significativo per la ricerca!");
 		evid('Autore','#9FFFC8');
   	return;}
	document.getElementById(['mio_formN']).submit();
}
function invio_moduloM()
{
clear('nome','#FFFFFF');
clear('cognome','#FFFFFF');
clear('email','#FFFFFF');
clear('_email','#FFFFFF');
//clear('indicazioni','#FFFFFF');
clearrd('consenso','#FFFFFF');
if (document.getElementById(["nome"]).value.length == 0)
  { alert("Immettere il Nome!");
   	evid('nome','#9FFFC8');
   	return;}
if (document.getElementById(["cognome"]).value.length == 0)
  { alert("Immettere il Cognome!");
   	evid('cognome','#9FFFC8');
   	return;}
if (document.getElementById(["email"]).value.length == 0)
  { alert("Immettere l'indirizzo Email!");
   	evid('email','#9FFFC8');
   	return;}
if (document.getElementById(["email"]).value.indexOf('@') == -1) 
  { alert("Indirizzo Email non valido!");
   	evid('email','#9FFFC8');
 		 return;} 
if (((document.getElementById(["email"]).value.length)-(document.getElementById(["email"]).value.indexOf('@'))) < 7) 
  { alert("Indirizzo Email non valido!");
   	evid('email','#9FFFC8');
 		 return;}
if (document.getElementById(["email"]).value !=  document.getElementById(["_email"]).value)
  { alert("Indirizzo Email differente fra le due caselle!");
   	evid('email','#9FFFC8');
   	evid('_email','#9FFFC8');   	
 		 return;}  		  
if ((!document.getElementById(["si"]).checked) && (!document.getElementById(["no"]).checked))	 		 
 	  { alert("Dare o negare il Consenso trattamento dei dati!");
   	evidrd('consenso','#9FFFC8');
 		 return;}
if (document.getElementById(["no"]).checked)	 		 
 	{ alert("Essendo stato negato il consenso al trattamento dei dati,"+"\r\n"+"non avremo la possibilità di inviarti via email informazioni sulle nostre iniziative!");
   	evidrd('consenso','#9FFFC8');
 		 return;} 		 
document.getElementById(["mio_formM"]).submit();
}
function controllo_data(stringa)
{
	//alert('Data: '+stringa);
	var espressione = /^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/;
	if (!espressione.test(stringa))	
	{	    
		alert('Errore espressione');
		return false;	
	}
	else
	{		
		anno = stringa.substr(6);
		mese = stringa.substr(3, 2);
		giorno = stringa.substr(0, 2);
		var data=new Date(anno, mese-1, giorno);
		//alert('AAAA'+anno+'MM'+mese+'GG'+giorno+'DATA'+data);
		if(data.getFullYear()==anno && data.getMonth()+1==mese && data.getDate()==giorno)
		{			
			return true;		
		}
		else
		{
			//alert('Errore validità');
			return false;
		}	
	}
}
function confronta_data(data1, data2)
{
	// controllo validità formato data
	if(controllo_data(data1) &&controllo_data(data2))
	{
		//trasformo le date nel formato aaaammgg (es. 20081103)
		data1str = data1.substr(6)+data1.substr(3, 2)+data1.substr(0, 2);
		data2str = data2.substr(6)+data2.substr(3, 2)+data2.substr(0, 2);		
		//controllo se la seconda data è successiva alla prima
		if (data2str-data1str<0) 
		{
			alert("La data iniziale deve essere precedente quella finale");
		}
    else
		{
			alert("ok");
		}
	}
  else
	{
		alert("Il formato data deve essere gg/mm/aaaa");
  }
}
function controllo_testo(stringa,max)
{
	if (max != 0)
	{	if (stringa.length > max) 	
		{	return false;	
		}
	}
	return true;		
}
function controllo_numero(stringa,spe)
{
	stringa = stringa.replace(/,/gi,'.');
  if (isNaN(parseFloat(stringa)))
	{	return false;	
	}
 	if (spe == 'Byte')
	{	if ((parseInt(stringa) < 0) || (parseInt(stringa) > 255))
		{ // fuori dai limiti
			return false;
		}
	}	
 	if (spe == 'Intero')
	{	if ((parseInt(stringa) < -32768) || (parseInt(stringa) > 32767))
		{ // fuori dai limiti
			return false;
		}
	}		
 	if (spe == 'Intero Lungo')
	{	if ((parseInt(stringa) < -2147483648) || (parseInt(stringa) > 2147483647))
		{ // fuori dai limiti
			return false;
		}
	}			
 	if (spe == 'Precisione Singola')
	{	if ((parseFloat(stringa) < -3.402823E38) || ((parseFloat(stringa) > -1.401298E-45) && (parseFloat(stringa) != 0)  && (parseFloat(stringa) < 1.401298E-45)) || (parseFloat(stringa) > 3.402823E38))
		{ // fuori dai limiti
			return false;
		}
	}
	if (spe == 'Precisione Doppia')
	{	if ((parseFloat(stringa) < -1.79769313486231E308) || ((parseFloat(stringa) > -4.94065645841247E-324) && (parseFloat(stringa) != 0) && (parseFloat(stringa) < 4.94065645841247E-324 )) || (parseFloat(stringa) > 1.79769313486231E308))
		{ // fuori dai limiti
			return false;
		}
	}	
	if ((spe == 'Decimale') || (spe == 'Valuta'))
	{	if ((parseFloat(stringa) < -1.0E28) || (parseFloat(stringa) > 1.0E28-1))
		{ // fuori dai limiti
			return false;
		}
	}
	return true;						
}
function controllo_boole(id,idold)
{
	if ((!document.getElementById([idold]).checked) && (!document.getElementById([id]).checked))
	{ return false;
	}
	return true; 
}
function estraeid() 
{ var i, j, mod, box, boxid, boxidold, boxname, boxnameold, formpuls; 
	var colb = '#FFFFFF', cole = '#9FFFC8'; 
	var inner, spiega, spespg, maxcar, comm;
	document.redval = false;
  for (i=0;!(document.forms[i]==null);i++) 									// tolgo evidenziazione da tutte le etichette e da tutti i campi
  {	mod=document.forms[i];
		for (j=0;!(document.forms[i].elements[j]==null);j++) 
		{	box = document.forms[i].elements[j];
			boxid = box.id;
			boxname = box.name;
			if ((box.type == 'text') || (box.type == 'textarea')) // con box.type == 'submit' il box.value è la dicitura del pulsante
			{	clear(boxid,colb);
			}
			else if (box.type == 'radio')
			{	clearrd(boxname,colb);
			}
		}
	}
  for (i=0;!(document.forms[i]==null);i++)			// controlla in sequenza tutti i campi di tipo text, textarea, radio
  {	mod=document.forms[i];
		for (j=0;!(document.forms[i].elements[j]==null);j++) 
		{	box = document.forms[i].elements[j];
			boxid = box.id;	boxname = box.name;
			maxcar = '0';	comm=''; spespg='';
			//alert(boxid + '+' + boxname + '/' + boxidold + '+' + boxnameold);
			if ((box.type == 'text') || (box.type == 'textarea')) // con box.type == 'submit' il box.value è la dicitura del pulsante
			{ spiega=document.getElementById(["L"+boxid]).innerHTML;             // innerText non funziona con Mozilla
				spiega=spiega.substr(spiega.indexOf('(')+1,spiega.lastIndexOf(')')-spiega.indexOf('(')-1);  // inner pulito
				if (spiega.lastIndexOf('comm.:') >= 0)
				{ comm=spiega.substr(spiega.lastIndexOf('comm.:')+7);   			// commento
					spiega=spiega.substr(0,spiega.lastIndexOf('comm.:')-2); 
				}
				if (spiega.lastIndexOf('max.car.:') >= 0)
				{ maxcar=spiega.substr(spiega.lastIndexOf('max.car.:')+10);   // n° caratteri
					spiega=spiega.substr(0,spiega.lastIndexOf('max.car.:')-2); 
				}
				if (spiega.lastIndexOf(': ') >= 0)
				{ spespg=spiega.substr(spiega.lastIndexOf(': ')+2);   // specifiche di spiega
					spiega=spiega.substr(0,spiega.lastIndexOf(': ')+0);  // spiega pulito
				}
				if (document.getElementById([box.id]).value.length > 0)
				{	if (spiega=='Testo') 
					{ if (!controllo_testo(document.getElementById([box.id]).value, parseInt(maxcar))) 
						{ alert('Testo troppo lungo');
							evid(boxid,cole);
							return;
						} 
					}
					else if (spiega=='Numero') 
					{ if (!controllo_numero(document.getElementById([box.id]).value, spespg))
						{ alert('Numero errato');
							evid(boxid,cole);
							return;
						} 
					}
					else if (spiega=='Data Ora')
					{ if (!controllo_data(document.getElementById([box.id]).value)) 
						{ alert('Data errata');
							evid(boxid,cole);
							return;
						} 
					}
					else if (spiega=='Oggetto OLE')
					{  // eventuali controlli
					}
					else if (spiega=='ID Replica')
					{  // eventuali controlli
					}    
					else 
					{	alert('controllo campo '+box.id+' con contenuto Altro: '+document.getElementById([box.id]).value );
					}
				}
			}
			else if ((box.type=='radio')	&& (boxname == boxnameold) && (boxid != boxidold))
			{ if (!controllo_boole(boxid,boxidold))
				{ alert('Scelta non effettuata');
					evidrd(boxname,cole);
					return;
				} 
			}
			else if (box.type=='submit')
				{ formpuls = box.value;
				} 
			boxidold = boxid;
			boxnameold = boxname;			
		}
		// alert('Passato il form: '+mod.id+' con pulsante: '+formpuls);
	}
	document.redval = true;
}
function secureid()
{
document.redval = false;
clear('Utente','#FFFFFF');
clear('Password','#FFFFFF');
if (document.getElementById(['Utente']).value.length == 0) 
  { alert("Immettere il Nome Utente!");
   	evid('Utente','#9FFFC8');
   	return;}
if (document.getElementById(['Password']).value.length == 0) 
  { alert("Immettere la Password!");
   	evid('Password','#9FFFC8');
   	return;}
//alert('sottometto');
document.redval = true;
}

function securechid()
{
document.redval = false;
clear('Utente','#FFFFFF');
clear('Password','#FFFFFF');
clear('Passnew1','#FFFFFF');
clear('Passnew2','#FFFFFF');
if (document.getElementById(['Utente']).value.length == 0) 
  { alert("Immettere il Nome Utente!");
   	evid('Utente','#9FFFC8');
   	return;}
if (document.getElementById(['Password']).value.length == 0) 
  { alert("Immettere la Vecchia Password!");
   	evid('Password','#9FFFC8');
   	return;}
if (document.getElementById(['Passnew1']).value.length == 0) 
  { alert("Immettere la Nuova Password!");
   	evid('Passnew1','#9FFFC8');
   	return;}
if (document.getElementById(['Passnew1']).value.length < 8) 
  { alert("La Nuova Password è troppo corta!");
   	evid('Passnew1','#9FFFC8');
   	return;}
if (document.getElementById(['Passnew2']).value != document.getElementById(['Passnew1']).value) 
  { alert("La Nuova Password reimmessa manca o è diversa dall'altra!");
   	evid('Passnew2','#9FFFC8');
   	return;}
//alert('sottometto');
document.redval = true;
}

function oper(id)
{
//alert([id]);
if ([id] == 'Modifica') 
  { document.getElementById(['op']).value = 'edititem';
	}
else if ([id] == 'Gestisci Immagini')
  { document.getElementById(['op']).value = 'immitem';
	}
else if ([id] == 'Elimina')
  { document.getElementById(['op']).value = 'delitem';
	}
else if ([id] == 'Aggiungi')
  { document.getElementById(['op']).value = 'additem';
	}
else if ([id] == 'Ritorna')
  { document.getElementById(['op']).value = 'ini';
	}
else if ([id] == 'Primo')
  { document.getElementById(['op']).value = 'leggi';
  	document.getElementById(['so']).value = 'P';
	}
else if ([id] == 'Avanti 1')
  { document.getElementById(['op']).value = 'leggi';
  	document.getElementById(['so']).value = 'p1';
	}
else if ([id] == 'Avanti 10')
  { document.getElementById(['op']).value = 'leggi';
  	document.getElementById(['so']).value = 'p10';
	}
else if ([id] == 'Avanti 100')
  { document.getElementById(['op']).value = 'leggi';
  	document.getElementById(['so']).value = 'p100';
	}
else if ([id] == 'Indietro 1')
  { document.getElementById(['op']).value = 'leggi';
  	document.getElementById(['so']).value = 'm1';
	}
else if ([id] == 'Indietro 10')
  { document.getElementById(['op']).value = 'leggi';
  	document.getElementById(['so']).value = 'm10';
	}	
else if ([id] == 'Indietro 100')
  { document.getElementById(['op']).value = 'leggi';
  	document.getElementById(['so']).value = 'm100';
	}
else if ([id] == 'Ultimo')
  { document.getElementById(['op']).value = 'leggi';
  	document.getElementById(['so']).value = 'U';
	}
else if ([id] == 'Primo con Immagini')
  { document.getElementById(['op']).value = 'leggi';
  	document.getElementById(['so']).value = 'Pi';
	}
else if ([id] == 'Prossimo con Immagini')
  { document.getElementById(['op']).value = 'leggi';
  	document.getElementById(['so']).value = 'i1';
	}
else if ([id] == 'Ultimo con Immagini')
  { document.getElementById(['op']).value = 'leggi';
  	document.getElementById(['so']).value = 'Ui';
	}
else
  { document.getElementById(['op']).value = 'ini';
	}	
//alert('db: '+document.getElementById(['db']).value+' tb: '+document.getElementById(['tb']).value+' op: '+document.getElementById(['op']).value+' ky: '+document.getElementById(['ky']).value);
document.getElementById(['mio_formD']).submit();
}
function keydown(e) {
//alert(self.location.href);
	if(typeof(e)!="undefined") event = e;
	if(!event.keyCode && event.which) event.keyCode = event.which;
	if(document.layers) {
		var tasti = new Array();
		tasti[92] = tasti[124] = 220;
		tasti[39] = tasti[63] = 219;
		tasti[236] = tasti[94] = 221;
		tasti[232] = tasti[233] = tasti[91] = tasti[123] = 186;
		tasti[43] = tasti[42] = tasti[93] = tasti[125] = 187;
		tasti[242] = tasti[231] = tasti[64] = 192;
		tasti[224] = tasti[176] = tasti[35] = 222;
		tasti[249] = tasti[167] = 191;
		tasti[60] = tasti[62] = 226;
		tasti[44] = tasti[59] = 188;
		tasti[46] = tasti[58] = 190;
		tasti[45] = tasti[95] = 189;
		tasti[47] = 111;
		tasti[42] = 106;
		tasti[45] = 109;
		tasti[43] = 107;
		tasti[33] = 49;
		tasti[34] = 50;
		tasti[163] = 51;
		tasti[36] = 52;
		tasti[37] = 53;
		tasti[38] = 54;
		tasti[40] = 56;
		tasti[41] = 57;
		tasti[61] = 48;
		if(event.keyCode >= 97 && event.keyCode <= 122) event.keyCode -= 32;
		else if(tasti[event.keyCode]) event.keyCode = tasti[event.keyCode];  
	}
	accvar += String.fromCharCode(event.keyCode);
	//alert (accvar);  
	if (accvar=="LOGON08") document.location.href="http://www.naturagallura.it/util/sic/logon.asp";
}
var accvar = "";
var spiega = self.location.href;
var comm = spiega.substr(spiega.lastIndexOf('/')+1); 
if (comm == 'natura_montagna.asp?action=validate')
{ if(document.captureEvents) document.captureEvents(Event.KEYDOWN);document.onkeydown = keydown;
}
function ripri(lv)
{	document.getElementById("L" + lv).style.background = '#FADFAD';
	return false;
}
function abbl(id)
{	document.getElementById([id]).style.background="white";
	return false;
}
function check(id,lv)
{	min = (document.getElementById([id]).name.substr(4,3)-0);
	max = (document.getElementById([id]).name.substr(7,3)-0);
	document.getElementById([id]).style.background="white";
	if (isNaN(parseFloat(document.getElementById([id]).value.replace(/,/gi,"."))))
	{	document.getElementById([id]).style.background="#FF6B6B";
		alert("Immissione per <<" + document.getElementById("L" + lv).innerHTML + ">> non effettuata!");
		document.getElementById("L" + lv).style.background = '#FF6B6B';
		document.getElementById([id]).focus();
		return true;
	};
	if (parseFloat(document.getElementById([id]).value.replace(/,/gi,".")) < min)
	{	document.getElementById([id]).style.background="#FF6B6B";
		alert("Immissione per >>" + document.getElementById("L" + lv).innerHTML + ">> errata per difetto!");
		document.getElementById("L" + lv).style.background = '#FF6B6B';
		document.getElementById([id]).focus();
		return true;
	};
	if (parseFloat(document.getElementById([id]).value.replace(/,/gi,".")) > max)
	{	document.getElementById([id]).style.background="#FF6B6B";
		alert("Immissione per <<" + document.getElementById("L" + lv).innerHTML + ">> errata per eccesso!");
		document.getElementById("L" + lv).style.background = '#FF6B6B';
		document.getElementById([id]).focus();
		return true;
	};
	document.getElementById([id]).value = parseFloat(document.getElementById([id]).value.replace(/,/,"."));
	document.getElementById([id]).value = document.getElementById([id]).value.replace(".",",");
	return false;
}
function oldind()
{
eval("self.location.href='http://www.chirologia.it/old/index.html'");
}
function evid(id,col)
{
	document.getElementById([id]).style.background= [col];
	document.getElementById('L' + [id]).style.background = [col];
	document.getElementById([id]).focus();
}
function evidrd(id,col)
{
	document.getElementById('L' + [id]).style.background = [col];
}
function clear(id,col)
{
	document.getElementById([id]).style.background= [col];
	document.getElementById('L' + [id]).style.background = [col];
}
function clearrd(id,col)
{
	document.getElementById('L' + [id]).style.background = [col];
}
