﻿function popup(pag, largura, altura) {
  var posX = (screen.availWidth - largura) / 2;
  var posY = (screen.availHeight - altura) / 2;

  windowAviso = window.open('../popUps/' + pag, 'Aviso', 'status=no,resizable=no,scrollbars=no,menubar=no,width=' + largura + ',height=' + altura + ',left=' + posX + ',top=' + posY);
  windowAviso.focus();
}

function limpaCampo(campo, msg, cor) {
  if (campo.value == msg) {
    campo.value = "";
    campo.style.color = cor;
  }
}

function retornaCampo(campo, msg, cor) {
  if (campo.value.length == 0) {
    campo.value = msg;
    campo.style.color = cor;
  }
}

function limpaCampoSenha(campo, msg, cor) {
  if (campo.value == msg) {
    campo.value = "";
    campo.type = "password";
    campo.style.color = cor;
  }
}

function retornaCampoSenha(campo, msg, cor) {
  if (campo.value.length == 0) {
    campo.value = msg;
    campo.type = "text";
    campo.style.color = cor;
  }
}

function mudaImagem(imagem, loja, cor) {
  document.getElementById("topoHome").style.background = "url(" + imagem + ") no-repeat";
  document.getElementById("loja1").style.color = "#FFFFFF";
  document.getElementById("loja2").style.color = "#FFFFFF";
  document.getElementById("loja3").style.color = "#FFFFFF";
  loja.style.color = cor;
}

function mostraMapa(numeroLoja) {
  document.getElementById("linkGaleria" + numeroLoja).style.display = "none";
  for (i = 1; i <= 3; i++) {
    if (numeroLoja != i) {
      document.getElementById("loja" + i).style.display = "none";
      document.getElementById("linkGaleria" + i).style.display = "block";
    }
    else {
      document.getElementById("loja" + i).style.display = "block";
      document.getElementById("linkGaleria" + i).style.display = "none";
    }
  }
}

function escondeMapa(numeroLoja) {
  document.getElementById("loja" + numeroLoja).style.display = "none";
  document.getElementById("linkGaleria" + numeroLoja).style.display = "block";
}

function imprimeMapa(numeroLoja) {
  document.getElementById("tituloLojas").style.display = "none";
  window.print();
}

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 getPag(){
 var pagina = document.getElementById("ctl00_phConteudo_txtNumPag").value;
 verPagina('../App_Themes/Default/imagens/cartilhaDiabetes/', 'fotoCartilha', 62, 'pagina', pagina); 
}

function verPagina(path, target, max, label, numPag) {
  if (numPag >=1 && numPag < max) {    
    document.getElementById(target).style.backgroundImage = 'url(' + path + numPag + '.gif)';
  }
  document.getElementById(label).innerHTML = numPag;
}

var imgSlide = 1;
function NextSlideNumerico(path, target, max, label) {    
  if (imgSlide < max) {
    imgSlide++;
    document.getElementById(target).style.backgroundImage = 'url(' + path + imgSlide + '.gif)';
  }
  document.getElementById(label).innerHTML = imgSlide;
}

function PrevSlideNumerico(path, target, label) {
  if (imgSlide > 1) {
    imgSlide--;
    document.getElementById(target).style.backgroundImage = 'url(' + path + imgSlide + '.gif)';
  }
  document.getElementById(label).innerHTML = imgSlide;
}