//test
function toDate (object) {
	if(typeof object.value != "undefined"){
		tmpVal = object.value;
		
		reDate = /(\d{4})-(?:0([1-9])|(1[012]))-([0-3][0-9])/;
		aMatches = tmpVal.match(reDate);
		if(aMatches != null){	
			
			if(typeof aMatches[2] == "undefined"){
				tmp_m = aMatches[3];
			}else{
				tmp_m = aMatches[2];
			}
			
			tmp_y = parseInt(aMatches[1]);
			tmp_m = parseInt(tmp_m) -1;
			tmp_d = parseInt(aMatches[4]);
			
			return new Date(tmp_y, tmp_m, tmp_d);
		}else{
			
		}
		return false;
	}
	return false;
};



Date.prototype.shiftDay = function (iDays) {
	this.setDate(this.getDate() + iDays);
	return this;
};
Date.prototype.shiftMonth = function (iMonths) {
	this.setMonth(this.getMonth() + iMonths);
	return this;
};
Date.prototype.shiftFullYear = function (iYears) {
	this.setFullYear(this.getFullYear() + iYears);
	return this;
};
Date.prototype.getNDate = function () {
	tmp_m = ((this.getMonth()+1) > 9) ? (this.getMonth() + 1).toString() : "0" + (this.getMonth() + 1).toString();
	tmp_d = (this.getDate() > 9) ? this.getDate().toString() : "0" + this.getDate().toString();
	
	return this.getFullYear().toString() + "-" + tmp_m + "-" +tmp_d;
};

Date.prototype.dateDiff = function(otherDate){
	return otherDate.getTime() - this.getTime();
};
