img_janela_off = new Image();
img_janela_off.src = "../../images/janela1.gif";

img_janela_on = new Image();
img_janela_on.src = "../../images/janela2.gif";


	ponto_off = new Image();
	ponto_off.src = "images/ponto_off.gif";
	ponto_on = new Image();
	ponto_on.src = "images/ponto_on.gif";

// ---------------------------------------------

function Ativa(name){
  if (document.all) document.images[name].src = eval("ponto_on.src");
  if (document.layers) document.layers["content"].document.images[name].src = eval("ponto_on.src");
}

function Desativa(name){
  if (document.all) document.images[name].src = eval("ponto_off.src");
  if (document.layers) document.layers["content"].document.images[name].src = eval("ponto_off.src");
}

// ---------------------------------------------


function troca(a,b){
if (document.all){
  document.images[b].src=eval("img_" + a + "_on.src")
}
if (document.layers){
  document.layers["navega"].document.images[b].src=eval("img_" + a + "_on.src")
}
}

function destroca(a,b){
if (document.all){
  document.images[b].src=eval("img_" + a+ "_off.src")
}
if (document.layers){
  document.layers["navega"].document.images[b].src=eval("img_" + a + "_off.src")
}
}

// ---------------------------------------------

function submete(esse) {



if (document.layers)
ofo = document.layers["content"].document.forms[0]

if (document.all)
ofo = document.forms[0]

if (esse.selectedIndex != 0) {

	valor = esse.options[esse.selectedIndex].value
	pos = valor.indexOf(",")

	ofo.item.value = valor.substring(0,pos)

	ofo.sub.value = valor.substring(pos+1, valor.length)
	ofo.submit()
}
}

// ---------------------------------------------

onload = loop
acre = 0
bot = 238
tot = 0
topog = 96

function loop() {

topog = topog - acre
bot= bot + acre
tot = tot + acre

  if (topog > 96) {
    topog=96
    bot=238
    tot=0
  }

  if (topog < 96 - (vari - 238)) {
    topog=96 - (vari - 238)
    bot=vari
    tot=vari - 238
  }

  if (document.layers) {
    layer = document.layers["navega"]
    layer.visibility = "show" 
    layer.top = topog
    layer.clip.left   = 0;
    layer.clip.top    = tot;
    layer.clip.right  = 170;
    layer.clip.bottom = bot;
  }
  if (document.all) {
    layer = document.all.navega.style
    layer.visibility = "visible"
    layer.posTop = topog
    layer.clip = 'rect(' + tot + ' ' +  170 + ' ' + bot + ' ' + 0 +')';
  }
  setTimeout("loop()",75)
}







//------------------------ sub funcoes do validator ----------------

var verf=0;
var nform=0;
var ofo;

function caixa(){
var campo = caixa.arguments

for(j=0; j<campo.length; j=j+1){
  if (ofo.elements[campo[j]].value == "")
  {
    ofo.elements[campo[j]].focus();
    alert("É preciso preencher o campo '" + ofo.elements[campo[j]].name + "'.");
    verf = 1;
    break;
  }}
 }

function combo(){
var campo = combo.arguments

 for(j=0; j<campo.length; j=j+1){
  if (ofo.elements[campo[j]].selectedIndex == 0)
  {
    ofo.elements[campo[j]].focus();
    alert("É preciso selecionar um item neste campo.");
    verf = 1;
    break;
  }
 }
}


function radio(){
var campo = radio.arguments


 for(j=0; j<campo.length; j++){
  teste=0

  for (i=0; i<eval('document.forms[' + nform + '].' + campo[j] + '.length'); i++)
  if (eval('document.forms[' + nform + '].' + campo[j] + '[' + i + '].checked')) teste = 1

  if (teste == 0) 
  {
    //ofo.elements[campo[j]].focus();
    alert("É preciso sempre selecionar uma das alternativas.");
    verf = 1;
    break;
  }

 }
}





function caracteres(){
var campo = caracteres.arguments

for(j=0; j<campo.length; j=j+2)
   {
        var pureza = campo[j+1];
        var checkStr = ofo.elements[campo[j]].value;
        var allValid = true;
        for (i = 0;  i < checkStr.length;  i++)
            {
            ch = checkStr.charAt(i);
               for (v = 0;  v < pureza.length;  v++)
               if (ch == pureza.charAt(v)) break;
           if (v == pureza.length)
              {
              allValid = false;
              break;
              }
            }
        if (!allValid)
            { 
              ofo.elements[campo[j]].focus();
              alert('Este campo não foi preenchido corretamente');
              verf = 1;
              break;
            }

     }
}



function car_pos(a,b){

         if (ofo.elements[a].value != "" && (ofo.elements[a].value.charAt(2) != b || ofo.elements[a].value.charAt(5) != b ))
            { 
              ofo.elements[a].focus();
              alert("A data não está no formato correto'");
              verf = 1;           
            }


}

function comprimento(){
var campo = comprimento.arguments

for(j=0; j<campo.length; j=j+3)
   {

         if (ofo.elements[campo[j]].value != "" && (ofo.elements[campo[j]].value.length < campo[j+1] ||ofo.elements[campo[j]].value.length >= campo[j+2]))
            { 
              ofo.elements[campo[j]].focus();
              alert('Este campo não foi preenchido corretamente');
              verf = 1;
              break;            
            }

   }
}


function email(){
var campo = email.arguments


for(j=0; j<campo.length; j=j+1)
   {

    if (ofo.elements[campo[j]].value != ""){

         if (ofo.elements[campo[j]].value.indexOf("@") == -1 || ofo.elements[campo[j]].value.indexOf("@") == ofo.elements[campo[j]].value.length - 1 || ofo.elements[campo[j]].value.indexOf("@") == 0 ||
             ofo.elements[campo[j]].value.indexOf(".") == -1 || ofo.elements[campo[j]].value.indexOf(".") == ofo.elements[campo[j]].value.length - 1 || ofo.elements[campo[j]].value.indexOf(".") == 0 ||
             ofo.elements[campo[j]].value.length < 6 || ofo.elements[campo[j]].value.indexOf(",") != -1)
             {
              alert("Seu e-mail não é válido");
              ofo.elements[campo[j]].focus()
              verf = 1;
              break; 
             }
       }


   }
}

