
String.prototype.getBytesLength = function() {
	return this.replace(/[^\x00-\xff]/g,"aA").length;
}

String.prototype.toDate = function() {
	
	var theday = null;
	
	var da = new Array(0, 0, 0);
	if (this.indexOf("/") > 0) {
		da = this.split("/");
	} else if (this.indexOf("-") > 0) {
		da = this.split("-");
	} else if (this.length == 8) {
		da[0] = parseInt(this.substr(0,4), 10);
		da[1] = parseInt(this.substr(4,2), 10);
		da[2] = parseInt(this.substr(6,2), 10);
	}

	if (da.length == 3) {
		theday = new Date(parseInt(da[0], 10), parseInt(da[1], 10) - 1, parseInt(da[2], 10));
		if (theday.getFullYear() != parseInt(da[0], 10) ||
				theday.getMonth() + 1 != parseInt(da[1], 10) ||
				theday.getDate() != parseInt(da[2], 10)) {
			theday = null;
		}
	}
	
	return theday;
}

String.prototype.Trim = function() 
{ 
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

String.prototype.TrimAll = function() 
{ 
	return this.replace(/(\s*)/g, "");
}

String.prototype.isNumberString = function() {
	var tmp = this.replace(/[0-9]/g, "");
	return (tmp.length == 0);
}

String.prototype.isAlphabetString = function() {
	var tmp = this.replace(/[a-zA-Z]/g, "");
	return (tmp.length == 0);
}

String.prototype.isAlphaNumString = function() {
	var tmp = this.replace(/[a-zA-Z0-9]/g, "");
	return (tmp.length == 0);
}
