
// Usada para abrir os menus da home  //
function some_menus()
{ 
	mn_secoes.style.display = 'none'
	mn_regioes.style.display = 'none'
	some_tudo.style.display = 'none'
}


// fade nas páginas do site //

      var oc=0;
	  var oc_turbo =0;
	
      function fadeIn(){
		var bloco_texto = document.getElementById('bloco_texto');
		if (bloco_texto){
			bloco_texto.style.filter="Alpha(opacity="+oc_turbo+")"
	  		oc_turbo = oc * 10; 
				if(oc!=100) setTimeout('oc++;fadeIn()',0);
				else return;
		}
      }


function display_menu(m)
{
	if (m == 's')
	{
		if (mn_secoes.style.display == 'none')
		{
			mn_secoes.style.display = ''
			mn_regioes.style.display = 'none'
		}
		else
		{
			mn_secoes.style.display = 'none'
			mn_regioes.style.display = 'none'
		}
	}	
	
	if (m == 'r')
	{
		if (mn_regioes.style.display == 'none')
		{
			mn_regioes.style.display = ''
			mn_secoes.style.display = 'none'

		}
		else
		{
			mn_regioes.style.display = 'none'
			mn_secoes.style.display = 'none'
		}
	}				
	some_tudo.style.display = ''
}

// Usada para abrir o popup de contato, anuncie e assinatura //
function rodape(){
	var roda = window.open('popup_seletor.htm', '', 'width=620,height=400 ,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no')
}

// Usada pra abrir o Texto de como pesquisar do guia
function guia_como(){
	var desktop = window.open('guia_como.asp', 'como', 'width=467, height=450 ,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no')
}

// Usada para abrir o popup que é gerado através do TooL //
function abrepopup(arq, altura, largura){
window.open('popup.asp?Arquivo='+arq, 'popup', 'height=' + altura + ',width=' + largura + ',left=200,top=155,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,directories=no,status=no')
}

function abrepopup2(arq, altura, largura){
window.open(arq, 'popup', 'height=' + altura + ',width=' + largura + ',left=200,top=155,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,directories=no,status=no')
}


// Usada na home para ativar o rollover do footer //
	function MM_jumpMenu(targ,selObj,restore)
	{
	  	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  	  	if (restore) selObj.selectedIndex=0;
	}


// Usada na home para abrir o popup do glossário //
function abre(){
	var desktop = window.open('glossario.asp', 'glossario', 'width=468,height=450 ,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no')
}

// Usada na home para limpar o text do glossário quando clicado //
function limpa_box_glossario()
{
if(glossario.palavra.value="Digite um termo")
{
glossario.palavra.value='';
}
}

// Usada na home para limpar o text do guia quando clicado //
function limpa_box_guia()
{
if(document.form_guia.texto2.value="Busca no guia")
{
document.form_guia.texto2.value='';
}
}


// Usadas para ativar o rollover dos links do rodapé//
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 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 isEmail(mail) {
	var ponto = 0;
	var arroba = 0;
	var letraAntes = 0;
	var letraDepois = 0;
	var i = 0;
	var l = mail.length;
	var ch = 0;
	if (l < 10)	return (false);
	for (i = 0; i < l; i++) {
		ch = mail.charCodeAt(i);
		if (ch == 46) {
			if (arroba > 0)	ponto += 1;
		} else {
			if (ch == 64) {
				arroba += 1;
			} else {
				if (((ch >= 65) && (ch <= 90)) || ((ch >= 97) && (ch <= 122))) {
					if (arroba > 0)
						letraDepois += 1;
					else
						letraAntes += 1;
				} else {
					if ((ch != 45) && (ch != 95)) {
						if ((ch < 48) || (ch > 57)) {
							return (false);
						}
					}
				}
			}
		}
	}
	if ((arroba == 1) && (ponto > 0) && (letraAntes > 1) && (letraDepois >= 5)) {
		return (true);
	} else {
		return (false);
	}
}
function Checaemail(campo)
{
	size=campo.value.length;
	i=1;
	numA=0;
	numP=0;
	lugarA=true;
	while (i<=size)
	{
		if (campo.value.charAt(i)!=" ") {
			if (campo.value.charAt(i)=="@") {
				numA++;
				if (campo.value.charAt(i+1)=="")
					lugarA=false;
			}
			if (campo.value.charAt(i)==".") {
				numP++;
				if (campo.value.charAt(i+1)=="")
					lugarA=false;
				if ( (campo.value.charAt(i+1)=="@") || (campo.value.charAt(i-1)=="@") )
					lugarA=false;
		}
	}
	else lugarA=false;
		i++;
	}
	if ( (lugarA) && (numA==1) && (numP>0) ){
		return true;
	}
	return false;
}
//=================================================================================== 
function retornaCodigoPagina(url){
	//alert(url);
	
	var objXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP")
	
	objXMLHTTP.Open("GET", url, false)
	objXMLHTTP.Send();

	var objXMLHTTP;
	
	//alert(objXMLHTTP.responseText);
	return objXMLHTTP.responseText;
	
}
//=========================================================================
	function consisteNum(){
		
		var key = event.keyCode;
		
		if  (!((key >= 48) && (key <= 57)))
		{
			event.keyCode = 0;
		}
	}
//=================================================================================== 
	function consisteData(){
		
		var key = event.keyCode;
		
		var contBarra = contaString(event.srcElement.value,'/');

		if (key == 92 || key == 47){
			if (contBarra < 2)
				event.keyCode = 47;
			else
				event.keyCode = 0;
		}else if (!((key >= 48) && (key <= 57))){
			event.keyCode = 0;
		}
	}
//=================================================================================== 	
	function contaString(vString,vString2){
		var temp = 0;
		if (vString.length>0 && vString2.length>0){
			for(i=0;i<vString.length;i++){
				//alert(vString.substr(i,vString2.length) + ' = ' + vString2)
				if (vString.substr(i,vString2.length)==vString2){
					temp++;
				}
			}
			return temp;
		}
		else return 0;
	}	
//=================================================================================== 	
function consisteTelefone(){
		
	var key = event.keyCode;
		
	if  (!((key >= 48) && (key <= 57)) && !(key == 45))
	{
		event.keyCode = 0;
	}
}


//=================================================================================== 
	function consisteChar()
	{
		var key = event.keyCode;
		
		if  ((key == 34) || (key == 39))
		{
			event.keyCode = 0;
		}
	}
//=================================================================================== 
	function consisteCharNum()
	{
		var key = event.keyCode;
		
		if (((key >= 48) && (key <= 57)) || ((key >= 65) && (key <= 90)) || ((key >= 97) && (key <= 122)))
        {
			event.keyCode = key;
        }
        else
        {
			event.keyCode = 0;
        }
    }
//=================================================================================== 
function consisteHexa()
	{
		
		var key = event.keyCode;
		
		if  (!((key >= 48) && (key <= 57)) && !((key >= 97)&& (key <= 102)) && !((key >= 65) && (key <= 70)))
		{
			event.keyCode = 0;
		}
		
	}
//=================================================================================== 
	function consisteDecimal(){
		var key = event.keyCode;
		
		if(key == 44 && (inStr(event.srcElement.value, '.') == 0)){
			event.keyCode = 46;
		}else if  (!(((key >= 48) && (key <= 57)) || (key==46)) || ((inStr(event.srcElement.value, '.') > 0) && (key==46)) ){
			event.keyCode = 0;
		}
	}
//===================================================================================
function isDate(campo) {
	if (campo != ""){
		if(campo.charAt(2) != "/" || campo.charAt(5) != "/" || campo.length != 10){
			return(false);
		}
		for(i=0;i<10;i++){
			if(i != 2 && i != 5){
				if(campo.charAt(i) != 0 && campo.charAt(i) != 1 && campo.charAt(i) != 2 && campo.charAt(i) != 3 && campo.charAt(i) != 4 && campo.charAt(i) != 5 && campo.charAt(i) != 6 && campo.charAt(i) != 7 && campo.charAt(i) != 8 && campo.charAt(i) != 9 || campo.charAt(i) == " "){
					return(false);
				}
			}
		}
		var Dia = 0;
		var Mes = 0;
		var Ano = 0;
		var Resto = 0;
		Dia = campo.substring(0,2);
		Mes = campo.substring(3,5);
		Ano = campo.substring(6,10);
		if (Ano < 1900) {
			return(false);
		}
		if ((Mes < 1) || (Mes > 12)) {
			return(false);
		}
		if ((Dia < 1) || (Dia > 31)) {
			return(false);
		}
		if ((Mes == "01") && (Dia <= 31)) {
			return(true);
		}
		if (Mes == "02") {
			Resto = Ano % 4;
			if ((Resto == 0) && (Dia <= 29)) {
				return(true);
			}
			if ((Resto != 0) && (Dia <= 28)) {
				return(true);
			}
		}
		if ((Mes == "03") && (Dia <= 31)) {
			return(true);
		}
		if ((Mes == "04") && (Dia <= 30)) {
			return(true);
		}
		if ((Mes == "05") && (Dia <= 31)) {
			return(true);
		}
		if ((Mes == "06") && (Dia <= 30)) {
			return(true);
		}
		if ((Mes == "07") && (Dia <= 31)) {
			return(true);
		}
		if ((Mes == "08") && (Dia <= 31)) {
			return(true);
		}
		if ((Mes == "09") && (Dia <= 30)) {
			return(true);
		}
		if ((Mes == "10") && (Dia <= 31)) {
			return(true);
		}
		if ((Mes == "11") && (Dia <= 30)) {
			return(true);
		}
		if ((Mes == "12") && (Dia <= 31)) {
			return(true);
		}
		return(false);
	}
}

function blockNonNumbers(obj, e, allowDecimal, allowNegative)
{
	var key;
	var isCtrl = false;
	var keychar;
	var reg;
		
	if(window.event) {
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
	}
	else if(e.which) {
		key = e.which;
		isCtrl = e.ctrlKey;
	}
	
	if (isNaN(key)) return true;
	
	keychar = String.fromCharCode(key);
	
	// check for backspace or delete, or if Ctrl was pressed
	if (key == 8 || isCtrl)
	{
		return true;
	}

	reg = /\d/;
	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
	
	return isFirstN || isFirstD || reg.test(keychar);
}

function URLEncode(vstring)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetci
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	if (!vstring)
		return;

	var plaintext = vstring;
	var encoded = "";
	
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" + ch + "' cannot be encoded using standard URL encoding.\n" +
				        "(URL encoding only supports 8-bit characters.)\n" +
						"A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for
	
	return encoded;

}
