﻿<!-- //
String.prototype.trim = new Function( "return this.replace(/^\\s+|\\s+$/g,'')" );

String.prototype.replaceStr = function( find, replace ) {
	return this.split( find ).join( replace );
};

String.prototype.escapeForXML = function() {
	return this.replaceStr( "&", "&amp;" ).
			    replaceStr( "\"", "&quot;" ).
			    replaceStr( "<", "&lt;" ).
			    replaceStr( ">", "&gt;" );
};

String.prototype.escapeForJS = function() {
	return this.replaceStr( '<', '' ).
			    replaceStr( '>', '' );
};

String.prototype.escapeForField = function() {
	return this.replaceStr( "&lt;", "<" ).
				replaceStr( "&", "&amp;" ).
				replaceStr( "\"", "&quot;" ).
				replaceStr( "<", "&lt;" ).
				replaceStr( ">", "&gt;" );
};

String.prototype.escapeForDisplay = function() {
	return this.replaceStr( "<", "&lt;" );
};

String.prototype.isEmpty = function() {
	var x = this.trim();

	if ( x.length == 0 ) {
		return true;
	}
	return false;
};

String.prototype.startsWith = function( str ) {
    return ( this.match( "^" + str ) == str );
};

String.prototype.endsWith = function( str ) {
    return ( this.match( str + "$" ) == str );
};
// -->