var getAmongPos = function(size,to){
var elpSize = $(to).getSize();
return {
\'top\':Math.abs((elpSize.y/2).toInt()-(size.height/2).toInt()+to.getPosition().y+elpSize.scroll.y),
\'left\':Math.abs((elpSize.x/2).toInt()-(size.width/2).toInt()+to.getPosition().x+elpSize.scroll.x)
};
};
$$(\'.grid .zoom a\').addEvent(\'click\',function(e){
e.stop();
if(this.retrieve(\'active\'))return;
var _this = this;
_this.store(\'active\',true);
var tpic = this.getParent(\'.items-gallery\').getElement(\'.goodpic img\');
var bpic_src = this.get(\'pic\');
var loading = new Element(\'div\',{
styles:{\'background\':\'#fff url(statics/loading.gif) no-repeat 50% 50%\',
\'width\':40,
\'height\':40,
\'border\':\'1px #e9e9e9 solid\',
\'opacity\':.5}}).inject(document.body).amongTo(tpic);
new Asset.image(bpic_src,{onload:function(img){
loading.remove();
var winsize = window.getSize();
var imgSize = $(img).zoomImg(winsize.x,winsize.y,1);
var fxv = $extend(getAmongPos(imgSize,window),imgSize);
var imgFx = new Fx.Morph(img,{link:\'cancel\'});
img.setStyles($extend(tpic.getCis(),{opacity:0.5})).inject(document.body).addClass(\'img-zoom\').addEvent(\'click\',function(){
imgFx.start(tpic.getCis()).chain(function(){this.element.remove();_this.store(\'active\',false);});
});
imgFx.start($extend(fxv,{opacity:1}));
document.addEvent(\'click\',function(){
img.fireEvent(\'click\');
document.removeEvent(\'click\',arguments.callee);
});
},onerror:function(){
_this.store(\'active\',false);
loading.remove();
}});
});
}();