// MESSAGGI DI AIUTO

b_text = "Inserisci un testo in NERETTO";
i_text = "Inserisci un testo in CORSIVO";
u_text = "Inserisci un testo SOTTOLINEATO";
c_text = "Inserisci un testo CENTRATO";size_text = "Modifica la DIMENSIONE del testo";
font_text = "Modifica il FONT del testo";
color_text = "Modifica il COLORE del testo";

url_text = "Inserisci un LINK IPERTESTUALE nel tuo messaggio";
email_text = "Inserisci un INDIRIZZO E-MAIL nel tuo messaggio";

tab_text = "Inserisci una TABLATURA nel tuo messaggio";
list_text = "Inserisci una LISTA ORDINATA nel tuo messaggio";
quote_text = "Inserisci una CITAZIONE nel tuo messaggio";image_text = "Inserisci un' IMMAGINE nel tuo messaggio";chk_text = "Controlla quanti caratteri hai ancora a disposizione";

// ERROR MESSAGES

already_open_text = "<< C'è già un tag di questo tipo aperto >>";

// TEXT FOR POP-UP PROMPTS

tag_prompt = "Inserisci il testo da formattare:";img_prompt = "Inserisci l'url dell'immagine:";tab_prompt = "Inserisci la tablatura:";

font_formatter_prompt = "Inserisci il testo a cui applicare";

link_text_prompt  = "Inserisci il testo che dovrà essere visualizzato come link";quote_by_prompt   = "Inserisci l'autore della citazione";
link_url_prompt   = "Inserisci l'indirizzo URL completo per il link";
link_email_prompt = "Inserisci l'indirizzo e-mail per il link";quote_text_prompt = "Inserisci il testo della citazione";

list_type_prompt  = "Che tipo di elenco vuoi?\nInserisci: '1' elenco numerato - '0' elenco puntato";
list_item_prompt  = "Inserisci un elemento dell'elenco.\nQuando hai inserito l'utlimo elemento, lascia il box vuoto o premi 'Annulla'";

tags = new Array();//Sono funzioni che garantiscono il funzionamento dello script anche con browser più vecchifunction getarraysize(thearray) {
	for (i = 0; i < thearray.length; i++) {
		if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
			return i;
		}
	return thearray.length;
}

function arraypush(thearray,value) {
	thearraysize = getarraysize(thearray);
	thearray[thearraysize] = value;
}


//Funzione per verificare la lunghezza del messaggio
function checklength(theform) {
	Message = "\nLa lunghezza massima è fissata a 10000 caratteri.";
	alert("Il tuo messaggio contiene "+theform.Message.value.length+" caratteri."+Message);
}

//Funzione per i messaggi di help
function stat(thevalue) {
	document.PostTopic.status.value = eval(thevalue+"_text");
}//Funzione per l'inseriemnto del neretto, sottolineatura, ecc
function vbcode(theform,vbcode,prompttext) {        if (vbcode=="IMG"){        inserttext = prompt(img_prompt,prompttext);        }else if (vbcode=="TAB"){        inserttext = prompt(tab_prompt,prompttext);
		}else{
		inserttext = prompt(tag_prompt+"\n["+vbcode+"]xxx[/"+vbcode+"]",prompttext);		}
		if ((inserttext != null) && (inserttext != "")){
			theform.Message.value += "["+vbcode+"]"+inserttext+"[/"+vbcode+"] ";
		}else{
		donotinsert = false;
		for (i = 0; i < tags.length; i++) {
			if (tags[i] == vbcode)
				donotinsert = true;
			}
		if (donotinsert){
			stat("already_open");
		}else{
			theform.Message.value += "["+vbcode+"]";
			arraypush(tags,vbcode);
		}
		}
	theform.Message.focus();
}//Funzione per la scelta del font, del colore e della dimensionefunction fontformat(theform,thevalue,thetype) {
		if (thevalue != 0) {		    if (thetype== "SIZE") {
		      typetext="la dimensione selezionata"		    }else if (thetype== "FONT") {
		      typetext="il font selezionato"		    }else if (thetype== "COLOR") {
		      typetext="il colore selezionato"		    }
			inserttext = prompt(font_formatter_prompt+" "+typetext,"");
			if ((inserttext != null) && (inserttext != "")){
				theform.Message.value += "["+thetype+"="+thevalue+"]"+inserttext+"[/"+thetype+"="+thevalue+"] ";
			}
		}else{
		theform.Message.value += "["+thetype+"="+thevalue+"]";
		arraypush(tags,thetype);
		}	theform.sizeselect.selectedIndex = 0;
	theform.fontselect.selectedIndex = 0;
	theform.colorselect.selectedIndex = 0;
	theform.Message.focus();
}//Funzione per l'inserimento automatico di url, mail e quotefunction namedlink(theform,thetype) {    if (thetype == "QUOTE") {       linktext = prompt(quote_by_prompt,"");    }else{       linktext = prompt(link_text_prompt,"");
    }
		var prompt_text;		var prompt_contents;		var tag_text;
		if (thetype == "URL") {
			prompt_text = link_url_prompt;
			prompt_contents = "http://";			tag_text = "link";
			}
		else if (thetype == "MAIL") {
			prompt_text = link_email_prompt;
			prompt_contents = "";			tag_text = "name";
			}		else{
			prompt_text = quote_text_prompt;
			prompt_contents = "";			tag_text = "by";
			}
	linkurl = prompt(prompt_text,prompt_contents);
	if ((linkurl != null) && (linkurl != "")) {
		if ((linktext != null) && (linktext != ""))
			theform.Message.value += "["+thetype+" "+tag_text+"="+linktext+"]"+linkurl+"[/"+thetype+"] ";
		else
			theform.Message.value += "["+thetype+"]"+linkurl+"[/"+thetype+"] ";
		}
	theform.Message.focus();
}//Funzione per l'inserimento di elenchi ordinati
function dolist(theform) {
	listtype = prompt(list_type_prompt, "");
	if ((listtype == "1")) {
		thelist = "[OL]\n";
		listend = "[/OL] ";
		}
	else {
		thelist = "[UL]\n";
		listend = "[/UL] ";
		}
	listentry = "initial";
	while ((listentry != "") && (listentry != null)) {
		listentry = prompt(list_item_prompt, "");
		if ((listentry != "") && (listentry != null))
			thelist = thelist+"[LI]"+listentry+"[/LI]"+"\n";
		}
	theform.Message.value += thelist+listend;
	theform.Message.focus();
}
//Funzione per l'inserimento degli smile
function insertsmile(smilieface){

	window.document.PostTopic.Message.value+=smilieface;
	window.document.PostTopic.Message.focus();
}