function gallery(cont,storage,big,ac)
{
 var t=de(ac).parentNode.getElementsByTagName('img');
 var timer={timer:null};
 for(var i=0;i<t.length;i++)
 {
  if(t[i].id==ac)
  {
   de(cont).getElementsByTagName('img')[1].src=de(storage).getElementsByTagName('img')[i].src;
   de(cont).getElementsByTagName('a')[0].href=de(big).getElementsByTagName('img')[i].src;
  }
   
   t[i].onclick=function(i)
   {
    return function()
	{
	 if(this==de(ac))
	  return;
	 clearTimeout(timer.timer);
	 this.src='images/'+ac+'.png';
	 this.style.cursor='default';
	 de(ac).src='images/'+ac.substr(0,ac.length-1)+'.png';
     de(ac).style.cursor='pointer';
	 changePic(de(cont).getElementsByTagName('img'),de(storage).getElementsByTagName('img')[i].src,timer);
	 de(cont).getElementsByTagName('a')[0].href=de(big).getElementsByTagName('img')[i].src;
	 de(ac).id='';
	 this.id=ac;
	}
   }(i);
 }
   
}

function changePic(objs,src,timer)
{
 function steps(i)
 {
  objs[0].style.opacity=1-i/10;
  objs[0].style.filter='alpha(opacity='+(100-i/10)+')';
  objs[1].style.opacity=i/10;
  objs[1].style.filter='alpha(opacity='+i*10+')';
  if(i<10)
   timer.timer=setTimeout(function(){steps(i+1);},50);
 }

 objs[0].src=objs[1].src;
 objs[0].style.opacity=1;
 objs[1].style.opacity=0;
 objs[0].style.filter='alpha(opacity=100)';
 objs[1].style.filter='alpha(opacity=0)';
 objs[1].src=src;
 steps(1);
}
