function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

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 cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

function resposta() {
janela="window.open('http://www.midiaville.com.br/news/listahpo.php','resposta', 'scrollbar=no,menubar=no,toolbar=no,resizable=no,width=450,height=350,left=100,top=100,location=no,modal=no,copyhistory=no,fullscreen=no');";
eval(janela);
}
function addBookmark(url,title) {
    if (window.sidebar) {
        window.sidebar.addPanel(title, url,"");
    } else if( document.all ) {
        window.external.AddFavorite( url, title);
    } else if( window.opera && window.print ) {
  return true;
}
}

 function abrirMapa(id){
        janela=window.open("mapaloc.php?chave="+id,"MidiaVilleMaps",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=790,height=520, top=0, left=0');
        text = "Se a janela não abrir\ntalvez seja porque você tenha um\nprograma bloqueador de pop-up!\nPara abrir a janela\né preciso desabilitar o bloqueador\nde popup's!";
        if(janela == null) { alert(text); return; }
   }
   
 function abrirMaparuas(id){
        janela=window.open("maparuas.php?chave="+id,"MidiaVilleMaps",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=790,height=520, top=0, left=0');
        text = "Se a janela não abrir\ntalvez seja porque você tenha um\nprograma bloqueador de pop-up!\nPara abrir a janela\né preciso desabilitar o bloqueador\nde popup's!";
        if(janela == null) { alert(text); return; }
   }
   
 function abrirMapacat(id){
        janela=window.open("mapacat.php?chave="+id,"MidiaVilleMaps",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=790,height=520, top=0, left=0');
        text = "Se a janela não abrir\ntalvez seja porque você tenha um\nprograma bloqueador de pop-up!\nPara abrir a janela\né preciso desabilitar o bloqueador\nde popup's!";
        if(janela == null) { alert(text); return; }
   }

 function abrirJoinville(){
        janela=window.open("mapaJoinville.php","MidiaVilleMaps",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=790,height=520, top=0, left=0');
        text = "Se a janela não abrir\ntalvez seja porque você tenha um\nprograma bloqueador de pop-up!\nPara abrir a janela\né preciso desabilitar o bloqueador\nde popup's!";
        if(janela == null) { alert(text); return; }
   }

 function abrirRecomende(){
        janela=window.open("recomende.php","Recomende",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=450,height=350, top=0, left=0');
        text = "Se a janela não abrir\ntalvez seja porque você tenha um\nprograma bloqueador de pop-up!\nPara abrir a janela\né preciso desabilitar o bloqueador\nde popup's!";
        if(janela == null) { alert(text); return; }
   }

 function abrirSugestoes(){
        janela=window.open("sugestoes.php","Recomende",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=450,height=490, top=0, left=0');
        text = "Se a janela não abrir\ntalvez seja porque você tenha um\nprograma bloqueador de pop-up!\nPara abrir a janela\né preciso desabilitar o bloqueador\nde popup's!";
        if(janela == null) { alert(text); return; }
   }
    
 function abrirEventos(){
        janela=window.open("enviaevento.php","Recomende",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=450,height=550, top=0, left=0');
        text = "Se a janela não abrir\ntalvez seja porque você tenha um\nprograma bloqueador de pop-up!\nPara abrir a janela\né preciso desabilitar o bloqueador\nde popup's!";
        if(janela == null) { alert(text); return; }
   }
 function abrirRecomendado(id){
        janela=window.open("enviarecomendado.php?id="+id,"Recomende",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=450,height=550, top=0, left=0');
        text = "Se a janela não abrir\ntalvez seja porque você tenha um\nprograma bloqueador de pop-up!\nPara abrir a janela\né preciso desabilitar o bloqueador\nde popup's!";
        if(janela == null) { alert(text); return; }
   }
    function abrirAniversario(){
        janela=window.open("aniversario.php","Promoção",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=555,height=610, top=0, left=0');
        text = "Se a janela não abrir\ntalvez seja porque você tenha um\nprograma bloqueador de pop-up!\nPara abrir a janela\né preciso desabilitar o bloqueador\nde popup's!";
        if(janela == null) { alert(text); return; }
   }
    function reportaErro(id){
        janela=window.open("reportaErro.php?id="+id,"Erro",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=450,height=500, top=50, left=50');
        text = "Se a janela não abrir\ntalvez seja porque você tenha um\nprograma bloqueador de pop-up!\nPara abrir a janela\né preciso desabilitar o bloqueador\nde popup's!";
        if(janela == null) { alert(text); return; }
   }
       function enviaEmailEmpresa(id){
        janela=window.open("enviaEmailEmpresa.php?id="+id,"Email",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=450,height=480, top=100, left=100');
        text = "Se a janela não abrir\ntalvez seja porque você tenha um\nprograma bloqueador de pop-up!\nPara abrir a janela\né preciso desabilitar o bloqueador\nde popup's!";
        if(janela == null) { alert(text); return; }
   }
