// Áreas restritas
function mostrarAreaRestrita(quem){
	document.getElementById(quem).style.display = "";
}

function esconderAreaRestrita(quem){
	document.getElementById(quem).style.display = "none";
}

function ativarAreaRestrita(quem){
	document.getElementById(quem).style.backgroundColor = "F4751B";
	document.getElementById(quem).style.color = "FFFFFF";
}

function desativarAreaRestrita(quem){
	document.getElementById(quem).style.backgroundColor = "";
	document.getElementById(quem).style.color = "D36719";
}

// Conteúdo
function mostrarConteudo(quem){
	if (document.getElementById(quem).style.display == "")
		document.getElementById(quem).style.display = "none";
	else
		document.getElementById(quem).style.display = "";		
}

// Abre Pop Up
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// Inicio da Função Auto Tab
var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e) {
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	
	if(input.value.length >= len && !containsElement(filter,keyCode)) {
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
}

function containsElement(arr, ele) {
	var found = false, index = 0;
	
	while(!found && index < arr.length)
		if(arr[index] == ele)
			found = true;
		else
			index++;
	
	return found;
}

function getIndex(input) {
	var index = -1, i = 0, found = false;
	
	while (i < input.form.length && index == -1)
		if (input.form[i] == input)
			index = i;
		else i++;
			return index;
	}
	
	return true;
}

// Valida E-mail
function validaEmail(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	
	if (str.indexOf(at)==-1){
	   alert("E-mail inválido!")
	   return false
	}
	
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("E-mail inválido!")
	   return false
	}
	
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("E-mail inválido!")
		return false
	}
	
	 if (str.indexOf(at,(lat+1))!=-1){
		alert("E-mail inválido!")
		return false
	 }
	
	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("E-mail inválido!")
		return false
	 }
	
	 if (str.indexOf(dot,(lat+2))==-1){
		alert("E-mail inválido!")
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		alert("E-mail inválido!")
		return false
	 }
	
	 return true					
}
