//
// ************************
// layer utility routines *
// ************************

// modificado por m.a. rojas. d. - junio 2006.
// en las weas que gasto mi tiempo.


function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
        // W3C DOM
        return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
        // MSIE 4 DOM
        return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
        // NN 4 DOM.. note: this won't find nested layers
        return document.layers[objectId];
    } else {
        return false;
    }
}



function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
        styleObject.visibility = newVisibility;
        return true;
    } else {
        // we couldn't find the object, so we can't change its visibility
        return false;
    }
}




function toggleObjectVisibility(objectId) {
  var styleObject = getStyleObject(objectId);
  if (styleObject) {
    if (styleObject.visibility=='visible') {
      styleObject.visibility = 'hidden';
      return true;
    }
    if (styleObject.visibility=='hidden') {
      styleObject.visibility = 'visible';
      return true;
    }
  } else {
    // we couldn't find the object, so we can't change its visibility
    return false;
  }
}



function moveObject(objectId, newXCoordinate, newYCoordinate) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
        styleObject.left = newXCoordinate;
        styleObject.top = newYCoordinate;
        return true;
    } else {
        // we couldn't find the object, so we can't very well move it
        return false;
    }
}






function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_changeProp(objName,x,theProp,theValue) { //v3.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+theValue+"'");
}

























function muestra(entrada) {                      // alias invariable para mostrar.
  changeObjectVisibility(entrada, 'visible');
}

function oculta(entrada) {                   // alias invariable para ocultar.
  changeObjectVisibility(entrada, 'hidden');
}


function muestra_solamente(entrada) {                      // alias invariable para mostrar.
  oculta('menu_individuo');
  changeObjectVisibility(entrada, 'visible');
}


function cambia(entrada) {                  // oculta el resto, y luego, togglea el elemento deseado.
  if (entrada!='menu_individuo') oculta('menu_individuo');

  toggleObjectVisibility(entrada);
}


function saca_menus() {
  oculta('menu_individuo');
}

function menu() {
  toggleObjectVisibility('menu_individuo');

  oculta('opc_cambia_IID');
  oculta('opc_lockear');
}






function validar (formulario) {
  if (formulario.nom.value.length <= 3) {
    formulario.nom.focus();
    return (false);
  }

  if (formulario.ape_pa.value.length <= 3) {
    formulario.ape_pa.focus();
    return (false);
  }

  if (formulario.ape_ma.value.length <= 3) {
    formulario.ape_ma.focus();
    return (false);
  }


  var checkOK = "0123456789";
  var checkStr = formulario.bir.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  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;
    }
    allNum += ch;
  }

  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (!allValid || (chkVal!="" && !(prsVal >= "1000" && prsVal <= "2007"))) {
    alert("Escriba un aņo valido en el nacimiento.");
    formulario.bir.focus();
    return (false);
  }

  return (true);
}




// era - i believe.