//////////////////////////////////////////////////////////////////////////////
// Cookie
//////////////////////////////////////////////////////////////////////////////
function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var fs = readCookie("fs");
  if ( !isNaN(parseInt(fs)) ) {
    document.body.style.fontSize = parseInt(fs)+"px";
    Ac.size = parseInt(fs);
  }
}


//////////////////////////////////////////////////////////////////////////////
// Fontes : Aumentar / Diminuir
//////////////////////////////////////////////////////////////////////////////

// Tamanho de fonte inicial
var tamanhoFontePagina = 11;
var tamanhoFontePaginaMax = 13;
var tamanhoFontePaginaMin = 10;
var tamanhoFontePaginaVar = 1;

// Aumentar o texto
function aumentarTexto() {
    if (tamanhoFontePagina <= tamanhoFontePaginaMax) {
        tamanhoFontePagina += tamanhoFontePaginaVar;
        alterarTamanhoFonte();
    }
}

// Diminuir o texto
function diminuirTexto() {
    // Se é maior igual ao mínimo
    if (tamanhoFontePagina >= tamanhoFontePaginaMin) {
        tamanhoFontePagina -= tamanhoFontePaginaVar;
        alterarTamanhoFonte();
    }
}

function alterarTamanhoFonte() {
	createCookie("fs", tamanhoFontePagina, 365);
	document.body.style.fontSize = tamanhoFontePagina + 'px';
	
}

//////////////////////////////////////////////////////////////////////////////
// Combo
//////////////////////////////////////////////////////////////////////////////
function change() {
    
    obj = document.getElementById("selectAcessoRapido");
    if (obj.value == "") {
        obj.selectedIndex = 0;
    } else {
        document.location = obj.value;
    }
}

//////////////////////////////////////////////////////////////////////////////
// Campo de busca
//////////////////////////////////////////////////////////////////////////////
function noEnter() {
    return !(window.event && window.event.keyCode == 13); 
}

//////////////////////////////////////////////////////////////////////////////
// Pesquisar
//////////////////////////////////////////////////////////////////////////////
function Pesquisar() {
    if (document.getElementById('txP') != null) {
        document.location = 'ResultadosBusca.aspx?q=' + document.getElementById('txP').value;
    } else {
        document.location = 'ResultadosBusca.aspx?q=' + document.forms[0].txP.value;
    }
}
