// JavaScript Document
String.prototype.trim = function(){ return this.replace(/^\W*|\W*$/g, ""); };	// Trim non-word characters from the start and end of the string
String.prototype.tags = function(){ var string = this.replace(/>/g, "&gt;"); return string.replace(/</g, "&lt;"); };
String.prototype.trimtrailing = function(){
	var lastchars = this.substr((this.length-2), this.length) ;
	if ( lastchars == "\r\n" ) { return this.substr(0, (this.length-2)) ; }
	else { return this ; }
};
String.prototype.parseadmin = function(admin_name, visitor_name){
	var output_string = this ;
	var temp_string ;
	if ( output_string.indexOf("image:") != -1 )
		output_string = output_string.replace( /image:(.*?)($| |<br>)/g, "<img src=$1 > " ) ;
	if ( output_string.indexOf("url:") != -1 )
	{
		var url_prefix = "http:" ;
		if ( output_string.indexOf("https:" ) != -1 )
			url_prefix = "https:" ;

		temp_string = regmatch( output_string, "url:(.*?)($| |<br>)" ) ;
		if ( temp_string.indexOf( url_prefix ) != -1 )
			temp_string = "<a href="+temp_string+" target=new >"+temp_string+"</a> " ;
		else
			temp_string = "<a href="+url_prefix+"//"+temp_string+" target=new >"+url_prefix+"//"+temp_string+"</a> " ;
		output_string = output_string.replace( /url:(.*?)($| |<br>)/g, temp_string ) ;
	}
	if ( output_string.indexOf("push:") != -1 )
	{
		var url_prefix = "http:" ;
		if ( output_string.indexOf("https:" ) != -1 )
			url_prefix = "https:" ;

		temp_string = regmatch( output_string, "push:(.*?)($| |<br>)" ) ;
		if ( temp_string.indexOf( url_prefix ) != -1 )
			temp_string = "[ Abrindo página: <a href="+temp_string+" target=new >"+temp_string+"</a> ]" ;
		else
			temp_string = "[ Abrindo página: <a href="+url_prefix+"//"+temp_string+" target=new >"+url_prefix+"//"+temp_string+"</a> ]" ;
		output_string = output_string.replace( /push:(.*?)($| |<br>)/g, temp_string ) ;
	}
	if ( output_string.indexOf("email:") != -1 )
		output_string = output_string.replace( /email:(.*?)($| |<br>)/g, "<a href=mailto:$1 >$1</a> " ) ;
	if ( output_string.indexOf("%%user%%") != -1 )
		output_string = output_string.replace( /%%user%%/g, visitor_name ) ;
	if ( output_string.indexOf("%%operator%%") != -1 )
		output_string = output_string.replace( /%%operator%%/g, admin_name ) ;
	return output_string ;
};