var ie = ( (navigator.appName.substr(0,27) == "Microsoft Internet Explorer") );
var ns = ( !ie );

// verifica se o site completo foi carregado
// if (location.href.indexOf("www.aumbandan.ig.hpg.com.br") == -1) {
//   top.location="http://www.aumbandan.ig.hpg.com.br";
// }


function abrecentral() {
  wincentral = window.open('http://www.acentralbs.hpg.com.br','central') ;
  wincentral.focus();
}

function vhr(obj, alt, larg) {

  if (obj ==null) return false;
  if (larg==null) larg=100;
  if (alt ==null) alt =100;

  if (ie) {
    layerheight = obj.style.height;
    layerwidth  = obj.style.width;
  } else {
    layerheight = alt;
    layerwidth  = larg;
  }

  layerheight = parseInt(layerheight);
  layerheight = unescape(layerheight);
  layerwidth  = parseInt(layerwidth);
  layerwidth  = unescape(layerwidth);

  // Altura
//  if (ie) { 
//    obj.style.top = ((document.body.scrollTop + document.body.clientHeight)-layerheight)-42;
//  } else { 
//    obj.top = ((pageYOffset+innerHeight) - larg);
//  }

  // Largura
  if (ie) { 
    obj.style.left = ((document.body.scrollLeft + document.body.clientWidth)-layerwidth);
  } else { 
    obj.left = ((pageXOffset + innerWidth) - alt);
  }

}

function vhrb(obj, alt, larg) {

  if (obj ==null) return false;
  if (larg==null) larg=100;
  if (alt ==null) alt =100;

  if (ie) {
    layerheight = obj.style.height;
    layerwidth  = obj.style.width;
  } else {
    layerheight = alt;
    layerwidth  = larg;
  }

  layerheight = parseInt(layerheight);
  layerheight = unescape(layerheight);
  layerwidth  = parseInt(layerwidth);
  layerwidth  = unescape(layerwidth);

  // Altura
  if (ie) { 
    obj.style.top = ((document.body.scrollTop + document.body.clientHeight)-layerheight)-42;
  } else { 
    obj.top = ((pageYOffset+innerHeight) - larg);
  }

  // Largura
  if (ie) { 
    obj.style.left = ((document.body.scrollLeft + document.body.clientWidth)-layerwidth);
  } else { 
    obj.left = ((pageXOffset + innerWidth) - alt);
  }

}

// Verifica a validade de data (com ano bissexto)
// Uso: 
//   if (!dataok(document.forms[0].nascimento) ) {
//       return false;
//   }
function dataok(dataObj) {

  temp = new String(dataObj.value);

  dia = temp.substring(0,2);
  if ((dia>31) || (dia<1)) {
    alert("Dia inválido !");
    return false;
  }

  if (temp.indexOf("/") == -1) {
    var mes = temp.substring(2,4);
    var ano = temp.substring(4,8);
  } else {
    var mes = temp.substring(3,5);
    var ano = temp.substring(6,10);
  }

  if ((mes>12) || (mes<1)) {
    alert("Mês inválido !");
    return false;
  }

  if ( (mes==4) || (mes==6) || (mes==9) || (mes==11) ) {
    if (dia>30) {
      alert("Dia inválido para este mês !");
      return false;
    }
  }

  if (mes==2) {
    // extrai módulo
    ano = parseInt(ano);
    ano = unescape(ano);
    divinteiro = Math.floor(ano/4);
    divisao    = (ano/4);
    resto = (divisao-divinteiro);

    if (resto>0) { // Não é ano bissexto
      if (dia>28) {
        alert("Neste ano fevereiro tem 28 dias !");
        return false;
      } else {
        if (dia>29) {
          alert("Fevereiro não pode ter mais que 29 dias !");
          return false;
        }
      }
    }
  }
  return true;
}


// Verifica a validade de hora
// Uso: 
//   if (!horaok(document.forms[0].horario) ) {
//       return false;
//   }

function horaok(horaObj) {

  temp = new String(horaObj.value);

  hora = temp.substring(0,2);
  if ((hora>23) || (hora<0)) {
    alert("Hora inválida !");
    return false;
  }

  if (temp.indexOf(":") == -1) {
    var minuto  = temp.substring(2,4);
    var segundo = temp.substring(4,6);
  } else {
    var minuto  = temp.substring(3,5);
    var segundo = temp.substring(6,8);
  }

  if ((minuto>59) || (minuto<0)) {
    alert("Minuto inválido !");
    return false;
  }

  if ((segundo>59) || (segundo<0)) {
    alert("Segundo inválido !");
    return false;
  }

  return true;
}

function escrevedata() {
   var now = new Date();
   var yr = now.getYear();
   var mName = now.getMonth() + 1;
   var dName = now.getDay() + 1;
   var dayNr = ((now.getDate()<10) ? "0" : "")+ now.getDate();
   var ampm = (now.getHours() >= 12) ? " pm" : " am"
   var hours = now.getHours();

   hours = ((hours > 12) ? hours - 12 : hours);

   var minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();
   var seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds();

   if(dName==1) Day = "Domingo";
   if(dName==2) Day = "Segunda-feira";
   if(dName==3) Day = "Terça-feira";
   if(dName==4) Day = "Quarta-feira";
   if(dName==5) Day = "Quinta-feira";
   if(dName==6) Day = "Sexta-feira";
   if(dName==7) Day = "Sábado";

   if(mName==1) Month="janeiro";
   if(mName==2) Month="fevereiro";
   if(mName==3) Month="março";
   if(mName==4) Month="abril";
   if(mName==5) Month="maio";
   if(mName==6) Month="junho";
   if(mName==7) Month="julho";
   if(mName==8) Month="agosto";
   if(mName==9) Month="setembro";
   if(mName==10) Month="outubro";
   if(mName==11) Month="novembro";
   if(mName==12) Month="dezembro";

   var DayDateTime=( Day
       + ", "
       + dayNr
       + " de "
       + Month
       + " de "
       + ""
       + yr
       + "." );
  document.writeln( DayDateTime );
  return true;
}


// Bloqueia a visualização do código fonte
function right(e) {
 var msg = "Criação:         A CENTRAL - Bureau de Serviços Ltda.\n\n";
     msg+= "Colaboração: médium Lúcio Moreira Fortes Filho\n";
     msg+= "                      médium Odilon Moraes\n\n";
     msg+= "Design:          André L. Fittipaldi\n\n";
     msg+= "www.umbandacomamor.kit.net - umbandan@bol.com.br";
//     msg+= "   www.umbandacomamor.kit.net\n";
//     msg+= "         umbandan@bol.com.br\n\n";
 if ( (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)) ||
      (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) ) {

// if ( confirm("Gostaria de ver nossa página de créditos?") ) abrecreditos();
   alert(msg);
   return false;
 }
 return false;
}
//document.onmousedown=right;
//if (document.layers) window.captureEvents(Event.MOUSEDOWN);
//window.onmousedown=right;

// document.onmousemove=cursortogether;
// if (document.layers) window.captureEvents(Event.MOUSEMOVE);
// window.onmousemove =cursortogether;

// document.onmousemove=cursortogether( 'cursormoving' )
// if (document.layers) window.captureEvents(Event.MOUSEMOVE);
// window.onmousemove =cursortogether( 'cursormoving' )

function cursortogether(e) {

  if (document.all)  obj = document.all.cursormoving;
  else               obj = document.layers.cursormoving;

  var mouseX = (ns)?objNS.pageX : event.clientX + document.body.scrollLeft;
  var mouseY = (ns)?objNS.pageY : event.clientY + document.body.scrollTop;
  obj.style.top  = mouseY+18;
  obj.style.left = mouseX+3;
}


window.onerror=null;

var menuskin = "skin1"; // skin0, or skin1
var display_url = 0; // Show URLs in status bar?
function showmenuie5() {
  var rightedge  = document.body.clientWidth-event.clientX;
  var bottomedge = document.body.clientHeight-event.clientY;
  if (rightedge < ie5menu.offsetWidth) ie5menu.style.left = document.body.scrollLeft + event.clientX - ie5menu.offsetWidth;
  else                                 ie5menu.style.left = document.body.scrollLeft + event.clientX;
  if (bottomedge < ie5menu.offsetHeight) ie5menu.style.top = document.body.scrollTop + event.clientY - ie5menu.offsetHeight;
  else                                   ie5menu.style.top = document.body.scrollTop + event.clientY;
  ie5menu.style.visibility = "visible";
  return false;
}
function hidemenuie5() {
  ie5menu.style.visibility = "hidden";
}
function highlightie5() {
  if (event.srcElement.className == "menuitems") {
    event.srcElement.style.backgroundColor = "highlight";
    event.srcElement.style.color = "white";
    if (display_url) window.status = event.srcElement.url;
   }
}
function lowlightie5() {
  if (event.srcElement.className == "menuitems") {
    event.srcElement.style.backgroundColor = "";
    event.srcElement.style.color = "black";
    window.status = "";
   }
}
function jumptoie5() {
  if (event.srcElement.className == "menuitems") {
    if (event.srcElement.getAttribute("target") != null)
      window.open(event.srcElement.url, event.srcElement.getAttribute("target"));
    else
      window.location = event.srcElement.url;
   }
}

function enviapagina( novolocal ) {
  doclocal = location.hostname;
  if ( doclocal == "" ) doclocal = document.location;
//  alert( doclocal );
  msgemail = "mailto:\?subject\=Veja este site que encontrei sobre terapia familiar.&body=Visite este site. É muito bom! O endereço é "+doclocal;
  window.location = msgemail;
}

function direitos() {
  endereco = location.hostname;  // vai informar www.endereco.com.br
  if ( endereco != "" ) endereco = "http://" + endereco + "/";

  document.write( "<hr size=1>" );
  document.write( "<table align=center cellpading=0 cellspacing=3>" );
//  document.write( "</td><td>" );
//  document.write("<tr><td rowspan='2'><img src='http://www.aumbandan.hpg.com.br/images/mundo.gif'></td><td><p class='center'><font face='verdana,arial,helvetica' size='-2' color='Gray'><a href='" + endereco + "' onmouseover='javascript:window.status=" + '"Visite nosso site"' + "; return true' onmouseout ='javascript:window.status=" + '""' + "; return true'>©2002 - <b>A Umbanda.com.amor</b> - Todos os direitos reservados</a></font></p></td></tr>" );
  document.write("<tr><td><p class='center'><font face='verdana,arial,helvetica' size='-2' color='Gray'><a href='" + endereco + "' onmouseover='javascript:window.status=" + '"Visite nosso site"' + "; return true' onmouseout ='javascript:window.status=" + '""' + "; return true'>©2003 - <b>APrTF - Associação Paranaense de Terapia Familiar</b> - Todos os direitos reservados</a></font></p></td></tr>" );
//  document.write( "<p>&nbsp;</p>" );
//  document.write( "<p class='center'><font face='verdana,arial,helvetica' size='-2' color='Gray'><a href='" + endereco + "' onmouseover='javascript:window.status=" + '"Visite nosso site"' + "; return true' onmouseout ='javascript:window.status=" + '""' + "; return true'>©2002 - <b>A Umbanda.com.amor</b> - Todos os direitos reservados</a></font></p>" );
  document.write( "<tr><td><p class='center'><font face='verdana,arial,helvetica' size='-2' color='Gray'><a href='mailto:aprtf@ig.com.br'  onmouseover='javascript:window.status=" + '"Converse conosco"' + "; return true'  onmouseout ='javascript:window.status=" + '""' + "; return true'>Converse conosco.</a></font></p></td></tr>" );
//  document.write( "<p>&nbsp;</p>" );
//  document.write( "</td></tr>" );
  document.write( "</table>" );

}

// controla o menu com o botão direito do mouse
// vê qual é o endereço onde está a página...
endereco = location.hostname;  // vai informar www.endereco.com.br
if ( endereco != "" ) endereco = "http://" + endereco + "/main.html";
document.write( '<style>\n' );
document.write( '.skin0 { z-index:0; position:absolute; text-align:left; width:200px; border:2px solid black; background-color:menu; font-family:Verdana; line-height:20px; cursor:default; visibility:hidden; }\n');
document.write( '.skin1 { cursor:default; font:menutext; position:absolute; text-align:left; font-family: Arial, Helvetica, sans-serif; font-size: 9pt; width:112px; background-color:menu; border:1 solid buttonface; visibility:hidden; border:2 outset buttonhighlight;}\n');
document.write( '.menuitems { padding-left:5px; padding-right:5px; }\n');
document.write( '</style>\n');
document.write( '<div id="ie5menu" class="skin0" onMouseover="highlightie5()" onMouseout="lowlightie5()" onClick="jumptoie5();">\n');
document.write( '  <div class="center">MENU</div>\n');
document.write( '  <hr>\n');
document.write( '  <div class="menuitems" url="javascript:history.back();">Voltar</div>\n');
document.write( '  <div class="menuitems" url="javascript:document.location.reload();">Reler a página</div>\n');
if ( endereco != "" ) document.write( '  <div class="menuitems" url="'+endereco+'" target="main">Página Principal</div>\n');
document.write( '  <div class="menuitems" url="javascript:print();">Imprimir página</div>\n');
document.write( '  <hr>\n');
document.write( '  <div class="menuitems" url="mailto:aprtf@ig.com.br">Entrar em contato</div>\n');
document.write( '  <div class="menuitems" url=javascript:enviapagina()>Indicar este site</div>\n');
document.write( '  <hr>\n');
document.write( '  <div class="menuitems" url="javascript:abrecentral()">Construtor</div>\n');
document.write( '</div>\n');
document.write( '<scr' + 'ipt language="JavaScript1.2">\n');
document.write( 'if (document.all && window.print) {\n');
document.write( 'ie5menu.className = menuskin;\n');

// verifica onde está para saber o que faz...
tempendereco = location.href;
// (tempendereco.indexOf("/menu.html") > 0) ||
if ( (tempendereco.indexOf("/nota.html") > 0) ) {
  document.write( 'document.onmousedown=right;\n');
} else {
  document.write( 'document.oncontextmenu = showmenuie5;\n');
  document.write( 'document.body.onclick = hidemenuie5;\n');
}
document.write( '}\n');
document.write( '</scr' + 'ipt>\n');

// this.focus();















/*** <config> ***/ 
startColor = "#000000"; // MouseOut link color 
endColor = "#ffffff";   // MouseOver link color 

stepIn = 20;  // delay when fading in 
stepOut = 20; // delay when fading out 

/* 
** set to true or false; true will 
** cause all links to fade automatically 
***/ 
autoFade = true; 
/* 
** set to true or false; true will cause all CSS 
** classes with "fade" in them to fade onmouseover 
***/ 
sloppyClass = true; 
/*** </config>  ***/ 

hexa = new makearray(16); 
for(var i = 0; i < 10; i++) 
hexa[i] = i; 
hexa[10]="a"; hexa[11]="b"; hexa[12]="c"; 
hexa[13]="d"; hexa[14]="e"; hexa[15]="f"; 

document.onmouseover = domouseover; 
document.onmouseout = domouseout; 

startColor = dehexize(startColor.toLowerCase()); 
endColor = dehexize(endColor.toLowerCase()); 

var fadeId = new Array(); 

function dehexize(Color){ 
var colorArr = new makearray(3); 
for (i=1; i<7; i++){ 
for (j=0; j<16; j++){ 
if (Color.charAt(i) == hexa[j]){ 
if (i%2 !=0) 
colorArr[Math.floor((i-1)/2)]=eval(j)*16; 
else 
colorArr[Math.floor((i-1)/2)]+=eval(j); 
} 
} 
} 
return colorArr; 
} 

function domouseover() { 
if(document.all){ 
  var srcElement = event.srcElement; 
  if ((srcElement.tagName == "A" && autoFade) || srcElement.className == "fade" || (sloppyClass && srcElement.className.indexOf("fade") != -1)) 
    fade(startColor,endColor,srcElement.uniqueID,stepIn); 
  } 
} 

function domouseout() { 
if (document.all){ 
var srcElement = event.srcElement; 
if ((srcElement.tagName == "A" && autoFade) || srcElement.className == "fade" || (sloppyClass && srcElement.className.indexOf("fade") != -1)) 
fade(endColor,startColor,srcElement.uniqueID,stepOut); 
} 
} 

function makearray(n) { 
this.length = n; 
for(var i = 1; i <= n; i++) 
this[i] = 0; 
return this; 
} 

function hex(i) { 
if (i < 0) 
return "00"; 
else if (i > 255) 
return "ff"; 
else 
return "" + hexa[Math.floor(i/16)] + hexa[i%16];} 

function setColor(r, g, b, element) { 
var hr = hex(r); var hg = hex(g); var hb = hex(b); 
element.style.color = "#"+hr+hg+hb; 
} 

function fade(s,e, element,step){ 
var sr = s[0]; var sg = s[1]; var sb = s[2]; 
var er = e[0]; var eg = e[1]; var eb = e[2]; 

if (fadeId[0] != null && fade[0] != element){ 
setColor(sr,sg,sb,eval(fadeId[0])); 
var i = 1; 
while(i < fadeId.length){ 
clearTimeout(fadeId[i]); 
i++; 
} 
} 

for(var i = 0; i <= step; i++) { 
fadeId[i+1] = setTimeout("setColor(Math.floor(" +sr+ " *(( " +step+ " - " +i+ " )/ " +step+ " ) + " +er+ " * (" +i+ "/" + 
step+ ")),Math.floor(" +sg+ " * (( " +step+ " - " +i+ " )/ " +step+ " ) + " +eg+ " * (" +i+ "/" +step+ 
")),Math.floor(" +sb+ " * ((" +step+ "-" +i+ ")/" +step+ ") + " +eb+ " * (" +i+ "/" +step+ ")),"+element+");",i*step); 
} 
fadeId[0] = element; 
}