// JavaScript Document

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


// ************************************************************************
			function MudaNova(Nova)
				{
					if(Nova == 0)
					{
				
					HideAllDivs();
					varAtual = document.getElementById("msg");
					varAtual.style.display = "block";
					return false;
					}
					else
					{				

					selecte = Nova;
					HideAllDivs();
					ShowDiv(selecte);
					}
				}

			function ChangeMenuAux(MenuPrincipal)
				{
					var idestado = document.form1.estado.selectedIndex;
					
					if(idestado == 0)
					{
					//alert("nao faz nada");
					HideAllDivs();
					varAtual = document.getElementById("msg");
					varAtual.style.display = "block";
					//document.getElementById('cidades').value = 0;
					return false;
					}
					else
					{				
					selected = MenuPrincipal.value;
					HideAllDivs();
					ShowDiv(selected)
					}
				}
	
			function HideAllDivs()
				{
				Divs =document.getElementsByTagName("var");
				for(i=0;i<Divs.length;i++)
					Divs[i].style.display = "none";			
				}
				
			function ShowDiv(NameOfDiv)
				{
				DivAtual = document.getElementById(NameOfDiv);
				DivAtual.style.display = "block";
				//var idEstado = document.form1.estado.selectedIndex;	so funciona no ie			
				//cid = "cidades"+idEstado;				
				//valor = document.getElementById(cid).value;				
				//document.getElementById('cidade').value = valor;
				}
				function trocavalor(valor){
				document.getElementById('cidades'+idestado).value = valor;
				//alert(idEstado);
				//alert(valor);
				}
				
				
	/*marcado = -1
	for (i=0; i<form1.cidades.length; i++) 
	{
		if (form1.cidades[i].selected)
		{
			marcado = i
			resposta = form1.cidades[i].value;
			alert(resposta);
		}
	}*/
	

				
//*****************************************************************************

/*
function valida() {
var nome=document.form1.nome.value;
var sobrenome=document.form1.sobrenome.value;
var email=document.form1.email1.value;
var telefone=document.form1.telefone1.value; 
var myDayStr = document.form1.dia.value;
var myMonthStr = document.form1.mes.value;
var myYearStr = document.form1.ano.value;
var myMonth = new Array('Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'); var myDateStr = myDayStr + ' ' + myMonth[myMonthStr] + ' ' + myYearStr;

// Using form values, create a new date object using the setFullYear function 
var myDate = new Date();
myDate.setFullYear( myYearStr, myMonthStr, myDayStr );

if (nome=="") {
window.alert("Você tem que digitar o seu nome.");
document.form1.nome.focus();
return false;
}
if (nome.indexOf(" ") >= 1) {
window.alert("Não é Permitido Espaços em Branco no Nome.");
document.form1.nome.focus();
document.form1.nome.value="";
return false;
}
if (sobrenome=="") {
window.alert("Você tem que digitar o seu Sobrenome.");
document.form1.sobrenome.focus();
return false;
}
if (email=="") {
window.alert("Digite seu e-mail");
document.form1.email1.focus();
return false;
}
if (email.indexOf("@") == -1 || email.indexOf(".") == -1) {
window.alert("Informe E-mail inválido.");
document.form1.email1.focus();
return false;
}
if(!email.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+.[a-zA-Z0-9._-]+)/gi)){
 			alert("Informe um e-mail válido");
 			document.form1.email1.focus();
 			return false
}
if (telefone=="") {
window.alert("Você tem que digitar o seu Telefone.");
document.form1.telefone1.focus();
return false;
}
if (form1.dia.selectedIndex == "0")
{
alert("É preciso Escolher o Dia em Que Você Nasceu!");
document.form1.dia.focus();
return false;
}
if (form1.mes.selectedIndex == "00")
{
alert("É preciso Escolher o Mês em Que Você Nasceu!");
document.form1.mes.focus();
return false;
}
if (form1.ano.selectedIndex == "0")
{
alert("É preciso Escolher o Ano em Que Você Nasceu!");
document.form1.ano.focus();
return false;
}

if ( myDate.getMonth() != myMonthStr ) {
  alert( 'Desculpe, mas " ' + myDateStr + ' " é uma Data Inválida Conserte.' );
  document.form1.dia.focus();
  return false
} 
 
return true;
document.form1.submit();
}*/

//************************************************************************************


	function cpf(){
		var cpf = document.form1.txt_cpf.value;
		if (cpf==""){
			alert("CPF Campo de preenchimento obrigatório!");
			document.form1.txt_cpf.focus();
			return false;
		}

		var mycpf = cpf;
		if (mycpf.length >= 14) 
		{
		
			var meucpf;
			meucpf = mycpf.substr(0,3);
			meucpf += mycpf.substr(4,3);
			meucpf += mycpf.substr(8,3);
			meucpf += mycpf.substr(12,2);
			//alert(meucpf);
		
		}
		else
		{
			alert("Digite o Cpf Conforme o Exemplo: 123.456.789-00");
			document.form1.txt_cpf.focus();
			return false;
		}
		

		var posicao, i, soma, dv, dv_inf;
		var digito = new Array(10);
		dv_inf = meucpf.substr(9,2);
//		alert(dv_inf); para teste!
		for(i=0;i<9;i++){
			digito[i]=meucpf.substr(i,1);
		}
		posicao=10;
		soma=0;
		for(i=0;i<9;i++){
			soma+=digito[i]*posicao;
			posicao=posicao-1;
		}
		digito[9]=soma%11;
		if(digito[9]<2){
			digito[9]=0;
		}
		else{
			digito[9]=11-digito[9];
		}
		posicao=11;
		soma=0;
		for(i=0;i<10;i++){
			soma=soma+digito[i]*posicao;
			posicao=posicao-1;
		}
		digito[10]=soma%11;
		if(digito[10]<2){
			digito[10]=0;
		}
		else{
			digito[10]=11-digito[10];
		}
		dv=	String(digito[9]) + String(digito[10]);
//		alert("DIGITO[9]="+digito[9]);
//		alert("DIGITO[10]="+digito[10]);
//		alert("DV: "+dv);
//		alert("DV_INF: "+dv_inf);		
		if(dv!=dv_inf){
			alert("CPF inválido!");
			document.form1.txt_cpf.value="";
			document.form1.txt_cpf.focus();
			return false;
		}
				
		var strcep = document.form1.cep.value;
		
		if(form1.estado.selectedIndex == "0")
		{
			alert("Escolha um Estado e depois escolha uma Cidade");
			document.form1.estado.focus();
			return false;
		}
	
		if(form1.endereco.value == "")
		{
			alert("Digite um Endereço!");
			document.form1.endereco.focus();
			return false
		}
		
		if(form1.cep.value == "")
		{	
			alert("Digite o CEP ( Zona Postal )");
			document.form1.cep.focus();
			return false;
		}
		if (strcep.length != 9){
 			alert("CEP informado inválido.");
 			document.form1.cep.focus();
 			return false
 		}else{
 			if (strcep.indexOf("-") != 5){
 				alert("Formato de CEP informado inválido.");
 				document.form1.cep.focus();
 				return false
 			}else{
 				if (isNaN(strcep.replace("-","0"))){
 					alert("CEP informado inválido.");
 					document.form1.cep.focus();
 					return false
 				}
 			}
 		}
		if(form1.area_profissao.selectedIndex == "0")
		{
			alert("Escolha uma Área Profissional ou Escolha Outras Profissoes");
			document.form1.area_profissao.focus();
			return false;
		}

		return true;
		document.form1.submit();		
	}
	
// *************************************************************************************


<!-- Original:  Ronnie T. Moore -->
<!-- Web Site:  The JavaScript Source -->

<!-- Dynamic 'fix' by: Nannette Thacker -->
<!-- Web Site: http://www.shiningstar.net -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter 
else 
countfield.value = maxlimit - field.value.length;
}
// End -->
