function Picture(node){var counter=Picture.counter++;var position={top:Math.floor(counter/this.countPerRow)*(node.offsetHeight+this.style.margin.vertical)+this.style.padding.top,left:Math.floor(counter%this.countPerRow)*(node.offsetWidth+this.style.margin.horizontal)+this.style.padding.left};var wrapper=node.firstChild,image=wrapper.firstChild;var offset={top:Math.round((image.offsetHeight-110)/2.0),left:Math.round((image.offsetWidth-110)/2.0)};node.style.top=position.top+"px";node.style.left=position.left+"px";image.style.marginTop=-offset.top+"px";image.style.marginLeft=-offset.left+"px";this.position=position;this.offset=offset;this.node=node;this.wrapper=wrapper;this.image=image;this.anim=new AnimHandler(this);node.handler=this;node.onmouseover=this.mouseover;node.onmouseout=this.mouseout}Picture.prototype={mouseover:function(event){this.handler.node.style.zIndex="1";var anim=this.handler.anim;anim.direction=1;anim.step=5;anim.increment=10;anim.start()},mouseout:function(event){var event=event||window.event,target=event.relatedTarget||event.toElement;var node=this.handler.node,anim=this.handler.anim;if(target){var parent=target.parentNode;while(parent)if(node!=parent)parent=parent.parentNode;else return}node.style.zIndex="0";anim.direction=-1;anim.step=5;anim.increment=15;anim.start()},setPos:function(scale){var offset=this.offset,position=this.position,node=this.node,image=this.image,wrapper=this.wrapper;var off_scale={top:Math.round(offset.top*scale),left:Math.round(offset.left*scale)};node.style.top=position.top-off_scale.top+"px";node.style.left=position.left-off_scale.left+"px";wrapper.style.width=off_scale.left*2+110+"px";wrapper.style.height=off_scale.top*2+110+"px";image.style.marginTop=-offset.top+off_scale.top+"px";image.style.marginLeft=-offset.left+off_scale.left+"px"}};Picture.counter=0;Picture.initialize=function(node){node.parentNode.style.height=node.parentNode.offsetHeight+"px";if(window.getComputedStyle)var nodeStyle=window.getComputedStyle(node,null),parentStyle=window.getComputedStyle(node.parentNode,null);else var nodeStyle=node.currentStyle,parentStyle=node.parentNode.currentStyle;Picture.prototype.style={margin:{vertical:parseInt(nodeStyle.marginLeft)+parseInt(nodeStyle.marginRight),horizontal:parseInt(nodeStyle.marginTop)+parseInt(nodeStyle.marginBottom)},padding:{top:parseInt(parentStyle.paddingTop),left:parseInt(parentStyle.paddingLeft)}};Picture.prototype.countPerRow=Math.round(node.parentNode.offsetWidth/(node.offsetWidth+Picture.prototype.style.margin.horizontal))};Picture.parse=function(){var pictures=document.getElementById("pictures").getElementsByTagName('a');if(pictures.length>0){Picture.initialize(pictures[0]);for(var i=0,picture;picture=pictures[i];i++)new Picture(picture);Picture.setStyle()}};Picture.setStyle=function(stylesheet){var rule=getCssRule(/^#pictures a$/i,document.styleSheets[0]);rule.style.position="absolute"};function getCssRule(selectorPattern,stylesheet){var imports=[];if(stylesheet.cssRules){for(var i=0,rules=stylesheet.cssRules;rule=rules[i];i++){if(selectorPattern.test(rule.selectorText))return rule;else if(rule.type==3)imports.push(rule.styleSheet)}}else{for(var i=0,rules=stylesheet.rules;rule=rules[i];i++){if(selectorPattern.test(rule.selectorText))return rule}imports=stylesheet.imports}for(var i=0,imp;imp=imports[i];i++){if(rule=getCssRule(selectorPattern,imp))return rule}return undefined}function AnimHandler(picture){this.picture=picture;this.frame=0;this.direction=0;this.step=10;this.incremet=0;this.active=false;AH.animations.push(this)}AnimHandler.prototype={start:function(){this.active=true;if(AH.intervalId===null)AH.intervalId=setInterval(AH.animate,20)},move:function(){this.frame+=(this.step+=this.increment)*this.direction;if((this.direction>0)?(this.frame>=100):(this.frame<=0)){this.frame=(this.direction>0)?100:0;this.active=false}this.picture.setPos(this.frame/100);return this.active}};AnimHandler.intervalId=null;AnimHandler.animations=[];AnimHandler.animate=function(){var active=0;for(var i=0,anim;anim=AH.animations[i];i++)if(anim.active&&anim.move())active++;if(!active){clearInterval(AH.intervalId);AH.intervalId=null}};var AH=AnimHandler;window.onload=function(){Picture.parse()};