// Función para abrir ventana con webcam
function abrir_webcam(pringao){
  var vent = open('http://www.ciberaula.com/webcam.php?img='+pringao,'webcam','scrollbars=no,width=340,height=290');
  if (vent) vent.moveTo(300,100);
}

// Objeto Webcam

// Constructor
function Webcam(img, period) {
  this.period = period*1000;
//  this.period = period;
  this.imgName = img.name;
  this.imgSrc = img.src.substr(0,img.src.indexOf("?"));
  this.varname = "w_" + img.name.substr(img.name.indexOf("_")+1, 300);
  this.reload = imageReload;
  this.change = imageChange;
  this.onError = imageError;
  this.imgBuffer = new Image();
  this.imgBuffer.name = this.varname;
  this.imgBuffer.onload = this.change;
  this.imgBuffer.onerror = this.onError;
  setTimeout(this.varname + ".reload()", this.period);
}

function imageReload () {
  this.imgBuffer.src = this.imgSrc + "?d=" + new Date().getTime();
  setTimeout(this.varname + ".reload()", this.period);
}

function imageChange () {
  eval("imgName =" + this.name + ".imgName");
  eval("document." + imgName + ".src = this.src");
}

function imageError () {
  eval("imgName =" + this.name + ".imgName");
  setTimeout("document." + imgName + ".reload()", 1000);
}

window.onerror = null;