function mudaRegiao(uf, url)
{
	var ddd = uf.substr(2,2);
	var uf  = uf.substr(0,2);
	
	writeCookie("region", uf, 24);

	window.location = url + "?regional=" + uf.toLowerCase();
}

function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire + ";path=/";
}

// Menu Vivo
var showMenu = false;

$(document).ready(function() {
	$(".menu-vivo-div").stop().fadeTo(0, 0);

	$(".menu-vivo").click(function(){
		if (!showMenu) {
			$(".menu-vivo-div").stop().fadeTo(1000, 1);
			showMenu = true;
		} else {
			$(".menu-vivo-div").stop().fadeTo(1000, 0);
			showMenu = false;
		}						   
	});
});

// Escreve cookie
function writeCookie(name, value, hours)
{
  var expire = "";

  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }

  document.cookie = name + "=" + escape(value) + expire;
}

// Lê cookie
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";

  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);

      if (end == -1) end = document.cookie.length;
      	cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }

  return cookieValue;
}

//Mostra conteúdo Suporte Ativar
var _janela  = '';
var _pag     = 0;
var ativ_pag = 0;

function abrirPopUp(janela, pag)
{	
	var id = "#" + janela + "_box-";
	
	navegaLista(0);
	
	$(".suporte-3g-suporte-links").hide();
	
	$("#suporte-" + janela).show();
	
	$(id + "0").show();
	$(id + "1").hide();
	$(id + "2").hide();
	$(id + "3").hide();
	$(id + "4").hide();
	$(id + "5").hide();
	$(id + "6").hide();
	
	_janela = janela;
	_pag    = pag;
	
	loadScroll();
}

function fechaPopUp(janela)
{
	$(".suporte-3g-suporte-links").show();
	$("#suporte-" + janela).hide();
}

function navegaConteudo(pag)
{
	var id = "#" + _janela + "_box-" + pag;
	
	$(".conteudobox").hide();
	$(id).fadeIn(1000);
	
	ativ_pag = pag;
	
	navegaLista(pag)
}

function navSeta(acao)
{	
	if (acao == 'avanca') {
		ativ_pag++;
		
		if (ativ_pag > _pag) ativ_pag = 0;
		
		$(".conteudobox").hide();
		$("#" + _janela + "_box-" + ativ_pag).fadeIn(1000);
	} else {
		ativ_pag--;
		
		if (ativ_pag < 0) ativ_pag = _pag;
		
		$(".conteudobox").hide();
		$("#" + _janela + "_box-" + ativ_pag).fadeIn(1000);
	}
	
	navegaLista(ativ_pag);
}

function navegaLista(pag)
{
	$('.menu-etapas ul li').each(function() { 
		var pos = this.firstChild.innerHTML; 
		
		if (pag == pos) {
			this.firstChild.className = "ativo";
		} else {
			this.firstChild.className = "";
		}
	})
}

