
function Ini()	{

	var d = new Date()
	var mm = parseInt(d.getMonth() + 1).toString()
	var yy = parseInt(d.getYear()).toString()

	
	aux1 = ((mm < 10) ? "0" + mm + "/": mm + "/") 
	aux2 = ((mm < 10) ? "0" + mm : mm) 

	if (yy<2000)	{
		aux1 += yy + 1900
		aux2 = (yy + 1900) + aux2
	}
	else	{
		aux1 += yy
		aux2 = yy + aux2		
	}

   if (parseInt(aux2) < parseInt("200006"))	{
		document.form1.TxtDI.value = "06/2000"
	}
	else	{
		document.form1.TxtDI.value = aux1		
	}

}

function Mensagens(valor)	{

	if (valor==1)	{
		alert("No campo, 'Período', digite o Mês/Ano no qual será realizada sua pesquisa.\nO formato do campo é mm/aaaa.\n\nPara a primeira opção:\n - O período deve estar entre 06/2000 e o mês atual.\n\nPara a segunda opção:\n - O período deve estar entre 05/2000 e o mês anterior ao mês atual.")
	}

}

function ValidaCampos(data1)	{

	//if (document.form1.TxtOpcao.value=="2") {
	//	alert("Opção temporariamente indisponível!")
	//	return false
	//}


	if (data1.value.length==0)	{
		alert("O campo 'Período' é obrigatório!")
		return false
	}

	if (data1.value.length != 7)	{
		alert("O campo 'Período' não está no formato 'MM/AAAA'!")
		return false
	}

	mes1 = data1.value.toString().substring(2,0)
	ano1 = data1.value.toString().substring(3,7)

	for (var i=0; i < data1.value.length; i++)	{
		var ch = data1.value.toString().substring(i,i+1)
		if ((i==2) && ch != "/") {
			alert("O campo 'Período' não está no formato 'MM/AAAA'!")
			return false
		}
		else if ((i!=2) && (ch < "0" || ch > "9")) {
			alert("O campo 'Período' não está no formato 'MM/AAAA'!")
			return false
		}
	}

	if (mes1>12 || mes1==0) {
		alert("O campo 'Período' está inválido!")
		return false
	}

	var d = new Date()

	if (document.form1.TxtOpcao.value=="1")	{
		
		var mm = parseInt(d.getMonth() + 1).toString()
		var yy = parseInt(d.getYear()).toString()

		aux2 = ((mm < 10) ? "0" + mm : mm) 
		
		if (yy<2000)	{
			aux2 = (yy + 1900) + aux2
		}
		else	{
			aux2 = yy + aux2		
		}
		
		if (parseInt(ano1+mes1)<parseInt("200006"))	{
			alert("O campo 'Período' não pode ser inferior a 06/2000!")
			return false
		}
		
		if	(parseInt(ano1+mes1) > parseInt(aux2))	{
			alert("O campo 'Período' não pode ser superior ao mês atual!")
			return false
		}

		
	}
	else	{
		if (parseInt(ano1+mes1)<parseInt("200005"))	{
			alert("O campo 'Período' não pode ser inferior a 05/2000!")
			return false
		}

		mm = parseInt(d.getMonth()).toString()
		yy = parseInt(d.getYear()).toString()

		aux2 = ((mm < 10) ? "0" + mm : mm) 
		
		if (yy<2000)	{
			aux2 = (yy + 1900) + aux2
		}
		else	{
			aux2 = yy + aux2		
		}

//		if	(ano1+mes1 == "200009")	{
//			alert("Mês solicitado ainda não apurado!")
//			return false
//		}
		if	(parseInt(ano1+mes1) > parseInt(aux2))	{
			alert("O campo 'Período' não pode ser igual ou superior ao mês atual!")
			return false
		}
	}

	if (document.form1.TxtOpcao.value=="1")	{
		document.form1.action="Resposta.asp?idpai=DEALCAMBIO"
	}
	else	{
		//alert("Opção temporariamente indisponível!")
		//return false
		document.form1.action="DetMensal.asp?idpai=DEALCAMBIO"
	}

	return true

}
