/**
 * like php functions
 * @author Helmut Wandl <wandls.net>
 */
var ENT_NOQUOTES = 0,
    ENT_COMPAT = 2,
    ENT_QUOTES = 3;
var htmlspecialchars = function(string, quote_style) {
	return string.replace(/[\&\<\>\"\']/g, function(h){
		switch(h) {
			case '&':  return '&amp;';
			case '<':  return '&lt;';
			case '>':  return '&gt;';
			case '"':  return quote_style & 2 ? '&quot;' : h;
			case '\'': return quote_style & 1 ? '&#039;' : h;
		}
	});
};
var htmlspecialchars_decode = function(string, quote_style) {
	return string.replace(/\&(?:amp|lt|gt|quot|\#039)\;/g, function(h){
		switch(h) {
			case '&amp;':  return '&';
			case '&lt;':   return '<';
			case '&gt;':   return '>';
			case '&quot;': return quote_style & 2 ? '"' : h;
			case '&#039;': return quote_style & 1 ? '\'' : h;
		}
	});
};
/************************************************************/


