/*
 **************************************
 * Validação de tipos v1.0
 * Autor: Wagner B. Soares
 * Alteracoes: Jackson Caset
 *************************************
*/
isUndefined = function(value) {
	return typeof(value) == 'undefined' ? true : false;
}
isNull = function(x) {
	if((x == 'undefined') || (x == null)){return true;}
	else{return false;}
};
isObject = function(x) {
	if(!isNull(x))
	{
		if(x.constructor == Object){return true;}
		else{return false;}
	}
	else{return false;}
};
isFunction = function(x) {
	if(!isNull(x)) {
		if(x instanceof Function){return true;}
		else{return false;}
	}
	else{return false;}
}
isBoolean = function(x) {
	if(!isNull(x)) {
		if(x.constructor == Boolean){return true;}
		else{return false;}
	}
	else{return false;}
};
isArray = function(x) {
	if(!isNull(x)) {
		if(x.constructor == Array){return true;}
		else{return false;}
	}
	else{return false;}
};
isString = function(x) {
	if(!isNull(x)) {
		if(x.constructor == String){return true;}
		else{return false;}
	}
	else{return false;}
};
isEmpty = function(str){
	return (str == null) || (str.length == 0);
}
isEmail = function(str){
	if(isEmpty(str)) return false;
	var re = /^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i
	return re.test(str);
}
isNumeric = function (str){
	var re = /[\D]/g;
	if (re.test(str)) return false;
	return true;
}
isAlpha = function(str){
	var re = /[^a-zA-Z]/g;
	if (re.test(str)) return false;
	return true;
}
isAlphaNumeric = function(str){
	var re = /[^a-zA-Z0-9\s]/g;
	if (re.test(str)) return false;
	return true;
}
isPhoneNumber = function(str){
	var re = /^\(\d{2}\)(\s\d{4})(-\d{4})/;
	return re.test(str);
}
isDate = function(str){
	var re = /^(\d{1,2})[\s\.\/-](\d{1,2})[\s\.\/-](\d{4})$/
	if(!re.test(str)) return false;
	var result = str.match(re);
	var d = result[1];
	var m = result[2];
	var y = result[3];
	
	if(m < 01 || m > 12|| y < 1900 || y > 2100) { return false; }
	if(m == 2) {
		var days = ((y % 4) == 0) ? 29 : 28;
	} else if(m == 4 || m == 6 || m == 9 || m == 11){
		var days = 30;
	} else {
		var days = 31;
	}
	return (d >= 1 && d <= days);
}
isInteger = function(x) {
	if(!isNull(x)) {
		if(isNumber(x)) {
			if((x%1) == 0){return true;}
			else{return false;}
		}
		else{return false;}
	}
	else{return false;}
};