
function FBTextBoxOnKeyPress(obj, type)
{
	//window.alert(event.keyCode);
	
	var key = event.keyCode;
	var retValue = false;
	
	if (type == 'Integer') // Integer
	{
		if ((key >= 48) && (key <= 57)) // 0 a 9
			retValue = true;
	} // Int
	
	if (type == 'Float') // Float
	{
		if ((key >= 48) && (key <= 57)) // 0 a 9
			retValue = true;
		
		if ((key == 46) && (obj.value.indexOf('.') == -1)) // '.'
			retValue = true;
	} // Float
	
	if (type == 'Date') // Date
	{
		if ((key >= 48) && (key <= 57)) // 0 a 9
			retValue = true;
		
		if (
			  (key == 47) && 
			  (
			    (obj.value.indexOf('/') == -1) || 
			    ((obj.value.substr(obj.value.indexOf('/') + 1)).indexOf('/') == -1)
			  )
		   ) // '/' duas vezes
			retValue = true;		
		
	} // Date
	
	if (type == 'String') // String
	{
		retValue = true;
	}
	
	return retValue;
}

function FBTextBoxOnBlur(obj, type)
{
	
	if ((type == 'Float') || (type == 'Integer')) // Float ou Integer
	{
		var val = new Number(obj.value);
		
		if (isNaN(val))
		{
			obj.focus();
			window.alert('Numero invalido!\nPor favor corrija.');
		} // if ...
	} // Float ou Integer
	
	if (type == 'Date') // Date
	{	
		//var year  = obj.value.substring(6,10);
		//var month = obj.value.substring(0,2);
		//var day = obj.value.substring(3,5);
		
		var a = obj.value;
		
		day = a.substr(0,a.indexOf('/'));
		a = a.substr(a.indexOf('/') + 1);

		month = a.substr(0,a.indexOf('/'));
		a = a.substr(a.indexOf('/') + 1);

		year = a;
		a = null;
		
		var fullDate = new Date(year,month - 1,day);
		
		if (
			(
			(day   != fullDate.getDate()) ||
			(month != fullDate.getMonth() + 1) ||
			(year  != fullDate.getFullYear())
			) &&
			(obj.value != '')
		)
		{
			obj.focus();
			window.alert('Data invalida!\nUse o seguinte formato: dd/mm/aaaa\nPor favor corrija.');
		} // if ...
	} // Date
}
