/*
* @file
* @brief    sigplus Image Gallery Plus image captions overlay engine with MooTools
* @author   Levente Hunyadi
* @version  1.2.7
* @remarks  Copyright (C) 2009-2010 Levente Hunyadi
* @remarks  Licensed under GNU/GPLv3, see http://www.gnu.org/licenses/gpl-3.0.html
* @see      http://hunyadi.info.hu/projects/sigplus
*/
function imageCaptions(c,b){var d={showDownload:false,showMetadata:false};b=$extend(d,b);Element.extend({getInnerSize:function(){var f=this.getSize().size;var e=f.x-this.getStyle("padding-left").toInt()-this.getStyle("padding-right").toInt()-this.getStyle("border-left-width").toInt()-this.getStyle("border-right-width").toInt();var g=f.y-this.getStyle("padding-top").toInt()-this.getStyle("padding-bottom").toInt()-this.getStyle("border-top-width").toInt()-this.getStyle("border-bottom-width").toInt();return{width:e>0?e:0,height:g>0?g:0}},getOuterSize:function(){var e=this.getSize().size;return{width:e.x+this.getStyle("margin-left").toInt()+this.getStyle("margin-right").toInt(),height:e.y+this.getStyle("margin-top").toInt()+this.getStyle("margin-bottom").toInt()}}});var a=c.getElements("ul li img");a.each(function(g){var f=g.getProperty("alt");var j=document.getElementById(g.getProperty("id")+"_options");if(!f&&!(j&&(b.showDownload||b.showMetadata))){return}var h=Element.getInnerSize(g);var l=Element.getOuterSize(g);var e=new Element("div",{"class":"imageCaptionContainer",styles:{width:l.width,height:l.height}});var m=g.getParent();if(m.getTag()=="a"){e.injectBefore(m);e.adopt(m)}else{e.injectBefore(g);e.adopt(g)}var n=new Element("div",{"class":"imageCaption imageCaptionHidden",styles:{width:h.width,marginLeft:g.getStyle("margin-left").toInt()+g.getStyle("border-left-width").toInt()+g.getStyle("padding-left").toInt(),marginRight:g.getStyle("margin-right").toInt()+g.getStyle("border-right-width").toInt()+g.getStyle("padding-right").toInt(),marginBottom:g.getStyle("margin-bottom").toInt()+g.getStyle("border-bottom-width").toInt()+g.getStyle("padding-bottom").toInt()}});n.setHTML(f);if(j&&(b.showDownload||b.showMetadata)){j=new Element(j);var k=new Element("div",{"class":"buttons"});if(b.showDownload){var i=j.getElement("a.download");if(i){i.injectInside(k)}}if(b.showMetadata){var o=j.getElement("a.metadata");if(o){sigplusMetadataDialog(o);o.injectInside(k)}}k.injectInside(n)}n.injectInside(e);e.addEvent("mouseenter",function(p){n.removeClass("imageCaptionHidden")});e.addEvent("mouseleave",function(p){n.addClass("imageCaptionHidden")})})};
