
function preLoad(carpeta,total) {
  fotos = new Array;
  for (i=1;i<=total;i++) {
    fotos[i] = new Image;
	fotos[i].src = 'imagenes/'+carpeta+'/foto-'+i+'.jpg';
  }
  return fotos;
}

function myfindObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function actualizaBotones(carpeta,actual,total) {
  av = myfindObj(carpeta+'_bot_avanza');
  re = myfindObj(carpeta+'_bot_retrocede');

  avsrc = '../../imagenes/arrow-right.gif';
  resrc = '../../imagenes/arrow-left.gif';

  if (actual<=1) {
    resrc = '../../imagenes/5x5.gif';
  }
  if (actual>=total) {
    avsrc = '../../imagenes/5x5.gif';
  }

  av.src = avsrc;
  re.src = resrc;
}

function LimpiaFoto(carpeta) {
  fo = myfindObj(carpeta);
  fo.src = 'imagenes/5x5.gif';
}

function actualizaFoto(carpeta,newactual,total) {
  fo = myfindObj(carpeta);
  fo.src = 'imagenes/5x5.gif';
 if (newactual<1) {
    newactual++;
	actual = newactual;
  } else if (newactual>total) {
    newactual--;
	actual = newactual;
  } else {
//    fo.src = fotos[newactual].src;
    fo.src = 'imagenes/'+carpeta+'/foto-'+newactual+'.jpg';
//	alert('imagenes/'+carpeta+'/foto-'+newactual+'.jpg');
  } 
  actualizaBotones(carpeta,newactual,total);
}

function actualizaFoto1(carpeta,newactual,total) {
  fo = myfindObj(carpeta);
  if (newactual<1) {
    newactual++;
	actual = newactual;
  } else if (newactual>total) {
    newactual--;
	actual = newactual;
  } else {
//    fo.src = fotos[newactual].src;
    fo.src = 'imagenes/'+carpeta+'/foto-'+newactual+'.jpg';
//	alert('imagenes/'+carpeta+'/foto-'+newactual+'.jpg');
  } 
  actualizaBotones(carpeta,newactual,total);
  document.fotos.texto.value=textos[newactual];
}