//---------------------------------------------------------PROTOTYPE--
String.prototype.toDate = function() {

var i, j;
var yy,dd,mm, h,m,s;

	i = this.search("/");
	j = i + this.substring(i+1, this.length).search("/") + 1;
	dd = this.substring(0, i);
	mm = this.substring(i+1, j);
	yy = this.substr(j+1, 4);

	i = this.search(":");
	if (i != -1) {
		j = i + this.substring(i+1, this.length).search(":") + 1;
		h = this.substr(i-2, 2);
		m = this.substr(i+1, 2);
		s = this.substr(j+1, 2);

//**/		Response.Write(this + "<br>");
//**/		Response.Write(yy + "-" + mm + "-" + dd + " ");
//**/		Response.Write(h + ":" + m + ":" + s);
		
		return new Date(Number(yy), Number(mm)-1, Number(dd), Number(h), Number(m), Number(s));
	}
	
//**/	Response.Write(yy + "-" + mm + "-" + dd + " ");

	return new Date(Number(yy), Number(mm)-1, Number(dd));
}


//---------------------------------------------------------PROTOTYPE--
String.prototype.toNumber = function() {

var num = new String(this);

	do {
		num = num.replace(",", "");
	} while( num.search(",") != -1 );

	return Number(num);
}


//---------------------------------------------------------PROTOTYPE--
String.prototype.toPrice = Number.prototype.toPrice = function() {

var fstr2	= String(this).replace(".", "/");
var fstr	= new String();
var pos	= fstr2.search("/");
if (pos <= 0) pos = fstr2.length;

	if (pos > 3) {
		for (var i=pos; i>0; i=i-3)
			fstr = fstr2.substring(i-3, i) + "," + fstr;

		fstr = fstr.substring(0, fstr.length-1);
		return fstr.replace("-,", "-");
	}

	return fstr2.replace("/", ".");
}


//---------------------------------------------------------PROTOTYPE--
String.prototype.replaceall = function(regExp, rep) {

var fstr = "";
var i = 0;
var pos;

	if (typeof this != "string")
		return "";
	else
		var istr = this;

	i = 0;
	do {
		pos = istr.search(regExp);
		if (pos != -1) {
			istr = istr.substring(pos+regExp.length, istr.length);
			fstr += istr.substring(0, pos) + rep;
		}
		else
			if (i == 0)
				fstr = this;

		i++;
	} while( (i < 100) && (pos != -1) );
	
	return fstr;
}

//---------------------------------------------------------PROTOTYPE--
String.prototype.toArray = function() {

var farray = new Array();
var fstr = String(this);
var i, f;

	i = 0;
	do {
		f = fstr.search(", ");
		if (f == -1) break;

		farray[i] = fstr.substring(0, f);
		fstr = fstr.substring(f+2, fstr.length);

		i++;
	} while(i < 1000);
	farray[i] = fstr;
	
	return farray;
}


//---------------------------------------------------------PROTOTYPE--
Date.prototype.toStringEx = function(nodate, notime) {

var str = "";

	if (!nodate) {
		if (this.getDate() < 10) str += "0";
		str += this.getDate() + "/";
		if (this.getMonth() < 9) str += "0";
		str += (this.getMonth()+1) + "/";
		str += this.getYear();
	}

	if (!notime) {
		if (!nodate) str += " ";

		if (this.getHours() < 10) str += "0";
		str += this.getHours() + ":";
		if (this.getMinutes() < 10) str += "0";
		str += this.getMinutes() + ":";
		if (this.getSeconds() < 10) str += "0";
		str += this.getSeconds();
	}

	return str;
}


//---------------------------------------------------------PROTOTYPE--
Date.prototype.toStringDB = function(nodate, notime) {

var str = "#";

	if (Date.parse(this.getVarDate()) < 0) return "";

	if (!nodate)
		str += this.getYear() + "-" + (this.getMonth()+1) + "-" + this.getDate();

	if (!notime && this.getMilliseconds() != 0) {
		if (!nodate) str += " ";

		str += this.getHours() + ":" + this.getMinutes() + ":" + this.getSeconds();
	}

	return str + "#";
}

