//'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//'<> Copyright (C) 2005-2006 Dogg Software All Rights Reserved
//'<>
//'<> By using this program, you are agreeing to the terms of the
//'<> SkyPortal End-User License Agreement.
//'<>
//'<> All copyright notices regarding SkyPortal must remain 
//'<> intact in the scripts and in the outputted HTML.
//'<> The "powered by" text/logo with a link back to 
//'<> http://www.SkyPortal.net in the footer of the pages MUST
//'<> remain visible when the pages are viewed on the internet or intranet.
//'<>
//'<> Support can be obtained from support forums at:
//'<> http://www.SkyPortal.net
//'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
helpstat = false;
stprompt = true;
basic = false;
text = ""

function thelp(swtch){
	if (swtch == 1){
		basic = false;
		stprompt = false;
		helpstat = true;
	} else if (swtch == 2) {
		helpstat = false;
		stprompt = false;
		basic = true;
	} else if (swtch == 0) {
		helpstat = false;
		basic = false;
		stprompt = true;
	}
}

function getActiveText(selectedtext) { 
	text = (document.all) ? document.selection.createRange().text : document.getSelection();
		if (selectedtext.createTextRange) {	
   			selectedtext.caretPos = document.selection.createRange().duplicate();	
  		}
		return true;
}

function AddText(text) {
	var tarea = document.PostTopic.Message;
	if (typeof tarea.selectionStart != 'undefined'){ // if it supports DOM2
		start = tarea.selectionStart;
		end = tarea.selectionEnd;
		var posTop = tarea.scrollTop;
		var posLeft = tarea.scrollLeft;
		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;
		tarea.scrollTop = posTop;
		tarea.scrollLeft = posLeft;
	} else if (tarea.createTextRange && tarea.caretPos) {
		var caretPos = tarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?   text + ' ' : text;
		tarea.focus(caretPos);
	} else {
		tarea.value += text;
	}
}

function AddText_original(text) {
if (document.PostTopic.Message.createTextRange && document.PostTopic.Message.caretPos) {
var caretPos = document.PostTopic.Message.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
}
else {
document.PostTopic.Message.value+=text
}
setfocus();
}
function setfocus() {
document.PostTopic.Message.focus();
}

function email() {
	var text = getText();
	if (helpstat) {
		alert("Converte un indirizzo email in link cliccabile.\n\nUSO #1: [url]qualcuno\@anywhere.com[/url] \nUSO #2: [url=\"qualcuno\@anywhere.com\"]testo link[/url]");
		}
	else if (basic) {
		AddTxt="[url]"+text+"[/url]";
		AddText(AddTxt);
		}
	else { 
		txt2=prompt("Testo da riportare al posto del link. (Lascia in bianco per riportare il semplice indirizzo email",""); 
		if (txt2!=null) {
			txt=prompt("Indirizzo email (da scrivere dopo il -mailto:-).","mailto:");      
			if (txt!=null) {
				if (txt2=="") {
					AddTxt="[url]"+txt+"[/url]";
					AddText(AddTxt);
				} else {
					AddTxt="[url=\""+txt+"\"]"+txt2+"[/url]";
					AddText(AddTxt);
				}         
			} 
		}
	}
}
function showsize(size) {
	var text = getText();
	if (helpstat) {
		alert("Size si riferisce alle dimenzioni del testo. Valori da 1 a 6.\n1=piccolo 6=gigante.\n\nUSO: [size="+size+"]Dimensione "+size+" per il testo[/size="+size+"]");
	} else if (basic) {
		AddTxt="[size="+size+"]"+text+"[/size="+size+"]";
		AddText(AddTxt);
	} else {                       
		txt=prompt("Testo da scrivere in dimensione "+size,"Testo"); 
		if (txt!=null) {             
			AddTxt="[size="+size+"]"+txt+"[/size="+size+"]";
			AddText(AddTxt);
		}        
	}
}

function bold() {
	var text = getText();
	if (helpstat) {
		alert("Grassetto.\n\nUSO: [b]Testo in grassetto[/b]");
	} else if (basic) {
		AddTxt="[b]"+text+"[/b]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Testo da scrivere in Grassetto.","Testo");     
		if (txt!=null) {           
			AddTxt="[b]"+txt+"[/b]";
			AddText(AddTxt);
		}       
	}
}

function italicize() {
	var text = getText();
	if (helpstat) {
		alert("Corsivo.\n\nUSO: [i]Testo in corsivo[/i]");
	} else if (basic) {
		AddTxt="[i]"+text+"[/i]";
		AddText(AddTxt);
	} else {   
		txt=prompt("Testo da mettere in corsivo","Testo");     
		if (txt!=null) {           
			AddTxt="[i]"+txt+"[/i]";
			AddText(AddTxt);
		}	        
	}
}

function quote() {
	var text = getText();
	if (helpstat){
		alert("Il Quote ti permette di scrivere il testo in un rettangolo come citazione.\n\nUSO: [quote]Testo quotato[/quote]");
	} else if (basic) {
		AddTxt="[quote]"+text+"[/quote]";
		AddText(AddTxt);
	} else {   
		txt=prompt("Testo da quotare","Testo");     
		if(txt!=null) {          
			AddTxt="[quote]"+txt+"[/quote]";
			AddText(AddTxt);
		}	        
	}
}

function showcolor(color) {
	var text = getText();
	if (helpstat) {
		alert("Color Tag Sets the text color. Any named color can be used.\n\nUSO: ["+color+"]This is some "+color+" text[/"+color+"]");
	} else if (basic) {
		AddTxt="["+color+"]"+text+"[/"+color+"]";
		AddText(AddTxt);
	} else {  
     	txt=prompt("Text to be "+color,"Text");
		if(txt!=null) {
			AddTxt="["+color+"]"+txt+"[/"+color+"]";
			AddText(AddTxt);        
		} 
	}
}

function center() {
	var text = getText();
 	if (helpstat) {
		alert("Testo allineato al centro.\n\nUSO: [center]Testo al centro[/center]");
	} else if (basic) {
		AddTxt="[center]"+text+"[/center]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Testo da centrare","Testo");     
		if (txt!=null) {          
			AddTxt="[center]"+txt+"[/center]";
			AddText(AddTxt);
		}	       
	}
}

function hyperlink() {
	var text = getText();
	if (helpstat) {
		alert("Inserisci Link \nConverte un URL in link cliccabile.\n\nUSO: [url]http://www.anywhere.com[/url]\n\nUSO: [url=http://www.anywhere.com]testo del link[/url]");
	} else if (basic) {
		AddTxt="[url]"+text+"[/url]";
		AddText(AddTxt);
	} else { 
		txt2=prompt("Testo da mostrare sul Link.\nLascialo in bianco se non vuoi specificarlo.",""); 
		if (txt2!=null) {
			txt=prompt("URL della pagina.","http://");      
			if (txt!=null) {
				if (txt2=="") {
					AddTxt="[url]"+txt+"[/url]";
					AddText(AddTxt);
				} else {
					AddTxt="[url=\""+txt+"\"]"+txt2+"[/url]";
					AddText(AddTxt);
				}         
			} 
		}
	}
}

function image() {
	var text = getText();
	if (helpstat){
		alert("Inserisce una foto esterna nel post.\n\nUSO: [img]http://www.anywhere.com/image.gif[/img]");
	} else if (basic) {
		AddTxt="[img]"+text+"[/img]";
		AddText(AddTxt);
	} else {  
		txt=prompt("URL immagine","http://");    
		if(txt!=null) {            
			AddTxt="[img]"+txt+"[/img]";
			AddText(AddTxt);
		}	
	}
}

function showcode() {
	if (helpstat) {
		alert("Code Tag Blockquotes the text you reference and preserves the formatting.\nUsefull for posting code.\n\nUSO: [code]This is formated text[/code]");
	} else if (basic) {
		AddTxt="[code]"+text+"[/code]";
		AddText(AddTxt);
	} else {   
		txt=prompt("Enter code","");     
		if (txt!=null) {          
			AddTxt="[code]"+txt+"[/code]";
			AddText(AddTxt);
		}	       
	}
}

function list() {
	var text = getText();
	if (helpstat) {
		alert("Serve per creare degli elenchi.\n\nUSO: [list] [*]item1[/*] [*]item2[/*] [*]item3[/*] [/list]");
	} else if (basic) {
		AddTxt="[list]"+text+"[*]  [/*]"+text+"[*]  [/*]"+text+"[*]  [/*]"+text+"[/list]";
		AddText(AddTxt);
	} else {  
		type=prompt("Tipo elenco, scrivi \'A\' per alfabetico, \'1\' per numerico, lascia in bianco per elenco puntato.","");               
		while ((type!="") && (type!="A") && (type!="a") && (type!="1") && (type!=null)) {
			type=prompt("ERROR! Gli unici valori da scrivere sono 'A' e '1' oppure nulla.","");               
		}
		if (type!=null) {
			if (type=="") {
				AddTxt="[list]";
			} else {
				AddTxt="[list="+type+"]";
			} 
			txt="1";
			while ((txt!="") && (txt!=null)) {
				txt=prompt("Inserisci gli elementi del tuo elenco (lascia in bianco per terminare la lista)",""); 
				if (txt!="") {             
					AddTxt+="[*]"+txt+"[/*]"; 
				}                   
			} 
			if (type=="") {
				AddTxt+="[/list] ";
			} else {
				AddTxt+="[/list="+type+"]";
			} 
			AddText(AddTxt); 
		}
	}
}

function underline() {
	var text = getText();
  	if (helpstat) {
		alert("Sottolineato.\n\nUSO: [u]testo sottolineato[/u]");
	} else if (basic) {
		AddTxt="[u]"+text+"[/u]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Testo da sottolineare.","Testo");     
		if (txt!=null) {           
			AddTxt="[u]"+txt+"[/u]";
			AddText(AddTxt);
		}	        
	}
}

function showfont(font) {
	var text = getText();
 	if (helpstat){
		alert("Font Tag per cambiare tipo di carattere.\n\nUSO: [font="+font+"]Il carattere cambia in "+font+"[/font]");
	} else if (basic) {
		AddTxt="[font="+font+"]"+text+"[/font="+font+"]";
		AddText(AddTxt);
	} else {                  
		txt=prompt("Testo da cambiare in "+font,"Testo");
		if (txt!=null) {             
			AddTxt="[font="+font+"]"+txt+"[/font="+font+"]";
			AddText(AddTxt);
		}        
	}  
}

function red() {
	var text = getText();
	if (helpstat) {
		alert("Red Tag Makes the enlosed text Red.\n\nUSO: [red]This is some red text[/red]");
	} else if (basic) {
		AddTxt="[red]"+text+"[/red]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Text to be made RED.","Text");     
		if (txt!=null) {           
			AddTxt="[red]"+txt+"[/red]";
			AddText(AddTxt);
		}       
	}
}

function blue() {
	var text = getText();
	if (helpstat) {
		alert("Blue Tag Makes the enlosed text Blue.\n\nUSO: [blue]This is some blue text[/blue]");
	} else if (basic) {
		AddTxt="[blue]"+text+"[/blue]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Text to be made BLUE.","Text");     
		if (txt!=null) {           
			AddTxt="[blue]"+txt+"[/blue]";
			AddText(AddTxt);
		}       
	}
}

function pink() {
	var text = getText();
	if (helpstat) {
		alert("Pink Tag Makes the enlosed text Pink.\n\nUSO: [pink]This is some pink text[/pink]");
	} else if (basic) {
		AddTxt="[pink]"+text+"[/pink]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Text to be made PINK.","Text");     
		if (txt!=null) {           
			AddTxt="[pink]"+txt+"[/pink]";
			AddText(AddTxt);
		}       
	}
}

function brown() {
	var text = getText();
	if (helpstat) {
		alert("Brown Tag Makes the enlosed text Brown.\n\nUSO: [brown]This is some brown text[/brown]");
	} else if (basic) {
		AddTxt="[brown]"+text+"[/brown]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Text to be made BROWN.","Text");     
		if (txt!=null) {           
			AddTxt="[brown]"+txt+"[/brown]";
			AddText(AddTxt);
		}       
	}
}

function black() {
	var text = getText();
	if (helpstat) {
		alert("Black Tag Makes the enlosed text Black.\n\nUSO: [black]This is some black text[/black]");
	} else if (basic) {
		AddTxt="[black]"+text+"[/black]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Text to be made BLACK.","Text");     
		if (txt!=null) {           
			AddTxt="[black]"+txt+"[/black]";
			AddText(AddTxt);
		}       
	}
}

function orange() {
	var text = getText();
	if (helpstat) {
		alert("Orange Tag Makes the enlosed text Orange.\n\nUSO: [orange]This is some orange text[/orange]");
	} else if (basic) {
		AddTxt="[orange]"+text+"[/orange]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Text to be made ORANGE.","Text");     
		if (txt!=null) {           
			AddTxt="[orange]"+txt+"[/orange]";
			AddText(AddTxt);
		}       
	}
}

function violet() {
	var text = getText();
	if (helpstat) {
		alert("Violet Tag Makes the enlosed text Violet.\n\nUSO: [violet]This is some violet text[/violet]");
	} else if (basic) {
		AddTxt="[violet]"+text+"[/violet]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Text to be made VIOLET.","Text");     
		if (txt!=null) {           
			AddTxt="[violet]"+txt+"[/violet]";
			AddText(AddTxt);
		}       
	}
}

function yellow() {
	var text = getText();
	if (helpstat) {
		alert("Yellow Tag Makes the enlosed text Yellow.\n\nUSO: [yellow]This is some yellow text[/yellow]");
	} else if (basic) {
		AddTxt="[yellow]"+text+"[/yellow]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Text to be made YELLOW.","Text");     
		if (txt!=null) {           
			AddTxt="[yellow]"+txt+"[/yellow]";
			AddText(AddTxt);
		}       
	}
}

function green() {
	var text = getText();
	if (helpstat) {
		alert("Green Tag Makes the enlosed text Green.\n\nUSO: [green]This is some green text[/green]");
	} else if (basic) {
		AddTxt="[green]"+text+"[/green]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Text to be made GREEN.","Text");     
		if (txt!=null) {           
			AddTxt="[green]"+txt+"[/green]";
			AddText(AddTxt);
		}       
	}
}

function gold() {
	var text = getText();
	if (helpstat) {
		alert("Gold Tag Makes the enlosed text Gold.\n\nUSO: [gold]This is some gold text[/gold]");
	} else if (basic) {
		AddTxt="[gold]"+text+"[/gold]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Text to be made GOLD.","Text");     
		if (txt!=null) {           
			AddTxt="[gold]"+txt+"[/gold]";
			AddText(AddTxt);
		}       
	}
}

function white() {
	var text = getText();
	if (helpstat) {
		alert("White Tag Makes the enlosed text White.\n\nUSO: [white]This is some white text[/white]");
	} else if (basic) {
		AddTxt="[white]"+text+"[/white]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Text to be made WHITE.","Text");     
		if (txt!=null) {           
			AddTxt="[white]"+txt+"[/white]";
			AddText(AddTxt);
		}       
	}
}

function purple() {
	var text = getText();
	if (helpstat) {
		alert("Purple Tag Makes the enlosed text Purple.\n\nUSO: [purple]This is some purple text[/purple]");
	} else if (basic) {
		AddTxt="[purple]"+text+"[/purple]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Text to be made PURPLE.","Text");     
		if (txt!=null) {           
			AddTxt="[purple]"+txt+"[/purple]";
			AddText(AddTxt);
		}       
	}
}

function beige() {
	var text = getText();
	if (helpstat) {
		alert("Beige Tag Makes the enlosed text Beige.\n\nUSO: [beige]This is some Beige text[/beige]");
	} else if (basic) {
		AddTxt="[beige]"+text+"[/beige]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Text to be made BEIGE.","Text");     
		if (txt!=null) {           
			AddTxt="[beige]"+txt+"[/beige]";
			AddText(AddTxt);
		}       
	}
}

function teal() {
	var text = getText();
	if (helpstat) {
		alert("Teal Tag Makes the enlosed text Teal.\n\nUSO: [teal]This is some teal text[/teal]");
	} else if (basic) {
		AddTxt="[teal]"+text+"[/teal]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Text to be made TEAL.","Text");     
		if (txt!=null) {           
			AddTxt="[teal]"+txt+"[/teal]";
			AddText(AddTxt);
		}       
	}
}

function navy() {
	var text = getText();
	if (helpstat) {
		alert("Navy Tag Makes the enlosed text Navy.\n\nUSO: [navy]This is some navy text[/navy]");
	} else if (basic) {
		AddTxt="[navy]"+text+"[/navy]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Text to be made NAVY.","Text");     
		if (txt!=null) {           
			AddTxt="[navy]"+txt+"[/navy]";
			AddText(AddTxt);
		}       
	}
}

function maroon() {
	var text = getText();
	if (helpstat) {
		alert("Maroon Tag Makes the enlosed text Maroon.\n\nUSO: [maroon]This is some maroon text[/maroon]");
	} else if (basic) {
		AddTxt="[maroon]"+text+"[/maroon]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Text to be made MAROON.","Text");     
		if (txt!=null) {           
			AddTxt="[maroon]"+txt+"[/maroon]";
			AddText(AddTxt);
		}       
	}
}

function limegreen() {
	var text = getText();
	if (helpstat) {
		alert("Limegreen Tag Makes the enlosed text Limegreen.\n\nUSO: [limegreen]This is some limegreen text[/limegreen]");
	} else if (basic) {
		AddTxt="[limegreen]"+text+"[/limegreen]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Text to be made LIMEGREEN.","Text");     
		if (txt!=null) {           
			AddTxt="[limegreen]"+txt+"[/limegreen]";
			AddText(AddTxt);
		}       
	}
}

function strike() {
	var text = getText();
	if (helpstat) {
		alert("Barrato.\n\nUSO: [s]Testo barrato[/]");
	} else if (basic) {
		AddTxt="[s]"+text+"[/s]";
		AddText(AddTxt);
	} else {   
		txt=prompt("Testo da barrare","Testo");     
		if (txt!=null) {           
			AddTxt="[s]"+txt+"[/s]";
			AddText(AddTxt);
		}	        
	}
}

function aleft() {
	var text = getText();
 	if (helpstat) {
		alert("Allinea a sinistra.\n\nUSO: [left]Questo testo allineato a sinistra[/left]");
	} else if (basic) {
		AddTxt="[left]"+text+"[/left]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Testo da allineare a sinistra","Testo");     
		if (txt!=null) {          
			AddTxt="[left]"+txt+"[/left]";
			AddText(AddTxt);
		}	       
	}
}

function aright() {
	var text = getText();
 	if (helpstat) {
		alert("Allinea a destra.\n\nUSO: [right]Questo testo allineato a destra[/right]");
	} else if (basic) {
		AddTxt="[right]"+text+"[/right]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Testo da allineare a destra","Testo");     
		if (txt!=null) {          
			AddTxt="[right]"+txt+"[/right]";
			AddText(AddTxt);
		}	       
	}
}

function pre() {
	var text = getText();
 	if (helpstat) {
		alert("Pre tag allows you to write freely.\n\nUSO: [pre]This   text   is   written   freely[/pre]");
	} else if (basic) {
		AddTxt="[pre]"+text+"[/pre]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Text to be pre","Text");     
		if (txt!=null) {          
			AddTxt="[pre]"+txt+"[/pre]";
			AddText(AddTxt);
		}	       
	}
}

function marquee() {
	var text = getText();
 	if (helpstat) {
		alert("Striscione.\n\nUSO: [marquee]Questo testo si muove[/marquee]");
	} else if (basic) {
		AddTxt="[marquee]"+text+"[/marquee]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Testo da scrivere in movimento","Testo");     
		if (txt!=null) {          
			AddTxt="[marquee]"+txt+"[/marquee]";
			AddText(AddTxt);
		}	       
	}
}

function sup() {
	var text = getText();
 	if (helpstat) {
		alert("Apice (esponente).\n\nUSO: Testo in[sup]apice[/sup]");
	} else if (basic) {
		AddTxt="[sup]"+text+"[/sup]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Testo da scrivere in apice","Testo");     
		if (txt!=null) {          
			AddTxt="[sup]"+txt+"[/sup]";
			AddText(AddTxt);
		}	       
	}
}

function sub() {
	var text = getText();
 	if (helpstat) {
		alert("Pedice.\n\nUSO: Testo in[sub]pedice[/sub]");
	} else if (basic) {
		AddTxt="[sub]"+text+"[/sub]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Testo da scrivere come pedice","Testo");     
		if (txt!=null) {          
			AddTxt="[sub]"+txt+"[/sub]";
			AddText(AddTxt);
		}	       
	}
}

function tt() {
	var text = getText();
 	if (helpstat) {
		alert("Teletype tag writes the enclosed text as TeleType.\n\nUSO: [tt]This text is TeleType[/tt]");
	} else if (basic) {
		AddTxt="[tt]"+text+"[/tt]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Text to be written as TeleType","Text");     
		if (txt!=null) {          
			AddTxt="[tt]"+txt+"[/tt]";
			AddText(AddTxt);
		}	       
	}
}





function hl() {
	var text = getText();
  	if (helpstat) {
		alert("Evidenziatore.\n\nUSO: [hl]Testo evidenziato in giallo[/hl]");
	} else if (basic) {
		AddTxt="[hl]"+text+"[/hl]";
		AddText(AddTxt);
	} else {  
		txt=prompt("Testo da evidenziare in giallo.","Testo");     
		if (txt!=null) {           
			AddTxt="[hl]"+txt+"[/hl]";
			AddText(AddTxt);
		}	        
	}
}


function hr() {
  	if (helpstat) {
		alert("Linea orizzontale.\n\nUSO: questa linea[hr]");
	} else if (basic) {
		AddTxt="[hr]";
		AddText(AddTxt);
	} else {  
		AddTxt="[hr]";
		AddText(AddTxt);
	}
}

function OpenPreview(){
	var curCookie = "strMessagePreview=" + escape(document.PostTopic.Message.value);
	document.cookie = curCookie;
	popupWin = window.open('pop_portal.asp?cmd=6', 'preview_page', 'scrollbars=yes,width=750,height=450')	
}

function ltrim(s) {
	return s.replace( /^\s*/, "" );
}
function rtrim(s) {
	return s.replace( /\s*$/, "" );
}
function trim ( s ) {
	return rtrim(ltrim(s));
}

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 '';
}
/********************************************************************************
*   OnlineVideos MOD 
*   bruno.in.dk [at] gmail.com
********************************************************************************/
// Google Video
function gvid() {
	var text = getText();
	if (helpstat){
		alert("Google Video.\n\nEsempio: [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\nEsempio: [tube]http://www.youtube.com/watch?v=MQ9PRzIyzFA[/tube]");
	} else if (basic) {
		AddTxt="[tube]" + text + "[/tube]";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("YouTube Video URL",text);
		} else {
			txt=prompt("YouTube Video URL","Copia qui l indirizzo della pagina del video");
		}
		if(txt!=null) {
			AddTxt="[tube]"+txt+"[/tube]";
			AddText(AddTxt);
		}
	}
}
// Flash Video
function flashv() {
	var text = getText();
	if (helpstat){
		alert("Flash Video.\n\nUtilizzo:: [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\nUtilizzo:: [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\nUtilizzo:: [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\nUtilizzo:: [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\nUtilizzo:: [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\nUtilizzo:: [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);
		}
	}
}
