String.prototype.isValidDate = function(){

	//pattern = /^(0[1-9]|[12][0-9]|[3][12])\/(0[1-9]|1[012])\/([12][0-9]{3})( ([01][0-9]|2[0-3])\:([0-5][0-9])(\:[0-5][0-9])?)?$/;
    pattern = /^(0[1-9]|[12][0-9]|[3][01])\/(0[1-9]|1[012])\/([12][0-9]{3})( ([01][0-9]|2[0-3])\:([0-5][0-9])(\:[0-5][0-9])?)?$/;


	if(this.search(pattern) == -1) return false;

	if(this.search(/ /) != -1){
		aDate = this.split(' ')[0].split('/');
	}else{
		aDate = this.split('/');
	}
	
	fAno = parseFloat(aDate[2]);
	fMes = parseFloat(aDate[1]);
	fDia = parseFloat(aDate[0]);

	if( fMes == 2 ) {
		if( fAno % 4 == 0 && ( fAno % 100 != 0 || fAno % 400 == 0) && fDia > 29 ) return false;
		if(! ( fAno % 4 == 0 && ( fAno % 100 != 0 || fAno % 400 == 0 ) ) && fDia > 28 ) return false;
	}
	if( ( fMes == 4 || fMes == 6 || fMes == 9 || fMes == 11) && fDia > 30 ) return false;
	if( ( fMes == 1 || fMes == 3 || fMes == 5 || fMes == 7 || fMes == 8 || fMes == 10 || fMes == 12 ) && fDia > 31 ) return false;
	return true;
}

Date.Parse = function(sDate){
	
	if(! sDate.isValidDate()) return new Date(1900,1,1,0,0,0);
	
	if(sDate.search(/ /) != -1)
	{
		aDate = sDate.split(' ')[0].split('/');
		aTime = sDate.split(' ')[1].split(':');
		if(aTime.length == 2) aTime.push(0);
	}else{
		aDate = sDate.split('/');
		aTime = new Array(0,0,0);
	}
	return new Date(aDate[2],aDate[1],aDate[0],aTime[0],aTime[1],aTime[2])
}

Date.prototype.isSQLSmallDate = function()
{

	if(	( this.getFullYear() < 1900 ) ||
			( this.getFullYear() == 1900 && ( this.getMonth()+1) < 1 ) ||
			( this.getFullYear() == 1900 && ( this.getMonth()+1) == 1 && this.getDate() < 1)
		)return false;
		
	if( ( this.getFullYear() > 2079 ) ||
			( this.getFullYear() == 2079 && (this.getMonth()+1) > 6) ||
			( this.getFullYear() == 2079 && (this.getMonth()+1) == 6 && this.getDate() > 6)
		)return false;
		
	return true;
}

Date.prototype.isSQLDate = function()
{
	if(	( this.getFullYear() < 1753 ) ||
			( this.getFullYear() == 1753 && ( this.getMonth()+1) < 1 ) ||
			( this.getFullYear() == 1753 && ( this.getMonth()+1) == 1 && this.getDate() < 1)
		)return false;
	return true;
}