// JavaScript Document

function abreTab(item)
{
	var tab = window.document.getElementById(item).style.display;
	if(tab == "none")
	{
		window.document.getElementById(item).style.display = "block";
	}
	else
	{
		window.document.getElementById(item).style.display = "none";
	}
}

function fechaTab(item)
{
	var tab = window.document.getElementById(item).style.display;
	if(tab == "none")
	{
		window.document.getElementById(item).style.display = "block";
	}
	else
	{
		window.document.getElementById(item).style.display = "none";
	}
}

function Verifica_Cep(cep, obrigatorio){
 //Se o parâmetro obrigatório for igual à zero, significa que elepode estar vazio, caso contrário, não
 	var cep    = document.getElementById(cep);
 	var strcep = cep.value;
 	if((obrigatorio == 1) || (obrigatorio == 0 && strcep != "")){
 		if (strcep.length != 9){
 			alert("CEP informado inválido.");
 			cep.focus();
 			return false
 		}else{
 			if (strcep.indexOf("-") != 5){
 				alert("Formato de CEP informado inválido.");
 				cep.focus();
 				return false
 			}else{
 				if (isNaN(strcep.replace("-","0"))){
 					alert("CEP informado inválido.");
 					cep.focus();
 					return false
 				}
 			}
 		}
 	}	  
 }
