function Conversao()	{
	var f = document.form1
	var dd = new Date()
	var ds = dd.getDay()

	if (ds==1 )	{
		dd.setDate(dd.getDate() - 3)
	}
	else if (ds==7)	{
		dd.setDate(dd.getDate() - 2)
	}
	else	{
		dd.setDate(dd.getDate() - 1)
	}
	
	aaa = dd.getDate()
	var mmm = (dd.getMonth() + 1)
	var yyy = dd.getYear()
	aux1 = ((aaa < 10) ? "0" + aaa + "/" :aaa + "/") 
	aux1 += ((mmm < 10) ? "0" + mmm + "/" : mmm + "/") 
	
	if (yyy<2000)	{
		aux1 += (yyy + 1900)
	}
	else	{
		aux1 += (yyy)
	}

	f.DataCotacao.value = aux1
	f.ChkMoedaOrigem.focus()
}

function Envia()	{
	var f = document.form1
	
		//Verifica se moeda origem = moeda destino
		if (f.ChkMoedaOrigem.selectedIndex == f.ChkMoedaDestino.selectedIndex) {
			alert("Selecione moedas diferentes para realizar a conversão.")
			f.ChkMoedaOrigem.focus()
			return false
		}
		
		//Valida o valor
		if (isEmpty(f.Valor.value)) {
			alert("O campo 'Quantidade a converter' é obrigatório.")
			f.Valor.focus()
			return false
		}
		
		if (f.Valor.value == 0) {
			alert("O campo 'Quantidade a converter' deve ser maior que zero.")
			f.Valor.focus()
			return false
		}
		
		if ((!isInteger(f.Valor.value)) && (f.Valor.value!=""))
		{
			alert("O campo 'Quantidade a converter' deve ser numérico.")
			f.Valor.focus()
			return
		}
		
		
		//Valida a data
		
		if (f.DataCotacao.value.length==0)	{
			alert("O campo 'Data da Cotação' é obrigatório.")
			f.DataCotacao.focus()
			return false
		}

		if (f.DataCotacao.value.length != 10) {
			alert("O campo 'Data da Cotação' não está no formato 'DD/MM/AAAA'.")
			f.DataCotacao.focus()
			return false
		}

		b1= f.DataCotacao.value.toString().substring(3,2)
		b2= f.DataCotacao.value.toString().substring(6,5)
		if (b1 != "/" || b2 != "/")	{
			alert("O campo 'Data da Cotação' não está no formato 'DD/MM/AAAA'.")
			f.DataCotacao.focus()
			return false
		}
		dia = f.DataCotacao.value.toString().substring(2,0)
		mes = f.DataCotacao.value.toString().substring(3,5)
		ano = f.DataCotacao.value.toString().substring(6,10)
	
	
		if (!checkDate(ano,mes,dia,"Data da Cotação", f.DataCotacao)) {
			f.DataCotacao.focus()
			return false
		}
			
		//Testa se é anterior a 01/02/1999
		f.DataCotacaoEnvio.value = ano + mes + dia
		if (f.DataCotacaoEnvio.value < "19990201") {
			alert("'Data da Cotação' deve ser a partir de 01/02/1999")
			f.DataCotacao.focus()
			return false
		}
			
		//hoje = new Date()
		//alert(hoje)
		
		f.ValorEnvio.value = CompletaNumero2(f.Valor.value,17)
		x = f.ChkMoedaOrigem.selectedIndex;
		f.MoedaOrigem.value = f.ChkMoedaOrigem.options[x].value;
		f.DescMoedaOrigem.value = f.ChkMoedaOrigem.options[x].text;
		x = f.ChkMoedaDestino.selectedIndex;
		f.MoedaDestino.value = f.ChkMoedaDestino.options[x].value;
		f.DescMoedaDestino.value = f.ChkMoedaDestino.options[x].text;
		
		//alert(f.MoedaOrigem.value + f.MoedaDestino.value + f.DataCotacaoEnvio.value + f.ValorEnvio.value)
		return true
}



