//////////////////////////////////////////////////////////////////////
// Descrição			: Funções em JavaScript
// Autor    			: Flávio Albuquerque
// Criação  			: 13/05/2002
// Motivo Alteração     : 
// Alteração			: 
// Responsável  		: 
//////////////////////////////////////////////////////////////////////
//window.onerror = handleErr
var txtLog = "";

	function handleErr()
	{
		txtLog = Array.prototype.join.call(arguments, '#');
		LogJS(txtLog);
		return true; 
	}



	function LogJS(msgErro)
	{
	    var strUrl           = "XMLAceite.aspx"
    	var strParametrosUrl = "acao=LOGJS&txt="+msgErro;
    	
    	    $.ajax
	        ({
                type: "GET",
                url: strUrl,
                data: strParametrosUrl,
                error: function(){},
                success: function(data){ return true; }
            });
            
            return true;
    }


//*************************************************************************
// funcoes que estavam no formCotacao
//*************************************************************************


		function findPosX( objRef )
		{
			var intLeft	= 0;
			
			try
			{
				if( objRef.offsetParent ) 
				{
					while( objRef.offsetParent )
					{
						intLeft	+=	objRef.offsetLeft
						objRef	=	objRef.offsetParent;
					}
				}
				else if(objRef.x)
					intLeft		+=	objRef.x;
				
				return intLeft;
			}
			catch(e)
			{
				return 0;
			}
		}

		function findPosY(objRef)
		{
			var intTop	=	0;

			try
			{
				if( objRef.offsetParent )
				{
					while( objRef.offsetParent )
					{
						intTop	+=	objRef.offsetTop;
						objRef	=	objRef.offsetParent;
					}
				} 
				else if(objRef.y)
					intTop		+=	objRef.y;

				return intTop;
			}
			catch(e)
			{
				return 0;
			}
		}



		function ItemMenuDestinoPopUpSimples ( strUrl, strNome ) {
			window.open ( strUrl, strNome + g_strIdJanelas , '');
		}
		
		function ItemMenuDestinoPopUp ( strUrl, strNome, intWidth, intHeight, intScroll ) {
			PopUp( strUrl, strNome ,'width='+intWidth+',height='+intHeight+',top='+PopUp_Top+',left='+PopUp_Left+',resizable=0,toolbar=0,status=0,menubar=0,scrollbars='+intScroll);
		}
		
		function PopUp( strUrl , strNome, strParametros )
		{	
			var objFormulario		= document.forms[0];
			
			objFormulario.action	= strUrl;
			objFormulario.target	= strNome;
			
			g_objPopUp = window.open ( strUrl, strNome + g_strIdJanelas, strParametros );
		}




		function ParaNumero(numero) 
		{
		var convertido;
		numero = numero.toString().replace(",", ".");
		convertido = parseFloat(numero);
		return convertido;
		}	

		function Numerico( chDado )
		{
			for(cont=0; cont<chDado.length; cont++)
				{
				if (" 0123456789,.-".indexOf(chDado.substring(cont,cont+1)) == -1) return false;
				}
			return true;
		}

		function round(number,X) {
			var Valor, tamanho;
			
			X = (!X ? 2 : X);
			Valor = Math.round(number*Math.pow(10,X))/Math.pow(10,X);
			Valor = Valor.toString();	
			if (Valor.indexOf(".") < 0 && Valor.indexOf(",") < 0) {
				Valor = Valor + ",00";
			}
			else if (Valor.substring(Valor.indexOf("."),Valor.length).length == 2) {
				Valor = Valor + "0";
			}
			if (Valor.indexOf(".") >= 0 && Valor.indexOf(",") < 0) {
				Valor = Valor.replace(".", ",");
			}
			return Valor;
		}

		function AbreviaNumero(strValor)
		{
		if( strValor.length == 0 )
			return '';
		if(!Numerico(strValor))
			return(strValor);
		strValor = ParaNumero(strValor);
		if (strValor.toString().length > 3) 
			{
			if (parseInt(strValor/1000000000) > 0) 
				{
				strValor = strValor/1000000000;
				strValor = round(strValor, 2);
				strValor = strValor + " B";
				}
			else if (parseInt(strValor/1000000) > 0) 
				{
				strValor = strValor/1000000;
				strValor = round(strValor, 2);
				strValor = strValor + " M";
				}
			else if (parseInt(strValor/1000) > 0) 
				{
				strValor = strValor/1000;
				strValor = round(strValor, 2);
				strValor = strValor + " K";
				}
			}
		else 
			{
			if (strValor.toString().indexOf(".") < 0 || strValor.toString().indexOf(",") < 0) 
				{
				strValor = strValor + ",00";
				}
			else
				strValor = round(strValor, 2);
			}
		return strValor;
		}
		
		function TiraVazioObjeto ( objElemento )
		{
			var strRetorno	= "";
			var intTamanho	= objElemento.value.length;
			var strValor	= objElemento.value;

			for (var i = 0; i < intTamanho; i++)
			{
				var testChar = strValor.charAt(i);
				if (testChar != " ")
					strRetorno += testChar;
			}
			return strRetorno;
		}
















//*************************************************************************
// fim
//*************************************************************************








//////////////////////////////////////////
// INICIO Funções para formatar Número	//
//////////////////////////////////////////
function formataDecimal( strValor, intQtdeDecimais, strSeparadorSaida )
{
	var strSeparador = '';
	var arrValorSplit;
	var strInteiros;
	var strDecimais = '';
	
	if( strValor == '' )
		return '';
	
	// Verifica se número possui separador decimal
	// Se possuir, armazena-o em uma variável
	if( strValor.indexOf(',') >= 0 )
		strSeparador = ',';
	else if( strValor.indexOf('.') >= 0 )
		strSeparador = '.';
	
	// Adiciona casas decimais especificadas em intQtdeDecimais
	if( strSeparador != '' )
	{
		arrValorSplit = strValor.split(strSeparador);
		
		strInteiros = arrValorSplit[0];
		strDecimais = arrValorSplit[1].toString();
		
		if ( ( strInteiros == '' ) || ( strInteiros == '-' ) )
			strInteiros += '0';
		
		if ( strDecimais.length < parseInt(intQtdeDecimais) )
			for (var i = strDecimais.length; i < intQtdeDecimais; i++)
				strDecimais += '0';
		else
			strDecimais = strDecimais.substring(0,intQtdeDecimais);
	}
	else
	{
		strInteiros = strValor;
		for (var i = 0; i < intQtdeDecimais; i++)
			strDecimais += '0';
	}
	// Concatena separador às casas decimais
	if( strDecimais.length > 0 )
		if( strSeparadorSaida != null || strSeparadorSaida == '' )
			strDecimais = strSeparadorSaida + strDecimais;
		else
			strDecimais = ',' + strDecimais;

	// Retorna valor formatado
	return strInteiros + strDecimais;
}

//********************************************************************************
// Objetivo  : critica se o formato digitado de campos numéricos está correto
// Premissas : padrão portugues para valores numéricos
// Entradas  : Nenhuma
// Retorno   : True ou False
//********************************************************************************
function formatarValor( strTecla, strValor, intQtdeDigitosInteiros, intQtdeDigitosDecimais )
{
	var posicao1;
	var posicao2;

	if ( "0123456789,-".indexOf(strTecla) == -1 )
		return false;

	posicao1 = strValor.indexOf(",");

	if ( posicao1 >= 0 )
	{
		if( strTecla == "," )
			return false;

		//verifica a qtde de dígitos inteiros
		if ( strValor.length - ( strValor.length - posicao1 ) > intQtdeDigitosInteiros )
			return false;

		//verifica a qtde de dígitos decimais
		if ( strValor.length - posicao1 == intQtdeDigitosDecimais + 1 )
			return false;
		
	}
	else
	{
		//verifica a qtde de dígitos inteiros
		if ( strValor.length >= intQtdeDigitosInteiros && strTecla != ',' )
			return false;

	}

	return true;
}

//********************************************************************************
// Objetivo  : Formatar valores negativos com milhar e decimal
// Premissas : Nenhuma
// Entradas  : Nenhuma
// Retorno   : Nenhum
//********************************************************************************
function formatarValorNegativo( strTecla, strValor, intQtdeDigitosInteiros, intQtdeDigitosDecimais ) {
	var posicao1;
	var posicao2;
	var digitoNegativo;

	if ( "0123456789,-".indexOf(strTecla) == -1 ) 
		return false;

	if( strValor.length != 0 && strTecla == '-' ) 
		return false;

	posicao2 = strValor.indexOf("-");

	if ( posicao2 >= 0 ) 
		digitoNegativo = 1;
	else
		digitoNegativo = 0;

	posicao1 = strValor.indexOf(",");

	if ( posicao1 >= 0 ) 
	{
		if( strTecla == "," ) 
			return false;

		//verifica a qtde de dígitos inteiros
		if ( strValor.length - ( strValor.length - posicao1 ) > intQtdeDigitosInteiros + digitoNegativo ) 
			return false;

		//verifica a qtde de dígitos decimais
		if ( strValor.length - posicao1 == intQtdeDigitosDecimais + 1 ) 
			return false;
	} 
	else 
	{
		//verifica a qtde de dígitos inteiros
		if ( strValor.length >= intQtdeDigitosInteiros + digitoNegativo && strTecla != ',' ) 
			return false;
	}
	return true;
}

//********************************************************************************
// Objetivo  : remove o formato de milhar de um valor
// Premissas : Nenhuma
// Entradas  : Nenhuma
// Retorno   : valor formatado
//********************************************************************************
function removerMilhar( strValor )
{
	while ( strValor.indexOf(".") != -1 )
		strValor = strValor.replace( ".", "" );
	
	return strValor;
}

//********************************************************************************
// Objetivo  : formatar número identidade
// Premissas : Nenhuma
// Entradas  : objCampo - nome do campo texto a ser formatado
// Retorno   : número de identidade formatado
//********************************************************************************
function formataRG( objCampo )
{
	var strCampo = objCampo.value.toString();
	
	var strCampoFormatado = "";
	
	if( strCampo.length < 2 )
		return false;
	
	strCampo = strCampo.replace("-", "");
	
	for( var intContador = 0; intContador < strCampo.length; intContador++ )
	{
		if( intContador == strCampo.length - 1 )
			strCampoFormatado += "-";
		
		strCampoFormatado += strCampo.charAt(intContador);
	}
	
	objCampo.value = strCampoFormatado;
}

//********************************************************************************
// Objetivo  : formata o valor com separador de milhar e decimal no padrão portugues
// Premissas : Nenhuma
// Entradas  : Nenhuma
// Retorno   : True ou False
//********************************************************************************
function formatarPortugues ( strValor, strDecimal, strMilhar, intQuantidadeDecimais, blnDecZero ) {
	var strAux;
	var posicao;
	
	var blnNegativo = false;
	
	if( intQuantidadeDecimais == null ) {
		intQuantidadeDecimais = 0;
	}
	
	
	// Formata para a quantidade decimal desejada
	strValor = formataDecimal( strValor, intQuantidadeDecimais, "." );
	
	if( strValor.indexOf( "-" ) > -1 )
	{
		strValor = strValor.substring( 1, strValor.length );
		blnNegativo = true;
	}
	
	strValor = strValor.replace( ".", strDecimal );
	
	posicao = strValor.indexOf( strDecimal );
	if ( posicao == -1 ) {
		posicao = strValor.length
	}
	posicao -= 4;
	
	while( posicao >= 0 ) {
		strAux = strValor.slice( 0, posicao + 1 );
		strValor = strAux + strMilhar + strValor.slice( posicao + 1 );		
		posicao -= 3;
	}
	
	if( strValor.length > 0 ) {
		strValor = formatarCasasDecimais( strValor, strDecimal, intQuantidadeDecimais );
	}
	
	if( blnNegativo )
		strValor = "-" + strValor;
	
	return strValor;
}

//********************************************************************************
// Objetivo  : formata valor completando as casas decimais com zeros até a qtde definida
// Premissas : Nenhuma
// Entradas  : Nenhuma
// Retorno   : valor formatado
//********************************************************************************
function formatarCasasDecimais( strValor, strDecimal, numeroCasas ) {
	var posicao;
	var i;
	
	posicao = strValor.indexOf( strDecimal );
	
	if ( posicao == -1 ) {
		
		if( numeroCasas > 0 ) {
			strValor += strDecimal;
			for( i = 0; i < numeroCasas; i++ ) {
				strValor += "0";
			}
		}
	}
	
	while ( posicao + numeroCasas + 1 > strValor.length ) {
		strValor += '0'
	}
	
	return strValor;
}

function PadraoDecimal( strValor )
{
	strValor = removerMilhar( strValor );
	strValor = strValor.replace( ',', '.' );
	return strValor;
}

function FormatarKMG( strNumero, intDecimais )
{
	var strResultado;
	var blnNegativo    = false;
	var intPosPonto    = 0;
	var strSufixo;
	
	if ( intDecimais == null )
		intDecimais = 2;
	
	/*
	if( isNaN(strNumero) )
		return strNumero; */

	strNumero = strNumero.toString();

	if( strNumero.length == 0 )
		return '';
	
	/*
	Para números muito grandes, se não for utilizada a função Str, resultará resultados absurdos!
	Ex.: 6,952E+09 = 6952000000, ou 6.952 G. Sem o Str a função retornaria 6.
	Como efeito colateral, a função Str ainda transforma todos os decimais em "."
	strNumero = Trim(Replace(Str(strNumero), ".", "")) */
	
	strNumero = PadraoDecimal( strNumero );
	
	var strNumeroSplit = strNumero.split(".");
	
	if( strNumeroSplit[0].charAt(0) == "-" )
	{
		blnNegativo = true;
		strNumeroSplit[0] = Math.abs( parseFloat(strNumeroSplit[0]) );
		strNumeroSplit[0] = strNumeroSplit[0].toString();
	}
	
	if( strNumeroSplit[0].length > 9 )
	{
		intPosPonto = strNumeroSplit[0].length - 9;
		strSufixo = " G";
	}
	else if( strNumeroSplit[0].length > 6 )
	{
		intPosPonto = strNumeroSplit[0].length - 6;
		strSufixo = " M";
	}
	else if( strNumeroSplit[0].length > 3 )
	{
		intPosPonto = strNumeroSplit[0].length - 3;
		strSufixo = " K";
	}
	else
	{
		intPosPonto = 0;
		strSufixo = '';
	}
	
	if( intPosPonto > 0 )
	{	
		if ( BuscaCaracter(strNumeroSplit[0].substring(intPosPonto, intPosPonto + 2), "0") )
			strResultado = strNumeroSplit[0].substring(0, intPosPonto) + strSufixo;
		else 
		{
			//if ( parseInt(strNumeroSplit[0].substring(intPosPonto + 2, intPosPonto + 3) ) > 5 )
			//	strResultado = strNumeroSplit[0].substring(0, intPosPonto) + "," + strNumeroSplit[0].substring(intPosPonto, intPosPonto + 1) + (  parseInt(strNumeroSplit[0].substring(intPosPonto + 1, intPosPonto + 2)) + 1 ) + strSufixo;
			//else
				strResultado = strNumeroSplit[0].substring(0, intPosPonto) + "," + strNumeroSplit[0].substring(intPosPonto, intPosPonto + 2) + strSufixo;
		}
	}
	else
	{
		strResultado = strNumeroSplit[0];
		if( strNumeroSplit.length > 1 )
		{
			if ( strNumeroSplit[1].length > 1 && strNumeroSplit[1].charAt(1) == "0")
				strNumeroSplit[1] = strNumeroSplit[1].charAt(0);
			
			strResultado = strResultado + "," + strNumeroSplit[1];
		}
	}
	
	strResultado = strResultado.toString();

	if( isNaN(strResultado.charAt(0)) )
		strResultado = "0" + strResultado;

	if( blnNegativo )
		strResultado = "-" + strResultado;

	return strResultado;
}

function BuscaCaracter ( strValor )
{
	var intContador	= 0;
	var intTamanho 	= strValor.length;

	for (var i = 0; i < intTamanho; i++)
	{
		var testChar = strValor.charAt(i);
		
		if (testChar == "0")
			intContador++;
	}
	if (intTamanho == intContador) { return true; }
	return false;
}

function FecharPopUp ()
{
	if ( window.opener != null )
	{	
		window.opener.ConsultaSessao();
		window.opener.g_objPoUp = null;
	}
}
//////////////////////////////////////////
// FIM Funções para formatar Número		//
//////////////////////////////////////////


//////////////////////////////////////////////////////
// INICIO Funções para formatar valores no grid		//
//////////////////////////////////////////////////////
function VerificarVazio( strTexto )
{
	if( strTexto.length == 0 )
		return '&nbsp;';
	else
		return strTexto;
}
//////////////////////////////////////////////////////
// FIM Funções para formatar valores no grid		//
//////////////////////////////////////////////////////


//////////////////////////////////////////
// INICIO Funções para formatar Texto	//
//////////////////////////////////////////
function ltrim( strSource )
{
	var iPosicao = 0;
	for ( ; iPosicao<strSource.length; iPosicao++)
		if (strSource.charAt(iPosicao)!=' ')
			break;
	return strSource.substring(iPosicao,strSource.length);
}

function rtrim( strSource )
{
	var iPosicao = strSource.length-1;
	for ( ; iPosicao>=0; iPosicao--)
		if (strSource.charAt(iPosicao)!=' ')
			break;
	return strSource.substring(0,iPosicao+1);
}

function trim( strSource )
{
	return ltrim(rtrim(strSource));
}
//////////////////////////////////////////
// FIM Funções para formatar Texto		//
//////////////////////////////////////////


//////////////////////////////////////////
// INICIO Funções para formatar Data	//
//////////////////////////////////////////
function DateToaaaammdd( dtData )
{
	var strDia = new String(dtData.getDate());
	var strMes = new String(parseInt(dtData.getMonth()) + 1);
	var strAno = new String(dtData.getFullYear());
	
	if( strDia.length == 1 )
		strDia = "0" + strDia;
	
	if( strMes.length == 1 )
		strMes = "0" + strMes;
	
	return strAno + strMes + strDia;
}

function aaaammdd( strData )
{
	var arrData = strData.split("/");
	
	if ( arrData.length < 3 )
		return "";
	
	var strDia	= arrData[0];
	var strMes	= arrData[1];
	var strAno	= arrData[2];
	
	if ( strDia.length == 1 ) 
		strDia = "0" + strDia
	
	if ( strMes.length == 1 )
		strMes = "0" + strMes

	return strAno + strMes + strDia;
}
function FormatarDataHora( strDataHora )
{
	if( strDataHora == null || strDataHora.length == 0 )
		return '';
	
	return  strDataHora.substring(6,8) + "/" + 
			strDataHora.substring(4,6) + "/" + 
			strDataHora.substring(0,4) + " " + 
			strDataHora.substring(8,10) + ":" +
			strDataHora.substring(10,12) + ":" + 
			strDataHora.substring(12,14);
	
}

function FormatarData( strData )
{
	if( strData == null || strData.length < 8 )
		return '';
	
	return  strData.substring(6,8) + "/" + 
			strData.substring(4,6) + "/" + 
			strData.substring(0,4);
}


function AbrirGrafico(strUrl)
{
	PopUp_Top = window.screenTop + 26;
	PopUp_Left = window.screenLeft;
	g_objPopUp = window.open (strUrl, "JanelaPadrao", 'width=790,height=510,top='+PopUp_Top+',left='+PopUp_Left+',resizable=0,toolbar=0,status=0,menubar=0,scrollbars=0');
}

function FormatarHora( strHora )
{
	var intPosFinal;
	
	if( strHora == null || strHora.length == 0 )
		return '';
	
	intPosFinal = strHora.length;
	
	return  strHora.substring(intPosFinal - 6, intPosFinal - 4) + ":" + 
			strHora.substring(intPosFinal - 4, intPosFinal - 2) + ":" + 
			strHora.substring(intPosFinal - 2, intPosFinal);
}

function FormatarDataHoraAPI( strDataHora )
{
	if( strDataHora == null || strDataHora.length == 0 )
		return '';
	
	return  strDataHora.substring(8,10) + "/" + 
			strDataHora.substring(5,7) + "/" + 
			strDataHora.substring(0,4) + " " + 
			strDataHora.substring(11,13) + ":" +
			strDataHora.substring(14,16) + ":" + 
			strDataHora.substring(17,19);
	
}

function FormatarDataAPI( strData )
{
	if( strData == null || strData.length < 10 )
		return '';
	
	return  strData.substring(8,10) + "/" + 
			strData.substring(5,7) + "/" + 
			strData.substring(0,4);
}

function Data(str)
//************************************************************
// Objetivo   : Verificar se o usuário digitou uma data válida
// Premissas  : Nenhuma premissa
// Efeitos    : Nenhum efeito
// Entradas   : str - campo a ser validado
// Retorno    : Nenhum retorno
// Chamado por: Todas as telas que necessitam de validação
//************************************************************
{
  if (str == null) { return false }
  if (str.length != 10) { return false }

  for (j=0; j<str.length; j++) {
    if ((j == 2) || (j == 5)) {
      if (str.charAt(j) != "/") { return false }
    } else {
      if ((str.charAt(j) < "0") || (str.charAt(j) > "9")) { return false }
    }
  }

  var day = str.charAt(0) == "0" ? parseInt(str.substring(1,2)) : parseInt(str.substring(0,2));
  var month = str.charAt(3) == "0" ? parseInt(str.substring(4,5)) : parseInt(str.substring(3,5));
  var begin = str.charAt(6) == "0" ? (str.charAt(7) == "0" ? (str.charAt(8) == "0" ? 9 : 8) : 7) : 6;
  var year = parseInt(str.substring(begin, 10));

  if (day == 0) { return false }
  if (month == 0 || month > 12) { return false }
  if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
    if (day > 31) { return false }
  } else {
    if (month == 4 || month == 6 || month == 9 || month == 11) {
      if (day > 30) { return false }
    } else {
      if (year%4 != 0) {
        if (day > 28) { return false }
      } else {
        if (day > 29) { return false }
      }
    }
  }
  return true;
}
//////////////////////////////////////////
// FIM Funções para formatar Data		//
//////////////////////////////////////////


//********************************************************************************
// Objetivo  :	Formata o valor do campo senha permitindo somente a entrada 
//				de números e letras;
// Premissas :	Nenhuma
// Entradas  :	objSenha
// Retorno   :	Valor formatado
//********************************************************************************
function FormatarSenha( objSenha )
{
	var strValor	= objSenha.value.toUpperCase();
	var strRetorno	= '';
	
	for ( var x = 0; x <=(strValor.length-1); x++ )
	{
		if ( ((strValor.charAt(x) >= '0') && (strValor.charAt(x) <= '9')) || ((strValor.charAt(x) >= 'A') && (strValor.charAt(x) <= 'Z')) )
			strRetorno += strValor.charAt(x);
	}
	
	objSenha.value = strRetorno;
}


	    
	    function AlertaTeclado( blnEstado )
	    {
	        if ( blnEstado )
	            divAlertaTeclado.style.display = "block";
	        else
	            divAlertaTeclado.style.display = "none";
	    }


function FormatarSenhaLogin( objSenha )
{
	objSenha.value  = '';

    // Alerta temporário
	AlertaTeclado( true );
}

function TiraVazio ( strValor )
{
	var strRetorno	= '';
	
	try
	{
	    var intTamanho	= strValor.length;
    	
	    for (var i = 0; i < intTamanho; i++)
	    {
		    var testChar = strValor.charAt(i);
		    if (testChar != ' ')
			    strRetorno += testChar;
	    }
	}
	catch(e)
	{}
	return strRetorno;
}

function RetornarNomePagina( strURL )
{
	try
	{
		// Assume página atual caso parâmetro não tenha sido informado
		if( strURL == null )
			strURL = window.document.URL;
		
		var intIndiceParametros = strURL.lastIndexOf("?");
		
		// Caso não existam parâmetros, assume tamanho da URL
		if( intIndiceParametros == -1 )
			intIndiceParametros = strURL.length;
		
		return strURL.substring(strURL.lastIndexOf("/") + 1,intIndiceParametros);
	}
	catch(e)
	{
		return '';
	}
}

function Random( intLimite )
{
	if( intLimite == null )
		intLimite = 10000;
	// Retorna um número aleatório entre 1 e o limite definido
	return Math.floor(Math.random() * intLimite) + 1;
}

function RemoveTralha ( strValor )
{
	var strRetorno	= '';
	var intTamanho	= strValor.length;

	for (var i = 0; i < intTamanho; i++)
	{
		var testChar = strValor.charAt(i);
		if (testChar != '#')
			strRetorno += testChar;
	}

	return strRetorno;
}

function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+'.'+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + 'R$' + num + ',' + cents);
}

function FormatarDiaMes( strData )
{
	if( strData == null || strData.length < 8 )
		return '';
	
	return  strData.substring(6,8) + "/" + 
			strData.substring(4,6);
}

Hoje = new Date() 
  
Data = Hoje.getDate() 
  
Dia = Hoje.getDay() 
  
Mes = Hoje.getMonth() 
  
Ano = Hoje.getYear() 
  
// 
  
if (Data<10) { 
  
Data = "0" + Data} 
  
if (Ano < 2000) { 
  
Ano = "19" + Ano} 
  
// 
  
NomeDia = new Array(7) 
  
NomeDia[0] = "Domingo" 
  
NomeDia[1] = "Segunda-feira" 
  
NomeDia[2] = "Terça-feira" 
  
NomeDia[3] = "Quarta-feira" 
  
NomeDia[4] = "Quinta-feira" 
  
NomeDia[5] = "Sexta-feira" 
  
NomeDia[6] = "Sábado" 
  
// 
  
NomeMes = new Array(12) 
  
NomeMes[0] = "Janeiro" 
  
NomeMes[1] = "Fevereiro" 
  
NomeMes[2] = "Março" 
  
NomeMes[3] = "Abril" 
  
NomeMes[4] = "Maio" 
  
NomeMes[5] = "Junho" 
  
NomeMes[6] = "Julho" 
  
NomeMes[7] = "Agosto" 
  
NomeMes[8] = "Setembro" 
  
NomeMes[9] = "Outubro" 
  
NomeMes[10] = "Novembro" 
  
NomeMes[11] = "Dezembro" 
  
// 
  
  
function MostrarData() { 
  
return ("<span class='textopadrao'>" + NomeDia[Dia] + ", " + Data + " de " + NomeMes[Mes] + " de " + Ano + "</span>") 
  
}
