ie=(document.all)?true:false;
ns=(document.layers)?true:false;

// funcion para abrir ventanas
function popUp(url,name,width,height,scrollbars,dependent,resizable){
  if(!dependent){
    dependent=false;
  }
  if(!resizable){
    resizable=true;
  }
  ventana=window.open(url,name,'width='+width+',height='+height+',scrollbars='+scrollbars+',left=0,top=0,dependent='+dependent+'resizable='+resizable);
}

function popUp2(url,name,width,height,scrollbars,dependent,resizable){
  if(!dependent){
    dependent=false;
  }
  if(!resizable){
    resizable=true;
  }
  ventana=window.open(url,name,'width='+width+',height='+height+',scrollbars='+scrollbars+',left=0,top=0,dependent='+dependent+'resizable='+resizable);
  
  return ventana;
}

// funcion para cambiar el color de fondo
function changeColor(where,color){
	where.style.cursor='hand';
	where.style.backgroundColor=color;
}

// funcion para validar una fecha
function check_date(fecha){
var checkstr = "0123456789";
var Datevalue = "";
var DateTemp = "";
var seperator = "/";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = fecha;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(2,2);
   month=month*1;
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(0,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
      return true;
   }
   /* Error-message if err != 0 */
   else {
      return false;
   }
}

function tabOnEnter2 (orden, evt) {
  var keyCode = document.layers ? evt.which : document.all ? evt.keyCode : evt.keyCode;
  
  if (keyCode != 13)
    return true;
  else {
    
    if(orden == 0) document.forms["f1"].ClaveAcceso_s.focus();
    if(orden == 1) document.forms["f1"].selopcion_s.focus();
    if(orden == 2) document.all.ir.focus();
    
    return false;
  }
}

netscape = "";
ver = navigator.appVersion; len = ver.length;
for(iln = 0; iln < len; iln++) if (ver.charAt(iln) == "(") break;
netscape = (ver.charAt(iln+1).toUpperCase() != "C");


/********************************************
/** codigo para usar el enter como tabulador 
/** copiar el siguiente codigo en la pagina 

nextfield = "box1"; // name of first box on page
*/

function keyDown(DnEvents) { // handles keypress
// determines whether Netscape or Internet Explorer
k = (netscape) ? DnEvents.which : window.event.keyCode;
if (k == 13) { // enter key pressed
if (nextfield == 'done') return true; // submit, we finished all fields
else { // we're not done yet, send focus to next box
eval('document.yourform.' + nextfield + '.focus()');
return false;
      }
   }
}
/*****
document.onkeydown = keyDown; // work together to analyze keystrokes
if (netscape) document.captureEvents(Event.KEYDOWN|Event.KEYUP);
*/

function showLayer(layer){
  if(ns){
    document.layers[layer].visibility="show";
  }else{
    document.all[layer].style.visibility="visible";  
  }
}
function hideLayer(layer){
  if(ns){
    document.layers[layer].visibility="hide";
    layerT="";
  }else{
    document.all[layer].style.visibility="hidden";
  }
}

layerTime=new Array;
timeDelay=300; //definir aqui el tiempo que tarda en cerrarse la capa

function showMenu(layer){
  if(layerTime[layer]){
    clearTimeout(layerTime[layer]);
    delete(layerTime[layer]);
  }
  showLayer(layer)
}

function hideMenu(layer){
  layerTime[layer]=setTimeout("hideLayer('"+layer+"')",timeDelay);
}

<!--
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_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_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 cambiaemail (info) {
 var res = "";
 for (var n = 0; n < info.length; n++)
 res += String.fromCharCode(info.charCodeAt(n));
 if (res.indexOf('@') < 0)
 res = res + '@' + 'joseazorrilla.es';
 location = "mail" + "to:" + res;
 }