//#################################################################################
//## Copyright (C) 2000-02 Michael Anderson, Pierre Gorissen,
//##                       Huw Reddick and Richard Kinser
//##
//## This program is free software; you can redistribute it and/or
//## modify it under the terms of the GNU General Public License
//## as published by the Free Software Foundation; either version 2
//## of the License, or any later version.
//##
//## All copyright notices regarding Snitz Forums 2000
//## must remain intact in the scripts and in the outputted HTML
//## The "powered by" text/logo with a link back to
//## http://forum.snitz.com in the footer of the pages MUST
//## remain visible when the pages are viewed on the internet or intranet.
//##
//## This program is distributed in the hope that it will be useful,
//## but WITHOUT ANY WARRANTY; without even the implied warranty of
//## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//## GNU General Public License for more details.
//##
//## You should have received a copy of the GNU General Public License
//## along with this program; if not, write to the Free Software
//## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//##
//## Support can be obtained from support forums at:
//## http://forum.snitz.com
//##
//## Correspondence and Marketing Questions can be sent to:
//## reinhold@bigfoot.com
//##
//## or
//##
//## Snitz Communications
//## C/O: Michael Anderson
//## PO Box 200
//## Harpswell, ME 04079
//#################################################################################

helpstat = false;
stprompt = false;
basic = true;

function thelp(swtch){
	if (swtch == 1){
		basic = false;
		stprompt = false;
		helpstat = true;
	} else if (swtch == 0) {
		helpstat = false;
		stprompt = false;
		basic = true;
	} else if (swtch == 2) {
		helpstat = false;
		basic = false;
		stprompt = true;
	}
}

/*function AddText(text) {
	var tarea = document.PostTopic.Message;
	if (tarea.selectionStart){ // if it supports DOM2
		tarea.value = tarea.value.substr(0,tarea.selectionStart)
			+ text + tarea.value.substr(tarea.selectionEnd);
		tarea.focus();
		tarea.selectionStart = tarea.selectionEnd + text.length;
		tarea.selectionEnd = tarea.selectionStart;
	} else {
		if (tarea.createTextRange && tarea.caretPos) {
			var caretPos = tarea.caretPos;
			caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?   text + ' ' : text;
		}
		else {
			tarea.value += text;
		}
		tarea.focus(caretPos);
	}
}*/

function AddText(text) {
	var crtScrollTop;
	var crtScrollLeft;
	try {
		var tarea = document.PostTopic.Message;
		if (typeof tarea.scrollTop != 'undefined') {
			crtScrollTop = tarea.scrollTop;
			crtScrollLeft = tarea.scrollLeft;
		}
	} catch (e) {};
	var tarea = document.PostTopic.Message;
	if (typeof tarea.selectionStart != 'undefined'){ // if it supports DOM2
		start = tarea.selectionStart;
		end = tarea.selectionEnd;
		tarea.value = tarea.value.substr(0,tarea.selectionStart)
			+ text + tarea.value.substr(tarea.selectionEnd);
		tarea.focus();
		tarea.selectionStart = ((start - end) == 0) ? start + text.length : start;
		tarea.selectionEnd = start + text.length;
	} else {
		if (tarea.createTextRange && tarea.caretPos) {
			var caretPos = tarea.caretPos;
			caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?   text + ' ' : text;
		}
		else {
			tarea.value += text;
		}
		tarea.focus(caretPos);
	};

	try {
		var tarea = document.PostTopic.Message;
		if (typeof tarea.scrollTop != 'undefined') {
			tarea.scrollTop = crtScrollTop;
			tarea.scrollLeft = crtScrollLeft;
		}
	} catch (e) {}; 
}

function bold() {
	var text = getText();
	if (helpstat) {
		alert("Il Tag Bold cambia il testo in grassetto.\n\nUSO: [b]Questo testo è in grassetto[/b]");
	} else if (basic) {
		AddTxt="[b]" + text + "[/b]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Il testo sarà formattato in GRASSETTO.",text);
		} else {
			txt=prompt("Il testo sarà formattato in GRASSETTO.","Text");
		}
		if (txt!=null) {
			AddTxt="[b]"+txt+"[/b]";
			AddText(AddTxt);
		}
	}
}

function italicize() {
	var text = getText();
	if (helpstat) {
		alert("Il Tag Italicize cambia il testo in corsivo.\n\nUSO: [i]Questo testo è in corsivo[/i]");
	} else if (basic) {
		AddTxt="[i]" + text + "[/i]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Il testo sarà formattato in corsivo",text);
		} else {
			txt=prompt("Il testo sarà formattato in corsivo","Text");
		}
		if (txt!=null) {
			AddTxt="[i]"+txt+"[/i]";
			AddText(AddTxt);
		}
	}
}

function underline() {
	var text = getText();
  	if (helpstat) {
		alert("Il Tag Underline cambia il testo in sottolineato.\n\nUSO: [u]Questo testo è sottolineato[/u]");
	} else if (basic) {
		AddTxt="[u]" + text + "[/u]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Il testo sarà formattato in sottolineato.",text);
		} else {
			txt=prompt("Il testo sarà formattato in sottolineato.","Text");
		}
		if (txt!=null) {
			AddTxt="[u]"+txt+"[/u]";
			AddText(AddTxt);
		}
	}
}

function strike() {
	var text = getText();
	if (helpstat) {
		alert("Il Tag Strike-Through cambia il testo in barrato.\n\nUSO: [s]Questo testo è barrato[/s]");
	} else if (basic) {
		AddTxt="[s]" + text + "[/s]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Il testo sarà formattato in barrato.",text);
		} else {
			txt=prompt("Il testo sarà formattato in barrato.","Text");
		}
		if (txt!=null) {
			AddTxt="[s]"+txt+"[/s]";
			AddText(AddTxt);
		}
	}
}

function left() {
	var text = getText();
 	if (helpstat) {
		alert("Il Tag Left allinea il testo a Sinistra.\n\nUSO: [left]Questo testo è allineato a Sinistra[/left]");
	} else if (basic) {
		AddTxt="[left]" + text + "[/left]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Il testo sarà allineato a Sinistra",text);
		} else {
			txt=prompt("Il testo sarà allineato a Sinistra","Text");
		}
		if (txt!=null) {
			AddTxt="[left]"+txt+"[/left]";
			AddText(AddTxt);
		}
	}
}

function center() {
	var text = getText();
 	if (helpstat) {
		alert("Il Tag Centered allinea il testo al Centro.\n\nUSO: [center]Questo testo è allineato al Centro[/center]");
	} else if (basic) {
		AddTxt="[center]" + text + "[/center]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Il testo sarà allineato al Centro",text);
		} else {
			txt=prompt("Il testo sarà allineato al Centro","Text");
		}
		if (txt!=null) {
			AddTxt="[center]"+txt+"[/center]";
			AddText(AddTxt);
		}
	}
}

function right() {
	var text = getText();
 	if (helpstat) {
		alert("Il Tag Right allinea il testo a Destra.\n\nUSO: [right]Questo testo è allineato a Destra[/right]");
	} else if (basic) {
		AddTxt="[right]" + text + "[/right]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Il testo sarà allineato a Destra",text);
		} else {
			txt=prompt("Il testo sarà allineato a Destra","Text");
		}
		if (txt!=null) {
			AddTxt="[right]"+txt+"[/right]";
			AddText(AddTxt);
		}
	}
}

function hr() {
	var text = getText();
	if (helpstat) {
		alert("il tag Horizontal Rule crea una riga orizzontale nel tuo messaggio.\n\nUSO: [hr]");
	} else {
		AddTxt="[hr]" + text;
		AddText(AddTxt);
	}
}

function hyperlink() {
	var text = getText();
	if (helpstat) {
		alert("Hyperlink Tag \nConverte un URL in link.\n\nUSO: [url]http://www.anywhere.com[/url]\n\nUSA: [url=\"http://www.anywhere.com\"]Testo linkato[/url]");
	} else if (basic) {
		AddTxt="[url]" + text + "[/url]";
		AddText(AddTxt);
	} else { 
		if (text!="") {
			txt2=text;
		} else {
			txt2=prompt("Testo che compare con il link.\nLascia bianco se vuoi che l'url sia mostrata come link.","");
		}
		if (txt2!=null) {
			txt=prompt("URL per il link.","http://");
			if (txt!=null) {
				if (txt2=="") {
					AddTxt="[url]"+txt+"[/url]";
					AddText(AddTxt);
				} else {
					AddTxt="[url=\""+txt+"\"]"+txt2+"[/url]";
					AddText(AddTxt);
				}
			}
		}
	}
}

function wbf() {
	var text = getText();
	if (helpstat) {
		alert("Tag Riquadro Bianco (wbf) inserisce il testo in un riquadro bianco. Il testo non si posiziona intorno\n\nUSO: No esempio");
	} else if (basic) {
		AddTxt="[wbf]" + text + "[/f]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Testo in riquadro bianco.",text);
		} else {
			txt=prompt("Testo in riquadro bianco.","Text");
		}
		if (txt!=null) {
			AddTxt="[wbf]"+txt+"[/f]";
			AddText(AddTxt);
		}
	}
}

function wbfw() {
	var text = getText();
	if (helpstat) {
		alert("Tag Riquadro Bianco wrap (wbfw) inserisce il testo in un riquadro bianco. Il testo gira intorno\n\nUSO: No esempio");
	} else if (basic) {
		AddTxt="[wbfw]" + text + "[/f]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Testo in riquadro bianco.",text);
		} else {
			txt=prompt("Testo in riquadro bianco.","Text");
		}
		if (txt!=null) {
			AddTxt="[wbfw]"+txt+"[/f]";
			AddText(AddTxt);
		}
	}
}

function tbf() {
	var text = getText();
	if (helpstat) {
		alert("Tag riquadro scuro (bbf) inserisce il testo in un riquadro scuro. Il testo non si posiziona intorno\n\nUSO: No esempio");
	} else if (basic) {
		AddTxt="[tbf]" + text + "[/f]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Testo in riquadro scuro.",text);
		} else {
			txt=prompt("Testo in riquadro scuro.","Text");
		}
		if (txt!=null) {
			AddTxt="[tbf]"+txt+"[/f]";
			AddText(AddTxt);
		}
	}
}

function tbfw() {
	var text = getText();
	if (helpstat) {
		alert("Tag riquadro scuro (bbfw) inserisce il testo in un riquadro scuro. Il testo si posiziona intorno\n\nUSO: No esempio");
	} else if (basic) {
		AddTxt="[tbfw]" + text + "[/f]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Testo in riquadro scuro.",text);
		} else {
			txt=prompt("Testo in riquadro scuro.","Text");
		}
		if (txt!=null) {
			AddTxt="[tbfw]"+txt+"[/f]";
			AddText(AddTxt);
		}
	}
}

function bbf() {
	var text = getText();
	if (helpstat) {
		alert("Tag riquadro trasparente(tbf) inserisce il testo in un riquadro trasparente. Il testo non si posiziona intorno\n\nUSE: No example");
	} else if (basic) {
		AddTxt="[bbf]" + text + "[/f]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Testo in riquadro trasparente.",text);
		} else {
			txt=prompt("Testo in riquadro trasparente.","Text");
		}
		if (txt!=null) {
			AddTxt="[bbf]"+txt+"[/f]";
			AddText(AddTxt);
		}
	}
}
 
function bbfw() {
	var text = getText();
	if (helpstat) {
		alert("Tag riquadro trasparente(tbfw) inserisce il testo in un riquadro trasparente. Il testo si posiziona intorno\n\nUSE: No example");
	} else if (basic) {
		AddTxt="[bbfw]" + text + "[/f]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Testo in riquadro trasparente.",text);
		} else {
			txt=prompt("Testo in riquadro trasparente.","Text");
		}
		if (txt!=null) {
			AddTxt="[bbfw]"+txt+"[/f]";
			AddText(AddTxt);
		}
	}
}

function tf() {
	var text = getText();
	if (helpstat) {
		alert("Tag riquadro senza bordi (tf) inserisce il testo in un riquadro senza bordi. Il testo non si posiziona intorno\n\nUSE: No example");
	} else if (basic) {
		AddTxt="[tf]" + text + "[/f]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Testo in riquadro senza bordi.",text);
		} else {
			txt=prompt("Testo in riquadro senza bordi.","Text");
		}
		if (txt!=null) {
			AddTxt="[tf]"+txt+"[/f]";
			AddText(AddTxt);
		}
	}
}

function tfw() {
	var text = getText();
	if (helpstat) {
		alert("Tag riquadro senza bordi (tfw) inserisce il testo in un riquadro senza bordi. Il testo si posiziona intorno\n\nUSE: No example");
	} else if (basic) {
		AddTxt="[tfw]" + text + "[/f]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Testo in riquadro senza bordi.",text);
		} else {
			txt=prompt("Testo in riquadro senza bordi.","Text");
		}
		if (txt!=null) {
			AddTxt="[tfw]"+txt+"[/f]";
			AddText(AddTxt);
		}
	}
}

function email() {
	if (helpstat) {
		alert("Il Tag E-mail modifica un indirizzo e-mail in un link.\n\nUSO #1: nome\@sito.com \nUSO #2: [url=\"nome\@sito.com\"]link text[/url]");
		}
	else {
		txt2=prompt("Il testo sarà mostrato come un link. lascia vuoto se vuoi mostrare l'indirizzo e-mail come un link.","");
		if (txt2!=null) {
			txt=prompt("URL come link.","mailto:");
			if (txt!=null) {
				if (txt2=="") {
					AddTxt=txt;
					AddText(AddTxt);
				} else {
					AddTxt="[url=\""+txt+"\"]"+txt2+"[/url]";
					AddText(AddTxt);
				}
			}
		}
	}
}


function sound() {
var text = getText();
	if (helpstat) {
		alert("Il tag sound inserisce un file audio nel messaggio. \n\nUSO: [sound]url[/sound]");
	} else if (basic) {
		AddTxt="[sound]" + text + "[/sound]";
		AddText(AddTxt);
	} else {
		txt=prompt(" URL del file sonoro","Text");
		if (txt!=null) {
			AddTxt="[sound]"+txt+"[/sound]";
			AddText(AddTxt);
		}
	}
}



function image() {
	var text = getText();
	if (helpstat){
		alert("Il Tag Image inserisce un'immagine nel messaggio.\n\nUSO: [img]http://www.sito.com/immagine.gif[/img]");
	} else if (basic) {
		AddTxt="[img]" + text + "[/img]";
		AddText(AddTxt);
	} else {
		txt=prompt("URL come immagine","http://");
		if(txt!=null) {
			AddTxt="[img]"+txt+"[/img]";
			AddText(AddTxt);
		}
	}
}

function showcode() {
	var text = getText();
	if (helpstat) {
		alert("Il Tag Blockquotes si usa per preservare la formattazione del testo.\nUtile per inserire codice.\n\nUSO: [code]Questo testo è un codice[/code]");
	} else if (basic) {
		AddTxt="[code]" + text + "[/code]";
		AddText(AddTxt);
	} else {
		txt=prompt("Inserisci codice","");
		if (txt!=null) {
			AddTxt="[code]"+txt+"[/code]";
			AddText(AddTxt);
		}
	}
}

function quote() {
	var text = getText();
	if (helpstat){
		alert("Il Tag Quote cambia il testo in una citazione.\n\nUSO: [quote]Questo testo è una citazione[/quote]");
	} else if (basic) {
		AddTxt=" [quote]" + text + "[/quote]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Il testo sarà modificato in una citazione",text);
		} else {
			txt=prompt("Il testo sarà modificato in una citazione","Text");
		}
		if(txt!=null) {
			AddTxt=" [quote] "+txt+" [/quote]";
			AddText(AddTxt);
		}
	}
}

function list() {
	if (helpstat) {
		alert("Il Tag List crea una lista puntata, numerata o alfabetica.\n\nUSO: [list] [*]punto1[/*] [*]punto2[/*] [*]punto3[/*] [/list]");
	} else if (basic) {
		AddTxt=" [list][*]  [/*][*]  [/*][*]  [/*][/list]";
		AddText(AddTxt);
	} else {
		type=prompt("Tipo di lista Inserisci \'A\' per alfabetica, \'1\' per numerica, Lascia vuoto per quella puntata.","");
		while ((type!="") && (type!="A") && (type!="a") && (type!="1") && (type!=null)) {
			type=prompt("ERRORE! I solo valori possibili sono vuoto, 'A' e '1'.","");
		}
		if (type!=null) {
			if (type=="") {
				AddTxt="[list]";
			} else {
				AddTxt="[list="+type+"]";
			}
			txt="1";
			while ((txt!="") && (txt!=null)) {
				txt=prompt("Inserisci gli elementi uno alla volta e premi ok. Lascia vuoto per terminare la lista","");
				if (txt!="") {
					AddTxt+="[*]"+txt+"[/*]";
				}
			}
			if (type=="") {
				AddTxt+="[/list] ";
			} else {
				AddTxt+="[/list="+type+"]";
			}
			AddText(AddTxt);
		}
	}
}

function sup() {
	var text = getText();
	if (helpstat) {
		alert("Il Marcatore Apice (sup) mette in Apice il testo incluso.\n\nUSO: Questo è un esempio di [sup]apice[/sup]");
	} else if (basic) {
		AddTxt="[sup]" + text + "[/sup]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Testo da mettere in Apice.",text);
		} else {
			txt=prompt("Testo da mettere in Apice.","Text");
		}
		if (txt!=null) {
			AddTxt="[sup]"+txt+"[/sup]";
			AddText(AddTxt);
		}
	}
}

function sub() {
	var text = getText();
	if (helpstat) {
		alert("Il Marcatore Pedice (sub) mette in Pedice il testo incluso.\n\nUSO: Questo è un esempio di [sub]pedice[/sub]");
	} else if (basic) {
		AddTxt="[sub]" + text + "[/sub]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Testo da mettere in Pedice.",text);
		} else {
			txt=prompt("Testo da mettere in Pedice.","Text");
		}
		if (txt!=null) {
			AddTxt="[sub]"+txt+"[/sub]";
			AddText(AddTxt);
		}
	}
}

function bigchar() {
	var text = getText();
	if (helpstat) {
		alert("Il Marcatore Grande (bigchar) aumenta la taglia del carattere in uso.\n\nUSO: Nessun esempio");
	} else if (basic) {
		AddTxt="[bigchar]" + text + "[/bigchar]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Testo da mettere in Grande.",text);
		} else {
			txt=prompt("Testo da mettere in Grande.","Text");
		}
		if (txt!=null) {
			AddTxt="[bigchar]"+txt+"[/bigchar]";
			AddText(AddTxt);
		}
	}
}



function pre() {
	var text = getText();
	if (helpstat) {
		alert("Il Marcatore Preformattato (pre) mantiene la formattazione del testo.\n\nUSO: Nessun esempio");
	} else if (basic) {
		AddTxt="[pre]" + text + "[/pre]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Testo di cui mantenere la Formattazione.",text);
		} else {
			txt=prompt("Testo di cui mantenere la Formattazione.","Text");
		}
		if (txt!=null) {
			AddTxt="[pre]"+txt+"[/pre]";
			AddText(AddTxt);
		}
	}
}

function tt() {
	var text = getText();
	if (helpstat) {
		alert("Il Marcatore Telescrivente (tt) mette in carattere tipo Telescrivente il testo incluso.\n\nUSO: [tt] Questo è un esempio di testo tipo Telescrivente[/tt]");
	} else if (basic) {
		AddTxt="[tt]" + text + "[/tt]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Testo da mettere in tipo Telescrivente.",text);
		} else {
			txt=prompt("Testo da mettere in tipo Telescrivente.","Text");
		}
		if (txt!=null) {
			AddTxt="[tt]"+txt+"[/tt]";
			AddText(AddTxt);
		}
	}
}

function marquee() {
	var text = getText();
	if (helpstat) {
		alert("Il Marcatore Scorri (marquee) fa scorrere il testo.\n\nUSO: [marquee]Questo è un esempio di Testo Scorrevole[/marquee]");
	} else if (basic) {
		AddTxt="[marquee]" + text + "[/marquee]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Testo da fare Scorrere.",text);
		} else {
			txt=prompt("Testo da fare Scorrere.","Text");
		}
		if (txt!=null) {
			AddTxt="[marquee]"+txt+"[/marquee]";
			AddText(AddTxt);
		}
	}
}

function showfont(font) {
	var text = getText();
 	if (font) {
	 	if (helpstat) {
			alert("Il Tag Font Specifica il tipo di carattere del testo.\n\nUSO: [font="+font+"]Il carattere di questo testo è "+font+"[/font="+font+"]");
		} else if (basic) {
			AddTxt="[font="+font+"]" + text + "[/font="+font+"]";
			AddText(AddTxt);
		} else {
			if (text) {
				txt=prompt("Il testo sarà formattato in carattere "+font,text);
			} else {
				txt=prompt("Il testo sarà formattato in carattere "+font,"Text");
			}
			if (txt!=null) {
				AddTxt="[font="+font+"]"+txt+"[/font="+font+"]";
				AddText(AddTxt);
			}
		}
	document.PostTopic.Font.selectedIndex = 0;
	}
}

function showsize(size) {
	var text = getText();
	if (size) {
		if (helpstat) {
			alert("I Tag Size impostano la grandezza del testo. I valori vanno da 1 a 6.\n1 è il più piccolo e 6 il più grande.\n\nUSO: [size="+size+"]This is size "+size+" text[/size="+size+"]");
		} else if (basic) {
			AddTxt="[size="+size+"]" + text + "[/size="+size+"]";
			AddText(AddTxt);
		} else {
			if (text) {
				txt=prompt("Il testo sarà formattato in grandezza "+size,text);
			} else {
				txt=prompt("Il testo sarà formattato in grandezza "+size,"Text");
			}
			if (txt!=null) {
				AddTxt="[size="+size+"]"+txt+"[/size="+size+"]";
				AddText(AddTxt);
			}
		}
	document.PostTopic.Size.selectedIndex = 0;
	}
}

function showcolor(color) {
	var text = getText();
	if (color) {
		if (helpstat) {
			alert("l Tag Color modifica il colore del testo.\n\nUSO: ["+color+"]Questo testo è "+color+"[/"+color+"]");
		} else if (basic) {
			AddTxt="["+color+"]" + text + "[/"+color+"]";
			AddText(AddTxt);
		} else {
			if (text) {
		     		txt=prompt("Il testo sarà formattato in "+color,text);
			} else {
	     			txt=prompt("Il testo sarà formattato in "+color,"Text");
			}
			if(txt!=null) {
				AddTxt="["+color+"]"+txt+"[/"+color+"]";
				AddText(AddTxt);
			}
		}
	document.PostTopic.Color.selectedIndex = 0;
	}
}

function resizeTextarea(tmpCookieURL)
{
	var today = new Date();
	var expires = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000); // plus 365 days
	if (document.PostTopic.SelectSize.value == 1)
	{
		document.PostTopic.Message.cols = 45;
		document.PostTopic.Message.rows = 11;
	}
	if (document.PostTopic.SelectSize.value == 2)
	{
		document.PostTopic.Message.cols = 70;
		document.PostTopic.Message.rows = 12;
	}
	if (document.PostTopic.SelectSize.value == 3)
	{
		document.PostTopic.Message.cols = 90;
		document.PostTopic.Message.rows = 12;
	}
	if (document.PostTopic.SelectSize.value == 4)
	{
		document.PostTopic.Message.cols = 130;
		document.PostTopic.Message.rows = 15;
	}
document.cookie = tmpCookieURL + "strSelectSize=" + document.PostTopic.SelectSize.value + "; expires=" + expires.toUTCString()
}

function storeCaret(ftext) {
	if (ftext.createTextRange) {
		ftext.caretPos = document.selection.createRange().duplicate();
	}
}

function getText() {
	var tarea = document.PostTopic.Message;
	if (tarea.createTextRange && tarea.caretPos) {
		return tarea.caretPos.text;
	} else if (typeof tarea.selectionStart != 'undefined'){
		return tarea.value.substr(tarea.selectionStart,tarea.selectionEnd-tarea.selectionStart)
	}
	return '';
}

function OpenPreview()
{
	if (document.PostTopic.Message) {
		if (trim(document.PostTopic.Message.value)=="") {
			alert("Nessun testo da mostrare in Anteprima!")
			return false
		}
		popupWin = window.open('pop_preview.asp', 'preview_page', 'scrollbars=yes,width=750,height=450')	
		return true
	}
}

function OpenSigPreview()
{
	if (document.Form1.Sig) {
		if (trim(document.Form1.Sig.value)=="") {
			alert("Nessun testo da mostrare in Anteprima!")
			return false
		}
		popupWin = window.open('pop_preview_sig.asp', 'preview_page', 'scrollbars=yes,width=750,height=450')	
		return true
	}
}

function validate(){
	if (document.PostTopic.Subject) {
		if (trim(document.PostTopic.Subject.value)=="") {
			alert("Devi inserire l'Oggetto")
			return false
		}
	}
	if (document.PostTopic.Message) {
		if (trim(document.PostTopic.Message.value)=="") {
			alert("Devi inserire il Messaggio")
			return false
		}
	}
	return true
}

function ResetForm(form) {
	var where_to= confirm("Vuoi veramente cancellare il contenuto dei campi?");
	if (where_to== true) {
		form.reset();
	}
}

//code below found here:  http://www.marzie.com/devtools/javascript/functions.asp

function ltrim(s) {
	return s.replace( /^\s*/, "" );
}
function rtrim(s) {
	return s.replace( /\s*$/, "" );
}
function trim ( s ) {
	return rtrim(ltrim(s));
}

/********************************************************************************
*   OnlineVideos MOD 
*   bruno.in.dk [at] gmail.com
********************************************************************************/
// Google Video
function gvid() {
	var text = getText();
	if (helpstat){
		alert("Google Video.\n\nUSE: [gvid]Google Video URL[/gvid]");
	} else if (basic) {
		AddTxt=" [gvid]" + text + "[/gvid]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Google Video URL",text);
		} else {
			txt=prompt("Google Video URL","Text");
		}
		if(txt!=null) {
			AddTxt=" [gvid]"+txt+"[/gvid]";
			AddText(AddTxt);
		}
	}
}
// Youtube Video
function tube() {
	var text = getText();
	if (helpstat){
		alert("YouTube Video.\n\nUSE: [tube]YouTube Video URL[/tube]");
	} else if (basic) {
		AddTxt=" [youtube]" + text + "[/youtube]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("YouTube Video URL",text);
		} else {
			txt=prompt("YouTube Video URL","Text");
		}
		if(txt!=null) {
			AddTxt=" [youtube]"+txt+"[/youtube]";
			AddText(AddTxt);
		}
	}
}
// Flash Video
function flashv() {
	var text = getText();
	if (helpstat){
		alert("Flash Video.\n\nUSE: [flash]Flash Video URL[/flash]");
	} else if (basic) {
		AddTxt=" [flash]" + text + "[/flash]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Flash Video URL",text);
		} else {
			txt=prompt("Flash Video URL","Text");
		}
		if(txt!=null) {
			AddTxt=" [flash]"+txt+"[/flash]";
			AddText(AddTxt);
		}
	}
}
// Metacafé Video
function metacafe() {
	var text = getText();
	if (helpstat){
		alert("Metacafe Video.\n\nUSE: [metacafe]Metacafe URL[/metacafe]");
	} else if (basic) {
		AddTxt=" [metacafe]" + text + "[/metacafe]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Metacafe Video URL",text);
		} else {
			txt=prompt("Metacafe Video URL","Text");
		}
		if(txt!=null) {
			AddTxt=" [metacafe]"+txt+"[/metacafe]";
			AddText(AddTxt);
		}
	}
}
// MySpace Video
function myspacev() {
	var text = getText();
	if (helpstat){
		alert("Myspace Video.\n\nUSE: [myspace]Myspace URL[/myspace]");
	} else if (basic) {
		AddTxt=" [myspace]" + text + "[/myspace]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Myspace Video URL",text);
		} else {
			txt=prompt("Myspace Video URL","Text");
		}
		if(txt!=null) {
			AddTxt=" [myspace]"+txt+"[/myspace]";
			AddText(AddTxt);
		}
	}
}
// Quicktime Video
function qtv() {
	var text = getText();
	if (helpstat){
		alert("QuickTime Video.\n\nUSE: [qt]QuickTime URL[/qt]");
	} else if (basic) {
		AddTxt=" [qt]" + text + "[/qt]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("QuickTime Video URL",text);
		} else {
			txt=prompt("QuickTime Video URL","Text");
		}
		if(txt!=null) {
			AddTxt=" [qt]"+txt+"[/qt]";
			AddText(AddTxt);
		}
	}
}
// Windows Media Video
function wmv() {
	var text = getText();
	if (helpstat){
		alert("Windows Media Video.\n\nUSE: [wmv]Windows Media Video URL[/wmv]");
	} else if (basic) {
		AddTxt=" [wmv]" + text + "[/wmv]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Windows Media Video URL",text);
		} else {
			txt=prompt("Windows Media Video URL","Text");
		}
		if(txt!=null) {
			AddTxt=" [wmv]"+txt+"[/wmv]";
			AddText(AddTxt);
		}
	}
}
// Real Video
function rv() {
	var text = getText();
	if (helpstat){
		alert("Real Video.\n\nUSE: [rv]Real Video URL[/rv]");
	} else if (basic) {
		AddTxt=" [rv]" + text + "[/rv]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Real Video URL",text);
		} else {
			txt=prompt("Real Video URL","Text");
		}
		if(txt!=null) {
			AddTxt=" [rv]"+txt+"[/rv]";
			AddText(AddTxt);
		}
	}
}

//MP3 MOD below

function mp3() {
   var text = getText();
   if (helpstat){
      alert("MP3 Tag Inserisce un mp3 nel messaggio.\n\nUSO: [mp3]http://www.anywhere.com/song.mp3[/mp3]");
   } else if (text != null && text!="") {
      AddTxt="[mp3]" + text + "[/mp3]";
      AddText(AddTxt);
   } else {
      txt=prompt("URL per mp3 file","http://");
      if(txt!=null) {
         AddTxt="[mp3]"+txt+"[/mp3]";
         AddText(AddTxt);
      }
   }
}

function pdf() {
   var text = getText();
   if (helpstat){
      alert("PDF Tag inserisce un file Pdf nel messaggio.\n\nUSE: [pdf]http://www.anywhere.com/file.pdf[/pdf]");
   } else if (text != null && text!="") {
      AddTxt="[pdf]" + text + "[/pdf]";
      AddText(AddTxt);
   } else {
      txt=prompt("URL per il pdf file","http://");
      if(txt!=null) {
         AddTxt="[pdf]"+txt+"[/pdf]";
         AddText(AddTxt);
      }
   }
}

function mediabox() {
	var text = getText();
	if (helpstat) {
		alert("Media Tag mostra vari formati di file multimediali.\n\nUSE: [media]http://www.domaingoeshere.com/media.swf[/media]");
	} else if (basic) {
		AddTxt="[media]" + text + "[/media]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("URL Link a file multimediale.",text);
		} else {
			txt=prompt("URL Link a file multimediale.","Text");
		}
		if (txt!=null) {
			AddTxt="[media]"+txt+"[/media]";
			AddText(AddTxt);
		}
	}
}

function evidenziato() {
	var text = getText();
	if (helpstat) {
		alert("Il Marcatore Evidenziato (hl) mette il testo in colore Evidenziato.\n\nUSO: [hl]Questo è un esempio di testo Evidenziato[/hl]");
	} else if (basic) {
		AddTxt="[hl]" + text + "[/hl]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Testo da mettere in Evidenziato.",text);
		} else {
			txt=prompt("Testo da mettere in Evidenziato.","Text");
		}
		if (txt!=null) {
			AddTxt="[hl]"+txt+"[/hl]";
			AddText(AddTxt);
		}
	}
}
