function isDateOld (year, month, day) 
{
	if (day.length==1){day='0'+day;}
	if (month.length==1){month='0'+month;}
	var strData = day +'/'+ month +'/'+ year; 
	var dia, mes, ano;
	//critica valor de um campo de data
	if(strData.length < 10) return false;
	mes = strData.substr(3,2);
	if(mes > "12" || mes == "00")
	return false;
	dia = strData.substr(0,2);
	if(dia=="00") return false;
	ano = strData.substr(6,4);
	if (ano < "0200") return false;
	if (mes=="01"||mes=="03"||mes=="05"||mes=="07"||mes=="08"||mes=="10"||mes=="12"){
	if (dia > "31")
	return false;
	}
	if(mes=="04"||mes=="06"||mes=="09"||mes=="11"){
	if (dia > "30")
	return false;
	}
	if(mes=="02"){
	if((parseInt(ano) % 4) ==0){
	if (dia > "29")
	return false;
	}
	else
	if (dia > "28") return false;
	}
	return true;
}

function isDate (day, month, year) 
{
	//alert(day+ '/' +month+ '/' +year);
	return isDateNew(day+ '/' +month+ '/' +year);
}

function isDateNew(dateStr) {
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
var matchArray = dateStr.match(datePat); // is the format ok?

if (matchArray == null) {
//alert("Please enter your birth date as dd/mm/yyyy. Your current selection reads: " + dateStr);
return false;
}

day = matchArray[1]; // p@rse date into variables
month = matchArray[3];
year = matchArray[5];

if (month < 1 || month > 12) { // check month range
//alert("Month must be between 1 and 12.");
return false;
}

if (day < 1 || day > 31) {
//alert("Day must be between 1 and 31.");
return false;
}

if ((month==4 || month==6 || month==9 || month==11) && day==31) {
//alert("Month "+month+" doesn`t have 31 days!");
return false;
}

if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day > 29 || (day==29 && !isleap)) {
//alert("February " + year + " doesn`t have " + day + " days!");
return false;
}
}
return true; // date is valid
}


function IsEmail(email){
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))) 
    	return (false);
    return (true);
}

// Removes leading whitespaces
function LTrim( value ) {
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// Removes ending whitespaces
function RTrim( value ) {
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

// Removes leading and ending whitespaces
function trim( value ) {
	return LTrim(RTrim(value));
}
