			var codeLighter = function() {
				// andr3a [ www.3site.it ] [ andrea@3site.it ]
				var used = Array();
				function codeLighter_add(str) {
					var codeLighterTextarea_add = '';
					var to_span = 'novalue';
					if(!document.getElementById('codeTextarea')) {
						alert('You need a TEXTAREA with id="codeTextarea" to use these buttons!');
					}
					if(document.getElementById('codeLighterTextareaSpanChecker')!=null) {
						to_span = document.getElementById('codeLighterTextareaSpanChecker').innerHTML;
						to_span = parseInt(to_span);
					}
					if(document.getElementById('codeLighter' + str).value == '['+str+']') {
						codeLighterTextarea_add = '['+str+']';
						document.getElementById('codeLighter' + str).value = '[/'+str+']';
						this.total.push('[/'+str+']');
						if(to_span!='novalue') {
document.getElementById('codeLighterTextareaSpanChecker').innerHTML = (to_span+1);
						}
					}
					else {
						for(var a=(this.total.length-1); a>=0; a--) {
							codeLighterTextarea_add += this.total[a];
							var my_str = this.total[a].substr(2, (this.total[a].length-3));
							document.getElementById('codeLighter' + my_str).value = '['+my_str+']';
							if(to_span!='novalue') {
								to_span--;
							}
							if(my_str==str) {
								break;
							}
						}
						if(this.total.length==0) {
					codeLighterTextarea_add += '[/'+str+']';
					document.getElementById('codeLighter' + str).value = '['+str+']';
							if(to_span!='novalue') {
								to_span--;
							}
						}
						this.total = Array();
						if(to_span!='novalue') {
		document.getElementById('codeLighterTextareaSpanChecker').innerHTML = to_span;
						}
					}
	document.getElementById('codeTextarea').value += codeLighterTextarea_add;
	document.getElementById('codeTextarea').focus();
					return true;
				}
				function codeLighter_closeTags(ar) {
					var to_span = 'novalue';
					for(var a=(ar.length-1); a>=0; a--) {
						document.getElementById('codeTextarea').value += ar[a];
						var my_str = ar[a].substr(2, (ar[a].length-3));
						document.getElementById('codeLighter' + my_str).value = '['+my_str+']';
					}
					this.total = Array();
					if(document.getElementById('codeLighterTextareaSpanChecker')!=null) {
						to_span = document.getElementById('codeLighterTextareaSpanChecker').innerHTML;
						to_span = parseInt(to_span);
					}
					if(to_span!='novalue') {
						document.getElementById('codeLighterTextareaSpanChecker').innerHTML = '0';
				}
					document.getElementById('codeTextarea').focus();
				}
				function codeLighter_maxChars() {
					if(this.counter!=false) {
					var check_len = document.getElementById('codeTextarea').value.length;
						var rest_len = 0;
						if ( check_len >= this.counter ) {
							document.getElementById('codeTextarea').value = document.getElementById('codeTextarea').value.substring(0, this.counter);
						}
						else {
							rest_len = this.counter - check_len;
						}
						document.getElementById('codeLighterTextareaSpanCounter').innerHTML = rest_len;
					}
					else {
						document.getElementById('codeLighterTextareaSpanCounter').innerHTML = document.getElementById('codeTextarea').value.length;
					}
				}
				this.total = used;
				this.add = codeLighter_add;
				this.close = codeLighter_closeTags;
				this.maxChars = codeLighter_maxChars;
				this.counter = false;
			}
			var codeLighter = new codeLighter();



function WM_toggle(id){
if (document.all){
if(document.all[id].style.display == 'none'){
document.all[id].style.display = '';
} else {
document.all[id].style.display = 'none';
}
return false;
} else if (document.getElementById){
if(document.getElementById(id).style.display == 'none'){
document.getElementById(id).style.display = 'block';
} else {
document.getElementById(id).style.display = 'none';
}
return false;
}
}



//codice per il secondo form con funzione di formattazione [Versione Inglese]
var codeLighter2 = function() {
var used = Array();
function codeLighter2_add(str) {
var codeLighterTextarea_add = '';
var to_span = 'novalue';
if(!document.getElementById('codeTextarea2')) {
alert('You need a TEXTAREA with id="codeTextarea2" to use these buttons!');
}
if(document.getElementById('codeLighterTextareaSpanChecker')!=null) {
to_span = document.getElementById('codeLighterTextareaSpanChecker').innerHTML;
to_span = parseInt(to_span);
}
if(document.getElementById('codeLighter2' + str).value == '['+str+']') {
codeLighterTextarea_add = '['+str+']';
document.getElementById('codeLighter2' + str).value = '[/'+str+']';
this.total.push('[/'+str+']');
if(to_span!='novalue') {
document.getElementById('codeLighterTextareaSpanChecker').innerHTML = (to_span+1);
}
}
else {
for(var a=(this.total.length-1); a>=0; a--) {
codeLighterTextarea_add += this.total[a];
var my_str = this.total[a].substr(2, (this.total[a].length-3));
document.getElementById('codeLighter2' + my_str).value = '['+my_str+']';
if(to_span!='novalue') {
to_span--;
}
if(my_str==str) {
break;
}
}
if(this.total.length==0) {
codeLighterTextarea_add += '[/'+str+']';
document.getElementById('codeLighter2' + str).value = '['+str+']';
if(to_span!='novalue') {
to_span--;
}
}
this.total = Array();
if(to_span!='novalue') {
document.getElementById('codeLighterTextareaSpanChecker').innerHTML = to_span;
}
}
document.getElementById('codeTextarea2').value += codeLighterTextarea_add;
document.getElementById('codeTextarea2').focus();
return true;
}

function codeLighter2_closeTags(ar) {
var to_span = 'novalue';
for(var a=(ar.length-1); a>=0; a--) {
document.getElementById('codeTextarea2').value += ar[a];
var my_str = ar[a].substr(2, (ar[a].length-3));
document.getElementById('codeLighter2' + my_str).value = '['+my_str+']';
}
this.total = Array();
if(document.getElementById('codeLighterTextareaSpanChecker')!=null) {
to_span = document.getElementById('codeLighterTextareaSpanChecker').innerHTML;
to_span = parseInt(to_span);
}
if(to_span!='novalue') {
document.getElementById('codeLighterTextareaSpanChecker').innerHTML = '0';
}
document.getElementById('codeTextarea2').focus();
}

function codeLighter2_maxChars() {
if(this.counter!=false) {
var check_len = document.getElementById('codeTextarea2').value.length;

var rest_len = 0;
if ( check_len >= this.counter ) {
document.getElementById('codeTextarea2').value = document.getElementById('codeTextarea2').value.substring(0, this.counter);
}
else {
rest_len = this.counter - check_len;
}
document.getElementById('codeLighterTextareaSpanCounter').innerHTML = rest_len;
}
else {
document.getElementById('codeLighterTextareaSpanCounter').innerHTML = document.getElementById('codeTextarea2').value.length;
					}
				}
				this.total = used;
				this.add = codeLighter2_add;
				this.close = codeLighter2_closeTags;
				this.maxChars = codeLighter2_maxChars;
				this.counter = false;
			}
			var codeLighter2 = new codeLighter2();



//codice per il terzo form con funzione di formattazione [Pagina POSIZIONE]
var codeLighter3 = function() {
var used = Array();
function codeLighter3_add(str) {
var codeLighterTextarea_add = '';
var to_span = 'novalue';
if(!document.getElementById('codeTextarea3')) {
alert('You need a TEXTAREA with id="codeTextarea3" to use these buttons!');
}
if(document.getElementById('codeLighterTextareaSpanChecker')!=null) {
to_span = document.getElementById('codeLighterTextareaSpanChecker').innerHTML;
to_span = parseInt(to_span);
}
if(document.getElementById('codeLighter3' + str).value == '['+str+']') {
codeLighterTextarea_add = '['+str+']';
document.getElementById('codeLighter3' + str).value = '[/'+str+']';
this.total.push('[/'+str+']');
if(to_span!='novalue') {
document.getElementById('codeLighterTextareaSpanChecker').innerHTML = (to_span+1);
}
}
else {
for(var a=(this.total.length-1); a>=0; a--) {
codeLighterTextarea_add += this.total[a];
var my_str = this.total[a].substr(2, (this.total[a].length-3));
document.getElementById('codeLighter3' + my_str).value = '['+my_str+']';
if(to_span!='novalue') {
to_span--;
}
if(my_str==str) {
break;
}
}
if(this.total.length==0) {
codeLighterTextarea_add += '[/'+str+']';
document.getElementById('codeLighter3' + str).value = '['+str+']';
if(to_span!='novalue') {
to_span--;
}
}
this.total = Array();
if(to_span!='novalue') {
document.getElementById('codeLighterTextareaSpanChecker').innerHTML = to_span;
}
}
document.getElementById('codeTextarea3').value += codeLighterTextarea_add;
document.getElementById('codeTextarea3').focus();
return true;
}

function codeLighter3_closeTags(ar) {
var to_span = 'novalue';
for(var a=(ar.length-1); a>=0; a--) {
document.getElementById('codeTextarea3').value += ar[a];
var my_str = ar[a].substr(2, (ar[a].length-3));
document.getElementById('codeLighter3' + my_str).value = '['+my_str+']';
}
this.total = Array();
if(document.getElementById('codeLighterTextareaSpanChecker')!=null) {
to_span = document.getElementById('codeLighterTextareaSpanChecker').innerHTML;
to_span = parseInt(to_span);
}
if(to_span!='novalue') {
document.getElementById('codeLighterTextareaSpanChecker').innerHTML = '0';
}
document.getElementById('codeTextarea3').focus();
}

function codeLighter3_maxChars() {
if(this.counter!=false) {
var check_len = document.getElementById('codeTextarea3').value.length;

var rest_len = 0;
if ( check_len >= this.counter ) {
document.getElementById('codeTextarea3').value = document.getElementById('codeTextarea3').value.substring(0, this.counter);
}
else {
rest_len = this.counter - check_len;
}
document.getElementById('codeLighterTextareaSpanCounter').innerHTML = rest_len;
}
else {
document.getElementById('codeLighterTextareaSpanCounter').innerHTML = document.getElementById('codeTextarea3').value.length;
					}
				}
				this.total = used;
				this.add = codeLighter3_add;
				this.close = codeLighter3_closeTags;
				this.maxChars = codeLighter3_maxChars;
				this.counter = false;
			}
			var codeLighter3 = new codeLighter3();



//codice per il quarto form con funzione di formattazione [Pagina POSIZIONE]
var codeLighter4 = function() {
var used = Array();
function codeLighter4_add(str) {
var codeLighterTextarea_add = '';
var to_span = 'novalue';
if(!document.getElementById('codeTextarea4')) {
alert('You need a TEXTAREA with id="codeTextarea4" to use these buttons!');
}
if(document.getElementById('codeLighterTextareaSpanChecker')!=null) {
to_span = document.getElementById('codeLighterTextareaSpanChecker').innerHTML;
to_span = parseInt(to_span);
}
if(document.getElementById('codeLighter4' + str).value == '['+str+']') {
codeLighterTextarea_add = '['+str+']';
document.getElementById('codeLighter4' + str).value = '[/'+str+']';
this.total.push('[/'+str+']');
if(to_span!='novalue') {
document.getElementById('codeLighterTextareaSpanChecker').innerHTML = (to_span+1);
}
}
else {
for(var a=(this.total.length-1); a>=0; a--) {
codeLighterTextarea_add += this.total[a];
var my_str = this.total[a].substr(2, (this.total[a].length-3));
document.getElementById('codeLighter4' + my_str).value = '['+my_str+']';
if(to_span!='novalue') {
to_span--;
}
if(my_str==str) {
break;
}
}
if(this.total.length==0) {
codeLighterTextarea_add += '[/'+str+']';
document.getElementById('codeLighter4' + str).value = '['+str+']';
if(to_span!='novalue') {
to_span--;
}
}
this.total = Array();
if(to_span!='novalue') {
document.getElementById('codeLighterTextareaSpanChecker').innerHTML = to_span;
}
}
document.getElementById('codeTextarea4').value += codeLighterTextarea_add;
document.getElementById('codeTextarea4').focus();
return true;
}

function codeLighter4_closeTags(ar) {
var to_span = 'novalue';
for(var a=(ar.length-1); a>=0; a--) {
document.getElementById('codeTextarea4').value += ar[a];
var my_str = ar[a].substr(2, (ar[a].length-3));
document.getElementById('codeLighter4' + my_str).value = '['+my_str+']';
}
this.total = Array();
if(document.getElementById('codeLighterTextareaSpanChecker')!=null) {
to_span = document.getElementById('codeLighterTextareaSpanChecker').innerHTML;
to_span = parseInt(to_span);
}
if(to_span!='novalue') {
document.getElementById('codeLighterTextareaSpanChecker').innerHTML = '0';
}
document.getElementById('codeTextarea4').focus();
}

function codeLighter4_maxChars() {
if(this.counter!=false) {
var check_len = document.getElementById('codeTextarea4').value.length;

var rest_len = 0;
if ( check_len >= this.counter ) {
document.getElementById('codeTextarea4').value = document.getElementById('codeTextarea4').value.substring(0, this.counter);
}
else {
rest_len = this.counter - check_len;
}
document.getElementById('codeLighterTextareaSpanCounter').innerHTML = rest_len;
}
else {
document.getElementById('codeLighterTextareaSpanCounter').innerHTML = document.getElementById('codeTextarea4').value.length;
					}
				}
				this.total = used;
				this.add = codeLighter4_add;
				this.close = codeLighter4_closeTags;
				this.maxChars = codeLighter4_maxChars;
				this.counter = false;
			}
			var codeLighter4 = new codeLighter4();



function inshr(numero){
var numero = numero;
if (numero=="0"){
document.forms[0].messaggio.value = document.forms[0].messaggio.value + "[HR]";
}
else if (numero=="1"){
document.forms[0].messaggio2.value = document.forms[0].messaggio2.value + "[HR]";
}
else if (numero=="2"){
document.forms[0].messaggio3.value = document.forms[0].messaggio3.value + "[HR]";
}
else if (numero=="3"){
document.forms[0].messaggio4.value = document.forms[0].messaggio4.value + "[HR]";
}
}


//funzione per contare i caratteri e fermare inserimento nella textarea
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) {
field.value = field.value.substring(0, maxlimit);
} else {
countfield.value = maxlimit - field.value.length;
}
}


// funzione per far visualizzare la foto caricata nel form descrizione del pannello gestionale
function preview(foto){
var foto = foto;
var el = document.forms[0].elements;
for (var i=0; i<el.length; i++){
if (foto!="0"){
document.getElementById("swap").src = foto;
}
else if (foto==""){
document.getElementById("swap").src = "img/spazio.gif";
}
else if (foto=="0"){
if(el[i].type=="file" && el[i].value!=""){
document.getElementById("swap").src = el[i].value;
}
}
}
}
function preview2(foto){
var foto = foto;
if (foto!=""){
document.getElementById("swap").src = foto;
}
}

// funzione per far comparire la pop-up per anterpima della news appena scritta
function OpenPreviewWindow(sezione){
var sezione=sezione;
if (sezione=="0"){
if (document.forms[0].messaggio.length != 0 && document.forms[0].messaggio.value != ''){
document.cookie ='Messaggio = ' + escape(document.forms[0].messaggio.value);
document.cookie ='Messaggio2 = ';
window.open('a_anteprima.asp', 'preview', 'scrollbars=yes,width=600,height=400,left=90')
}
else{
alert("Per visualizzare un\'anteprima,\ndovresti inserire del testo..\nNon credi..!?!?");
return false
}
}

else if (sezione=="1"){
if (document.forms[0].messaggio.length != 0 && document.forms[0].messaggio.value != '' && document.forms[0].messaggio2.length != 0 && document.forms[0].messaggio2.value != ''){
document.cookie ='Messaggio = ' + escape(document.forms[0].messaggio.value);
document.cookie ='Messaggio2 = ' + escape(document.forms[0].messaggio2.value);
window.open('a_anteprima.asp', 'preview', 'scrollbars=yes,width=600,height=400,left=90')
}
else{
alert("Per visualizzare un\'anteprima,\ndovresti inserire del testo..\nNon credi..!?!?");
return false
}
}
else{
alert("Per visualizzare un\'anteprima,\ndovresti inserire del testo..\nNon credi..!?!?");
return false
}
}

//funzione per disabilitare e cambiare il testo sul tasto submit nel momento di invio dati
function disabilita(){
document.forms[0].submit.value = "Attendere..";
document.forms[0].submit.disabled = true;
}


//funzione che mi permette di ridimensionare immagine nel guestbbok quanto mi basta per non rovinare il layout
function ridimensiona(){ 
for (imm in document.images){ 
img = document.images[imm] 
if (img.className=="image"){ 
if (img.width > 400){ 
img.width=400 
} 
if (img.height> 500){ 
img.height = 500 
} 
} 
} 
}


function addSmile(picName) {
	document.shout.messaggio.value = document.shout.messaggio.value + picName;
	document.shout.messaggio.focus();
}
