var timerID = 0;
var n = 0;
var m = 0;
var t = 0;
var imgfile='';
var playing = false;

function showest() {
     imgfile=imgp+n+'-'+m+'.jpg';
     document.getElementById('pil'+n).src=imgfile;
     //document.title=imgfile;
}

function player() {
   if (m>=t) {m=1;} else {m=m+1;}
   showest();
   tiempo=500;
   if(timerID) {
      clearTimeout(timerID);
   }
   timerID = setTimeout("player()", tiempo);
}

function Start(p,pt) {
  if (!playing){
  	n=p;
	m=1;
	t=pt;
	showest();
	timerID  = setTimeout("player()", 500);
	playing=true;
   } else {
	if(timerID) {
		clearTimeout(timerID);
		timerID  = 0;
	}
	playing=false;
   }
}

function Stop(f){
   m=f;
   showest();
   if(timerID) {
      clearTimeout(timerID);
      timerID  = 0;
   }
   playing=false;
}

