var ratio = .02;

function setZoom(img, dir, width, height, zIndex, delay, opac) 
{
  setTimeout(function() 
	{
    if (img.dir==dir) 
		{
      img.style.width=width;
      img.style.height=height;
      img.style.zIndex=zIndex;
      img.parentNode.parentNode.style.zIndex=zIndex;
			if (img.filters)
				img.filters.alpha.opacity = opac;
			else
				img.style.MozOpacity = (opac/100);
    }
  }, delay);
}

function larger(img, width, height) 
{
  img.dir = 'rtl';
  now = parseInt(img.style.zIndex);
	o_inc = (100-60)/10;
  for (i=now+1; i<=10; i++) 
	{
		w = (width*(1+(ratio*i)))+'px';
    h = (height*(1+(ratio*i)))+'px';
		o = (i*o_inc) + 70;
    setZoom(img, 'rtl', w, h, i, 20*(i-now), o);	
  }
	
}

function smaller(img, width, height) 
{
  img.dir = 'ltr';
  now = parseInt(img.style.zIndex);
	o_inc = (100-60)/10;
  for (i=now-1; i>=0; i--) 
	{
		w = (width*(1+(ratio*i)))+'px';
    h = (height*(1+(ratio*i)))+'px';
 		o = (i*o_inc) + 60;
   setZoom(img, 'ltr', w, h, i, 20*(now-i), o);
  }
}
