// JavaScript Document

function turnOn(lay){
	turnOff();
	lay.style.display='block'
}

function turnOff(){
	col = document.all.tags("TR");
	for (x = 0; x < col.length; x++)		
		if (col[x].id.indexOf("tab") > -1)
			col[x].style.display='none';
}

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 MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_showHideLayers() { //v3.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
obj.visibility=v; }
}

function displayHide(){
	var i,p,v,obj,args=displayHide.arguments;
	for (i=0; i<(args.length-2); i+=3) 
	if ((obj=MM_findObj(args[i]))!=null) { 
		v=args[i+2];    				
		obj.style.display=v; 
		if (v == 'block'){
			obj.innerHTML = legendas[args[i+1]];		
		}
	}
}

function displayLegenda(indice){
	legenda.innerHTML = legendas[indice];				
}

function FrontPage_Form1_Validator(theForm)
{
if (theForm.cliente.value == "")
  {
    alert("Digite o nome do cliente no campo \"Cliente\".");
    theForm.cliente.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789- \t\r\n\f";
  var checkStr = theForm.cliente.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Digite o nome do cliente corretamente no campo \"Cliente\".");
    theForm.cliente.focus();
    return (false);
  }
  if (theForm.email.value == "")
  {
    alert("Digite um email no campo \"E-mail\".");
    theForm.email.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789-@._\t\r\n\f";
  var checkStr = theForm.email.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Digite o email corretamente no campo \"E-mail\".");
    theForm.email.focus();
    return (false);
  }

  if (theForm.idade.value == "")
  {
    alert("Digite a idade do cliente no campo \"Idade\".");
    theForm.idade.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789-@._ \t\r\n\f";

  var checkStr = theForm.idade.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Digite somente sua idade para o campo\"Idade\".");
    theForm.idade.focus();
    return (false);
  }

    
  if (theForm.telefone.value == "")
  {
    alert("Digite um telefone no campo \"Telefone\".");
    theForm.telefone.focus();
    return (false);
  }

  var checkOK = "()-0123456789,xxXX \t\r\n\f";
  var checkStr = theForm.telefone.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Digite corretamente o Telefone no campo \"Telefone\".");
    theForm.telefone.focus();
    return (false);
  }
  
if (theForm.dia.value == "")
  {
    alert("Digite o dia de sua preferência no campo \"Dia\".");
    theForm.dia.focus();
    return (false);
  }

  var checkOK = "0123456789\t\r\n\f";
  var checkStr = theForm.dia.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Digite somente números no campo \"Dia\".");
    theForm.dia.focus();
    return (false);
  }


if (theForm.horario.value == "")
  {
    alert("Digite o horário da consula no campo \"Horário\".");
    theForm.horario.focus();
    return (false);
  }

  var checkOK = "horasHORAS0123456789:.- \t\r\n\f";
  var checkStr = theForm.horario.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Digite o horário correto no campo \"Horário\".");
    theForm.horario.focus();
    return (false);
  }
}

function getFotoA() {
  // Create the arrays
  fotoA = new Array(4);

  fotoA[0] = "images/fotos/exame.jpg";
  fotoA[1] = "images/fotos/letreiro.jpg";
  fotoA[2] = "images/fotos/predio.jpg";
  fotoA[3] = "images/fotos/recepcao.jpg";
  fotoA[4] = "images/fotos/atendimento.jpg";
       
  // Escolha aleatória do 1º banner
  fotoNumA = Math.floor(Math.random() * fotoA.length);

  document.write('<IMG NAME="fotoA" SRC="' + fotoA[fotoNumA] + '">');
  window.setTimeout('rotateFotoA();', 5000);
}

function rotateFotoA() {
  if (++fotoNumA > 4)
    fotoNumA = 0;
    document.images["fotoA"].src = fotoA[fotoNumA];
    window.setTimeout('rotateFotoA();', 5000);  
}

function getFotoB() {
  // Create the arrays
  fotoB = new Array(4);

  fotoB[0] = "images/fotos/exame.jpg";
  fotoB[1] = "images/fotos/letreiro.jpg";
  fotoB[2] = "images/fotos/predio.jpg";
  fotoB[3] = "images/fotos/recepcao.jpg";
  fotoB[4] = "images/fotos/atendimento.jpg";
       
  // Escolha aleatória do 1º banner
  fotoNumB = Math.floor(Math.random() * fotoB.length);

  document.write('<IMG NAME="fotoB" SRC="' + fotoB[fotoNumB] + '">');
  window.setTimeout('rotateFotoB();', 5000);
}

function rotateFotoB() {
  if (--fotoNumB < 0)
    fotoNumB = 4;
    document.images["fotoB"].src = fotoB[fotoNumB];
    window.setTimeout('rotateFotoB();', 5000);  
}
