
var UTIL_versionID='$ Id: Util.js 05/01 $'
//+ Version : @version  %I %E %U


function verifyFrameset(){
	if(!window.top.parent_frame)
		/*
		window.top.document.location.href = "https://200.162.59.57/helpdesk/helpdesk/index.vm"
		*/
		window.top.document.location.href = "/helpdesk/helpdesk/index.vm"
}

// verify if ti is in the arrat
function UTIL_isInArray (array, value) {
    for (count = 0; count < array.length; count++) {
 		if (array[count] == value) 
			return true;
	}
	
	return false;
}


function UTIL_checkCNPJNoSeparator(string) {
	var parsed = parseInt(string, 10);
	return ((string.length == (parsed+"").length) && (parsed == string) && (parsed > 0));
}

// Initial and final dates verification before submit the form
function UTIL_checkDates ( newDate, minDate, maxDate ) {
    // Initial date verification

    if(!UTIL_verifyDate(newDate)) {
        alert ( "Data inválida. " +
                "\nFavor especificar uma data no formato dd/mm/aaaa." );
        return false;
    }

    if (!UTIL_verifyDate(minDate) || !UTIL_verifyDate(maxDate)) {
	alert ("Datas máxima/mínima inválidas!");
	return false;
    }
    
    var maxDateArr = UTIL_parseDateString(maxDate);
    var minDateArr = UTIL_parseDateString(minDate);
    var currDateArr = UTIL_parseDateString(newDate);

    var minDateDat = new Date (parseInt(minDateArr[2],10),
			       parseInt(minDateArr[1],10),
			       parseInt(minDateArr[0],10),
			       0,0,0);
    
    var maxDateDat = new Date (parseInt(maxDateArr[2],10),
			       parseInt(maxDateArr[1],10),
			       parseInt(maxDateArr[0],10),
			       0,0,0);

    var currDateDat = new Date (parseInt(currDateArr[2],10),
				parseInt(currDateArr[1],10),
				parseInt(currDateArr[0],10),
				0,0,0);

    if (!(currDateDat.getTime() > minDateDat.getTime() &&
	    currDateDat.getTime() <= maxDateDat.getTime())) 
	{
        alert ("Data informada fora do limite permitido");
        return false;
	}
	
	return true;
}


    
var UTIL_DebugObject;


function UTIL_setDebugObject ( dbgObj ) {
    this._dbgObj = dbgObj;
}

function UTIL_debug(msg) {
    if ( Debug ) {
	Debug.showMessage(msg);
    }
    else {
	alert(msg);
    }
}

function UTIL_crlf() {
    if ( this._dgbObj ) {
	return this._dbgObj._crlf + this._dbgObj.prefix();
    }
    else {
	return '\n';
    }
}

function UTIL_basename ( filename ) {
    if ( typeof filename == 'string' ) {
//	var f = '' + filename;
    	var f = new String (filename);
	var idx = f.lastIndexOf ( '/' ) + 1;
	var result = f.substring ( idx );
	return result;
    }
    return null;
}


function UTIL_dirname ( filename ) {
    var f = '' + filename;
    var idx = f.lastIndexOf ( '/' );
    var result = f.substring ( 0, idx + 1 );
    return result;
}



//Formats a CEP number from a form field, since it contains 8 digits,
//placing a - before the last 3 digits of the CPF. The resulting string
//is left on the field itself. The field remains unchanged when 8
//numeric digits cannot be extracted from the field.
function UTIL_formatCEP(cepField) {
   var cep = cepField.value;
   var numericCep = UTIL_extractNumber(cep);
   if (numericCep.length == 8) {
     numericCep = numericCep.substring (0, 5) + '-' + numericCep.substring (5, 8);
     cepField.value = numericCep;
   }

}



/*
* Verifies whether a string represents a valid CEP format
*/
function UTIL_checkCEP(cep) {

   var isValidCEP = true;
   var indexOfSeparator = cep.indexOf('-');

   if ( ( indexOfSeparator ==  5 ) &&
        ( cep.length == 9 ) ) {
      var number_prefix = cep.substr(0, indexOfSeparator);
      var number_suffix = cep.substr(indexOfSeparator + 1);

      prefix_re = /\d\d\d\d\d/;
      suffix_re = /\d\d\d/;

      if ((!number_prefix.match(prefix_re)) ||
          (!number_suffix.match(suffix_re))) {
         isValidCEP = false;
      }

   } else {
      isValidCEP = false;
   }

   return isValidCEP;
}



/*
* Verifies whether a string represents a valid CPF format
*/
function UTIL_checkCPF(cpf) {

   var isValidCPF = true;
   var indexOfSeparator = cpf.indexOf('-');

   if ( ( indexOfSeparator ==  9 ) &&
        ( cpf.length == 12 ) ) {
      var number_prefix = cpf.substr(0, indexOfSeparator);
      var number_suffix = cpf.substr(indexOfSeparator + 1);

      prefix_re = /\d\d\d\d\d\d\d\d\d/;
      suffix_re = /\d\d/;

      if ((!number_prefix.match(prefix_re)) ||
          (!number_suffix.match(suffix_re))) {
         isValidCPF = false;
      }

   } else {
      isValidCPF = false;
   }

   return isValidCPF;
}



/*
* Verifies whether a string represents a valid CNPJ format
*/
function UTIL_checkCNPJ(cnpj) {

   var isValidCNPJ = true;
   var index1OfSeparator = cnpj.indexOf('/');
   var index2OfSeparator = cnpj.indexOf('-');

   if ( ( index1OfSeparator ==  8 ) &&
        ( index2OfSeparator ==  13 ) &&
        ( cnpj.length == 16 ) ) {
      var number1_prefix = cnpj.substr(0, index1OfSeparator);
      var number2_prefix = cnpj.substr(index1OfSeparator + 1, index2OfSeparator - index1OfSeparator - 1);
      var number_suffix = cnpj.substr(index2OfSeparator + 1);

      prefix1_re = /\d\d\d\d\d\d\d\d/;
      prefix2_re = /\d\d\d\d/;
      suffix_re = /\d\d/;

      if ((!number1_prefix.match(prefix1_re)) ||
          (!number2_prefix.match(prefix2_re)) ||
          (!number_suffix.match(suffix_re))) {
         isValidCNPJ = false;
      }

   } else {
      isValidCNPJ = false;
   }

   return isValidCNPJ;
}


/*
* Retira os espaços em branco do início e do final da string
*/
function UTIL_trim ( string )
   {
   var array = string.split(' ');
   var start = 0;
   var end   = array.length - 1;
   var result = '';
   while ( array[start] == '' ) {
      start++;
   }
   while ( array[end] == '' ) {
      end--;
   }
   for ( var i = start; i<= end; i++ ) {
       if ( result == '' ) {
 	   result = array[i];
      }
       else {
	   result += ' ' + array[i];
       }
   }

   return result;
}



/*
*
*/
function UTIL_dump (obj, obj_name) {


   var name = ( obj_name ? obj_name : obj.name ? obj.name : obj );
   var resultArray = new Array ();
   var result = "";
   var index = 0;

   if ( obj.name == 'UtilObject' || obj.name == 'Util' ) {
       resultArray [ index ] = '[' + obj.name + ' cannot be dumped]';
       return resultArray;
   }

   var lineCount = 0;
   var check = 0;
   for (var i in obj) {
       var value = obj[i];
       var type = typeof ( value );
       if ( type != 'function' && type != 'Object' && i != 'Util' ) {
	   var message = 'i = ' + i + ': typeof (value) = ' + typeof(value);
	   var newValue =
	       name +
	       "." +
	       i +
	       " = " +
	       obj[i] ;
	   result += newValue + UTIL_crlf() ;
	   lineCount ++;
	   var alertLines = this._alertLines;
	   if ( lineCount % alertLines == 0 ) {
	       lineCount = 0;
	       resultArray [  index  ]  = result;
	       index ++;
	       result = "";
	   }
       }
   }
   resultArray [  index  ] = result;
   return resultArray;
}


/*
* Mostra as propriedades de um objeto.
*/
function UTIL_alertProps (obj, obj_name)
{
   var name = ( obj_name ? obj_name : obj.name ? obj.name : obj );
   var arr = UTIL_dump ( obj, name );
   for ( var i in arr ) {
       this.debug ( arr [ i ] );
   }
}


/*
* Altera o location.
* Útil quando se está em um frame e é necessário atualizar informações em outro frame.
*/
function UTIL_jumpTo (  target, params ) {
   var p = null;

   if ( params ) {
      for ( var i in params ) {
          p = ( p == null ? params[i] : p + '&' + params[i] );
      }
   }

   var location = this._action + ( p != null ? '?' +  p : '' );

   <!--alert ( location );-->

   target.document.location = location;
}

/*
*
*/
function UTIL_setAction ( url ) {
    this._action = url;
}


/*
*
*/
function UTIL_setAlertLines ( lines )
{
    this._alertLines = lines;
    return false;
}


/*
* Exibe uma mensagem na barra de status.
*/
function UTIL_message ( msg )
{
    window.status = msg;
    return true;
}


/*
* Verifica se uma string representa um número.
*/
function UTIL_checkNumeric ( string ) {
	// Replace 0 with 1
	var tmp = String(string);
	string = string.replace("0","1");
	while(tmp != string) {
		tmp = string;
		string = string.replace("0","1");
	}

    var parsed = parseInt (string, 10);
    return ((string.length == (parsed+"").length) && (parsed == string) && (parsed > 0));
}


/*
* Verifica se um campo numérico foi preenchido corretamente.
*/
function UTIL_checkNumericField ( field ) {
    if ( ! UTIL_checkNumeric ( field.value ) )
     {
       return false;
     }
    return true;
}

/*
* Verifica se um campo do moeda data foi preenchido corretamente.
*/
function UTIL_verifyCurrency ( curString )
{
   var curStr = UTIL_trim(curString);

   if ( curStr && curStr != '' )
   {
      var a = curStr.split ( '.' );
      if(a.length > 2)
      	return false;

      var r = a[0];
      if ( UTIL_checkNumeric ( r ) == false ) return false;
      
      if (a.length == 2)
      {
      	var c = a[1];
      	if (!(c.length == 1 || c.length == 2) || UTIL_checkNumeric ( c ) == false ) return false;
      }

      return true;
   }

    return false;
}


/*
* Completa uma string com o caracter passado como parâmetro (ch).
*/
function pad ( original, length, ch )
 {
       ch = ( ch ? ch : '0' );
       var result = '' + original;
       while ( result.length < length )
       {
           result = ch + result;
       }
       return result;
}



//Formats a date from a form field, assigning to the form field a
//string with the mask DD/MM/YYYY. The resulting string
//is left on the field itself. The field remains unchanged when any errors
//during this conversion occurrs.
/*function UTIL_formatDateField(dateField) {

	alert("Entrou1");

   var date = dateField.value;
   if ( date && UTIL_trim(date) != '') {
   if (!UTIL_verifyDate (date)) {
	var onlyNumericDate = UTIL_extractNumber(date);
	if (onlyNumericDate.length >=6)
	   date = onlyNumericDate.substring (0, 2) + '/' + onlyNumericDate.substring (2, 4) + '/' + onlyNumericDate.substring (4, onlyNumericDate.length);
   }

   if (UTIL_verifyDate (date))
	dateField.value = UTIL_getDateAsString(date);
   }
}
*/
function UTIL_formatDateField(form, fieldName) {
   var date = form[fieldName].value;
   if ( date && UTIL_trim(date) != '') {
   if (!UTIL_verifyDate (date)) {
	var onlyNumericDate = UTIL_extractNumber(date);
	if (onlyNumericDate.length >=6)
	   date = onlyNumericDate.substring (0, 2) + '/' + onlyNumericDate.substring (2, 4) + '/' + onlyNumericDate.substring (4, onlyNumericDate.length);
   }

   if (UTIL_verifyDate (date))
	form[fieldName].value = UTIL_getDateAsString(date);
   }
}

function UTIL_normalizeDate ( dateStr )
{
   if ( dateStr )
   {
      var a = dateStr.split ( '/' );
      var d = pad ( eval (a[0]), 2, '0' );
      var m = pad ( Number(a[1])-1, 2, '0' );
      var y = eval (a[2]);

      //Ano entre 0 e 69 sera transformado em 2000 + valor do ano
      if(parseInt(y,10)<70)
         y = 2000+parseInt(y,10);

      //Ano entre 70 e 99 sera transformado em 1900 + valor do ano
      else if(parseInt(y,10)<=99)
         y = 1900+parseInt(y,10);

      //Ano maior que 1000 sera deixado como esta
      else if (parseInt(y,10)<1000)
         y = 1000 + parseInt(y,10);

      //y %= 100;
      //Data menor que 1970 da erro
      //y += y < 70 ? 2000 : 1900;
      //y = this.pad ( y, 2, '0' );

      return '' + y + m + d;
   }
}

function UTIL_normalizeDateBR ( dateStr )
{
   if ( dateStr )
   {
      var a = dateStr.split ( '/' );
      var d = pad ( eval (a[0]), 2, '0' );
      var m = pad ( Number(a[1])-1, 2, '0' );
      var y = eval (a[2]);

      //Ano entre 0 e 69 sera transformado em 2000 + valor do ano
      if(parseInt(y,10)<70)
         y = 2000+parseInt(y,10);

      //Ano entre 70 e 99 sera transformado em 1900 + valor do ano
      else if(parseInt(y,10)<=99)
         y = 1900+parseInt(y,10);

      //Ano maior que 1000 sera deixado como esta
      else if (parseInt(y,10)<1000)
         y = 1000 + parseInt(y,10);

      //y %= 100;
      //Data menor que 1970 da erro
      //y += y < 70 ? 2000 : 1900;
      //y = this.pad ( y, 2, '0' );

      return d + "/" + m + "/" + y;
   }
}



    // Transform a date string into array of day, month and year value
    // Returned array is:
    //    parsedDate[0]: day
    //    parsedDate[1]: month
    //    parsedDate[2]: year
    function UTIL_parseDateString(dateString) {
        var fullDate = dateString.split("/");

        if (fullDate.length != 3) {
            return null;
        } else {
           var parsedDate = new Array();
           parsedDate[0] = fullDate[0];
           parsedDate[1] = fullDate[1];
           parsedDate[2] = fullDate[2];
           return parsedDate;
        }
    }



    // Return <0 if date1 is previous than date2,
    // return 0 if date1 is equal than date2, or
    // return >0 if date1 is greater than date2.
    function UTIL_compareDates(date1, date2) {
        var fullDate1 = UTIL_parseDateString(date1);
        var dateDay1   = parseInt(fullDate1[0], 10);
        var dateMonth1 = parseInt(fullDate1[1], 10);
        var dateYear1  = parseInt(fullDate1[2], 10);

        var fullDate2 = UTIL_parseDateString(date2);
        var dateDay2   = parseInt(fullDate2[0], 10);
        var dateMonth2 = parseInt(fullDate2[1], 10);
        var dateYear2  = parseInt(fullDate2[2], 10);

        if (dateYear2 > dateYear1) {
            return -1;
        } else if (dateYear2 < dateYear1) {
            return +1;
        }

        // dateYear2 == dateYear1
        if (dateMonth2 > dateMonth1) {
            return -1;
        } else if (dateMonth2 < dateMonth1) {
            return +1;
        }

        // dateMonth2 == dateMonth1
        if (dateDay2 > dateDay1) {
            return -1;
        } else if (dateDay2 < dateDay1) {
            return +1;
        } else {
            return 0;
        }
    }



function UTIL_checkDateItem ( item ) {
   var c1 = eval ( 'parseInt ( item, 10 )' );
   if ( c1 != item ) {
      var c2 = c1.length;
   }
   return (c1 == item);
}

/*
* Verifica se um campo do tipo data foi preenchido corretamente.
*/
function UTIL_verifyDate ( dateString )
{

   var dateStr = UTIL_trim(dateString);

   if ( dateStr && dateStr != '' )
   {
      var a = dateStr.split ( '/' );
      if(a.length != 3)
	return false;
      var d = a[0];
      if ( UTIL_checkDateItem ( d ) == false ) return false;
      var m = a[1];
      if ( UTIL_checkDateItem ( m ) == false ) return false;
      var y = a[2];
      if ( UTIL_checkDateItem ( y ) == false ) return false;

      y = parseInt(y,10);
      if(y < 70)
         y = 2000 + y;
      else if(y <= 99)
         y = 1900 + y;
      else if (y < 1000)
         y = 1000 + y;

      var oldDate = pad ( d, 2, '0' ) + '/' +
                    pad ( m, 2, '0' ) + '/' + y;
      var date = new Date ( y, m - 1, d );
      var str  = pad ( date.getDate(), 2, '0') + '/' +
                 pad ( date.getMonth() + 1, 2, '0') + '/' +
                 date.getFullYear();
      return ( oldDate == str );
   }
   return true;
}

function UTIL_getDateAsString(date) {
   var result = "";
   var strDate = date.split("/");
   var day   = pad ( strDate[0], 2 , '0');
   var month = pad ( strDate[1], 2 , '0');
   var year  = strDate[2];
   var y = parseInt(year,10);

   if(y < 70)
      year = 2000 + y;
   else if(y <= 99)
      year = 1900 + y;
   else if (y < 1000)
      year = 1000 + y;
   result = day+"/"+month+"/"+year;

   return result;
}



/*
* Verifica se um campo do tipo hora, minutos ( formato = hh:mm ) foi preenchido corretamente.
*/
function UTIL_verifyTime ( timeStr )
{
  if ( timeStr && timeStr != '')
  {
    var a = timeStr.split(':');
    var h = a[0];
    if ( Util_checkDateItem ( h ) == false ) return false;
    var m = a[1];
    if ( Util_checkDateItem ( m ) == false ) return false;

    if ( (h > 24) || (h < 0)) return false;
    if ( (m > 60) || (m < 0)) return false;
  }
  return true;
}


/*
* Verifica se um campo do tipo data,hora, minutos ( formato = dd/mm/aa hh:mm ) foi preenchido corretamente.
*/
function UTIL_verifyFullDate ( dateStr ) {

if ( dateStr && dateStr != '' )
      {
         var a = dateStr.split (' ');
         var data = a[0];
         var time = a[1];

         if (time && time != '' ) {
           if (UTIL_verifyDate( data ) == false ) return false;
           if (UTIL_verifyTime ( time ) == false ) return false;
         }
         else
         return false;
      }
 return true;
}



/*
* Recupera a data e hora do sistema.
*/
function UTIL_generateDate ()
{
  var today = new Date();
  var formattedDate = '';
  var aux;

  aux =  today.getUTCDate();

  if ( eval(aux) < 10 )
   aux = '0' + aux;

  formattedDate = formattedDate + aux +'/';

  aux =  today.getUTCMonth();

  if ( ( aux = eval(aux) + 1 ) < 10 )
   aux = '0' + aux;

  formattedDate = formattedDate + aux +'/';

  formattedDate = formattedDate + today.getUTCFullYear()+' ';

  aux =  today.getHours();

  if ( eval(aux) < 10 )
   aux = '0' + aux;

  formattedDate = formattedDate + aux +':';

  aux =  today.getMinutes();

  if ( eval(aux) < 10 )
   aux = '0' + aux;

  formattedDate = formattedDate + aux +':';

  aux =  today.getSeconds();

  if ( eval(aux) < 10 )
   aux = '0' + aux;

  formattedDate = formattedDate + aux;

  return formattedDate;
}


/* Substitui espaco em branco pela letra B
 * Substitui ":" por "_"
 * Na versao do Netscape 4.03, ocorre um erro de javascript quando o valor de um parametro está no formato "dd/mm/yy hh:mm".
 * O problema ocorre por causa do caracter ":". Além disso, nao podem existir espacos em branco.
*/
function UTIL_formatDate(oldString)
{
   var array = oldString.split(' ');
   var start = 0;
   var end   = array.length - 1;
   var firstReplace = '';
   var result = '';
   var i;

   for (  i = start; i < end; i++ )
   {
      firstReplace += array[i] + 'B';
   }

   firstReplace += array[i];

   array = firstReplace.split(':');
   end = array.length - 1;

   for (  i = start; i < end; i++ )
   {
      result += array[i] + '_';
   }

   result += array[i];

   return result;
}

function UTIL_errorMessage ( msg ) {
    if ( msg &&
	 msg != '&nbsp;' &&
	 msg != '<!-- UNDEFINED -->' &&
	 msg != '' ) {
	alert ( msg );
    }
    else {
	msg = this._savedMessage;
	if ( msg &&
	     msg != '&nbsp;' &&
	     msg != '<!-- UNDEFINED -->' &&
	     msg != '' ) {
	    alert ( msg );
	}
    }
    return false;
}


// Substitui caracteres dentro de uma string.
// Esse metodo aparece para suprir a falta do metodo String.replace,
// que so e implementado em Javascript 1.1 e que provavelmente nao
// vai existir no IE.
// @param orig (String) string original
// @param from (char)   caracter que vai ser retirado
// @param to   (char)   caracter que vai ser colocado em seu lugar
function UTIL_replaceString(orig, from, to) {
   var result="";
   var size=orig.length;

   for(var i=0;i<size;i++) {
     var ch=orig.charAt(i);
     if(ch==from) {
        result += to;
     }
     else {
        result += ch;
     }
   }
   return result;
}

/**
 * Verifica se a URL a ser passada para o servidor esta valida
 * para isso nao devem existir caracters que necessitem ser passados
 * na forma %<Ascii_code>
 */
function UTIL_validateURL(url) {
   var result = "";
   var size = url.length;
   var i;
   var currentChar;
   for(i=0;i<size;i++)
	result += escape(url.charAt(i));
   return result;
}



function UTIL_isAnyItemSelected(form, baseName) {
   var i=0;
   var selected = false;
   var result = new Array();
   var count = 0;
   var item = form[baseName+"0"];
   for (i=1;item;i++) {
      if(item.checked) {
         result[count] = item.value;
	 count++;
      }
      item = form[baseName+i];
   }
   if(count>0)
      return result;
   else
      return false;
}

function UTIL_moveOptions(source, target) {
   if(source.selectedIndex == -1)
      return false;
   if( (source.options[0])&&(source.options[0].value == '-1') ) {
      source.options[0] = null;
      return true;
   }

   // O IE 'capota' se o tamanho de uma lista for alterado de
   // qualquer maneira ( seja atribuindo 'null' a um valor ou
   // alterando a propriedade options.length ) se o numero de
   // itens selecionado for maior do que o numero de itens que
   // e' mostrado ao mesmo tempo na tela (o que corresponde ao
   // atributo SIZE do <SELECT>. v.

   // salvando a lista de itens a serem movidos...
   var toMoveIndexes = new Array();
   for ( var i = 0; i < source.length; i ++ ) {
       if ( source[i].selected ) {
	   toMoveIndexes[toMoveIndexes.length] = i;
       }
   }

   // deselecionando as duas listas...
   source.selectedIndex = -1;
   target.selectedIndex = -1;

   // movendo os itens...
   var listSize = toMoveIndexes.length;
   var moved = 0;
   for ( var i = 0; i < listSize; i ++ ) {
       // alreadyMoved serve para ajustar a movimentacao. sem ele,
       // acontece o seguinte cenario:
       // lista pra mover: [ 0, 1, 2 ]
       //     lista   #itens.
       // 1:[ A, B, C ] (3) -> retira o item 0 -> [ B, C ]
       // 2:   [ B, C ] (2) -> retira o item 1 -> [ B ]
       // 3:      [ B ] (1) -> retira o item 2 -> erro, a lista nao tem
       //                          mais aquele elemento
       // pra comecar, ja tirou o elemento errado, deveria ter retirado B e nao C
       // no passo 2.
       //
       // entao, o cenario corrigido fica:
       // lista pra mover: [ 0, 1, 2 ], moved(m) = 0;
       //     lista   #itens.
       // 1:[ A, B, C ] (3) -> retira o item 0 (0-m=0) -> [ B, C ], moved = 1
       // 2:   [ B, C ] (2) -> retira o item 0 (1-m=0) -> [ C ],    moved = 2
       // 3:      [ B ] (1) -> retira o item 0 (2-m=0) -> [] OK
       //
       var index = toMoveIndexes[i] - moved;
       var opt = new Option(source[index].text, source[index].value);
       if((target.options[0])&&(target.options[0].value == '-1'))
	   target.options[0] = null;
       target.options[target.length] = opt;
       source.options[index] = null;
       moved++;
   }

   return true;
}


//extracts from a floating number a number with nonDecimalDigits
//number of non-decimal digits.
function UTIL_parseFloatWithNonDecimalDigits( number, nonDecimalDigits) {
   var stringNumber = '' + number;
   var splittedNumber = stringNumber.split(".");
   if (splittedNumber.length == 0)
	return -1;
   var result = '' + splittedNumber[0];
   if (splittedNumber.length == 2) {
	var nonDecimalNumber = '' + splittedNumber[1];
	var numberOfNonDecimal = nonDecimalDigits;
	if (numberOfNonDecimal > nonDecimalNumber.length)
          numberOfNonDecimal = nonDecimalNumber.length;
	var newNonDecimal = nonDecimalNumber.substring (0, numberOfNonDecimal);
	result += "." + newNonDecimal;
   }
   return parseFloat (result);
}



// analiza uma string e devolve sua representacao como um numero de
// ponto flutuante. O metodo verifica se o parametro contem alguma
// virgula pra decidir se deve manipula-lo antes de invocar parseFloat.
// @param number (String,float,int) o numero a ser analizado
// @see #replaceString
function UTIL_checkFloat(number) {
   var result = 0;
   var isdecimal = true;
   var counter = 0;
   var size = number.length;


   // checando a existencia de caracteres nao numericos
   var nstr = UTIL_replaceString(number, ',','');
   nstr = UTIL_replaceString(nstr, '.', '');
   if ( !UTIL_checkNumeric(nstr) ) {
        return number.NaN;
   }else
        //varrendo o número de trás para frente
   	for(var i=(size-1);i>=0;i--){
	    if (i == (size-1)){
               //a ultima coisa encontrada no número não pode ser '.' nem ','
               if  ((number.charAt(i)== ',') || (number.charAt(i)== '.' )){
	           return number.NaN;
	       }
	    }
            //verifica se esta é a primeira vírgula encontrada
            else if ((number.charAt(i)== ',') && (isdecimal == true)){
		    isdecimal = false;
		    var n_decimal = counter;
 		    counter = 0;
                  //verifica que esta não é a primeira vírgula
		 }else if ((number.charAt(i)== ',') && (isdecimal == false)){
		           return number.NaN;
	               }else  if (number.charAt(i)== '.'){
				    //verifica se existe 3 numeros antes do ponto
				    if (counter != 3){
				        return number.NaN;
                                    }else {
				            //constata que o numero nao tem parte decimal
					     if (isdecimal == true){
                                                n_decimal = 0;
				                isdecimal = false;
    				             }
					     //verifica se o primeiro caracter nao e ponto
				             if (i == 0){
					         return number.NaN;
				             }
					  }
			      }
	    //conta a quantidade de numeros entre dois '.'
	    if ((number.charAt(i)== ',') || (number.charAt(i)== '.' )){
	        counter = 0;
	    }else
		counter+= 1;

        }


   // elimina os '.' do numero
   number = UTIL_replaceString(number, '.', '');

   if ( number.indexOf (',') != -1 ) {
      number = UTIL_replaceString(number, ',', '.');
   }

   result = parseFloat(number, 10);
   return result;
}




function UTIL_getMaxValue(digits, fract) {
   var maxValue='';
   for(i=0;i<digits;i++)
	maxValue+='9';
   maxValue+='.';
   for(i=0;i<fract;i++)
	maxValue+='9';
   if(maxValue!='')
	return parseFloat(maxValue)
   return 0;
}



function UTIL_getDateAsCrystalParameter(date) {
   var result = "";
   var strDate = date.split("/");
   var day   = pad ( eval (strDate[0]), 2, '0' );
   var month = pad ( eval (strDate[1]), 2, '0' );
   var year  = strDate[2];
   var y = parseInt(year,10);

   if(y < 70)
      year = 2000 + y;
   else if(y <= 99)
      year = 1900 + y;
   else if (y < 1000)
      year = 1000 + y;
   result = "Date("+year+", "+month+", "+day+")";

   return result;
}


function UTIL_formatNumber(text, digits) {
   if(!digits)
      digits = 2;
   var index = text.indexOf('.');
   var endText = "";
   var i;
   // Numero no formato (,25)
   if(index==0) {
      for(i=0;i<=(digits-text.length);i++)
         endText+="0";
      text = '0'+text+endText;
   }
   // Numero no formato (2)
   else if(index==-1) {
      endText=",";
      for(i=0;i<digits;i++)
         endText+="0";
      text += endText;
   }
   // Numero no formato (2,1)
   else {
      var remainingDigits = digits - (text.length-index);
      if(remainingDigits>=0) {
         for(i=0;i<=remainingDigits;i++)
	    endText+="0";
         text += endText;
      }
      else {
         text = text.substring(0, index+digits+1);
      }
   }
   text = UTIL_replaceString(text, '.', ',');
   return text;
}



function UTIL_toString () {
    return UTIL_dump ( this, 'UtilObject' );
}



function UTIL_checkEmptyField ( field ) {
    var check = true;
    if ( field.type ) {
	var type = field.type;
	if ( type == 'text' || type == 'textarea' || type == 'password' ) {
	    check = UTIL_trim ( field.value ) <= 0;
	}
	else if ( type.indexOf ('select') != -1 ) {
	    check = field.length > 0 ? field.selectedIndex == 0 || field.selectedIndex == -1 : false;
	}
    }
    return check;
}



function UTIL_checkNotEmpty ( form, fields )
{
    var result=true;
    var emptyField=null;
    for (var i in fields) {
	var field = fields [ i ];

	var check = UTIL_checkEmptyField ( form[ field ] );

	if ( !emptyField ) {
	    if ( check ) {
		emptyField = field;
	    }
	}
    }
    return emptyField;
}



function UTIL_checkAllFieldsEmpty ( form, fields )
{
    for (var i in fields) {
	var field = fields [ i ];
	var check = UTIL_checkEmptyField ( form[ field ] );
	if ( ! check ) {
	   return false;
	}
    }
    return true;
}



function UTIL_checkMandatoryFields (form, fields, message) {
    var emptyField = UTIL_checkNotEmpty ( form, fields );

    var msg = 'Um ou mais campos obrigatórios não estão preenchidos.\n' +
              'Por favor, repita a operação.';

    msg = ( message ? message : msg );

    if ( emptyField ) {
	alert ( msg );
	with ( form[emptyField] ) {
	    if ( type == 'text' || type == 'textfield' ) {
		value = ' ';
		select();
		focus();
	    }
	    else {
		form [ emptyField ].focus();
	    }
	}
	return false;
    }
    else {
	return true;
    }
}



function UTIL_getFirstNonEmptyField ( form, fields )
{
    var result=true;
    var nonEmptyField=null;
    for (var i in fields) {
	var field = fields [ i ];

	var check = UTIL_checkEmptyField ( form[ field ] );

	if ( !nonEmptyField ) {
	    if ( !check ) {
		nonEmptyField = field;
	    }
	}
    }
    return nonEmptyField;
}



function UTIL_invalidSymbol ( string )
{
    var chars = null;
    var index = 0;
    var resultstr = '';
    var mark = '^';
    var validChars = "_-()&@" +
	"0123456789" +
	"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
	"abcdefghijklmnopqrstuvwxyz";
    for (var i=0; i < string.length; i++ ) {
	var letter = string.charAt ( i );
	if ( validChars.indexOf ( letter ) == -1 )
            return letter;
    }
    return null;
}



function UTIL_unregularSymbol ( string )
{
    var chars = null;
    var index = 0;
    var resultstr = '';
    var mark = '^';
    var invalidChars = "#'¨@$%&*!?<>";
    for (var i=0; i < string.length; i++ ) {
	var letter = string.charAt ( i );
	if ( invalidChars.indexOf ( letter ) != -1 )
            return letter;
    }
    return null;
}



function UTIL_checkInvalidSymbolInField ( field ) {
    var check = null;
    if ( field.type ) {
	var type = field.type;
	if ( type == 'text' || type == 'textarea' || type == 'password' ) {
	    check = UTIL_unregularSymbol (UTIL_trim ( field.value ));
	}
    }
    return check;
}



function UTIL_checkInvalidSymbolInFields ( form, fields )
{
    var invalidField=null;
    for (var i in fields) {
	var field = fields [ i ];



	var check = UTIL_checkInvalidSymbolInField ( form[ field ] );

	if ( !invalidField ) {
	    if ( check != null ) {
		invalidField = field;
	    }
	}
    }
    return invalidField;
}



function UTIL_checkInvalidFields (form, fields, message) {
    var invalidField = UTIL_checkInvalidSymbolInFields ( form, fields );

    var msg = 'Detectado caracter inválido.\n' +
              'Por favor, reescreva, eliminando o caracter inválido: ';

    msg = ( message ? message : msg );

    if ( invalidField != null ) {
	msg += UTIL_checkInvalidSymbolInField ( form[ invalidField ] );
	alert ( msg );
	with ( form[invalidField] ) {
	    if ( type == 'text' || type == 'textfield' ) {
		select();
		focus();
	    }
	    else {
		form [ invalidField ].focus();
	    }
	}
	return false;
    }
    else {
	return true;
    }
}



//eliminates the non-numeric characters from the string, returning
//a new string containing only numeric digits.
function UTIL_extractNumber(string) {
   var result="";

   for (var i=0; i<string.length; i++) {
     if ( UTIL_checkNumeric ( string.substring(i,i+1) ) )
	result += string.substring(i,i+1);
   }
   return result;
}



//Formats a CPF number or a CNPJ number, according to the
//boolean value of the isCpf parameter
function UTIL_formatCPFCNPJ(cpfField, isCpf) {
   if (isCpf)
      UTIL_formatCPF (cpfField);
   else
      UTIL_formatCNPJ (cpfField);
}



//Formats a CPF number from a form field, since it contains 11 digits,
//placing a - before the last 2 digits of the CPF. The resulting string
//is left on the field itself. The field remains unchanged when 11
//numeric digits cannot be extracted from the field.
function UTIL_formatCPF(cpfField) {
   var cpf = cpfField.value;
   var numericCpf = UTIL_extractNumber(cpf);
   if (numericCpf.length == 11) {
     numericCpf = numericCpf.substring (0, 9) + '-' + numericCpf.substring (9, 11);

     cpfField.value = numericCpf;
   }

}



  //calculates and returns the first check digit (D1) for a CPF number
  //(containing a total of 11 digits) using the algorithm:
  //* multiply the first 9 digits from left to right by the factors
  //  10,9,8,7,6,5,4,3,2 respectively
  //* sum the products and divide by 11
  //* subtract the remaining from 11
  //* if the result (as a positive number) is less than 10, then D1 = the result
  //* otherwise D1 = 0
  //In case of any errors decomposing the cpf supplied (for instance,
  //non-numeric fields), the function returns -1.
  function UTIL_calculateCPFD1 (cpf) {
     var stCpf = UTIL_trim(cpf);

     if (stCpf.length > 11)
       return -1;

     //checking D1...
     var sum = 0;
     for ( var i=0; i<9; i++ ) {
       if (! UTIL_checkNumeric ( stCpf.substring(i,i+1) ) )
         return -1;

       sum += (10-i)*parseInt(stCpf.substring(i,i+1),10);

     }

     var d1 = (sum % 11) - 11;

     if (d1 < 0)
       d1 = -1 * d1;
     if ( d1 >= 10 )
       d1 = 0;

     return d1;

  }



  //calculates the second check digit (D2) for a CPF number
  //(containing a total of 11 digits) using the algorithm:
  //* multiply the first 10 digits from left to right by the factors
  //  11,10,9,8,7,6,5,4,3,2 respectively
  //* sum the products and divide by 11
  //* subtract the remaining from 11
  //* if the result (as a positive number) is less than 10, then D1 = the result
  //* otherwise D1 = 0
  function UTIL_calculateCPFD2 (cpf) {
     var stCpf = UTIL_trim(cpf);

     if (stCpf.length > 11)
       return -1;

     //checking D2...
     var sum = 0;
     for ( var i=0; i<10; i++ ) {
       if (! UTIL_checkNumeric ( stCpf.substring(i,i+1) ) )
         return -1;

       sum += (11-i)*parseInt(stCpf.substring(i,i+1),10);

     }

     var d2 = (sum % 11) - 11;

     if (d2 < 0)
       d2 = -1 * d2;

     if ( d2 >= 10 )
       d2 = 0;

     return d2;
  }



  //checks whether a cpf is valid (returning true) or not (returning false)
  //some valid CPF to test: 01234567890, 10529068850, 15138298828
  function UTIL_isValidCPF ( cpf ) {

     if (!UTIL_checkCPF(UTIL_trim(cpf)))
	return false;

     var numericCPF = UTIL_extractNumber(cpf);

     var d1 = UTIL_calculateCPFD1(numericCPF);
     if ( d1 == -1 )
	return false;

     if ( parseInt(numericCPF.substring(9,10)) != d1 )
	return false;

     var d2 = UTIL_calculateCPFD2(numericCPF);
     if ( d2 == -1 )
	return false;

     if ( parseInt(numericCPF.substring(10,11)) != d2 )
	return false;

     return true;

  }



//Formats a CNPJ number from a form field, since it contains 14 digits,
//placing a - before the last 2 digits of the CNPJ and a / before the last
//6 digits of the CNPJ. The resulting string
//is left on the field itself. The field remains unchanged when 16
//numeric digits cannot be extracted from the field.
function UTIL_formatCNPJ(cnpjField) {

   var cnpj = cnpjField.value;
   var numericCnpj = UTIL_extractNumber(cnpj);
   if (numericCnpj.length == 14) {
     numericCnpj = numericCnpj.substring (0, 8) + '/' + numericCnpj.substring (8, 12) + '-' + numericCnpj.substring (12, 14) ;

     cnpjField.value = numericCnpj;
   }

}



  //calculates and returns the first check digit (D1) for a CNPJ number
  //(containing a total of 14 digits) using the algorithm:
  //* multiply the first 12 digits from left to right by the factors
  //  5,4,3,2,9,8,7,6,5,4,3,2 respectively
  //* sum the products and divide by 11
  //* subtract the remaining from 11
  //* if the result (as a positive number) is less than 10, then
  // D1 = the result
  //* otherwise D1 = 0
  //In case of any errors decomposing the cnpj supplied (for instance,
  //non-numeric fields), the function returns -1.
  function UTIL_calculateCNPJD1 (cnpj) {
     var stCnpj = UTIL_trim(cnpj);

     if (stCnpj.length > 14)
       return -1;

     //checking D1...
     var sum = 0;
     for ( var i=0; i<12; i++ ) {
       if (! UTIL_checkNumeric ( stCnpj.substring(i,i+1) ) )
         return -1;

       sum += parseInt("543298765432".substring(i,i+1),10) * parseInt(stCnpj.substring(i,i+1),10);

     }

     var d1 = (sum % 11) - 11;

     if (d1 < 0)
       d1 = -1 * d1;
     if ( d1 >= 10 )
       d1 = 0;

     return d1;

  }



  //calculates the second check digit (D2) for a CNPJ number
  //(containing a total of 14 digits) using the algorithm:
  //* multiply the first 13 digits from left to right by the factors
  //  6,5,4,3,2,9,8,7,6,5,4,3,2 respectively
  //* sum the products and divide by 11
  //* subtract the remaining from 11
  //* if the result (as a positive number) is less than 10, then
  //  D1 = the result
  //* otherwise D1 = 0
  function UTIL_calculateCNPJD2 (cnpj) {
     var stCnpj = UTIL_trim(cnpj);

     if (stCnpj.length > 14)
       return -1;

     //checking D2...
     var sum = 0;
     for ( var i=0; i<13; i++ ) {
       if (! UTIL_checkNumeric ( stCnpj.substring(i,i+1) ) )
         return -1;

       sum += parseInt("6543298765432".substring(i,i+1),10) * parseInt(stCnpj.substring(i,i+1),10);
     }

     var d2 = (sum % 11) - 11;

     if (d2 < 0)
       d2 = -1 * d2;

     if ( d2 >= 10 )
       d2 = 0;

     return d2;
  }



  //checks whether a cnpj is valid (returning true) or not (returning false)
  //some valid CNPJ to test: 65477952/0001-46, 61586558/0005-19,
  //45543915/0001-81, *57699209/0001-65 (or 57699209/0001-02),
  //03373371/0001-07, 33033028/0023-90, 01615814/0045-14
  function UTIL_isValidCNPJ ( cnpj ) {

     if (!UTIL_checkCNPJ(UTIL_trim(cnpj)))
	return false;

     var numericCNPJ = UTIL_extractNumber(cnpj);

     var d1 = UTIL_calculateCNPJD1(numericCNPJ);
     if ( d1 == -1 )
	return false;

     if ( parseInt(numericCNPJ.substring(12,13)) != d1 )
	return false;

     var d2 = UTIL_calculateCNPJD2(numericCNPJ);
     if ( d2 == -1 )
	return false;

     if ( parseInt(numericCNPJ.substring(13,14)) != d2 )
	return false;

     return true;

  }


//Formats a declaration number from a form field, since it contains 9 digits,
//placing zeroes at the left of the number.
function UTIL_formatDeclarationNumber(declNumberField) {
   var declNumber = declNumberField.value;
   var numericDeclNumber = UTIL_extractNumber(declNumber);
   if (numericDeclNumber.length > 0) {
     numericDeclNumber = pad (numericDeclNumber, 9, '0');
     declNumberField.value = numericDeclNumber;
   }

}


/*
* Verifies whether a string represents a valid declaration number format
*/
function UTIL_checkDeclarationNumber( declaration ) {
   var stDeclaration = UTIL_trim(declaration);

   mask = /\d\d\d\d\d\d\d\d\d/;

   if (!stDeclaration.match(mask) )
     return false;

   return true;
}



  //calculates and returns the check digit (D) for a declaration number
  //(containing a total of 9 digits) using the algorithm:
  //* multiply the 8 digits from left to right by the factors
  //  1,3,4,5,6,7,8,10, respectively
  //* sum the products and divide by 11
  //* D = the last digit of the division by 11's remainder
  //In case of any errors decomposing the declaration number supplied
  //(for instance, non-numeric fields), the function returns -1.
  function UTIL_calculateDeclarationNumberD (declarationNumber) {

     var stDeclarationNumber = UTIL_trim(declarationNumber);

     if (stDeclarationNumber.length > 9)
       return -1;

     //checking the D digit...
     var sum = 0;
     for ( var i=0; i<8; i++ ) {
       if (! UTIL_checkNumeric ( stDeclarationNumber.substring(i,i+1) ) )
         return -1;

       if (i == 0)
	 sum = parseInt(stDeclarationNumber.substring(i,i+1),10);
       else if ( i == 7 )
	 sum += (i+3)*parseInt(stDeclarationNumber.substring(i,i+1),10);
       else
         sum += (i+2)*parseInt(stDeclarationNumber.substring(i,i+1),10);
     }

     var remainder = sum % 11;

     var stRemainder  = UTIL_trim(remainder + '');

     var d = parseInt(stRemainder.substring( (stRemainder.length - 1),(stRemainder.length)),10);

     return d;

  }



  //checks whether a declaration number is valid (returning true) or not
  //(returning false)
  //some valid declaration numbers to test: 000007273, 000026570, 000000775,
  //000022574, 000026542
  function UTIL_isValidDeclarationNumber ( declarationNumber ) {

     if (!UTIL_checkDeclarationNumber(UTIL_trim(declarationNumber)))
	return false;

     var d = UTIL_calculateDeclarationNumberD(declarationNumber);

     if ( d == -1 )
	return false;

     if ( parseInt(declarationNumber.substring(8,9)) != d )
	return false;

     return true;

  }



function UTIL_checkRestrictedAccessCode(pwd) {
   return (pwd == 'fisc1t');
}



function UTIL_launchGARE (GAREurl, docID, format, code, total, finalTotal, day, month, year, payer, cpfCNPj, address, city, cep, uf, fone, fine, GAREnumber, selic, finalTotal, comments1, comments2, comments3) {

     	var parameters = 'docID=' + docID + '&format=' + format + '&CODREC=' + code + '&VALOR=' + total + '&TOTAL='+ finalTotal  + '&DIA=' + day + '&MES=' + month + '&ANO=' + year + '&CONTRIB=' + payer  + '&CPFCNPJ=' + cpfCNPj + '&ENDERECO=' + address + '&MUNICIPIO=' + city + '&CEP=' + cep + '&UF=' + uf + '&FONE=' + fone + '&MULTA=' + fine + '&NGARE=' + GAREnumber  + '&JUROS=' + selic + '&VL_TOTAL=' + finalTotal + '&OBS1=' + comments1 + '&OBS2=' + comments2 + '&OBS3=' + comments3;


	var gareWindow = window.open( "", 'GARE',
          'toolbar=1,location=0,directories=0,status=0,' +
          'menubar=1,scrollbars=1,resizable=1,locationbar=no,' +
          'copyhistory=0,width=755,height=470');

//        UTIL_setAction ('http://172.16.32.121:8182/impdoc/impdoc.jsp');
        UTIL_setAction (GAREurl);
        UTIL_jumpTo (gareWindow, new Array(parameters));

}

function UTIL_trim (s) {

     for (var i=0; (i < s.length) && (s.charAt(i)==' '); i++);
     s = s.substring(i,s.length);

     for (var i=s.length-1; (i >= 0) && (s.charAt(i)==' '); i--);
     s = s.substring(0,i+1);

     return s;
     
}

function UTIL_checkNumeric (string) {
   		var parsed = parseInt(string, 10);
   		return (parsed == string);
}



function UtilObject() {

    this.name = 'UtilObject';
    this._alertLines   = 20 ;

    this.toString      = UTIL_toString;
    this.alertProps    = UTIL_alertProps;
    this.dump          = UTIL_dump;
    this.setAlertLines = UTIL_setAlertLines;
    this.message       = UTIL_message;
    this.setAction     = UTIL_setAction;
    this.jumpTo        = UTIL_jumpTo;

    // integracao com Debug.js
    this.debug             = UTIL_debug;
    this.dbgObj            = UTIL_DebugObject;
    this.setDebugObject    = UTIL_setDebugObject;

    // separar a parte de checagem numerica em um .js
    // separado.

    this.checkCEP          = UTIL_checkCEP;
    this.checkNumericField = UTIL_checkNumericField;
    this.checkNumeric      = UTIL_checkNumeric;
    this.verifyCurrency    = UTIL_verifyCurrency;
    this.verifyDate        = UTIL_verifyDate;
    this.checkDates        = UTIL_checkDates;
    this.verifyTime        = UTIL_verifyTime;
    this.verifyFullDate    = UTIL_verifyFullDate;
    this.trim              = UTIL_trim;
    this.generateDate	   = UTIL_generateDate;
    this.formatDate        = UTIL_formatDate;
    this.formatNumber      = UTIL_formatNumber;
    this.errorMessage      = UTIL_errorMessage;
    this.getDateAsString   = UTIL_getDateAsString;
    this.normalizeDate     = UTIL_normalizeDate;
	this.normalizeDateBR     = UTIL_normalizeDateBR;
    this.replaceString     = UTIL_replaceString;
    this.validateURL       = UTIL_validateURL;
    this.isAnyItemSelected = UTIL_isAnyItemSelected;
    this.moveOptions       = UTIL_moveOptions;
    this.checkFloat        = UTIL_checkFloat;
    this.getMaxValue       = UTIL_getMaxValue;
    this.dirname           = UTIL_dirname;
    this.basename          = UTIL_basename;
    this.checkAllFieldsEmpty   = UTIL_checkAllFieldsEmpty;
    this.checkEmptyField       = UTIL_checkEmptyField
    this.checkMandatoryFields  = UTIL_checkMandatoryFields;
    this.checkInvalidFields    = UTIL_checkInvalidFields;
    this.getFirstNonEmptyField = UTIL_getFirstNonEmptyField;
    this.parseDateString   = UTIL_parseDateString;
    this.compareDates      = UTIL_compareDates;
    this.extractNumber     = UTIL_extractNumber;
    this.calculateCPFD1    = UTIL_calculateCPFD1;
    this.calculateCPFD2    = UTIL_calculateCPFD2;
    this.isValidCPF        = UTIL_isValidCPF;
    this.checkCPF          = UTIL_checkCPF;
    this.calculateCNPJD1    = UTIL_calculateCNPJD1;
    this.calculateCNPJD2    = UTIL_calculateCNPJD2;
    this.isValidCNPJ        = UTIL_isValidCNPJ;
    this.checkCNPJ          = UTIL_checkCNPJ;
    this.checkDeclarationNumber         = UTIL_checkDeclarationNumber;
    this.calculateDeclarationNumberD    =  UTIL_calculateDeclarationNumberD;
    this.isValidDeclarationNumber       = UTIL_isValidDeclarationNumber;
    this.parseFloatWithNonDecimalDigits = UTIL_parseFloatWithNonDecimalDigits;
    this.formatCPF                 = UTIL_formatCPF;
    this.formatCNPJ                = UTIL_formatCNPJ;
    this.formatCPFCNPJ             = UTIL_formatCPFCNPJ;
    this.formatCEP                 = UTIL_formatCEP;
    this.formatDateField           = UTIL_formatDateField;
    this.formatDeclarationNumber   = UTIL_formatDeclarationNumber;
    this.checkRestrictedAccessCode = UTIL_checkRestrictedAccessCode;
    this.launchGARE = UTIL_launchGARE;
    this.trim = UTIL_trim;
    this.checkNumeric = UTIL_checkNumeric;
    this.isInArray = UTIL_isInArray;
    this.checkCNPJNoSeparator = UTIL_checkCNPJNoSeparator;
}

var Util = new UtilObject ();










