String.prototype.str_replace = function str_replace(search, replace) {

    var f = search, r = replace, s = this;
    var ra = r instanceof Array, sa = s instanceof Array, f = [].concat(f), r = [].concat(r), i = (s = [].concat(s)).length;
 
    while (j = 0, i--) {
        if (s[i]) {
            while (s[i] = (s[i]+'').split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
        }
    };
 
    return sa ? s : s[0];
}


String.prototype.removeHtml = function removeHtml(){
	
	var reg1 = new RegExp("((<|</)([^<>]+)(>))","gi");
	return  this.replace(reg1,'');
	
		
}

String.prototype.formdate2date = function formdate2date(){
	
				var dd = this.substring(0,2);
				var mm = this.substring(3,5);
				var yyyy = this.substring(6,10);
				var hh = this.substring(11,13);
				var ii = this.substring(14,16);
				var ss = this.substring(17,29);
				var str = yyyy+','+mm+','+dd+','+hh+','+ii+','+ss;
				var date = new Date(yyyy,mm,dd,hh,ii,ss);
				return date;

}

String.prototype.replaceAll = function replaceAll(search, repl) {
str = this;
while (this.indexOf(search) != -1)
str = str.replace(search, repl);
return str;
}


String.prototype.stripAccent = function stripAccent()
{
var s=this;

var rExps=[ /[\xC0-\xC2]/g, /[\xE0-\xE2]/g,
/[\xC8-\xCA]/g, /[\xE8-\xEB]/g,
/[\xCC-\xCE]/g, /[\xEC-\xEE]/g,
/[\xD2-\xD4]/g, /[\xF2-\xF4]/g,
/[\xD9-\xDB]/g, /[\xF9-\xFB]/g ];

var repChar=['A','a','E','e','I','i','O','o','U','u'];

for(var i=0; i<rExps.length; i++)
s=s.replace(rExps[i],repChar[i]);

return s;
}



/* Add a class to a string */
String.prototype.addClass = function(theClass)
{
	if (this != "")
	{
		if (!this.classExists(theClass))
		{
			return this + " " + theClass;
		}
	}
	else
	{
		return theClass;
	}
	
	return this;
}




/* Check if a class exists in a string */
String.prototype.classExists = function(theClass)
{
	var regString = "(^| )" + theClass + "\W*";
	var regExpression = new RegExp(regString);
	
	if (regExpression.test(this))
	{
		return true;
	}
	
	return false;
}




/* Check if a string is the nodeName of an accepted element */
String.prototype.isAcceptedElementName = function()
{
	var elementList = new Array("#text", "a", "em", "h1", "h2", "h3", "h4", "h5", "h6", "img", "li", "ol", "p", "strong", "ul");
	var theName = this.toLowerCase();
	
	for (var i = 0; i < elementList.length; i++)
	{
		if (theName == elementList[i])
		{
			return true;
		}
	}
	
	return false;
}




/* Check if a string is the nodeName of an inline element */
String.prototype.isInlineName = function()
{
	var inlineList = new Array("#text", "a", "em", "font", "span", "strong", "u");
	var theName = this.toLowerCase();
	
	for (var i = 0; i < inlineList.length; i++)
	{
		if (theName == inlineList[i])
		{
			return true;
		}
	}
	
	return false;
}




/* Remove a class from a string */
String.prototype.removeClass = function(theClass)
{
	var regString = "(^| )" + theClass + "\W*";
	var regExpression = new RegExp(regString);
	
	return this.replace(regExpression, "");
}




/* Reverse a string */
String.prototype.reverse = function()
{
	var theString = "";
	
	for (var i = this.length - 1; i >= 0; i--)
	{
		theString += this.charAt(i);
	}
	
	return theString;
}




/* Make tags valid by converting uppercase element and attribute names to lowercase and quoting attributes */
String.prototype.stripTags = function(){
	
	//Delete all META tags
	doc = this.replace(/<\/?META[^>]*>/gi, '')
	
	//Delete all LINK tags
	.replace(/<\/?LINK[^>]*>/gi, '')
	
	//Delete all XML tags
	.replace(/<\\?\?xml[^>]*>/gi, '')
	
	//Delete all commments
	.replace(/<\/?!--[^>]*>/gi, '')
	
	//Delete Class attributes
	.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, '<$1$3')
	
	//Delete Style attributes
	.replace(/<(\w[^>]*) style='([^']*)'([^>]*)/gi, '<$1$3')
	
	//Delete Lang attributes
	.replace(/<(\w[^>]*) size=([^ |>]*)([^>]*)/gi, '<$1$3')

	//Delete Face attributes
	.replace(/<(\w[^>]*) face=([^ |>]*)([^>]*)/gi, '<$1$3')
	
	
	//Delete Lang attributes
	.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, '<$1$3')
	
	//Delete XML elements and declarations
	.replace(/<\\?\?xml[^>]*>/gi, '')
	
	//Delete Tags with XML namespace declarations: <o:p></o:p>
	.replace(/<\/?\w+:[^>]*>/gi, '')
	
	
	//Delete the MARGIN: 0cm 0cm 0pt; IE puts in when pasting from Word
	.replace(/MARGIN: 0cm 0cm 0pt;/gi, '')
	
	//Clean up tags
	.replace(/<B [^>]*>/gi,'<b>')
	.replace(/<I [^>]*>/gi,'<i>')
	.replace(/<LI [^>]*>/gi,'<li>')
	.replace(/<UL [^>]*>/gi,'<ul>')
	
	//Replace outdated tags
	.replace(/<B>/gi,'<strong>')
	.replace(/<\/B>/gi,'</strong>')
	.replace(/<I>/gi,'<em>')
	.replace(/<\/I>/gi,'</em>')
	
	//Delete empty tags
	.replace(/<strong><\/strong>/gi,'')
	.replace(/<strong> <\/strong>/gi,'')
	.replace(/<em><\/em>/gi,'')
	.replace(/<em> <\/em>/gi,'')
	
	
	return doc;

}




