var ns4 = (document.layers)? true:false;
var ie4 = (document.all)? true:false;

function addEvent(elemento,nomevento,funcion,captura) {
  if (elemento.attachEvent) {
    elemento.attachEvent('on'+nomevento,funcion);
    return true;
  }
  else if (elemento.addEventListener) {
    elemento.addEventListener(nomevento,funcion,captura);
    return true;
  }
  else
    return false;
}

function Cambio_Clase(nested, Clase) {
  nested.className = Clase;
}

function WindowStatus(Descripcion){
  window.status = Descripcion;
  return true;
}

function AddWindowStatus(Descripcion){
  window.status = window.defaultStatus +' - '+ Descripcion;
  return true;
}

function PreloadImages() {
  for(var i=0; i < ArrayImages.length; i++) {
    var img = new Image();
    img.src = ArrayImages[i];
  }
}

function VerificarUnCampo(Campo, Condicion, Verifica, Mensaje) {
  if (Condicion=='==') {
    if (Campo.value==Verifica) {window.alert(Mensaje); Campo.focus(); return true;}
  }
  else {
    if (Condicion=='<>') {
      if (Campo.value!=Verifica) {window.alert(Mensaje); Campo.focus(); Campo.select(); return true;}
    }
  }
}

function VerificarEntero(Campo, Minimo, Maximo, Mensaje) {
  if (Minimo!=Maximo)
    var regEnteros = new RegExp("^(([-])?([0-9])+)$", "");
  else
    var regEnteros = new RegExp("^((([-])?([0-9])+)?)$", "");
  if (Campo.value.search(regEnteros)){
    window.alert(Mensaje); Campo.focus(); Campo.select(); return true;}
  if (Minimo!=Maximo) {
    if (Campo.value<Minimo) {
      window.alert(Mensaje + ' - Debe ser Mayor o igual a ' + Minimo);
      Campo.focus(); Campo.select(); return true;
    }
    if (Campo.value>Maximo) {
      window.alert(Mensaje + ' - Debe ser Menor o igual a ' + Maximo);
      Campo.focus(); Campo.select(); return true;
    }
  }
}

function VerificarReal(Campo, Minimo, Maximo, Mensaje) {
  var regReal = new RegExp("^(([-])?([0-9])+([<?echo substr(trim(9/2),1,1);?>]?[0-9]+)?)$", "");
  if (Campo.value.search(regReal)){
    window.alert(Mensaje); Campo.focus(); Campo.select(); return true;}
  if (Minimo!=Maximo) {
    if (Campo.value<Minimo) {
      window.alert(Mensaje + ' - Debe ser Mayor o igual a ' + Minimo);
      Campo.focus(); Campo.select(); return true;
    }
    if (Campo.value>Maximo) {
      window.alert(Mensaje + ' - Debe ser Menor o igual a ' + Maximo);
      Campo.focus(); Campo.select(); return true;
    }
  }
}

function VerificarRadio(Campo, Mensaje) {
  chequeado = false;
  ii = 0;
  while ((ii < Campo.length) && (!chequeado)) {if (Campo[ii].checked) chequeado = true; ii++;}
  if (!(chequeado)) {window.alert(Mensaje); Campo[0].focus(); return true;}
}

function VerificarEMail(Campo, Mensaje) {
  if (Campo.value!='')
    if (Campo.value.search (/^(\+)*\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
      {window.alert(Mensaje); Campo.focus(); Campo.select(); return true;}
}

function OpenSitio(Sitio,Nombre,SWidth,SHeight) {
  a= SWidth + 39;
  b= SHeight + 32;
  x = ((screen.availWidth-a)/2);
  y = ((screen.availHeight-b)/2);
  var choose=window.open(Sitio,Nombre,'top='+y+',left='+x+',width='+a+',height='+b+',scrollbars=yes,resizable=no,location=no,toolbar=no,menubar=no,titlebar=no,status=no');
  //choose.resizeTo(a,b);
  //choose.moveTo(x,y);
}