// JavaScript Document


function valInt(field) {
  var re = /^[0-9]*$/;
  
  if (!re.test(field.value) )
    field.value = field.value.replace(/[^0-9]/g,"");
} 


function valFloat(field)
{
    var re  = /^\d{1}\.?[0-9]*$/;  //one char . val
	var re2 = /^\d{1}\,?[0-9]*$/;  //one char , val
     
    //alert(f.value + " - re:" + re.test(f.value) );
    if ( !re.test(field.value) && !re2.test(field.value) ) 
       field.value = field.value.replace(/[^0-9]/g,"");
}


function changeCommaDot( value )
{
	return value.replace(",",".");
}


/** Cria função de trim e passa implementa em uma string **/

function trim_string() {
	var ichar, icount;
	var strValue = this;
	ichar = strValue.length - 1;
	icount = -1;
	while (strValue.charAt(ichar)==' ' && ichar > icount)
		--ichar;
	if (ichar!=(strValue.length-1))
		strValue = strValue.slice(0,ichar+1);
	ichar = 0;
	icount = strValue.length - 1;
	while (strValue.charAt(ichar)==' ' && ichar < icount)
		++ichar;
	if (ichar!=0)
		strValue = strValue.slice(ichar,strValue.length);
	return strValue;
}

// Extend the string object to include a trim function
String.prototype.Trim = trim_string;

/** end **/