function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

// JavaScript Document
function abrir() { 
  window.open('digital/visor.html','Digital','scrollbars=auto,resizable=yes,width=900,height=700');
}
// AntiSpam
function mailnobot (nm, dm) {
	mailurl = "mailto:" + nm + "@" + dm + " ";
	window.location = mailurl;
}
// recargar pagina
function recargar() {
	window.location.reload();
}
// Ampliar foto ,ancho,alto
function ver(foto) { 
  window.open('../images/' + foto,'','scrollbars=no,resizable=no');
}

// ventana ampliar fotos ,width=' + ancho +',height=' + alto +'
function ampliar(codigo, ancho, alto) { 
  window.open('../comunes/ampliar.php?catalogoID=' + codigo,'','scrollbars=no,resizable=yes,menu=no,direction=no,width=' + ancho +',height=' + alto +'');
}

// AntiSpam
function mailnobot (nm, dm) {
	mailurl = "mailto:" + nm + "@" + dm + " ";
	window.location = mailurl;
}
// ventana respaldo
function respaldo() { 
  window.open('../admin/backup.php','','scrollbars=no,resizable=no,width=250,height=300');
}
// pop-up envio
function createTarget(t)
	{
	window.open("", t, "width=300,height=200");
	return true;
}
function news()
	{
	window.open('../comunes/newsletters.php','','scrollbars=no,resizable=yes,width=300,height=600');
}

// pagocondeposito()
function pagocondeposito() { 
  window.open('../comunes/depositos.php','','scrollbars=no,resizable=no,width=400,height=300');
}




// Validar TDC
function validarTarjeta(campo) {
  //Limpiamos el número de tarjeta  de posibles espacios en blanco...
  var expReg = /W/gi;
  var numero = campo.value.replace(expReg, "");

  //Chequeamos que el numero entrado tenga formato numérico...
  if (isNaN(numero)) {
    alert("El número de la tarjeta de crédito no tiene formato numérico.");
    campo.focus();
    return false;
  }

  //Chequeamos que el numero tenga 16 o 18 dígitos...
  if ((numero.length!=16) && (numero.length!=18)) {
     alert("El número de dígitos en la tarjeta de crédito es incorrecto.");
     campo.focus();
     return false;
  }

  var suma = 0;
  for (i = numero.length; i > 0; i--) {

    //Si la posición es impar
    if (i % 2 == 1) {
      var doble = "" + (parseInt(numero.substring(i - 1, i)) * 2);

      //Si el doble tiene más dos cifras (o sea es mayor que 9)
      if (doble.length == 2) {
         doble = parseInt(doble.substring(0,1)) + parseInt(doble.substring(1,2));
      }
      suma += parseInt(doble);
    }
    //Si la posición es par
    else {
      suma += parseInt(numero.substring(i - 1, i));
    }
  }

  //Si la suma total no es divisible por 10 entonces el número no es válido
  if (suma % 10 != 0) {
    alert("El número de la tarjeta de crédito no es válido.");
    campo.focus();
    return false;
  }

  //En cualquier otro caso el número es válido
  return true;
}

// No permitir seleccionar
function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE route
	target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
	target.style.MozUserSelect="none"
else //All other route (ie: Opera)
	target.onmousedown=function(){return false}
target.style.cursor = "default"
}
//Sample usages
//disableSelection(document.body) //Disable text selection on entire body
//disableSelection(document.getElementById("mydiv")) //Disable text selection on element with id="mydiv"


////////////////////////////////////////////////////////////

function comollegar() { 
  window.open('../images/comollegar.gif','','scrollbars=no,resizable=no');
}

function mostrar(nombreCapa){ 
document.getElementById(nombreCapa).style.visibility="visible"; 
} 
function ocultar(nombreCapa){ 
document.getElementById(nombreCapa).style.visibility="hidden"; 
} 

