// --------------------------------------------------
// str_trim* & change_quotes prototypes realization
// 0.05 (11.12.2003 10:55:15)
//			+ str_chop() - see below
// 0.04	(28.08.2003 13:15:56)
//			+ str_trim_all() - see below
// 0.03	(30.07.2003 15:41:24)
//			x* rewritten change_quotes() to work even with ie5
// 0.02	(05.05.2003 12:52:35)
//			x* change_quotes() changed (RE)
// 0.01	(15.12.2002 16:39:31)
// --------------------------------------------------
function str_trim() {
	s=this.toString()
	if (s==" ") return ""

	re=/^\s+/gi;
	s1 = s.replace(re,"")
	re=/\s+$/gi;
	s1 = s1.replace(re,"")

	if (s1==" ") return ""

	return s1
} // str_trim()

// --------------------------------------------------
// str_chop() - removes line ends
// --------------------------------------------------
function str_chop() {
	re=/\n|\r|\r\n/i;
	s=this.toString()
	s1 = s.replace(re,"")
	return s1
} // str_chop()

// --------------------------------------------------
// change_quotes()
// 22.04.2003 18:16:44
// --------------------------------------------------
function change_quotes() {
	// ie [5.0] doesn't recognize ? in .*? (ns/mozilla DO)
	// and i don't know why
	var re = /"(.*)"($|[\,\;\:\.\-\s\<\(\)\!=]+)/i;

	s=this.toString()
	s=s.trim()
	if (s=="") return ""

	if (s.search(re)!=-1) {
		s1 = s.replace(re,"&laquo;"+"$1"+"&raquo;"+"$2")
		return s1
	}
	else return s
} // change_quotes()

// --------------------------------------------------
// str_trim_all()
// ALL THIS SHIT IS BECAUSE OF IE 5.0 !!!
// it doesn't recognize " " in strings, passed by POST
// it uses char(160) instead of `space`
// 0.04	(28.08.2003 13:15:56)
// --------------------------------------------------
function str_trim_all() {
	//var char160 = String.fromCharCode(160)

	s=this.toString()
	s1 = s.trim()
	if (s1==" " || s1=="") return "";

	// it's not a space below (in `re`), it's a char160 !!!
	re=/\s| /g;
	s1 = s.replace(re,"")
	if (s1==" ") return ""

	return s1
} // str_trim_all()

String.prototype.trimall=str_trim_all
String.prototype.trim=str_trim
String.prototype.chop=str_chop
String.prototype.quotes=change_quotes
