function change(e) {
	var etarget = ns6 ? e.target : event.srcElement;
	if ((!document.all && !ns6) ||
		(ns6 && !etarget.id=="menupai") ||
		(!(etarget.id=="menupai"))) {
		return;
	}
	var imagetarget = etarget;
	nested = ns6 ? etarget.nextSibling.nextSibling : document.all[etarget.sourceIndex+1];
	if (nested.style.display=="none") {
		nested.style.display=''
	} else {
		nested.style.display="none";
	}
}

function arrumaLISTA() {
	document.all["lista"].style.height = document.body.clientHeight-130;
}
			
function arrumaLista(a) {
	if (document.all["lista"] != null) {
		document.all["lista"].style.height = document.body.clientHeight-a;
	}
}
			
function validaCPF(campo) {
	re = /\d\d\d.\d\d\d.\d\d\d-\d\d/;
	if (!re.test(campo.value)) {
		alert("Campo Incompleto");
		campo.focus();
	}
}

function digitaNUMERO(campo) {
	re = /[^0-9]/;
	digito = String.fromCharCode(event.keyCode);
	if (re.test(digito)) {
		return false;
	}
}

function digitaCPF(campo) {
	re = /[^0-9]/;
	digito = String.fromCharCode(event.keyCode);
	if (re.test(digito)) {
		return false;
	}
	formataCPF(campo);
}

function digitaCEP(campo) {
	re = /[^0-9]/;
	digito = String.fromCharCode(event.keyCode);
	if (re.test(digito)) {
		return false;
	}
	formataCEP(campo);
}

function digitaDATA(campo) {
	re = /[^0-9]/;
	digito = String.fromCharCode(event.keyCode);
	if (re.test(digito)) {
		return false;
	}
	formataDATA(campo);
}

function formataDATA(campo) {
	var valor = "";
	var teste = campo.value;
	for (var i = 1;i<=teste.length;i++) {
		if (!isNaN(teste.charAt(i-1))) {
			valor += teste.charAt(i-1);
			if (valor.length == 2 || valor.length==5) {
				valor += "/";
			}
		}
	}
	campo.value=valor;
}

function formataCEP(campo) {
	var valor = "";
	var teste = campo.value;
	for (var i = 1;i<=teste.length;i++) {
		if (!isNaN(teste.charAt(i-1))) {
			valor += teste.charAt(i-1);
			if (valor.length==5) {
				valor += "-";
			}
		}
	}
	campo.value=valor;
}

function formataCPF(campo) {
	var valor = "";
	var teste = campo.value;
	for (var i = 1;i<=teste.length;i++) {
		if (!isNaN(teste.charAt(i-1))) {
			valor += teste.charAt(i-1);
			if (valor.length==3|valor.length==7) {
				valor += ".";
			}
			if (valor.length==11) {
				valor += "-";
			}
		}
	}
	campo.value=valor;
}
				
		
function teste(e) {
	var etarget = ns6 ? e.target : event.srcElement;
	if ((!document.all && !ns6) ||
		(ns6 && !etarget.id=="menupai") ||
		(!(etarget.id=="menupai"))) {
		return;
	}
	var imagetarget = etarget;
//			if ((etarget.id=="menunivel1") || (ns6 && etarget.parentNode.id=="menunivel1")) {
//  			if (ns6 && etarget.parentNode.id=="menunivel1")	{
//					nested=etarget.parentNode.nextSibling.nextSibling;
//					imagetarget=etarget.parentNode;
//  			} else {
			nested = ns6 ? etarget.nextSibling.nextSibling : document.all[etarget.sourceIndex+1];
//				}
	if (nested.style.display=="none") {
			nested.style.display=''
	//		if (anterior != null && anterior!=nested) {
	//			anterior.style.display="none";
	//		}
		} else {
			nested.style.display="none";
		}
	//	anterior = nested;
	//}
}
function validarEmail(campo) {
	if (!/^[\w\.]+\@\w+(\.\w+)+$/.test(campo.value)) {
		alert("e-mail inválido");
		campo.focus();
		return false;
	}
	return true;
}		



