function trim(str, charlist) {
	var whitespace,
	l = 0,
	i = 0;
	str += '';
	if (!charlist) {
		whitespace = " \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000";
	} else {
		charlist += '';
		whitespace = charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '$1');
	}

	l = str.length;
	for (i = 0; i < l; i++) {
		if (whitespace.indexOf(str.charAt(i)) === -1) {
			str = str.substring(i);
			break;
		}
	}

	l = str.length;
	for (i = l - 1; i >= 0; i--) {
		if (whitespace.indexOf(str.charAt(i)) === -1) {
			str = str.substring(0, i + 1);
			break;
		}
	}

	return whitespace.indexOf(str.charAt(0)) === -1 ? str: '';
}

function removeErrorDiv(divname){
	return;
	if (jQuery('#error_' + divname).val() != undefined) {
		jQuery('#error_' + divname).remove();
		if (jQuery('#div_error div').length == 0) {
			jQuery('#div_error').remove();
		}
	}
}

function xss_ajax(url){
	var script_id = null;
	var script = document.createElement('script');
	script.setAttribute('type', 'text/javascript');
	script.setAttribute('src', url);
	script.setAttribute('id', 'script_id');
	script_id = document.getElementById('script_id');
	if (script_id){
		document.getElementsByTagName('head')[0].removeChild(script_id);
	} 
	document.getElementsByTagName('head')[0].appendChild(script);
}

function ucwords(str) {
	return (str + '').replace(/^(.)|\s(.)/g, 
	function($1) {
		return $1.toUpperCase();
	});
}

