/*
COOKIE ===============
USO ###############
SrCmndCkes_Leggi = restituisce il valore, se il cookie non c'è restituisce "null"; se ne sono presenti più di 1 mostra il primo
		* Struttura		SrCmndCkes_Leggi(NomeCookie);
		* Parametri:	NomeCookie = stringa che identifica il nome del cookie
		* Esempio:		if(SrCmndCkes_Leggi('nome')==null) ...
SrCmndCkes_Scrivi = restituisce TRUE o FALSE a seconda che sia avvenuta o no correttamente la scrittura; la mancanza del valore comporta la cancellazione del cookie, la mancanza dei parametri tempo genera un cookie di sessione, il path "/" è sempre consigliato
		* Struttura:	SrCmndCkes_Scrivi(NomeCookie [,ValoreCookie] [,UdM, Tempo] [,Path] [,Domain] [,Secure]);
		* Parametri:	NomeCookie = stringa che identifica il nome del cookie
									ValoreCookie = contenuto cookie
									UdM = stringa che indica unità di misura per indicare la durata; OPZIONALE, se non specificato è TEMPORANEO;
												valori ammessi: anni/mesi/giorni/ore/minuti/secondi/GMT
									Tempo = stringa che indica la durata numerica del cookie; OPZIONALE, ma richiesta se è stato usato il precedente parametro
									Path = stringa che indica lo "scope" del cookie: "/" per tutto "" per attuale e figli (default)
									Domain = idem di Path, ma a livello di dominio
									Secure = scritta che attiva il criptaggio: per criptare basta "1" o "secure" mentre vuoto o altro per lasciare così
		* Esempio:		if(!SrCmndCkes_Scrivi('Lingua','Ita')) alert('Scrittura non riuscita');
SrCmndCkes_Cancella = restistuisce TRUE o FALSE; FALSE significa che cmq un cookie con quel nome c'è ancora, e ciò può essere perchè le proprietà non coincidono o perchè ce ne erano più di uno con lo stesso nome
		* Struttura:	SrCmndCkes_Cancella(NomeCookie [,Path] [,Domain]);
		* Parametri:	NomeCookie = stringa che identifica il nome del cookie
									Path = stringa che indica lo "scope" del cookie: "/" per tutto "" per attuale e figli (default)
									Domain = idem di Path, ma a livello di dominio
		* Esempio:		if(SrCmndCkes_Cancella('nome' [,'path: "\" per tutto "" per attuale e figli'] [,'Domain'])) alert('OK'); else alert('Ancora No');
SrCmnmCkes_CancellaTutti = restituisce TRUE o FALSE; FALSE significa che dei cookie sono ancora presenti, probabilmente perchè le proprietà non coincidono
		* Struttura:	SrCmnmCkes_CancellaTutti();
		* Parametri:	
		* Esempio:		if(SrCmnmCkes_CancellaTutti()) alert('Cookie cancellati'); else alert('Sono rimasti ancora dei cookie');
SrCmndCkes_Visualizza = mostra alert con contenuto di tutti i cookie, mettendo in risalto quello eventualmente indicato, con il conteggio delle ripetizioni; restistuisce TRUE, a meno che l'eventuale cookie indicato non esista allora restituisce FALSE; 
		* Struttura:	
		* Parametri:	
		* Esempio:		if(SrCmndCkes_Visualizza(['nome'])) alert('Il cookie esiste'); else alert('Il cookie non esiste');

EVENTI ===============
SrCmndEvnt_Add = accoda funzioni da eseguire all'avveramento di eventi su di un oggetto
		* Struttuta:	SrCmndEvnt_Add(Oggetto,Evento,Funzione);
		* Parametri:	Oggetto 	= oggetto
									Evento 		= stringa che indica l'eventi
									Funzione 	= cosa deve fare 
		* Esempio: 		SrCmndEvnt_Add(window,'load',function(){funzione('pippo')});

FLASH ================
SrCmndFlsh_Include = 	include gli oggetti flash nel punto di richiamo; in questo modo viene raggirata la protezione di IE che renderebbe il flash disattivato e tratteggiato
		* Struttura:	SrCmndFlsh_Include(FlashFile,WidthPx,HeightPx); 
		* Parametri:	FlashFile	= stringa dell'url per recuperare il file
									WidthPx, HeightPx = pixel della dimensione del riquadro dedicato al flash
		* Esempio:		SrCmndFlsh_Include('http://www.pippo.it/file.swf,640,480); 

IMMAGINI =============
SrCmndImmg_Change = cambia il src di una immagine con effetto fading, attendendo l'onload, nel mentre però c'è il vuoto; utilizza SrCmndStleEfftFadingTo
		* Struttura:	SrCmndImmg_Change(id,urla[,sec])
		* Parametri:	id = id dell'immagine (non so se deve avere un width) 
									urla = url assoluto della nuova immagine
									sec = durata del passaggio in secondi (default = 1.6sec)
		* Esempio:		SrCmndImmg_Change('RiquadroFoto');		
SrCmndImmg_Load = accoda onload il caricamento di immagini in cache in modo da averle pronte per gli effetti
		* Struttura:	SrCmndImmg_Preload('Path', 'FileName01', 'FileName02', 'FileName03', 'FileName04', ...);
		* Parametri:	Path = percorso da usare per trovare le immagini
									FileNameXX = nomi file immagine, possono essere infiniti
		* Esempio:		SrCmndImmg_Preload('http://www.sito.it/__SrTmpl/', 'bottoneover1', 'bottoneover2', 'bottoneover3');

LOGIN ================
SrCmndLgin_Login = effettua il controllo prima del submit
		* Struttura:	SrCmndLgin_Login(Id,Messaggio);
		* Parametri:	Id	= stringa col nome del form, se diverso dal default=SrMdliLginForm
									Messaggio = stringa con il messaggio "non hai digitato tutti i campi"
		* Esempio:		SrCmndLgin_Login('','<?php echo $SrVcbl_LginAlrtMnca ?>');
SrCmndLgin_Logout = effettua il logout della sessione, in pratica cancella il cookie di sessione
		* Struttura:	SrCmndLgin_Logout();
		* Parametri:	nessuno
		* Esempio:		SrCmndLgin_Logout();

MENU =================
		REQUISITO
		- necessita l'impostazione del modulo php "SrCmndMenu" nel Layout della pagina, che permette di generare il database in javascript
		2 MODI DI DARE L'INPUT
		- 'this' = identifica l'elemento tramite href e class "LinkRAL4" del tag A ...che quindi devono essere correttamente impostate altrimenti non funziona
				-> implica l'uso di una classe per l'identificazione della posizione, quindi è un metodo incompatibile nelle strutture complesse che richiedono class proprie (come Album)
		- '#' = indentifica in diretta
		OPZIONI SEMPRE VALIDE
		- GET: prendo quanto già c'è, nel this dal href, nel # dal database, e poi aggiunge ciò che è stato passato
		- MENU: parte l'analisi di tutti i A, confrontanto i class e href, si capisce se devono esser attivati/disattivati
		- HIDDEN: per le eventuali strutture a div nascoste parte un'analisi di tutti i DIV, vengono presi in considerazione le strutture "SrLyotR4C32_Home.php" e chiuse/aperte se necessario tramite class "Tsto" o "Hide"
		MODALITA'
		- per AJAX basta impostare il nome del div
				!) usando # bisogna ricordare che necessita di impostare la query string poichè nel database non è presente, mentre href non viene considerato

SrCmndMenuGoto = apre i link presenti nel database, sia ricorrendo a Ajax, sia alla tecnica dei div nascosti, sia usando querystring
		* Struttura:	SrCmndMenuGoto(Oggetto<A> [,EventualeQueryString [,EventualeNomeDivDaRicaricaConAjax]]); il risultato ok restituisce false per permettere di annullare il <A>
		* Parametri:	Oggetto<A> = oggetto che fa partire il link, in alternativa si può passare il numero del Cdce direttamente
									EventualeQueryString = ...
									EventualeNomeDivDaRicaricaConAjax = ...
		* Esempio:		<a href="home.php" onclick="return SrCmndMenuGoto(this,'','SrLyotR3C2');"> // aggiorna con ajax il div 'SrLyotR3C2' con quello contenuto nella pagina 'home.php'
									<a href="foto.php?id=1" onclick="return SrCmndMenuGoto(5,'id=1','Cornice');"> // usato nell'album: aggiorna con ajax il div 'Cornice' con quello contenuto nella pagina del link n°5 che corrisponde a 'home.php', ma andrà aggiunto la query string 'id=1' poichè nel database non è presente
									... class="LinkRAL3" ... per avere un aggiornamento sugli stili dei bottoni nel menu, negli altri casi non serve quindi si può omottere
SrCmndMenuUpdt = aggiorna un div con Ajax
		* Struttura: 	SrCmndMenuUpdt(Cosa,ConCosa,AttesaMassima);
		* Parametri:
		* Esempi:

STATISTICHE ==========
SrCmndStatShny_Increase = lo script di shinystat è xhtml invalido poichè usa document.write, ma non potevo ricorrere alla IMG sostitutiva perchè lo script cmq resttuisce info sul browser, per questo ho creato questa funzione
		* Struttura:	SrCmndStatShny_Increase(TagId,User); 
		* Parametri:	TagId = Id del tag IMG su cui verrà caricato l'immagine-contatore
									User = stringa che identifica l'account in Shinystat
		* Esempio:		SrCmndStatShny_Increase('SrCmndStatShnyImmg','primamano'); 

STILE Effetti ======== (Tween: non accetta underscore nel nome)
SrCmndStlePrprGet = legge l'eventuale proprietà di stile impostata inline, altrimenti la pesca dal file css
		* Struttura:	SrCmndStlePrprGet(id/oggetto,styleCss)
		* Parametri:	el = stringa con id del tag, in alternativa si può passare direttamente l'oggetto, lui capisce da sè
									styleCss = nome della proprietà Css da ricavare, con la sinstassi originale
		* Esempio:		SrCmndStlePrprGet('pippo','background-Color'); equivale a 
									SrCmndStlePrprGet(document.getElementById('pippo'),'background-Color');
SrCmndStleEfftChangeFading = effettua una qualsiasi operazione ma aggiungendo un fading all'inizio e alla fine
		* Struttura:	SrCmndStleEfftChangeFading(id[,ev])
		* Parametri:	id = id del div che effettuerà il fading (deve avere un background-color, e credo anche un width) 
									ev = la funzione che sarà eseguita
		* Esempio:		SrCmndStleEfftChangeFading('RiquadroFoto', function(){ document.getElementById('Foto').src='foto2.jpg'; } );
SrCmndStleEfftChangeTextFading = idem a sopra, ma il fading con il testo in IE distrugge lo smooth shift del font, quindi qui si ricorre alla creazione di una pecetta che poi verrà distrutta
		* Struttura:	SrCmndStleEfftChangeTextFading(id[,ev])
		* Parametri:	id = id del div che effettuerà il fading (deve avere un background-color, e credo anche un width. il parentNode deve avere un position) 
									ev = la funzione che sarà eseguita 
		* Esempio:		SrCmndStleEfftChangeTextFading('RiquadroCommento', function(){ document.getElementById('RiquadroCommento').innerHMTL='titolo'; } );
SrCmndStleEfftFadingTo = effettua il fading
		* Struttura:	SrCmndStleEfftFadingTo(id [,val [,sec [,callback]]])
		* Parametri:	id = id del div che effettuerà il fading (deve avere un background-color, e credo anche un width.)
									val = valore di opacity da raggiungere (default = 0 = trasparente, max=100)
									sec = durata del passaggio in secondi (default = 0.8sec)
									callback = la funzione da eseguire al termine
		* Esempio:		SrCmndStleEfftFadingTo('RiquadroCommento', '', '', function(){ document.getElementById('RiquadroCommento').innerHMTL='titolo'; } );
SrCmndStleEfftOpacity = change the opacity for different browsers // non è Tween
		* Struttura:	SrCmndStleEfftOpacity(id/oggetto, opacity);
		* Parametri:	id = stringa con id del tag, in alternativa si può passare direttamente l'oggetto, lui capisce da sè
									opacity = numero da 0 (invisibile) a 100 (visibile)
		* Esempio:		SrCmndStleEfftOpacity('IdCommenti',0); // lo rende invisibile
SrCmndStleEfftTween = imposta modifiche agli oggetti
		* Struttura:	var t = new Tween(object,property,easing,start,end,duration,suffixe);
		* Parametri:	object = object you want to modify
									property = string che rappresenta The property that is updated on the target object, it can be empty ('')
									easing = nome della Function easing that will be applied to motion
										Tween.regularEaseIn
										Tween.regularEaseOut
										Tween.regularEaseInOut
										Tween.strongEaseIn
										Tween.strongEaseOut
										Tween.strongEaseInOut
										Tween.backEaseOut
										Tween.backEaseIn
										Tween.backEaseInOut
										Tween.bounceEaseOut
										Tween.bounceEaseIn
										Tween.bounceEaseInOut
										Tween.elasticEaseIn
										Tween.elasticEaseOut
										Tween.elasticEaseInOut
									start = the Number Start value
									end = the Number End value
									duration = the Number Animation duration in seconds
									suffixe = A string to append to the updated property ('%','pt','em' ...). 
		* Metodi:			.start(); .rewind(); .fforward(); .stop(); .resume();
									.continueTo(end,duration); .yoyo(); .addListener=listenerObject; .removeListener=listenerObject;
		* Events:			.onMotionStarted=eventObject; .onMotionChanged=eventObject; .onMotionFinished=eventObject;
									.onMotionStopped=eventObject; .onMotionLooped=eventObject; .onMotionResumed=eventObject;
		* Esempio:		[Usando i Metodi] ========
									t1A = new SrCmndStleEfftTween(document.getElementById('sqA').style,'left',Tween.elasticEaseOut,0,500,1,'px');
									t1A.onMotionFinished = function(){alert( 'onMotionFinished' )};
									t1A.start();
									[Usando addListener] =====
									t1B = new Tween(document.getElementById('sqA').style,'left',Tween.elasticEaseOut,0,500,1,'px');
									var a = new Object();
									a.onMotionFinished = function(){ alert( 'onMotionFinished' ) };
									a.onMotionStarted = function(){ alert( 'onMotionStarted' ) }
									t1B.addListener(a)
									t1B.start();
SrCmndStleEfftFade = cambia opacità agli elementi (è necessario dare width al box con file Css)
		* Struttura:	var t = new SrCmndStleEfftFade(Object,easing,startOpacity,endOpacity,duration);
		* Esempio:		var t = new SrCmndStleEfftFade(document.getElementById('square33'),Tween.bounceEaseOut, 100, 0, 3); t.start();
SrCmndStleEfftGradient = sfuma da un colore all'altro
		* Struttura:	var t = new SrCmndStleEfftGradient(object,property,easing,startColor,endColor,duration);
		* Esempio:		var t = new SrCmndStleEfftGradient(document.getElementById('square22').style, 'backgroundColor', Tween.bounceEaseOut, 'FF0000', '0000FF', 3); t.start();
SrCmndStleEfftParallel = avvia degli effetti in parallelo
SrCmndStleEfftSequence = avvia degli effetti in sequenza, ogni effetto aspetta la fine del precedente
		* Metodi:			.addChild( Tween ); .removeChild( Tween ); .start(); .rewind(); .fforward(); .stop(); .resume();
		* Eventi:			.onMotionStarted=eventObject; .onMotionFinished=eventObject; .onMotionStopped=eventObject;
									.onMotionLooped=eventObject; .onMotionResumed=eventObject;
		* Esempio:		var my_seq = new SrCmndStleEfftSequence();
									my_seq.addChild(new Tween(elem1.style,'width',Tween.bounceEaseOut,25,100,0.5,'px'));
									my_seq.addChild(new Tween(elem2.style,'width',Tween.bounceEaseOut,25,100,0.5,'px'));
									my_seq.start()

WINDOWS ==============
SrCmndWndw_CloseAfter = dopo tot millisecondi, lancia CloseNow e ricarica il contenuto della finestra opener
		* Struttura:	SrCmndWndw_CloseAfter(Millisecondi); 
		* Parametri:	Millisecondi = numero di millisecondi di attesa prima della chiusura
		* Esempio:		SrCmndWndw_CloseAfter(1000);
SrCmndWndw_CloseNow = chiude la finestra dov'è presente il codice
		* Struttura:	SrCmndWndw_CloseNow(); 
		* Parametri:	
		* Esempio:		SrCmndWndw_CloseNow();
*/






// COOKIE
/* NOTE ##############
LETTURA: non è possibile leggere le singole proprietà: expires, path, domain , secure
ELIMINAZIONE: non è possibile eliminare tutto insieme con "document.cookie='';", i browser cancellano i cookie nel momento preciso in cui vengono SCRITTI con un qls "expires" scaduto
o nel momento in cui RECUPERANO i cookies con "document.cookie" e trovano che "expires" è scaduto o non esiste; c'è chi per cancellare scrive la scadenza "Thu, 01 Jan 1970 00:00:01 GMT" ma se qualcosa è errato, mentre NN ricoscosce abbastanza tutto IE no, e quindi questo invece che cancellare un cookie ne scrive uno che non scade mai;
non è vero che IE cancella i cookie se si inserisce in contenuto vuoto, è solo un'apparenza, poichè tale contenuto è salvato come "nome;" che quindi nella lettura non viene trovato perchè si cerca "nome=;" quindi sembra cancellato invece c'è, occupa spazio, ed è inutilizzato
*/
function SrCmndCkes_Leggi(CookieNome){
	if (CookieNome.length==0) return null;
	var PosizioneIniziale = document.cookie.indexOf(CookieNome+"=");
		if (PosizioneIniziale == -1) return null;
		PosizioneIniziale += CookieNome.length+1;  // restituisce la posizione del primo carattere del valore della variabile-cookie
	var PosizioneFinale = document.cookie.indexOf(";",PosizioneIniziale);
		if (PosizioneFinale == -1) PosizioneFinale = document.cookie.length;  // serve perchè se il cookie è l'ultimo non avrà ";"
	return unescape(document.cookie.substring(PosizioneIniziale,PosizioneFinale));
}
function SrCmndCkes_Scrivi(name,value,expiresUdM,expires,path,domain,secure){
	if (!name) { return false }
	if (!value) { return SrCmndCkes_Cancella(name); }  // se è vuoto non si può fare la scrittura purtroppo, perchè, mentre in NN esiste il cookie vuoto "nome=;", in IE viene scritto "nome;" e quindi al check non risulta e inoltre occupa spazio
	if ((expiresUdM && expires) && (expiresUdM!='GMT')) {
		var ExpiresMillisec = ExpiresDate = Oggi = new Date();
		switch (expiresUdM) {    // calcola i JS-millisecondi del momento di scadenza
			case "anni":    ExpiresMillisec=Oggi.getTime()+expires*1000*60*60*24*365; break;
			case "mesi":    ExpiresMillisec=Oggi.getTime()+expires*1000*60*60*24*31; break;
			case "giorni":  ExpiresMillisec=Oggi.getTime()+expires*1000*60*60*24; break;
			case "ore":     ExpiresMillisec=Oggi.getTime()+expires*1000*60*60; break;
			case "minuti":  ExpiresMillisec=Oggi.getTime()+expires*1000*60; break;
			case "secondi": ExpiresMillisec=Oggi.getTime()+expires*1000; break;
			default:        ExpiresMillisec=Oggi.getTime()+expires;  // ha poco senso ma qlcs ci andava messo
			}
		ExpiresDate.setTime(ExpiresMillisec);   // converte JS-millisecondi in Date
		expires = ExpiresDate.toGMTString(); }  // converte Date in GMT-stringa
	secure = (secure=="1" || secure==1 || secure=="secure") ? 1 : "";
	document.cookie = name + "=" +escape(value) +
	        ( (expiresUdM && expires) ? "; expires=" + expires : "") +
	        ( (path) ? "; path=" + path : "") + 
	        ( (domain) ? "; domain=" + domain : "") +
	        ( (secure) ? "; secure" : "");

	if (SrCmndCkes_Leggi(name)==null && secure!=1) { return false } else { return true }
}
function SrCmndCkes_Cancella(CookieNome, CookiePath, CookieDomain){
	var DoveSiTrovaPrima = document.cookie.indexOf(CookieNome);
	if(DoveSiTrovaPrima==-1) {   // se non c'è si taglia corto
		return true;
	} else {
		if( CookiePath &&  CookieDomain) { SrCmndCkes_Scrivi(CookieNome,'cancellato','anni',-1,CookiePath,CookieDomain); }  // dovevo inventare un contenuto sennò saltava la scrittura
		if( CookiePath && !CookieDomain) { SrCmndCkes_Scrivi(CookieNome,'cancellato','anni',-1,CookiePath); }
		if(!CookiePath &&  CookieDomain) { SrCmndCkes_Scrivi(CookieNome,'cancellato','anni',-1,'',CookieDomain); }
		if(!CookiePath && !CookieDomain) { SrCmndCkes_Scrivi(CookieNome,'cancellato','anni',-1); }
		var DoveSiTrovaDopo = document.cookie.indexOf(CookieNome);
		if(DoveSiTrovaPrima!=DoveSiTrovaDopo) { return true } else { return false } // se Prima<>Dopo vuol dire che qualcosa è stato fatto; si guarda a questo e non alla semplice verifica di lettura perchè in presenza di 2 cookie omonimi la verifica fallirebbe
	}
}
function SrCmndCkes_CancellaTutti(){
	stringa=document.cookie.split(";");
	for(i=0;i<stringa.length;i++) {
		var c=stringa[i].split("=");
		if(c[0]) SrCmndCkes_Cancella(c[0],'/');
		};
	return (document.cookie.length==0);
}
function SrCmndCkes_Visualizza(CookieNome){
	// recupera info su tutti i cookie
	testo= 'STRINGA COOKIES\nContenuto= \"' +unescape(document.cookie)+ '\"\n\n';
	esito=1;
	// recupera info sul cookie richiesto
	if(CookieNome) {
		cloni=0;
		valore=SrCmndCkes_Leggi(CookieNome);
		if(valore==null){
			esito=0;
		}else{
			i=-1;
			do { i=document.cookie.indexOf(CookieNome+"=",i+1); if(i!=-1) cloni++; } while(i!=-1);
			testo+='SINGOLO COOKIE\nNome= \"' +CookieNome+ '\"\nPrimo Valore= \"' +valore+ '\"\nRipetizioni= '+cloni;
		}
	}
	// produce output
	alert(testo);
	if(esito==1) return true; else return false;
}


// EVENTI
function SrCmndEvnt_Add(obj,ev,fn){
	if(obj.addEventListener) {
		// metodo w3c
		obj.addEventListener(ev, fn, false);
	} else if(obj.attachEvent) {
		// metodo IE
		obj.attachEvent('on'+ev, fn);
	} else {
		// se i suddetti metodi non sono applicabili
		// se esiste gia' una funzione richiamata da quel gestore evento
		if(typeof(obj['on'+ev])=='function'){
			// salvo in variabile la funzione gia' associata al gestore
			var f=obj['on'+ev];
			// setto per quel gestore una nuova funzione 
			// che comprende la vecchia e la nuova
			obj['on'+ev]=function(){if(f)f();fn()}
			}
		// altrimenti setto la funzione per il gestore
		else obj['on'+ev]=fn;
		}
}


// FLASH
function SrCmndFlsh_Include(FlashFile,Xxx,Yyy){
	document.write('<br /><embed src="'+FlashFile+'" width="'+Xxx+'" height="'+Yyy+'" /><br />&nbsp;'); 
}


// IMMAGINI
function SrCmndImmg_Change(id,urla,sec){
	sec = sec || 1.8; sec *=0.5;
	var SrCmndImmg_Temp=new Image();
	SrCmndImmg_Temp.src=urla;
	SrCmndStleEfftFadingTo(id,0,sec,function(){
		SrCmndImmg_Temp.onload= function(){
			document.getElementById(id).src=SrCmndImmg_Temp.src; SrCmndStleEfftFadingTo(id,100,sec);
			};
		SrCmndImmg_Temp.src=urla;
		});
}
function SrCmndImmg_Load(){
	if(typeof(SrCmndImmg_Array)=='undefined') SrCmndImmg_Array=new Array();
	for (var i=1;i<SrCmndImmg_Load.arguments.length;i++){
		SrCmndImmg_Array[SrCmndImmg_Array.length]				= new Image();
		SrCmndImmg_Array[SrCmndImmg_Array.length-1].src	= SrCmndImmg_Load.arguments[0]+SrCmndImmg_Load.arguments[i];
		}
}


// LOGIN
function SrCmndLgin_Login(id,msg){
	var id = id || 'SrMdliLginForm';
	var msg= msg || 'Scrivi in tutti i campi';
	var fo = document.getElementById(id);
	for(var i=0; i<fo.elements.length; i++)
		if((fo.elements[i].type=='password' || fo.elements[i].type=='text') && fo.elements[i].value=='')
			{ alert(msg); fo.elements[i].focus();	return false; }
	fo.submit();
	return false;
}
function SrCmndLgin_Logout(){
	SrCmndCkes_Cancella('SrLginSssnCdce', '/');
	return true;
}


// MENU
function SrCmndMenuGoto(SrCmndLnksElmnSrce, SrCmndLnksElmnUrlA, SrCmndLnksElmnPrmtGett, SrCmndLnksElmnPrmtAjax, SrCmndLnksElmnPrmtPpup) {
	if(typeof(SrCmnsMenuStts)=='undefined' || SrCmnsMenuStts==0) return true;
	function SrCmndMenuGotoUrllClear(urll,what){
		urll = urll || '';
		what = what || '';
		if(what.indexOf('NoQuery')>-1			&& (urll.indexOf('?')>-1)) 	urll = urll.substr(0,urll.indexOf('?'));				// tolgo query
		if(what.indexOf('NoPath')>-1			&& (urll.indexOf('/')>-1))	urll = urll.substr(urll.lastIndexOf('/')+1);		// tolgo directory
		if(what.indexOf('NoExt&Query')>-1	&& (urll.indexOf('.')>-1))	urll = urll.substr(0,urll.lastIndexOf('.'));		// tolgo estensione e query
		return urll;
	}
	function SrCmndMenuGotoTaggClssRamo(ogg){
		var result = null;
		if(ogg.className.indexOf('Pgna')>-1) result = ogg.className.substr(ogg.className.indexOf('Pgna')+4,1);
		if(ogg.className.indexOf('Link')>-1) result = ogg.className.substr(ogg.className.indexOf('Link')+4,1);
		return result;
	}
	function SrCmndMenuGotoTaggClssLvll(ogg){
		var result = null;
		if(ogg.className.indexOf('Pgna')>-1) result = ogg.className.substr(ogg.className.indexOf('Pgna')+6,1);
		if(ogg.className.indexOf('Link')>-1) result = ogg.className.substr(ogg.className.indexOf('Link')+6,1);
		return Number(result);
	}

	// RICOSTRUZIONE INFO DI BASE
	SrCmndLnksElmnUrlA = SrCmndLnksElmnUrlA || SrCmndLnksElmnSrce.href; if(SrCmndLnksElmnUrlA.length==0) alert('Error: è stato passato un link senza url');
	SrCmndLnksElmnPgna = SrCmndMenuGotoUrllClear(SrCmndLnksElmnUrlA,'NoQuery NoPath');
	SrCmndLnksElmnPgnaNome = SrCmndMenuGotoUrllClear(SrCmndLnksElmnUrlA,'NoQuery NoExt&Query');
	SrCmndLnksElmnPrmtAjax = SrCmndLnksElmnPrmtAjax || '';
	SrCmndLnksElmnPrmtGett = SrCmndLnksElmnPrmtGett || '';
	SrCmndLnksElmnPrmtPpup = SrCmndLnksElmnPrmtPpup || '';
	SrCmndLnksElmnQery = (SrCmndLnksElmnPrmtGett.length>0) ? ('&amp;'+SrCmndLnksElmnPrmtGett) : ('');
	SrCmndLnksElmnQery+= (SrCmndLnksElmnUrlA.indexOf('?')>-1) ? ('&amp;'+SrCmndLnksElmnUrlA.substr(SrCmndLnksElmnUrlA.indexOf('?')+1)) : ('');
	SrCmndLnksElmnQery = (SrCmndLnksElmnQery!='') ? ('?'+SrCmndLnksElmnQery) : ('');
	SrCmndLnksElmnRamo = SrCmndMenuGotoTaggClssRamo(SrCmndLnksElmnSrce); if(SrCmndLnksElmnRamo==null) alert('Error: è stato passato un link senza ramo');
	SrCmndLnksElmnLvll = SrCmndMenuGotoTaggClssLvll(SrCmndLnksElmnSrce); if(SrCmndLnksElmnLvll==null) alert('Error: è stato passato un link senza livello');
	

	// MECCANISMO dei DIV NASCOSTI
	var DivTrovati=0;
	for(var j=0;j<document.getElementsByTagName('div').length;j++)
		var ogg=document.getElementsByTagName('div')[j];
		if(SrCmndMenuGotoTaggClssRamo(ogg)==SrCmndLnksElmnRamo){
			if(SrCmndMenuGotoTaggClssLvll(ogg)< SrCmndLnksElmnLvll)
				ogg.style.display='';
			if(SrCmndMenuGotoTaggClssLvll(ogg)>=SrCmndLnksElmnLvll)
				ogg.style.display='none';
			if(ogg.id.indexOf(SrCmndLnksElmnPgna)>-1){
				ogg.style.display='';
				ogg.parentNode.scrollTop=0;
				DivTrovati++;
				}
			}

	// AJAX: Aggiorno con Ajax se è richiesto: se fallisce fermo tutto e abilito il tag A
	if(SrCmndLnksElmnPrmtAjax.length>0)
		if(!SrCmndMenuUpdt(SrCmndLnksElmnPrmtAjax,SrCmndMenuGotoUrllClear(SrCmndLnksElmnUrlA,'NoQuery')+SrCmndLnksElmnQery,10))
			return true;

	// DEVO APRIRE UNA NUOVA PAGINA ? solo se non ho trovato div nascosti e non è il caso di ajax
	if(DivTrovati==0 && SrCmndLnksElmnPrmtAjax.length==0){
		if(SrCmndLnksElmnPrmtPpup!='')		window.open(SrCmndMenuGotoUrllClear(SrCmndLnksElmnUrlA,'NoQuery')+SrCmndLnksElmnQery,'_blank',SrCmndLnksElmnPrmtPpup);
		else															window.location.href=SrCmndMenuGotoUrllClear(SrCmndLnksElmnUrlA,'NoQuery')+SrCmndLnksElmnQery;
		return false;
	}

	// AGGIORNO MENU
	SrCmndLnksElmnSrce.blur();
	for(var j=0;j<document.getElementsByTagName('a').length;j++)
		var A = document.getElementsByTagName('a')[j];
		if(SrCmndMenuGotoTaggClssRamo(A)==SrCmndLnksElmnRamo){
			if(SrCmndMenuGotoTaggClssLvll(A)< SrCmndLnksElmnLvll)			if(A.parentNode.className!='LinkOnnn') 																		A.parentNode.className='LinkOnnn';
			if(SrCmndMenuGotoTaggClssLvll(A)= SrCmndLnksElmnLvll)			if(SrCmndLnksElmnPgna==SrCmndMenuGotoUrllClear(A.href,'NoQuery NoPath'))	A.parentNode.className='LinkOnnn'; else A.parentNode.className='LinkOfff';
			if(SrCmndMenuGotoTaggClssLvll(A)> SrCmndLnksElmnLvll)			if(A.parentNode.className=='LinkOnnn') 																		A.parentNode.className='LinkOfff';
		}

	return false;
}
function SrCmndMenuUpdt(Cosa,ConCosa,AttesaMassima) {
	var	UpdtAjaxRqst, UpdtAjaxRqstTimeChck;

	// COMPATIBILITA': verifico se Ajax è supportato dal browser e determina il return per link di origine: se false funzionerà il tag <A>
	var UpdtAjaxRqstSppr=false,
			UtntBrwsNome = navigator.userAgent.toUpperCase();
	if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object"){
		UpdtAjaxRqstSppr=true;
		UpdtAjaxRqst = new XMLHttpRequest(); }
	else if(window.ActiveXObject && UtntBrwsNome.indexOf("MSIE 4") < 0){
		UpdtAjaxRqstSppr=true;
		if(UtntBrwsNome.indexOf("MSIE 5") < 0) UpdtAjaxRqst = new ActiveXObject("Msxml2.XMLHTTP");
		else UpdtAjaxRqst = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
	// EXE: se c'è supporto ajax allora accoda richiesta e verifico che i controlli dell'handler siano attivi
	if(UpdtAjaxRqstSppr==false){
		return false;
	}else{
		// LOADING: piazza il loading nel div
		if(SrTmplUrlA)  document.getElementById(Cosa).innerHTML='<img src="'+SrTmplUrlA+'SrTmplMenu_Loading.gif" alt="loading..." title="" style="width:16px; height:16px;" />';	
		else						document.getElementById(Cosa).innerHTML='loading...';
    // CHECKER status: funzione
    UpdtAjaxRqst.onreadystatechange = function() {
      // se la richiesta è già stata completata
      if(UpdtAjaxRqst.readyState === 4) {
        // annulliamo la funzione di verifica tempo
        verificaTempoTrascorso = function(){};

        // e continuiamo con i normali controlli
        if(UpdtAjaxRqst.status == 200)
					document.getElementById(Cosa).innerHTML= UpdtAjaxRqst.responseText;
				else
					document.getElementById(Cosa).innerHTML= 'Richiesta Fallita. <a href="#" onclick="SrCmndMenuUpdt(\''+Cosa+'\',\''+ConCosa+'\',\''+AttesaMassima+'\');">Riprova</a>.';
    	}
    } // checker

 
    // CHECKER timer: funzione
		var
    	ChiamataData = new Date(),
    	ChiamataOra = ChiamataData.getTime();
			if(!AttesaMassima)	var AttesaMassima=15000;	else	AttesaMassima*=1000;
		UpdtAjaxRqstTimeChck = function() {
	    var AttesaData = new Date();
		  if((AttesaData.getTime() - ChiamataOra) > AttesaMassima) {
				UpdtAjaxRqst.onreadystatechange = function(){return;};
				UpdtAjaxRqst.abort();
				document.getElementById(UpdtAjaxRqstList[0]['Cosa']).innerHTML= 'Richiesta Fallita. <a href="#" onclick="SrCmndMenuUpdt('+'\''+UpdtAjaxRqstList[0]['Cosa']+'\','+'\''+UpdtAjaxRqstList[0]['ConCosa']+'\','+UpdtAjaxRqstList[0]['AttesaMassima']+','+UpdtAjaxRqstList[0]['TraQuanto']+','+UpdtAjaxRqstList[0]['QuanteVolte']+','+UpdtAjaxRqstList[0]['OgniQuanto']+');">Riprova</a>.';
			}else{
				setTimeout(UpdtAjaxRqstTimeChck, 100);
			}
		} // checker
		

    // SEND: invio richiesta
		UpdtAjaxRqst.open('POST', ConCosa, true);    // impostazione richiesta asincrona in GET del file specificato
		UpdtAjaxRqst.setRequestHeader("connection", "close");    // rimozione dell'header "connection" come "keep alive"
		UpdtAjaxRqst.setRequestHeader("content-type", "application/x-www-form-urlencoded");	// necessario per l'invio di variabili con POST
		UpdtAjaxRqst.send('ajax='+Cosa);    // invio richiesta


		return true; // return true significa che è andato bene
	}
}

// STATISTICHE
function SrCmndStatShny_Increase(TagId,User){
	c_="";l_=""+screen.width;d_=document.referrer;
	if (self != top){try {r_=""+escape(parent.document.referrer);}catch(e_r) {r_=""+escape(d_);}}
	else {r_=""+escape(d_);}
	if(navigator.appName!="Netscape"){c_=screen.colorDepth}
	else{c_=screen.pixelDepth}
	document.getElementById(TagId).src='http://s2.shinystat.com/cgi-bin/shinystat.cgi?USER='+User+'&REFER='+r_+'&COLOR='+c_+'&SIZE='+l_;
}



// STILE Effetti
// **** Tween.js of 28/01/2007 from http://jstween.blogspot.com including Easing Equations by Robert Penner
// **** sono incluse le funzioni derivate: Color, Opacity, Text, Parallel, Sequence

	
function SrCmndStlePrprGet(obj,styleCss){ 
  // se invece dell'oggetto fosse passato solo l'id, allora recupero l'oggetto 
  if(typeof(obj)=='string') var obj=document.getElementById(obj); 

    // funzione per converite la sintassi Css in quella usata da Javascript 
    function toCamelCase(s) { 
        for(var exp = toCamelCase.exp; 
            exp.test(s); s = s.replace(exp, RegExp.$1.toUpperCase()) ); 
        return s; 
    } 
    toCamelCase.exp = /-([a-z])/; 
    var styleJs=toCamelCase(styleCss); 
     
    // se l'elemento avesse già un valore inline (che predomina) restituisco quello 
    var value = obj.style[styleCss]; 
    if(!value) 
        // metodo x FF: vuole il nome della proprietà con la sintassi originale 
        if(document.defaultView)    value = document.defaultView.getComputedStyle(obj, null).getPropertyValue(styleCss); 
        // metodo x IE: vuole il nome della proprietà con la sintassi javascript 
        else if(obj.currentStyle)   value = obj.currentStyle[styleJs]; 
    return value; 
}
function SrCmndStleEfftChangeFading(id,fn){
	// la funzione prende solo "id" e non "obj" perchè id mi serve per dare il nome all'effetto
	// imposto i valori di default
	var start=100;
	// se un effetto esiste già lo fermo e setto il valore di partenza dell'opacità al valore attuale (altrimenti alla partenza ho scatti strani)
	if(eval('typeof('+id+'_EfftFade)!=\'undefined\''))
		eval(id+'_EfftFade.stop(); start=100*SrCmndStlePrprGet(\''+id+'\',\'opacity\'); ');
	// resetto l'effetto e la scorciatoia/riferimento
	eval(id+'_EfftFade = new SrCmndStleEfftFade(document.getElementById(\''+id+'\'),Tween.regularEaseIn,'+start+',0,3);');
	eval('var Ogg='+id+'_EfftFade;');
	Ogg.onMotionFinished = function(){
		Ogg.onMotionFinished = undefined;
		fn.call(this);
		Ogg.continueTo(100,0.8);
	}
	Ogg.continueTo(0,0.3);
}
function SrCmndStleEfftChangeTextFading(id,fn){
	// la funzione prende solo "id" e non "obj" perchè id mi serve per dare il nome all'effetto
	// imposto i valori di default
	var start=100;
	//creo l'elemento
	if(document.getElementById(id+'_Efft_Pecetta')==null) {
		var pecettaImage=document.createElement('div');
		pecettaImage.id=id+'_Efft_Pecetta';
		// gli dico per il momento di essere invisibile, finche' non ho costruito lo stile voluto, altrimenti si potrebbero vedere fotogrammi dei passaggi
		eval('pecettaImage.'+((document.all && !window.opera)?('style.setAttribute("cssText",\''):('setAttribute("style",\''))+"display:none');");
		document.getElementById(id).parentNode.appendChild(pecettaImage);
		var pecetta = document.getElementById(id+'_Efft_Pecetta');
		SrCmndStleEfftOpacity(pecetta,0);
		pecetta.style.backgroundColor=SrCmndStlePrprGet(id,'background-color');
		pecetta.style.position='absolute';
		pecetta.style.zIndex=5;
		pecetta.style.top=document.getElementById(id).offsetTop+'px';
		pecetta.style.left=document.getElementById(id).offsetLeft+'px';
		pecetta.style.width=document.getElementById(id).offsetWidth+'px';
		pecetta.style.height=document.getElementById(id).offsetHeight+'px';
		pecetta.style.display='block';
		}
	// se un effetto esiste già lo fermo
	if(eval('typeof('+id+'_EfftFade)!=\'undefined\''))
		eval(id+'_EfftFade.stop();');
	// resetto l'effetto (e la scorciatoia/riferimento) con il valore di partenza dell'opacità preso dal valore attuale (altrimenti alla partenza ho scatti strani)
	eval('start=100*SrCmndStlePrprGet(\''+id+'_Efft_Pecetta\',\'opacity\');');
	eval(id+'_EfftFade = new SrCmndStleEfftFade(document.getElementById(\''+id+'_Efft_Pecetta\'),Tween.regularEaseIn,'+start+',100,3);');
	eval('var Ogg = '+id+'_EfftFade; ');
	//manipolo l'effetto
	Ogg.onMotionFinished = function(){
		// alla fine distruggo tutto, poiche' altrimenti la pecetta mi copre il testo del div non permettendomi di selezionarlo
		Ogg.onMotionFinished = function() { var c=document.getElementById(id+'_Efft_Pecetta'); c.parentNode.removeChild(c); eval('delete '+id+'_Efft; delete Ogg;'); }
		fn.call(this);
		document.getElementById(id+'_Efft_Pecetta').style.height=document.getElementById(id).offsetHeight+'px'; // deve stare immediatamente dopo altrimenti in FF si vede un fotogramma
		document.getElementById(id+'_Efft_Pecetta').style.width=document.getElementById(id).offsetWidth+'px';
		Ogg.continueTo(0,0.8);
	}
	Ogg.continueTo(100,1);
}
function SrCmndStleEfftFadingTo(id,val,sec,callback){
	// la funzione prende solo "id" e non "obj" perchè id mi serve per dare il nome all'effetto
	// imposto i valori di default
	val = val || 0; 
	sec = sec || 0.8; 
	start = (val>50) ? 0 : 100;
	// se un effetto esiste già lo fermo e setto il valore di partenza dell'opacità al valore attuale (altrimenti alla partenza ho scatti strani)
	if(eval('typeof('+id+'_EfftFade)!=\'undefined\''))
		eval(id+'_EfftFade.stop(); start=100*SrCmndStlePrprGet(\''+id+'\',\'opacity\'); ');
	// resetto l'effetto e la scorciatoia/riferimento
	eval(id+'_EfftFade = new SrCmndStleEfftFade(document.getElementById(\''+id+'\'),Tween.regularEaseIn,'+start+','+val+','+sec+');');
	eval('var Ogg='+id+'_EfftFade;');
	Ogg.onMotionFinished = function(){
		Ogg.onMotionFinished = undefined;
		if(callback!=null) callback.call(this);
	}
	Ogg.continueTo(val,sec);
}
function SrCmndStleEfftOpacity(obj,opacity){
  if(typeof(obj)=='string') var obj=document.getElementById(obj).style; else var obj=obj.style; 
  obj.opacity = (opacity / 100); 
  obj.MozOpacity = (opacity / 100); 
  obj.KhtmlOpacity = (opacity / 100); 
  obj.filter = "alpha(opacity=" + opacity + ")"; 
}


// **** STILE Effetti > Tween > Tween.js (core) = SrCmndStleEfftTween
function Delegate() {}
Delegate.create = function (o, f) {
	var a = new Array() ;
	var l = arguments.length ;
	for(var i = 2 ; i < l ; i++) a[i - 2] = arguments[i] ;
	return function() {
		var aP = [].concat(arguments, a) ;
		f.apply(o, aP);
	}
}

var Tween = function(obj, prop, func, begin, finish, duration, suffixe){
	this.init(obj, prop, func, begin, finish, duration, suffixe)
}
var t = Tween.prototype;

t.obj = new Object();
t.prop='';
t.func = function (t, b, c, d) { return c*t/d + b; };
t.begin = 0;
t.change = 0;
t.prevTime = 0;
t.prevPos = 0;
t.looping = false;
t._duration = 0;
t._time = 0;
t._pos = 0;
t._position = 0;
t._startTime = 0;
t._finish = 0;
t.name = '';
t.suffixe = '';
t._listeners = new Array();	
t.setTime = function(t){
	this.prevTime = this._time;
	if (t > this.getDuration()) {
		if (this.looping) {
			this.rewind (t - this._duration);
			this.update();
			this.broadcastMessage('onMotionLooped',{target:this,type:'onMotionLooped'});
		} else {
			this._time = this._duration;
			this.update();
			this.stop();
			this.broadcastMessage('onMotionFinished',{target:this,type:'onMotionFinished'});
		}
	} else if (t < 0) {
		this.rewind();
		this.update();
	} else {
		this._time = t;
		this.update();
	}
}
t.getTime = function(){
	return this._time;
}
t.setDuration = function(d){
	this._duration = (d == null || d <= 0) ? 100000 : d;
}
t.getDuration = function(){
	return this._duration;
}
t.setPosition = function(p){
	this.prevPos = this._pos;
	var a = this.suffixe != '' ? this.suffixe : '';
	this.obj[this.prop] = Math.round(p) + a;
	this._pos = p;
	this.broadcastMessage('onMotionChanged',{target:this,type:'onMotionChanged'});
}
t.getPosition = function(t){
	if (t == undefined) t = this._time;
	return this.func(t, this.begin, this.change, this._duration);
};
t.setFinish = function(f){
	this.change = f - this.begin;
};
t.geFinish = function(){
	return this.begin + this.change;
};
t.init = function(obj, prop, func, begin, finish, duration, suffixe){
	if (!arguments.length) return;
	this._listeners = new Array();
	this.addListener(this);
	if(suffixe) this.suffixe = suffixe;
	this.obj = obj;
	this.prop = prop;
	this.begin = begin;
	this._pos = begin;
	this.setDuration(duration);
	if (func!=null && func!='') {
		this.func = func;
	}
	this.setFinish(finish);
}
t.start = function(){
	this.rewind();
	this.startEnterFrame();
	this.broadcastMessage('onMotionStarted',{target:this,type:'onMotionStarted'});
	//alert('in');
}
t.rewind = function(t){
	this.stop();
	this._time = (t == undefined) ? 0 : t;
	this.fixTime();
	this.update();
}
t.fforward = function(){
	this._time = this._duration;
	this.fixTime();
	this.update();
}
t.update = function(){
	this.setPosition(this.getPosition(this._time));
}
t.startEnterFrame = function(){
	this.stopEnterFrame();
	this.isPlaying = true;
	this.onEnterFrame();
}
t.onEnterFrame = function(){
	if(this.isPlaying) {
		this.nextFrame();
		setTimeout(Delegate.create(this, this.onEnterFrame), 0);
	}
}
t.nextFrame = function(){
	this.setTime((this.getTimer() - this._startTime) / 1000);
}
t.stop = function(){
	this.stopEnterFrame();
	this.broadcastMessage('onMotionStopped',{target:this,type:'onMotionStopped'});
}
t.stopEnterFrame = function(){
	this.isPlaying = false;
}
t.continueTo = function(finish, duration){
	this.begin = this._pos;
	this.setFinish(finish);
	if (this._duration != undefined)
		this.setDuration(duration);
	this.start();
}
t.resume = function(){
	this.fixTime();
	this.startEnterFrame();
	this.broadcastMessage('onMotionResumed',{target:this,type:'onMotionResumed'});
}
t.yoyo = function (){
	this.continueTo(this.begin,this._time);
}
t.addListener = function(o){
	this.removeListener (o);
	return this._listeners.push(o);
}
t.removeListener = function(o){
	var a = this._listeners;	
	var i = a.length;
	while (i--) {
		if (a[i] == o) {
			a.splice (i, 1);
			return true;
		}
	}
	return false;
}
t.broadcastMessage = function(){
	var arr = new Array();
	for(var i = 0; i < arguments.length; i++){
		arr.push(arguments[i])
	}
	var e = arr.shift();
	var a = this._listeners;
	var l = a.length;
	for (var i=0; i<l; i++){
		if(a[i][e])
		a[i][e].apply(a[i], arr);
	}
}
t.fixTime = function(){
	this._startTime = this.getTimer() - this._time * 1000;
}
t.getTimer = function(){
	return new Date().getTime() - this._time;
}

Tween.backEaseIn = function(t,b,c,d,a,p){
	if (s == undefined) var s = 1.70158;
	return c*(t/=d)*t*((s+1)*t - s) + b;
	}
Tween.backEaseOut = function(t,b,c,d,a,p){
	if (s == undefined) var s = 1.70158;
	return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	}
Tween.backEaseInOut = function(t,b,c,d,a,p){
	if (s == undefined) var s = 1.70158; 
	if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
	return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	}
Tween.elasticEaseIn = function(t,b,c,d,a,p){
		if (t==0) return b;  
		if ((t/=d)==1) return b+c;  
		if (!p) p=d*.3;
		if (!a || a < Math.abs(c)) {
			a=c; var s=p/4;
		}
		else 
			var s = p/(2*Math.PI) * Math.asin (c/a);
		
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	}
Tween.elasticEaseOut = function (t,b,c,d,a,p){
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b);
	}
Tween.elasticEaseInOut = function (t,b,c,d,a,p){
	if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) var p=d*(.3*1.5);
	if (!a || a < Math.abs(c)) {var a=c; var s=p/4; }
	else var s = p/(2*Math.PI) * Math.asin (c/a);
	if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	}
Tween.bounceEaseOut = function(t,b,c,d){
	if ((t/=d) < (1/2.75)) {
		return c*(7.5625*t*t) + b;
	} else if (t < (2/2.75)) {
		return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
	} else if (t < (2.5/2.75)) {
		return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
	} else {
		return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
	}
	}
Tween.bounceEaseIn = function(t,b,c,d){
	return c - Tween.bounceEaseOut (d-t, 0, c, d) + b;
	}
Tween.bounceEaseInOut = function(t,b,c,d){
	if (t < d/2) return Tween.bounceEaseIn (t*2, 0, c, d) * .5 + b;
	else return Tween.bounceEaseOut (t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
Tween.strongEaseInOut = function(t,b,c,d){
	return c*(t/=d)*t*t*t*t + b;
	}
Tween.regularEaseIn = function(t,b,c,d){
	return c*(t/=d)*t + b;
	}
Tween.regularEaseOut = function(t,b,c,d){
	return -c *(t/=d)*(t-2) + b;
	}
Tween.regularEaseInOut = function(t,b,c,d){
	if ((t/=d/2) < 1) return c/2*t*t + b;
	return -c/2 * ((--t)*(t-2) - 1) + b;
	}
Tween.strongEaseIn = function(t,b,c,d){
	return c*(t/=d)*t*t*t*t + b;
	}
Tween.strongEaseOut = function(t,b,c,d){
	return c*((t=t/d-1)*t*t*t*t + 1) + b;
	}
Tween.strongEaseInOut = function(t,b,c,d){
	if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
	return c/2*((t-=2)*t*t*t*t + 2) + b;
	}

var SrCmndStleEfftTween = Tween;


// **** STILE Effetti > Tween > OpacityTween.js = SrCmndStleEfftFade
OpacityTween.prototype = new Tween();
OpacityTween.prototype.constructor = Tween;
OpacityTween.superclass = Tween.prototype;

function OpacityTween(obj,func,fromOpacity,toOpacity,duration){
	this.targetObject = obj;
	this.init(new Object(),'x',func,fromOpacity,toOpacity,duration);
}
var o = OpacityTween.prototype;
o.targetObject = {};
o.onMotionChanged = function(evt){
/* codice originale: questo modo di scrivere richiede l'uso css di filter:alpha(opacity=100); invece usando la sintassi di bytefx serve solo un 'width', poi ho calcolato l'intero di 'v' che in FF generava delle notice
	var v = evt.target._pos;
	var t = this.targetObject;
	t.style['opacity'] = v / 100;
	t.style['-moz-opacity'] = v / 100;
	if(t.filters) t.filters.alpha['opacity'] = v;
*/
	var v = Math.round(evt.target._pos);
	var t = this.targetObject.style;
  t.opacity = (v / 100); 
  t.MozOpacity = (v / 100); 
  t.KhtmlOpacity = (v / 100); 
  t.filter = "alpha(opacity=" + v + ")"; 
}

var SrCmndStleEfftFade = OpacityTween;


// **** STILE Effetti > Tween > ColorTween.js = SrCmndStleEfftGradient
ColorTween.prototype = new Tween();
ColorTween.prototype.constructor = Tween;
ColorTween.superclass = Tween.prototype;

function ColorTween(obj,prop,func,fromColor,toColor,duration){
	this.targetObject = obj;
	this.targetProperty = prop;	
	this.fromColor = fromColor;
	this.toColor = toColor;
	this.init(new Object(),'x',func,0,100,duration);
	this.listenerObj = new Object();
	this.listenerObj.onMotionChanged = Delegate.create(this,this.onColorChanged);
	this.addListener(this.listenerObj);
}
var o = ColorTween.prototype;
o.targetObject = {};
o.targetProperty = {};
o.fromColor = '';
o.toColor = '';
o.currentColor = '';
o.listenerObj = {};
o.onColorChanged = function(){
	this.currentColor = this.getColor(this.fromColor,this.toColor,this._pos);
	this.targetObject[this.targetProperty] = this.currentColor;
}

		/***********************************************
		*
		* Function    : getColor
		*
		* Parameters  :    start - the start color (in the form "RRGGBB" e.g. "FF00AC")
		*            end - the end color (in the form "RRGGBB" e.g. "FF00AC")
		*            percent - the percent (0-100) of the fade between start & end
		*
		* returns      : color in the form "#RRGGBB" e.g. "#FA13CE"
		*
		* Description : This is a utility function. Given a start and end color and
		*            a percentage fade it returns a color in between the 2 colors
		*
		* Author      : www.JavaScript-FX.com
		*
		*************************************************/ 
o.getColor = function(start, end, percent)
{
	var r1=this.hex2dec(start.slice(0,2));
    var g1=this.hex2dec(start.slice(2,4));
    var b1=this.hex2dec(start.slice(4,6));

    var r2=this.hex2dec(end.slice(0,2));
    var g2=this.hex2dec(end.slice(2,4));
    var b2=this.hex2dec(end.slice(4,6));

    var pc = percent/100;

    r= Math.floor(r1+(pc*(r2-r1)) + .5);
    g= Math.floor(g1+(pc*(g2-g1)) + .5);
    b= Math.floor(b1+(pc*(b2-b1)) + .5);

    return("#" + this.dec2hex(r) + this.dec2hex(g) + this.dec2hex(b));
}
		/*** These are the simplest HEX/DEC conversion routines I could come up with ***/
		/*** I have seen a lot of fade routines that seem to make this a             ***/
		/*** very complex task. I am sure somene else must've had this idea          ***/
		/************************************************/  

o.dec2hex = function(dec){return(this.hexDigit[dec>>4]+this.hexDigit[dec&15]);}
o.hexDigit=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
o.hex2dec = function(hex){return(parseInt(hex,16))};

var SrCmndStleEfftGradient = ColorTween;


// **** STILE Effetti > Tween > Parallel.js = SrCmndStleEfftParallel
function Parallel(){
	this.children = new Array();
	this.numChildren = 0;
	this._listeners = new Array();
	this.addListener(this);
}
var s = Parallel.prototype;
s.endObject = new Object();
s.addChild = function(tween){
	this.children.push(tween)
	this.numChildren++;
}
s.start = function(){
	this.play();
	this.broadcastMessage('onMotionStarted', {target:this, type:'onMotionStarted'});
}
s.play = function(){
	for(var u = 0; u < this.numChildren; u++){
		if(u==(this.numChildren-1)){
			this.endObject = new Object();
			this.endObject.onMotionFinished = Delegate.create(this, this.end);
			this.children[u].addListener(this.endObject);
		}
		this.children[u].start();
	}
}

s.end = function(){
	this.children[this.numChildren-1].removeListener(this.endObject);
	this.broadcastMessage('onMotionFinished', {target:this, type:'onMotionFinished'});
}
s.stop = function(){
	this.enumAction('stop');
	this.broadcastMessage('onMotionStopped', {target:this, type:'onMotionStopped'});
	}
s.rewind = function(){
	this.enumAction('rewind');
	}
s.fforward = function(){
	this.enumAction('fforward');
	}
s.resume = function(){
	this.enumAction('resume');
	this.broadcastMessage('onMotionResumed', {target:this, type:'onMotionResumed'});
	}
s.yoyo = function(){
	this.enumAction('yoyo');
	}


s.enumAction = function(action){
	for(var u = 0; u < this.numChildren; u++){
		this.children[u][action]();
	}
}

s.addListener = function(o){
	this.removeListener (o);
	return this._listeners.push(o);

}
s.removeListener = function(o){
	var a = this._listeners;	
	var i = a.length;
	while (i--) {
		if (a[i] == o) {
			a.splice (i, 1);
			return true;
		}
	}
	return false;
}
s.broadcastMessage = function(){
	var arr = new Array();
	for(var i = 0; i < arguments.length; i++){
		arr.push(arguments[i])
	}
	var e = arr.shift();
	var a = this._listeners;
	var l = a.length;
	for (var i=0; i<l; i++){
		if(a[i][e])
		a[i][e].apply(a[i], arr);
	}
}

var SrCmndStleEfftParallel = Parallel;


// **** STILE Effetti > Tween > Sequence.js = SrCmndStleEfftSequence
function Sequence(){
	this.children = new Array();
	this.currentChildIndex = 0;
	this._listeners = new Array();
	this.nextObject = new Object();
	this.addListener(this);
}
var s = Sequence.prototype;
s.addChild = function(tween){
	this.children.push(tween)
}
s.removeChild = function(tween){
	var a = this.children;	
	var i = a.length;
	while (i--) {
		if (a[i] == tween) {
			a.splice (i, 1);
			return true;
		}
	}
	return false;
}
s.start = function(){
	this.rewind();
	this.play();
	this.broadcastMessage('onMotionStarted',{target:this,type:'onMotionStarted'});
}
s.next = function(){
	this.children[this.currentChildIndex].removeListener(this.nextObject);
	if(this.currentChildIndex < this.children.length-1){
		this.currentChildIndex++;
		this.play();
	}
	else{
		this.stop();
		this.broadcastMessage('onMotionFinished',{target:this,type:'onMotionFinished'});
	}
}
s.play = function(){
	this.nextObject = new Object();
	this.nextObject.onMotionFinished = Delegate.create(this, this.next);
	this.children[this.currentChildIndex].addListener(this.nextObject);
	this.children[this.currentChildIndex].start();
}
s.stop = function(){
	this.children[this.currentChildIndex].stop();
	this.broadcastMessage('onMotionStopped',{target:this,type:'onMotionStopped'});
}
s.rewind = function(){
	this.children[this.currentChildIndex].removeListener(this.nextObject);
	this.currentChildIndex = 0;
	for(var i = 0; i < this.children.length; i++){
		this.children[i].rewind();
	}
}
s.fforward = function(){
	this.children[this.currentChildIndex].removeListener(this.nextObject);
	for(var i = 0; i < this.children.length; i++){
		this.children[i].fforward();
	}
	this.currentChildIndex = this.children.length - 1;
}
s.resume = function(){
	this.children[this.currentChildIndex].resume();
	this.broadcastMessage('onMotionResumed',{target:this,type:'onMotionStopped'});
}
s.addListener = function(o){
	this.removeListener (o);
	return this._listeners.push(o);

}
s.removeListener = function(o){
	var a = this._listeners;	
	var i = a.length;
	while (i--) {
		if (a[i] == o) {
			a.splice (i, 1);
			return true;
		}
	}
	return false;
}
s.broadcastMessage = function(){
	var arr = new Array();
	for(var i = 0; i < arguments.length; i++){
		arr.push(arguments[i])
	}
	var e = arr.shift();
	var a = this._listeners;
	var l = a.length;
	for (var i=0; i<l; i++){
		if(a[i][e])
		a[i][e].apply(a[i], arr);
	}
}

var SrCmndStleEfftSequence = Sequence;





// WINDOWS
function SrCmndWndw_CloseAfter(attesa){
	window.opener.location.reload(true);
	setTimeout('SrCmndWndw_CloseNow();',attesa);
}

function SrCmndWndw_CloseNow(){
	window.opener.focus(); 
	self.close();
}





function SrCmndCart_Change(id,item,variazione){
	if(variazione==0 || variazione==''){ alert('non è stata specificata la quantità da variare'); return false; }

	// aggiorno il cookie
	var stringa=SrCmndCkes_Leggi('SrCmndCart_'+id);
	if(stringa==null) stringa='';
	if(variazione>0)
		for(var i=0;i<variazione;i++)
				stringa +=' '+item;
	if(variazione<0)
		for(var i=0;i>variazione;i--)
			if(stringa.indexOf(item)>-1){
				stringa = stringa.substr(0,stringa.indexOf(item))+' '+stringa.substr(stringa.indexOf(item)+item.length);
				}
	stringa.replace(/^\s+|\s+$/g, ''); // trim
	SrCmndCkes_Scrivi('SrCmndCart_'+id,stringa);

	// update del totale del carrello
	var i=0;
	stringa=' '+stringa+' ';
	while(stringa.indexOf(' '+item+' ')>-1){
		i++;
		stringa = stringa.substr(0,stringa.indexOf(item))+' '+stringa.substr(stringa.indexOf(item)+item.length);
	}

	// update del totale del carrello	
	document.getElementById(id+item+'Qntt').innerHTML=i;

	// update del totale del prodotto
	UpdtAjaxRqstInsr('CarrelloInfo','http://www.dagiovanna.com/LaCantina_Prodotti.php',5);

}

function SrCmndFormChckRqrd(id,oggetti){
	if(!oggetti || oggetti.length==0) return true;
	function SrCmndFormChckRqrd_Colora(ogg){
		ogg.style.backgroundColor='red';
		ogg.style.color='white';
	}
	function SrCmndFormChckRqrd_Decolora(ogg){
		ogg.style.backgroundColor='';
		ogg.style.color='';
	}
	var qnt=0;
	var modulo=document.forms[id];
	var oggetti=oggetti.split(' ');
	for(var i=0; i<oggetti.length; i++){
		var el=modulo.elements[oggetti[i]];
		if(!el) continue;
		switch(el.type){
			case 'checkbutton':
				if(el.checked==false)		{ qnt++; SrCmndFormChckRqrd_Colora(el); } else { SrCmndFormChckRqrd_Decolora(el); }
				break;
			case 'radio':
				break;
			case 'select-one':
			case 'select-multiple':
				if(el.selectedIndex==0)	{ qnt++; SrCmndFormChckRqrd_Colora(el); } else { SrCmndFormChckRqrd_Decolora(el); }
				break;
			default:
				if(el.value.length==0)	{ qnt++; SrCmndFormChckRqrd_Colora(el); } else { SrCmndFormChckRqrd_Decolora(el); }
			}
		}

	alert(qnt);
	if(qnt>1){
		alert('Ci sono '+qnt+' campi che non hai riempito.');
		return false;
	}else if(qnt==1){
		alert('C\'è '+qnt+' campo che non hai riempito.');
		return false;
	}else{
		return true;
	}
}
