var d=document;
 
var running=false;
var th=new Array();
var xId=null;
var nmax=1;
var xi=0;
function stopRotate(el){running=false;clearTimeout ( xId );el.src=th[0];}
 
function getElemByID(id){
    return d.getElementById?d.getElementById(id):(d.all?d.all[id]:(d.layers?d.layers[id]:null));
}
function setThumbs(turl,a){
th=new Array();
xs=turl.split(".jpg");
td=xs[0];
 th[0]=turl;
for (i=1;i<=a;i++)
 th[i]=td+"_"+i+".jpg";
 //alert(th);
}
function dog(idStr){
  el=getElemByID(idStr);
  if (xi<nmax)
   xi++;
  else xi=1;
  imageObj = new Image();
  imageObj.src=th[xi];
  nTURL=imageObj.src;
  if (running){el.src=nTURL;
  exprStr="dog('"+idStr+"');";
  xId=setTimeout ( exprStr, 500);
  }
}
function rotate(el,a){
running=true;
thumbURL=el.src;
setThumbs(thumbURL,a);
nmax=a;
dog(el.id);
}

