window.onload=function(){ImgFooter.init();}
var ImgFooter={
    _idPref:"if_",_imgPref:"imgfooter",_current:null,
    init:function(){
        imgArray=$$('img[id^='+this._imgPref+']');
        imgArray.each(function(el){
            f=$(ImgFooter._getFooter(el));
            if(!f){return;}
            el.footer=f;
            el.observe("mouseover",function(){ImgFooter.showF(this)});
        });
    },
    _positioned:function(el){
        imgPosition=el.cumulativeOffset();
        imgPosition.top+=el.getHeight()-f.getHeight();
        el.footer.setStyle({top:imgPosition.top+"px",left:imgPosition.left+"px",width:el.getWidth()+"px"});
    },
    _makeHZ:function(el){
        if(el.hz){el.hz.each(function(h){h.remove()});}
        dimensions=el.getDimensions();
        ElPosition=el.cumulativeOffset();
        positionTop=ElPosition.top-10;
        positionLeft=ElPosition.left-10;
        hotTop = new Element('div', { 'class': 'hot_zone'}).update("&nbsp;");
        document.body.appendChild(hotTop);
        hotTop.setStyle({top:positionTop+"px",left:positionLeft+"px",width:(dimensions.width+20)+"px",height:"10px"});
        hotTop.observe("mouseover",function(){ImgFooter.hideF()});
        hotRight = new Element('div', { 'class': 'hot_zone'}).update("&nbsp;");
        document.body.appendChild(hotRight);
        hotRight.setStyle({top:positionTop+"px",left:(positionLeft+dimensions.width+10)+"px",width:"10px",height:(dimensions.height+20)+"px"});
        hotRight.observe("mouseover",function(){ImgFooter.hideF()});
        hotBottom = new Element('div', { 'class': 'hot_zone'}).update("&nbsp;");
        document.body.appendChild(hotBottom);
        hotBottom.setStyle({top:(positionTop+dimensions.height+10)+"px",left:positionLeft+"px",width:(dimensions.width+20)+"px",height:"10px"});
        hotBottom.observe("mouseover",function(){ImgFooter.hideF()});
        hotLeft = new Element('div', { 'class': 'hot_zone'}).update("&nbsp;");
        document.body.appendChild(hotLeft);
        hotLeft.setStyle({top:positionTop+"px",left:positionLeft+"px",width:"10px",height:(dimensions.height+20)+"px"});
        hotLeft.observe("mouseover",function(){ImgFooter.hideF()});
        el.hz=[hotTop,hotRight,hotBottom,hotLeft];
    },
    hideF:function(){
        if(!this._current || this._current==null) return;
        this._current.footer.fade({duration:0.5});
        this._current=null;
    },
    showF:function(el){
      ImgFooter._makeHZ(el);
      ImgFooter._positioned(el);
      el.footer.appear({to:0.7,duration:0.5});
      this._current=el;
    },
    _getFooter:function(imgEl){
        return imgEl.id.sub(/.*B([^E]+)E/,function(m){return m[1]});
    }
};
