/*
ARRAY ================
SrCmndArry_FromString = produce un array da una stringa; abbiamo il corrispondente PHP $_GET se passiamo 'a=1&amp;b=2', altrimenti un array degli elementi della lista 'a,b,c'
		* Struttura		SrCmndArry_FromString(Stringa);
		* Parametri:	Stringa = una query string del tipo 'a=1&amp;b=2', oppure una lista del tipo 'a,b,c,d'
		* Esempio:		string2array('nome,pippo'); 										// pruduce 1=>nome, 2=>pippo
									string2array('nome=pippo&amp;cognome=bianchi');	// produce nome=>pippo, cognome=>bianchi


CARRELLO =============
SrCmndCart_Change


CONTENUTI ============
SrCmndCntnUpdt = aggiorna con Ajax 1 elemento della pagina
		* Struttura: 	SrCmndCntnUpdt(IdTagTarget,PaginaDaChiamare,IdTag2Capture,QueryString,Mode,CallBack);
		* Parametri:	IdTagTarget = Id del tag da aggiornare; se "[callback]id" il risultato verrà restituito alla funzione passata come callback, l'id aggiuntivo permette comunque di identificare questa chiamata che altrimenti sarebbe identificata dal generico [callback]
									PaginaDaChiamare = Url relativo della pagina da richiamare, può avere la querystring se per qualche motivo usare QueryString per l'invio di parametri in post
									IdTagTarget2Capture = l'elemento da far restituire dal server, se "[thesame]" (default) verrà richiesto l'IdTagTarget, se "[all]" non sarà applicato alcun filtro dal server
									QueryString = Parametri da passare alla chiamata. Se non diversamente definito in 'Mode' il metodo sarà POST 
									Mode = Stringa dove la presenza di parametri attiva delle opzioni:
										[viapost](default)/[viaget] = imposto il metodo della richiesta. Il post non implica che non si possa richiamare una pagina con querystring 
										[progressinlinetxt] = testo "loading..." dentro il tag, si annulla dopo 5 sec.
										[progressinlineimg] = immagine dentro il tag, si annulla dopo 5 sec.
										[progressinoverlay] = crea un overlay con progress e bottone [annulla]
										[attesamassimaXsec] = dove X indica i secondi limite, altrimenti 15 sec è default
									CallBack = eventuale funzione da eseguire al termine del caricamento
		* Risultato:	false = se la chiamata non è partita per qualche problema (questo risultato è l'unica certezza)
									true = la chiamata è partita
		* Esempio1:		<a href="test.htm" onclick="return SrCmndCntnUpdt('boxBody','test.htm','[thesame]','','[progressinoverlay]');">....
		* Esempio2:		USARE AL VOLO il valore recuperato: non è possibile usare il return perchè la funzione viene terminata quando in realtà gli handler sono ancora attivi. Quindi passiamo come callback la funzione che deve usare il valore, e indichiamo al callback di usare il risultato della chiamata mettendo "[callback]id" come TargetId
									SrCmndCntnUpdt('[callback]001','carrello.php?exe=saldo','[all]','prodotto=3124','[viaget][progressinoverlay]',function(x){alert(x);}));
		* Esempio3:		ANNULLARE una richiesta: a meno che non si tenga traccia globale di tutte queste chiamate è impossibile rientrarci dentro per chiuderle, quindi ci limitiamo a togliere la protezione visibile (nelle altre non c'è possibilità di annullare) ed il TargetId tra le chiamate aperte, così ogni effetto di tale chiamata aperta sarà inefficace ogni produzione di output verifica sempre tale stringa
									<input type="button" onclick="SrCmndWndwOvrl('Close');AjaxAprt=AjaxAprt.replace('['+IdTagTarget+']','');" value="annulla richiesta ajax" />
		
COOKIE ===============
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; l'utilità è nella definizione di una corretta sequenza di eseguzione, senza tuttavia attendere il completamento degli effetti
		* 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); 

FORM =================
SrCmndFormVldz = esegue le validazioni sui form, restituisce TRUE o FALSE a seconda dell'esito
		* Struttura:	SrCmndFormVldz(id,msg,RlesNeed,RlesType,RlesQntt,RlesQntM,RlseRnge,RlseRngM);
		* Parametri:	id											= id del form: 'ordine'
									msg											= array associativo (Need,TypE,TypN,TypD,Qntt,QntM,Rnge,RngM) javascript con i testi dei vari messaggi
									RlesNeed								= stringa con i nomi dei campi da richiedere: 'nome,email,cel'
									RlesType								= query string (&amp;) con i generi da verificare: 'Emil=email&amp;Cell=numero&amp;Nascita=data'
									RlesQntt / RlesQntM			=	query string (&amp;) con i limiti di conteggio(checkbox)/lunghezza(stringa): 'pin=5'
									RlseRnge / RlseRngM			= query string (&amp;) con i limiti dai valori: 'Eta=0' e 'Eta=120'
		* Esempio:		onsubmit=" return SrCmndFormVldz(id,msg,RlesNeed,RlesType,RlesQntt,RlesQntM,RlseRnge,RlseRngM); "

IMMAGINI =============
SrCmndImmg_Change = cambia il src di una immagine con effetto fading (SrCmndStleEfftFadingTo); la seconda immagine parte solo quando è caricata, e di default solo dopo che la prima è scomparsa, con parametro 'Crossing' invece se ne frega e può generare una sovrapposizione di effetti
		* Struttura:	SrCmndImmg_Change(id,urla[,fade[,sec]])
		* Parametri:	id = id dell'immagine (non so se deve avere un width) 
									urla = url assoluto della nuova immagine
									fade = 'Separate' (default) se i fading sono in sequenza, 'Crossing'se i fading sono incrociati
									sec = durata della transazione in secondi (default = 1.6sec)
		* Esempio:		SrCmndImmg_Change('RiquadroFoto','http://www.sito.it/foto3.jpg');		
									SrCmndImmg_Change('SrTmplLyot_BaseR2C2_Foto',picts[n-1],'Crossing',2.5);
		* Modello Separate:
									<div id="SrTmplLyot_BaseR2C2">
									<img id="SrTmplLyot_BaseR2C2_Foto" 			src="<?php	echo $SrCnfg['Path']['Esterne']['Templates'] ?>SrTmplImmg_Trasparente.gif" alt="foto" />
									</div>
									#SrTmplLyot_BaseR2C2							{ position:relative; height:380px; width:500px; text-align:center; overflow:hidden; background:url(SrTmplMenu_Loading.gif) no-repeat Xpx Ypx}
									#SrTmplLyot_BaseR2C2_Foto					{ position:absolute; top:0px; left:0px; z-index:4; }
		* Modello Crossing:
									<div id="SrTmplLyot_BaseR2C2">
									<img id="SrTmplLyot_BaseR2C2_FotoBack" 	src="<?php	echo $SrCnfg['Path']['Esterne']['Templates'] ?>SrTmplImmg_Trasparente.gif" alt="foto" />
									<img id="SrTmplLyot_BaseR2C2_Foto" 			src="<?php	echo $SrCnfg['Path']['Esterne']['Templates'] ?>SrTmplImmg_Trasparente.gif" alt="foto" />
									</div>
									#SrTmplLyot_BaseR2C2							{ position:relative; height:380px; width:500px; text-align:center; overflow:hidden;  background:url(SrTmplMenu_Loading.gif) no-repeat Xpx Ypx}
									#SrTmplLyot_BaseR2C2_Foto					{ position:absolute; top:0px; left:0px; z-index:4; }
									#SrTmplLyot_BaseR2C2_FotoBack			{ position:absolute; top:0px; left:0px; z-index:3; }
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');
SrCmndImmg_Protect = accoda dei listener di protezione alle immagini che controllano gli eventi su di essi
		* Struttura:	SrCmndImmg_Protect(Msg,Id1,Id2,Id3,...);
		* Parametri:	Msg = testo di protezione;
									Parameters = id delle immagini da proteggere
		* Esempio:		SrCmndImmg_Protect('Alt!'); // protegge tutte le immagini del documento
									SrCmndImmg_Protect('Alt!','img10','img12'); // protegge le 2 immagini indicate dal rispettivo id


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();


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 (numero) di opacity da raggiungere (default = 0 = trasparente, max=100)
									sec = durata (numero) del passaggio in secondi (default = 0.8sec)
									callback = la funzione da eseguire al termine
		* Esempio:		SrCmndStleEfftFadingTo('RiquadroCommento', '', '', function(){ document.getElementById('RiquadroCommento').innerHMTL='titolo'; } );
		* Attenzione:	se l'opacità non è definita precedentemente c'è il rischio di produrre strani flash, quindi un valore di partenza è sempre bene definirlo, con CSS o meglio con questa funzione; se faccio FadeTo(100) ad una immagine visibile ma priva di CSS lui non sa da quanto si parte e fa strani effetti
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(); = corre come definito
									.stop(); = si ferma
									.resume(); = riprende dal punto corrente a correre come definito
									.rewind(); .fforward(); = stop + vai a inizio/fine corsa
									.continueTo(end,duration); = stop il movimento in corso + ridefinisce dal punto corrente a quello specificato + start
									.yoyo(); = ridefinisce il movimento, ribaltandolo dal punto corrente a quello che era l'inizio + start
		* Events:			.onMotionStarted=eventObject; .onMotionChanged=eventObject; .onMotionFinished=eventObject; (finito=quando arriva al termine del percorso)
									.onMotionStopped=eventObject; .onMotionLooped=eventObject; .onMotionResumed=eventObject;
		* ToKnow:			http://jstween.blogspot.com/
									http://codepunk.hardwar.org.uk/css2js.htm (Css2Js)
									la definizione degli effetti ripesca gli oggetti interessati, che quindi devono essere presenti prima di tale definizione
									Gli effetti Tween, anche se di durata 0sec non possono essere scritti in sequenza, finisce che si sovrappongono e realizzano l'effetto a scatto o per niente (Chrome e Safari).
									Quindi è opportuno annidare il tutto con l'uso di Parallel o Sequence (http://www.powerping.be/js/jstween/sequence_.html), con l'unico vincolo che si possono solo aggiungere altri effetti Tween e non sembra altre funzioni scritte inline, in quanto non riesce a creare i Listener se non su effetti Tween
									In alternativa, annidare con "callback" che non si sbaglia mai...
		* Esempio:		t1A = new SrCmndStleEfftTween(document.getElementById('sqA').style,'left',Tween.elasticEaseOut,0,500,1,'px');
									t1A.onMotionFinished = function(){alert( 'onMotionFinished' )};
									t1A.start();
		* Advanced		[Usando addListener] =====
									.addListener=listenerObject; .removeListener=listenerObject;
									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();
SrCmndStleEfftParallel = avvia degli effetti in parallelo
SrCmndStleEfftSequence = avvia degli effetti in sequenza, ogni effetto aspetta la fine del precedente
		* Avvertenza:	funziona per accodare solo oggetti Tween e non altre funzioni o funzioni costruite sui Tween
		* Metodi:			.addChild(oggetto Tween); .removeChild(oggetto Tween);
		* Esempio:		var my_seq = new SrCmndStleEfftSequence();
									my_seq.addChild(new Tween(elem1.style,'width',Tween.bounceEaseOut,25,100,0.5,'px')); // è importante il new!!!
									my_seq.addChild(new Tween(elem2.style,'width',Tween.bounceEaseOut,25,100,0.5,'px'));
									my_seq.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();

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();
SrCmndWndw_GetDocumentSize = restituisce la dimensione della pagina, considerando sia lo scroll sia la possibilità che body sia inferiore alla dimensione del monitor
		* Struttura:	SrCmndWndw_GetDocumentSize(asse); 
		* Parametri:	asse = quale dimensione si desidera 'x' o 'y' (default)
		* Esempio:		width=SrCmndWndw_GetDocumentSize('x')+"px";
SrCmndWndw_GetVisibleSize = restituisce la dimensione della parte visibile della pagina html
		* Struttura:	SrCmndWndw_GetVisibleSize(asse); 
		* Parametri:	asse = quale dimensione si desidera 'x' o 'y' (default)
		* Esempio:		width=SrCmndWndw_GetVisibleSize('x')+"px";
SrCmndWndwOvrl = gestisce una maschera in overlay stile Lightbox 
		* Struttura:	SrCmndWndwOvrl(Action,Content);
		* Parametri:	Action = 'Close' chiude l'overlay, 'Open' la apre o comunque aggiorna con i nuovi contenuti
									Content = il codice html da caricare dentro il box, se 'blank' lascia vuoto, se vuoto inserisce un loading standard con la possibilità di chiudere 
		* Risultato:	true = viene fatto, false = c'è un errore
		* Attenzione:	la presenza di "<!--[SrCmndWndwOvrlContentWidth]=300-->" all'interno di Content determinerà la larghezza del box, altrimenti si adeguerà al contenuto ma con risultati dubbi ed incerti
									è per esclusione il modo più sicuro, poichè il problema era che un div avrà sempre la massima larghezza, o se non è così, comunque il contenuto influisce sull'altezza ma non sulla larghezza
		* Esempio:		<input type="button" onclick="SrCmndWndwOvrl('Close');" value="close" />
*/





// ARRAY
function SrCmndArry_FromString(stringa){
	// se è query string
	if(stringa.indexOf('=')>-1){
		var records=stringa.split('&amp;'); 
		var matrice=new Array();
		for(var i=0; i<records.length; i++){
			var record=records[i].split("="); 
			matrice[record[0]]=record[1];
			}
	// se è lista
	}else{
		var records=stringa.split(','); 
		var matrice=new Array();
		for(var i=0; i<records.length; i++){
			matrice[matrice.length]=records[i];
			}
	}
	return matrice;
}


// CARRELLO
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
	SrCmndMenuUpdt('CarrelloInfo',location.href,5);

}


// CONTENUTI
function SrCmndCntnUpdt(IdTagTarget,PaginaDaChiamare,IdTag2Capture,QueryString,Mode,CallBack) {

	// CHECK TAG TARGET
	if(IdTagTarget==null || IdTagTarget==''){alert('Errore da segnalare.\nElemento target non definito.');return false;}
	else if(IdTagTarget.indexOf('[callback]')==-1 && document.getElementById(IdTagTarget)==null){alert('Errore da segnalare.\nElemento \''+IdTagTarget+'\' non trovato.');return false;}
	else if(IdTagTarget.indexOf('[callback]')>-1 && CallBack==null){alert('Errore da segnalare.\CallBack non definita.');return false;}
	
	// CHECK ALTRI PARAMETI
	var PaginaDaChiamare=PaginaDaChiamare||'';
	var IdTag2Capture=IdTag2Capture||'[thesame]';
	var QueryString=QueryString||'';
	var Mode=Mode||'';

	// CHECK COMPATIBILITA': verifichiamo la compatibilità e definiamo l'oggetto "AjaxRqst" per le chiamate Ajax a seconda del browser
	var AjaxSppr = false;
	var AjaxRqst = new Object();
	var	BrwsNome = navigator.userAgent.toUpperCase();
	if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object"){
			AjaxSppr = true;
			AjaxRqst = new XMLHttpRequest(); }
	else if(window.ActiveXObject && BrwsNome.indexOf("MSIE 4") < 0){
			AjaxSppr = true;
		if(BrwsNome.indexOf("MSIE 5") < 0)
			AjaxRqst = new ActiveXObject("Msxml2.XMLHTTP");
		else
			AjaxRqst = new ActiveXObject("Microsoft.XMLHTTP");
		}
	if(AjaxSppr==false){
		return false;
	}

	// ANTI-DOUBLE CLICK: "AjaxAprt" è una stringa (non locale) con i nomi dei tag in fase di aggiornamento, cioè con richiesta Ajax aperte
	if(typeof(AjaxAprt)=='undefined') AjaxAprt="";
	if(AjaxAprt.indexOf("["+IdTagTarget+"]")!=-1) return true;
	else AjaxAprt += "["+IdTagTarget+"]";

	// PROGRESS
	if(Mode.indexOf('[progressinoverlay]')>-1){
		var Content = '<!--[SrCmndWndwOvrlContentWidth]=200--><p style="text-align:center;color:#222;font-weight:bold;font-size:20px;font-family:\'Trebuchet MS\',Arial;">Loading</p><div style="margin:5px 0px 10px;float:left;"><img src="'+SrTmplUrlA+'SrTmplMenu_Loading02_198x3.gif" style="float:left;width:198px;height:3px;margin-left:4px;" alt="" /><img src="'+SrTmplUrlA+'SrTmplMenu_Loading02_198x3.gif" style="float:left;width:198px;height:3px;margin-left:2px;" alt="" /><img src="'+SrTmplUrlA+'SrTmplMenu_Loading02_198x3.gif" style="float:left;width:198px;height:3px;" alt="" /></div><input type="button" onclick="SrCmndWndwOvrl(\'Close\'); 	AjaxAprt=AjaxAprt.replace(\'['+IdTagTarget+']\',\'\');" value="annulla" style="margin:5px;cursor:pointer;font-size:11px;border:1px solid #888;color:#777;background-color:#bbb;font-family:\'Trebuchet MS\',Arial;" />';
		SrCmndWndwOvrl('Open',Content);
	}else if(SrTmplUrlA && Mode.indexOf('[progressinlineimg]')>-1){
		var AjaxHtmlOld=document.getElementById(IdTagTarget).innerHTML;
		document.getElementById(IdTagTarget).innerHTML='<img src="'+SrTmplUrlA+'SrTmplMenu_Loading03_16x9.gif" alt="loading..." title="" style="width:16px; height:9px;" />';	
	}else	if(Mode.indexOf('[progressinlinetxt]')>-1){
		var AjaxHtmlOld=document.getElementById(IdTagTarget).innerHTML;
		var AjaxPrgrPntiCntt=0;
		var AjaxPrgrPntiFnzn=function(){ AjaxPrgrPntiCntt++; document.getElementById(IdTagTarget).innerHTML='loading...'.substring(0,(7+(AjaxPrgrPntiCntt%3))); };
		var AjaxPrgrPntiTmer=setInterval(AjaxPrgrPntiFnzn,500);
	} // if progesss

 	// CHECKER (timer & status)
	var AjaxTimeChckTmer; // sta fuori perchè deve essere una variabile collegata alla chiamata principale
	var AjaxChckStop=function(){
		// quando succede qualcosa (timeout o richiesta fallita) dobbiao interrompere il timer ed il controllo di stato, poi lanciando AjaxRsltExe verrà anche deciso cosa fare con le protezioni
		if(typeof(AjaxTimeChckTmer)!='undefined') clearTimeout(AjaxTimeChckTmer); // elimino il controllo del tempo
		AjaxRqst.onreadystatechange = function(){}; // inibisco il checker sullo stato
		}; // function checker
	var AjaxChckStart=function(){
	  // TIMER: funzione con attesa standard 15sec.
		if(Mode.indexOf('[attesamassima')>-1){ var txt=Mode.substring(Mode.indexOf('[attesamassima')+14); txt=txt.substring(0,txt.indexOf('sec]')); AttesaMassimo=parseInt(txt); }
		var ChiamataData = new Date();
	  var ChiamataOra = ChiamataData.getTime();
		if(!AttesaMassima)	var AttesaMassima=15000;	else	AttesaMassima*=1000;
		var AjaxTimeChckFnzn=function(){ var AttesaData=new Date(); if((AttesaData.getTime()-ChiamataOra)>AttesaMassima) {AjaxChckStop();AjaxRsltExe(504);} }
		AjaxTimeChckTmer=setInterval(AjaxTimeChckFnzn,500);
		// STATUS: organizzo i comportamenti dell'oggetto ajax (4=concluso)
	  AjaxRqst.onreadystatechange = function() {if(AjaxRqst.readyState === 4){AjaxChckStop();AjaxRsltExe(AjaxRqst.status);} }
		}; // function checker

	// RESULT
	var AjaxRsltExe=function(esito){
		// esito: 200=ok, {altro}=errore ma chiedi cosa fare
		// ATTENZIONE: la proprietà "status" non è sempre disponibile, infatti IE la crea solo a conclusione della chiamata
		// IMPORTANTE: ogni azione che può produrre effetti esterni deve prima verificare che la chiamata sia ancora tra quelle attive. C'è possibilità che l'utente con [annulla] non voglia proseguire.

		// Unico caso in cui ricominciamo: ci sono stati problemi e l'utente vuole riprovare
		if(esito!=200 && AjaxAprt.indexOf('['+IdTagTarget+']')>-1){if(window.confirm('Operazione fallita (errore '+esito+').\nDesideri riprovare?')){AjaxChckStart();AjaxRqstSend();return true;}}

		// In tutti gli altri casi chiudiamo
		// - progress
		if(typeof(AjaxPrgrPntiTmer)!='undefined') clearTimeout(AjaxPrgrPntiTmer); // elimino il movimento dei punti di loading
		if(Mode.indexOf('[progressinoverlay]')>-1 && AjaxAprt.indexOf('['+IdTagTarget+']')>-1) SrCmndWndwOvrl('Close');
		// - result: se gli effetti sono ancora voluti dall'utente...
		if(AjaxAprt.indexOf('['+IdTagTarget+']')>-1) if(esito==200){
			//abbiamo una risposta valida
			if(IdTagTarget.indexOf('[callback]')>-1) {if(CallBack!=null) CallBack.apply(this,AjaxRqst.responseText);}
			else{document.getElementById(IdTagTarget).innerHTML=AjaxRqst.responseText; if(CallBack!=null) CallBack.call(this);}
		}else{ 
			//non c'è alcuna riposta valida, ripristino i precedenti contenuti se tolti
			if(Mode.indexOf('[progressinlineimg]')>-1 || Mode.indexOf('[progressinlinetxt]')>-1) document.getElementById(IdTagTarget).innerHTML= AjaxHtmlOld;
		}
		// - protezione
		AjaxAprt=AjaxAprt.replace('['+IdTagTarget+']',''); // pulisco il tag dalla stringa dei processi aperti
		// - istanza
		//AjaxRqst.abort(); //cancella tutto dalla ram - tolto perchè su IE stoppava il javascript
	}; //function

	// SENDER
	var AjaxRqstSend=function(){
	  // invio richiesta usando 'post' perchè il parametro che attiva il filtro lato server è in 'post'
    // il 'post' passa parametri dentro il metodo send, il 'get' vuole send(null) ed i parametri saranno passati nell'url
		var AjaxRqstPrmtGett='';
		var AjaxRqstPrmtPost=(IdTag2Capture=='[all]') ? '' : (IdTag2Capture=='[thesame]') ? ('ajax='+IdTagTarget) : ('ajax='+IdTag2Capture);
		if(QueryString.length>0 && Mode.indexOf('[viaget]')==-1)	AjaxRqstPrmtPost+='&'+QueryString;
		if(QueryString.length>0 && Mode.indexOf('[viaget]')>-1)		AjaxRqstPrmtGett=((QueryString.indexOf('?')>-1)?('&'):('?'))+QueryString;
		AjaxRqst.open('POST', PaginaDaChiamare+AjaxRqstPrmtGett, true);    // il terzo parametro imposta richiesta asincrona in GET del file specificato
		if(typeof(AjaxRqst.timeout)!='undefined') AjaxRqst.timeout=60000; // IE gestisce il timeout, e per evitare che sia più corto del mio (causando l'abort e quindi cancellazione di tutto) lo setto ad un limite alto di 60sec
		AjaxRqst.setRequestHeader("connection", "close");    // rimozione dell'header "connection" come "keep alive"
		AjaxRqst.setRequestHeader("content-type", "application/x-www-form-urlencoded");	// necessario per l'invio di variabili con POST
		AjaxRqst.send(AjaxRqstPrmtPost); // invio richiesta
	}; // sender function

	// EXE
	AjaxChckStart();
	AjaxRqstSend();
	return true;
}


// 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;'); 
}


// FORM
function SrCmndFormVldz(id,msg,RlesNeed,RlesType,RlesQntt,RlesQntM,RlseRnge,RlseRngM){
	// Rules: Need, Type, Quantità min/Max, Range min/Max
	if(!RlesNeed && !RlesType && !RlesQntt && !RlesQntM && !RlseRnge && !RlseRngM) return true;
	// Flag
	function SrCmndFormChck_Colora(ogg){
		ogg.style.backgroundColor='red';
		ogg.style.color='white';
	}
	function SrCmndFormChck_Decolora(ogg){
		ogg.style.backgroundColor='';
		ogg.style.color='';
	}
	function SrCmndFormChck_Flagga(id){
		id=id.replace("[]","");
		document.getElementById('Form_Alert_ArrowRedRight_'+id).style.display='inline';
	}
	function SrCmndFormChck_Deflagga(id){
		id=id.replace("[]","");
		document.getElementById('Form_Alert_ArrowRedRight_'+id).style.display='none';
	}
	// Verifiche
	var modulo=document.forms[id];
	// 1)necessari
	if(RlesNeed){if(RlesNeed.length>0){
		var qnt=0;
		var oggetti=SrCmndArry_FromString(RlesNeed);
		for(var i=0; i<oggetti.length; i++){
			var el=modulo.elements[oggetti[i]];
			if(!el) el=modulo.elements[oggetti[i]+'[]']; // se non trovo forse è perchè è un checkbox
			if(!el) continue;
			switch(el.type){
				case 'checkbox':
				case 'radio':
					if(el.length==undefined){
						if(el.checked==false)		{ qnt++; SrCmndFormChck_Flagga(el.name); } else { SrCmndFormChck_Deflagga(el.name); }
					}else{
						var qnt2=0; for(var j=0; j<el.length; j++) if(el[j].checked==true) qnt2++;
						if(qnt2==0){SrCmndFormChck_Flagga(el[0].name); qnt++; }
									else {SrCmndFormChck_Deflagga(el[0].name); }
					}
					break;
				case 'select-one':
				case 'select-multiple':
						if(el.selectedIndex==0)	{ qnt++; SrCmndFormChck_Colora(el); } else { SrCmndFormChck_Decolora(el); }
					break;
				default:
						if(el.value.length==0)	{ qnt++; SrCmndFormChck_Colora(el); } else { SrCmndFormChck_Decolora(el); }
				}
		}}
		//	alert
		if(qnt>0){
			alert(msg['Need']);
			return false;
		}
	}
	// 2)genere
	if(RlesType){if(RlesType.length>0){
		var oggetti=SrCmndArry_FromString(RlesType);
		// 2.1) email
		var qnt=0;
		var Filtro = /^([a-z0-9_\.\-])+\@(([a-z0-9\-]{2,})+\.)+([a-z0-9]{2,})+$/i;
		for(var i in oggetti){
			el=modulo.elements[i];	if(!el) continue;
			if(oggetti[i]=='email'){
				if(!Filtro.test(el.value))
					{ qnt++; SrCmndFormChck_Colora(el); } else { SrCmndFormChck_Decolora(el); }
			}
		}
		if(qnt>0){
			alert(msg['TypE']);
			return false;
			}
		// 2.2) numeri				
		var qnt=0;
		var Filtro = /^([0-9\.\,])+$/;
		for(var i in oggetti){
			el=modulo.elements[i];	if(!el) continue;
			if(oggetti[i]=='numero'){
				if(!Filtro.test(el.value))
					{ qnt++; SrCmndFormChck_Colora(el); } else { SrCmndFormChck_Decolora(el); }
			}
		}
		if(qnt>0){
			alert(msg['TypN']);
			return false;
			}
		// 2.3) data
		var qnt=0;
		var Filtro = /^([0-9\.\/\-])+$/;
		for(var i in oggetti){
			el=modulo.elements[i];	if(!el) continue;
			if(oggetti[i]=='data'){
				if(!Filtro.test(el.value))
					{ qnt++; SrCmndFormChck_Colora(el); } else { SrCmndFormChck_Decolora(el); }
			}
		}
		if(qnt>0){
			alert(msg['TypD']);
			return false;
			}
	}}
	// 3)Quantità
	if(RlesQntt){if(RlesQntt.length>0){

	}}
	if(RlesQntM){if(RlesQntM.length>0){

	}}
	// 4)Range
	if(RlseRnge){if(RlseRnge.length>0){

	}}
	if(RlseRngM){if(RlseRngM.length>0){

	}}

	return true;
}


// IMMAGINI
function SrCmndImmg_Change(id,urla,fade,sec){
	sec = sec || 1.8;
	fade = fade || 'Separate';
	if(fade=='Crossing'){
		document.getElementById(id+"Back").style.left= (document.getElementById(id).parentNode.offsetWidth  - document.getElementById(id).offsetWidth)/2  +"px";
		document.getElementById(id+"Back").style.top=  (document.getElementById(id).parentNode.offsetHeight - document.getElementById(id).offsetHeight)/2 +"px";
		document.getElementById(id+"Back").src = document.getElementById(id).src;
		SrCmndStleEfftFadingTo(id+"Back",100,0, function(){
			SrCmndStleEfftFadingTo(id,0,0, function(){
				SrCmndStleEfftFadingTo(id+"Back",0,sec);
				document.getElementById(id).onload= function(){
					document.getElementById(id).style.left= (document.getElementById(id).parentNode.offsetWidth  - document.getElementById(id).offsetWidth)/2  +"px";
					document.getElementById(id).style.top= 	(document.getElementById(id).parentNode.offsetHeight - document.getElementById(id).offsetHeight)/2 +"px";
					SrCmndStleEfftFadingTo(id,100,sec);
					};
				document.getElementById(id).src = urla;
			});
		});
	}else{
		var SrCmndImmg_Temp=new Image();
		SrCmndImmg_Temp.src=urla;
		SrCmndStleEfftFadingTo(id,0,sec/2,function(){
			document.getElementById(id).onload= function(){
				document.getElementById(id).style.left= (document.getElementById(id).parentNode.offsetWidth  - document.getElementById(id).offsetWidth)/2  +"px";
				document.getElementById(id).style.top= 	(document.getElementById(id).parentNode.offsetHeight - document.getElementById(id).offsetHeight)/2 +"px";
				SrCmndStleEfftFadingTo(id,100,sec/2);
				};
			document.getElementById(id).src=SrCmndImmg_Temp.src;
		});
	}
}
function SrCmndImmg_Load(){
	if(typeof(SrCmndImmg_Array)=='undefined') var 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];
		}
}
function SrCmndImmg_Protect(msg){
	msg= msg || 'Copyrights';
	if(typeof(document.images)=='undefined') return true;
	// funzione di blocco
	function SrCmndImmg_Protect_block(e){
		if(window.event) rightButton=(window.event.button==2); else rightButton=(e.which==3);
		if(rightButton){ alert(msg);return false; }
	}
	// funzione di accodo degli eventi
	function SrCmndImmg_Protect_addEventListener(obj){
		SrCmndEvnt_Add(obj,'mousedown',SrCmndImmg_Protect_block);
		// previene il menu in FF
		SrCmndEvnt_Add(obj,'mouseup',function(){return false});
		// previene il menu in FF nonostante l'impostazione dell'utente di non lasciare personalizzare il menu
		SrCmndEvnt_Add(obj,'click',function(e){if(e.preventDefault) e.preventDefault(); e.returnValue=false; return false;});
	}
	// ritocchiamo tutte le immagini del documento se non ci sono immagini passate (id) come argomento
	if(arguments.length>1){
    for(var i=1;i< arguments.length;i++)
			if(document.getElementById(arguments[i]))
	    	SrCmndImmg_Protect_addEventListener(document.getElementById(arguments[i]));
	}else{
    for(var i=0;i< document.images.length;i++)
    		SrCmndImmg_Protect_addEventListener(document.images[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;
}


// 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
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.
	// Per ogni elemento creo l'oggetto globale {id}_EfftFade così posso stopparlo prima di modificare il suo movimento.
	// Precedentemente avevo usato continueTo per modificare effetti già creati invece che definirli exnovo. Ma in questo approccio corretto c'è un bug tecnico: se l'elemento viene eliminato e poi ricreato, l'oggetto {id}_EfftFade rimane associato al primo elemento che non c'è più, quindi ogni effetto non avrà effetti 
	
	// imposto i valori di default
	val = val || 0; 
	sec = sec || 0.8;
	// se un effetto esiste già lo fermo per evitare casini in fase di ridefinizione del movimento
	eval(' if(typeof('+id+'_EfftFade)!=\'undefined\') '+id+'_EfftFade.stop(); ');
	// ridefinisco il movimento dallo stato attuale
	var start=100*SrCmndStlePrprGet(id,'opacity'); eval(id+'_EfftFade = new SrCmndStleEfftFade(document.getElementById(\''+id+'\'),Tween.regularEaseIn,'+start+','+val+','+sec+');');
	// creo la scorciatoia/riferimento ed importo il callback
	eval('var Ogg='+id+'_EfftFade;');
	Ogg.onMotionFinished = function(){
		Ogg.onMotionFinished = undefined;
		if(callback!=null) callback.call(this);
		}
	// start
	Ogg.start();
}
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 + ")"; 
}


// WINDOWS
function SrCmndWndw_CloseAfter(attesa){
	window.opener.location.reload(true);
	setTimeout('SrCmndWndw_CloseNow();',attesa);
}
function SrCmndWndw_CloseNow(){
	window.opener.focus(); 
	self.close();
}
function SrCmndWndw_GetVisibleSize(asse){
	if(asse=='x' || asse=='X'){
		var viewX = self.innerWidth ?	self.innerWidth : (document.documentElement&&document.documentElement.clientWidth) ? document.documentElement.clientWidth :  document.body ? document.body.clientWidth : 0;
		return viewX;
	}else{
		var viewY = self.innerHeight ? self.innerHeight : (document.documentElement&&document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body ? document.body.clientHeight : 0;
		return viewY;
	}
}
function SrCmndWndw_GetDocumentSize(asse){
	if(asse=='x' || asse=='X'){
		var pageX = (window.innerWidth && window.scrollMaxX) ? (window.innerWidth+window.scrollMaxX) : (document.body.scrollWidth > document.body.offsetWidth) ? document.body.scrollWidth : (document.body.scrollWidth && document.body.scrollWidth) ? document.body.scrollWidth :	document.body.offsetWidth;
		var viewX = SrCmndWndw_GetVisibleSize('x');
		return ((pageX<viewX)?(viewX):(pageX));
	}else{
		var pageY = (window.innerHeight && window.scrollMaxY) ? (window.innerHeight+window.scrollMaxY) : (document.body.scrollHeight > document.body.offsetHeight) ? document.body.scrollHeight : (document.body.scrollHeight && document.body.scrollHeight) ? document.body.scrollHeight : document.body.offsetHeight;
		var viewY = SrCmndWndw_GetVisibleSize('y');
		return ((pageY<viewY)?(viewY):(pageY));
	}
}
function SrCmndWndwOvrl(Action,Content){
	//note: l'effetto FadingTo andrebbe applicato in parallelo, ma questo è possibile solo con gli oggetti Tween
	//note: i box non possono stare uno dentro l'altro perchè hanno una diversa opacità
	//alberatura:
	// -Protection (zindex=100)
	// -Hole (zindex=101,overflow=hidden perchè il frame è in realtà sotto lo shadow)
	// ---Shadow
	// ---Frame
	// -----Control
	// -----Content
	if(Action==null || (Action!='Close' && Action!='Open')){alert('Errore da segnalare.\nAction in WndwOvrl errato.');return false;} 
	var Content = Content || ''; // se non viene passato definiamo che è comunque una stringa vuota
	var d=document,
			e1=d.getElementById('WndwOvrlProtection'),
			e2=d.getElementById('WndwOvrlHole')
	//parametri di dafault
	if(typeof(SrCmndWndwOvrlPrmt)=='undefined')	SrCmndWndwOvrlPrmt={Padding:10,Margin:10,Top:20,FirstWidth:50,FirstHeight:5,RequestedWidth:0}
	//anti-doubleclick
	if(typeof(SrCmndWndwOvrlMotionStatus)=='undefined') SrCmndWndwOvrlMotionStatus=1;
	else if(SrCmndWndwOvrlMotionStatus==1){ if(Action=='Close') setTimeout("SrCmndWndwOvrl('Close');",300); return false; } // se un movimento è in corso chiudo qui, tuttavia se è stato chiesto di chiudere (e quindi molto probabilmente si sta ancora aprendo se c'è un movimento) rilancio il comando di chiusura poco dopo
	else SrCmndWndwOvrlMotionStatus=1;
	//actions
	if(Action=='Close' && e1!=null){
		window.onresize='';
		SrCmndStleEfftFadingTo('WndwOvrlProtection',0,0.2,function(){e1.parentNode.removeChild(e1);SrCmndWndwOvrlMotionStatus=0;});
		SrCmndStleEfftFadingTo('WndwOvrlHole',0,0.2,function(){e2.parentNode.removeChild(e2);SrCmndWndwOvrlMotionStatus=0;});
	}else if(Action=='Open'){
		//definisco gli step
		var step1=function(callback){ // crea
			// creo gli elementi
			var e,
					d=document,
					OvrlProtection 	= d.createElement('div'),
					OvrlHole 				= d.createElement('div'),
					OvrlShadow 			= d.createElement('div'),
					OvrlFrame 			= d.createElement('div'),
					OvrlContent 		= d.createElement('div')
			OvrlProtection.setAttribute('id','WndwOvrlProtection');
			OvrlHole.setAttribute('id','WndwOvrlHole');
			OvrlShadow.setAttribute('id','WndwOvrlShadow');
			OvrlFrame.setAttribute('id','WndwOvrlFrame');
			OvrlContent.setAttribute('id','WndwOvrlContent');
			// li colloco
			d.getElementsByTagName('body')[0].appendChild(OvrlProtection);
			d.getElementsByTagName('body')[0].appendChild(OvrlHole);
			d.getElementById('WndwOvrlHole').appendChild(OvrlShadow);
			d.getElementById('WndwOvrlHole').appendChild(OvrlFrame);
			d.getElementById('WndwOvrlFrame').appendChild(OvrlContent);
			// stile OvrlHole
			with(d.getElementById('WndwOvrlHole').style){
				position='absolute';
				display='block';
				zIndex='101';
				width=SrCmndWndw_GetVisibleSize('x')-10+'px'; //tolgo 10 così evito che lo sbordare permetta ulteriori scroll orizzontali
				left = (window.pageXOffset ? window.pageXOffset : document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) +'px';
				top =  SrCmndWndwOvrlPrmt.Top + (window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) +'px';
				textAlign='center';
				}
			// stile OvrlShadow
			with(d.getElementById('WndwOvrlShadow').style){
				margin='0px auto';
				width=SrCmndWndwOvrlPrmt.FirstWidth+(SrCmndWndwOvrlPrmt.Margin*2)+(SrCmndWndwOvrlPrmt.Padding*2)+'px';
				height=SrCmndWndwOvrlPrmt.FirstHeight+(SrCmndWndwOvrlPrmt.Margin*2)+(SrCmndWndwOvrlPrmt.Padding*2)+'px';
				background='#000';
				}
			// stile OvrlFrame
			with(d.getElementById('WndwOvrlFrame').style){
				position='relative';
				top=-SrCmndWndwOvrlPrmt.Margin-(SrCmndWndwOvrlPrmt.Padding*2)-SrCmndWndwOvrlPrmt.FirstHeight+'px';
				margin='0px auto';
				padding=SrCmndWndwOvrlPrmt.Padding+'px';
				width=SrCmndWndwOvrlPrmt.FirstWidth+'px';
				height=SrCmndWndwOvrlPrmt.FirstHeight+'px';
				background='#fff';
				overflow='hidden';
				textAlign='center';
				}
			// stile OvrlProtection (ho posizionato dopo il frame perchè quest'ultimo durante la creazione può allungare la pagina...ma lasciando la protezione alla precedente misura)
			with(document.getElementById("WndwOvrlProtection").style){
				width="100%";
				position='absolute';
				zIndex='100';
				top='0px';
				left='0px';
				backgroundColor='#000';
				height=SrCmndWndw_GetDocumentSize('y')+"px";
				}
			// resize
			window.onresize=function(){
				d.getElementById('WndwOvrlProtection').style.width=SrCmndWndw_GetDocumentSize('x')+"px";
				d.getElementById('WndwOvrlProtection').style.height=SrCmndWndw_GetDocumentSize('y')+"px";
				d.getElementById('WndwOvrlHole').style.width=SrCmndWndw_GetVisibleSize('x')+'px';
			}
			// opacità
			SrCmndStleEfftOpacity('WndwOvrlProtection',0);
			SrCmndStleEfftOpacity('WndwOvrlHole',0);
			SrCmndStleEfftOpacity('WndwOvrlShadow',0);
			SrCmndStleEfftOpacity('WndwOvrlFrame',0);
			SrCmndStleEfftOpacity('WndwOvrlContent',0);
			SrCmndStleEfftFadingTo('WndwOvrlProtection',60,0.2);
			SrCmndStleEfftFadingTo('WndwOvrlHole',100,0.2);
			SrCmndStleEfftFadingTo('WndwOvrlShadow',20,0.2);
			SrCmndStleEfftFadingTo('WndwOvrlShadow',20,0.2);
			SrCmndStleEfftFadingTo('WndwOvrlFrame',100,0.2,function(){callback.call(this);});
		}
		var step2=function(code,callback){ // posiziono il contenuto
			if(code=='black') code='';
			else if(code=='') code='<input type="button" onclick="SrCmndWndwOvrl(\'Close\');AjaxAprt=\'\';" value="chiudi" style="cursor:pointer;font-size:11px;border:1px solid #888;color:#777;background-color:#bbb;font-family:\'Trebuchet MS\',Arial;" />'; //resettiamo anche la variabile per il controllo delle richieste aperte
			document.getElementById('WndwOvrlContent').innerHTML=code;
			if(code.indexOf('<!--[SrCmndWndwOvrlContentWidth]')>-1)	SrCmndWndwOvrlPrmt.RequestedWidth=parseInt(code.match(/\<\!\-\-\[SrCmndWndwOvrlContentWidth\]\=([0-9]+)\-\-\>/)[1]); //match restituisce un array: primo risultato è il match generico, il secondo quello tra parentesi che interessa a me
			if(callback!=null) callback.call(this);
		}
		var step3=function(callback){ // effettuo il resize al content
			//calcolo il valore attuale (1) e quello target (2), inner (x,y) e outer (X,Y)
			var x1=d.getElementById('WndwOvrlFrame').clientWidth;
			var y1=d.getElementById('WndwOvrlFrame').clientHeight;
			var x2=(SrCmndWndwOvrlPrmt.RequestedWidth>0)?(SrCmndWndwOvrlPrmt.RequestedWidth):(d.getElementById('WndwOvrlContent').clientWidth+10); // +10 altrimenti mangia troppo
			var y2=d.getElementById('WndwOvrlContent').clientHeight;
			var X1=x1+(SrCmndWndwOvrlPrmt.Margin*2)+(SrCmndWndwOvrlPrmt.Padding*2);
			var X2=x2+(SrCmndWndwOvrlPrmt.Margin*2)+(SrCmndWndwOvrlPrmt.Padding*2);
			var Y1=y1+(SrCmndWndwOvrlPrmt.Margin*2)+(SrCmndWndwOvrlPrmt.Padding*2);
			var Y2=y2+(SrCmndWndwOvrlPrmt.Margin*2)+(SrCmndWndwOvrlPrmt.Padding*2);
			//preparo il box scuro ed il buco, nel caso in cui i valori target stiano per andare ad allargare la finistra (X0,Y0)
			var Y0=SrCmndWndw_GetDocumentSize('y');
			var Y0top=parseInt(d.getElementById('WndwOvrlProtection').style.top);
			d.getElementById('WndwOvrlProtection').style.height=(((Y2+Y0top)>Y0)?(Y2+Y0top):(Y0))+'px';
			var X0=SrCmndWndw_GetDocumentSize('x');
			d.getElementById('WndwOvrlHole').style.width=((X2>X0)?(X2):(X0-10))+'px'; //tolgo 10 così evito che lo sbordare permetta ulteriori scroll orizzontali
			//creo il movimento di adattamento del box
			var ev1=new SrCmndStleEfftParallel();
			ev1.addChild(new SrCmndStleEfftTween(d.getElementById('WndwOvrlFrame').style,'width',Tween.regularEaseIn,x1,x2,0.3,'px'));
			ev1.addChild(new SrCmndStleEfftTween(d.getElementById('WndwOvrlShadow').style,'width',Tween.regularEaseIn,X1,X2,0.3,'px'));
			var ev2=new SrCmndStleEfftParallel();
			ev2.addChild(new SrCmndStleEfftTween(d.getElementById('WndwOvrlFrame').style,'height',Tween.regularEaseOut,y1,y2,0.3,'px'));
			ev2.addChild(new SrCmndStleEfftTween(d.getElementById('WndwOvrlShadow').style,'height',Tween.regularEaseOut,Y1,Y2,0.3,'px'));
			ev2.addChild(new SrCmndStleEfftTween(d.getElementById('WndwOvrlFrame').style,'top',Tween.regularEaseOut,-y1-(SrCmndWndwOvrlPrmt.Padding*2)-SrCmndWndwOvrlPrmt.Margin,-y2-(SrCmndWndwOvrlPrmt.Padding*2)-SrCmndWndwOvrlPrmt.Margin,0.3,'px'));
			var ev=new SrCmndStleEfftSequence();
			ev.addChild(ev1);
			ev.addChild(ev2);
			if(callback!=null) ev.onMotionFinished = function(){ev.onMotionFinished=function(){};callback.call(this);};
			ev.start();
		}
		var step4=function(callback){ // visualizza il contenuto
			SrCmndStleEfftFadingTo('WndwOvrlContent',100,0.3,callback);	
		}
		var step5=function(callback){ // nasconde content
			SrCmndStleEfftFadingTo('WndwOvrlContent',0,0.2,callback);	
		}

		//metto in coda gli step e li avvio
		if(e1==null){
			//creo l'elemento perchè non c'è
			step1(function(){step2(Content,function(){step3(function(){step4(function(){SrCmndWndwOvrlMotionStatus=0;})})})});
		}else{
			//svuoto l'elemento e lo resetto perchè c'era sicuramente qualcosa se esiste
			step5(function(){step2(Content,function(){step3(function(){step4(function(){SrCmndWndwOvrlMotionStatus=0;})})})});
		}

	} // if actions
	return true;		

} // funtion










// **** 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
// **** 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 < tEis.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;


