<!--
    function select(anchor, message) {
        window.status = message;
        document.images[anchor].src = anchor + "_2.jpg";
        return true;
    }
    
    function deselect(anchor) {
        document.images[anchor].src = anchor + "_1.jpg";
        return false;
    }
//-->
var indTop = 1;///Indice control boton subir
<!--
    function selectgif(anchor, message) {
        window.status = message;
        document.images[anchor].src = anchor + "_2.gif";
        return true;
    }
    
    function deselectgif(anchor) {
        document.images[anchor].src = anchor + "_1.gif";
        return false;
    }
//-->

<!--
if(navigator.appName!='Netscape'&&parseInt(

navigator.appVersion)==4)document.write("<\!"+"--")

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];}
}

//-->

//CHECKFORM

//--------------------------------------------------------------------------------------------------------
// Language settings
//--------------------------------------------------------------------------------------------------------

var msgNumber  = "debe ser un numero";
var msgEMail   = "debe ser una direccion de e-mail";
var msgURL     = "debe ser una direccion web";
var msgDate    = "debe ser dd/mm/aaaa";
var msgFillOut = "Por favor completa el campo";
var msgNoForm  = "Formulario no existe";
var msgNoField = "Campo no existe";

//--------------------------------------------------------------------------------------------------------
// Functions
//--------------------------------------------------------------------------------------------------------

function _trim(str) {
  if(str) {
    str = str.replace(/^\s+/, "");
    str = str.replace(/\s+$/, "");
  }
  return str;
}

function _isDate(year, month, day) {
  month--;
  if(year < 100) year += 2000;
  var d = new Date(year, month, day);
  return ((day == d.getDate()) && (month == d.getMonth()) && (year == d.getFullYear()));
}

function checkForm() {
  var args = checkForm.arguments;
  var f = args[0];
  var msg = "";
  var arr, field, title, type, minLength, elem, val, cnt, i, j;
  var format, d, day, month, year;

  var valid_url = /^(https?|ftp):\/\/([a-z0-9._-]+:[a-z0-9._-]+@)?[a-z0-9äöüÄÖÜ#._\/~% -]+(\?([a-z0-9_-]+(=[a-zA-Z0-99äöüÄÖÜß+%?_-]+&?)?)*)?$/i;
  var valid_mail = /^[a-z0-9._-]+@[a-z0-9äöüÄÖÜ.-]+\.[a-z]{2,4}$/i;

  if(document.forms[f]) {
    for(i = 1; i < args.length; i++) {
      arr = args[i].split(":");
      field = _trim(arr[0]);
      title = _trim(arr[1]);
      if(!title) title = field;
      type = _trim(arr[2].toLowerCase());
      minLength = _trim(arr[3]);
      elem = document.forms[f].elements[field];

      if(elem) {
        val = _trim(elem.value);

        if(val != "") {
          if(type == "number") {
            val = val.replace(",", ".");
            if(isNaN(val)) msg += '"' + title + '" ' + msgNumber + "\n";
          }
          else if(type == "mail" && val.search(valid_mail) == -1) msg += '"' + title + '" ' + msgEMail + "\n";
          else if(type == "url" && val.search(valid_url) == -1) msg += '"' + title + '" ' + msgURL + "\n";
          else if(type.indexOf("date") != -1) {
            if(type.indexOf("(") != -1) format = type.substr(type.indexOf("("));
            else format = "(dmy)";
            d = val;

            for(j = 1; j < format.length - 1; j++) {
              cnt = d.search(/[^0-9]/);
              if(cnt == -1) cnt = d.length;

              switch(format.charAt(j)) {
                case "d": day = parseInt(d.substr(0, cnt)); d = d.substr(cnt + 1); break;
                case "m": month = parseInt(d.substr(0, cnt)); d = d.substr(cnt + 1); break;
                case "y": year = parseInt(d.substr(0, cnt)); d = d.substr(cnt + 1); break;
              }
            }
            if(!_isDate(year, month, day)) msg += '"' + title + '" ' + msgDate + "\n";
          }
        }

        if(minLength) {
          if(elem.length) {
            if(elem.options) {
              for(j = cnt = 0; j < elem.options.length; j++) {
                if(elem.options[j].selected && elem.options[j].value != "") cnt++;
              }
            }
            else for(j = cnt = 0; j < elem.length; j++) {
              if(elem[j].checked) cnt++;
            }
          }
          else if(elem.type == "checkbox") cnt = elem.checked ? 1 : 0;
          else cnt = val.length;
          if(cnt < minLength) msg += msgFillOut + ' "' + title + '"\n';
        }
      }
      else msg += msgNoField + ': "' + field + '"\n';
    }

    if(msg) alert(msg);
    else document.forms[f].submit();
  }
  else alert(msgNoForm + ': "' + f + '"');
}

//--------------------------------------------------------------------------------------------------------

function IsNumeric(valor) 
{ 
var log=valor.length; var sw="S"; 
for (x=0; x<log; x++) 
{ v1=valor.substr(x,1); 
v2 = parseInt(v1); 
//Compruebo si es un valor numérico 
if (isNaN(v2)) { sw= "N";} 
} 
if (sw=="S") {return true;} else {return false; } 
} 

var primerslap=false; 
var segundoslap=false; 
function formateafecha(fecha) 
{ 
var long = fecha.length; 
var dia; 
var mes; 
var ano; 

if ((long>=2) && (primerslap==false)) { dia=fecha.substr(0,2); 
if ((IsNumeric(dia)==true) && (dia<=31) && (dia!="00")) { fecha=fecha.substr(0,2)+"/"+fecha.substr(3,7); primerslap=true; } 
else { fecha=""; primerslap=false;} 
} 
else 
{ dia=fecha.substr(0,1); 
if (IsNumeric(dia)==false) 
{fecha="";} 
if ((long<=2) && (primerslap=true)) {fecha=fecha.substr(0,1); primerslap=false; } 
} 
if ((long>=5) && (segundoslap==false)) 
{ mes=fecha.substr(3,2); 
if ((IsNumeric(mes)==true) &&(mes<=12) && (mes!="00")) { fecha=fecha.substr(0,5)+"/"+fecha.substr(6,4); segundoslap=true; } 
else { fecha=fecha.substr(0,3);; segundoslap=false;} 
} 
else { if ((long<=5) && (segundoslap=true)) { fecha=fecha.substr(0,4); segundoslap=false; } } 
if (long>=7) 
{ ano=fecha.substr(6,4); 
if (IsNumeric(ano)==false) { fecha=fecha.substr(0,6); } 
else { if (long==10){ if ((ano==0) || (ano<1900) || (ano>2100)) { fecha=fecha.substr(0,6); } } } 
} 

if (long>=10) 
{ 
fecha=fecha.substr(0,10); 
dia=fecha.substr(0,2); 
mes=fecha.substr(3,2); 
ano=fecha.substr(6,4); 
// Año no viciesto y es febrero y el dia es mayor a 28 
if ( (ano%4 != 0) && (mes ==02) && (dia > 28) ) { fecha=fecha.substr(0,2)+"/"; } 
} 
return (fecha); 
} 

//Abrir Ventana

function abrir_ventana(mypage,myname,w,h,scroll,resize){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable='+resize+''
win = window.open(mypage,myname,settings);
win.focus();
}



//Imprimir Selección
function imprSelec(nombre)
{
var ficha = document.getElementById(nombre);
var ventimp = window.open(' ', 'popimpr');
ventimp.document.write( ficha.innerHTML );
ventimp.document.close();
ventimp.print( );
ventimp.close();
} 
