/*
 * jQuery easy-caption plugin
 * Examples and documentation at: http://www.easy-tuts.com/downloads/jquery-plugins/
 * version 1.4 (06-APR-2011)
 * Requires jQuery v1.4 or later
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Author: alexander@easy-tuts.com
 */
 
 (function($){$.fn.caption=function(o){if(this.length==0){if(!$.isReady&&this.selector){var s=this.selector,c=this.context;$(function(){$(s,c).caption(o);});}return this;}return this.each(function(){if(this.tagName.toLowerCase()!='img')return $(this);if(!this.complete){var img=this;$('<img />').attr('src',img.src).load(function(){captionNow(img);});return img;}else{captionNow(this);}});function captionNow(img){var $this=$(img),alt=$(img).attr('alt'),$bg=$('<div />'),$fg=$('<div />'),$bottomDiff=0,$offset={top:img.offsetTop,left:img.offsetLeft},$caption=$('<div />'),$close=$('<span />'),height,$temp,animations,randomIn,randomOut,image={width:$(img).outerWidth(true),height:$(img).outerHeight(true)};if(alt!=''){if(o===undefined){o={};}if(o.wrapping===undefined||o.wrapping!==true&&o.wrapping!==false)o.wrapping=true;if(o.fixed===undefined||o.fixed=='true'||o.fixed===true){o.fixed=true;}else{o.fixed=false;}if(o.button===true||o.button=='true'){o.button=true;}else{o.button=false;}if(o.delay===undefined){o.delay=0;}if(o.animation!==undefined){o.animationIn=o.animation;o.animationOut=o.animation;}if(o.duration!==undefined){o.durationIn=o.duration;o.durationOut=o.duration;}if(o.animationIn===undefined){if(o.fixed===true){o.animationIn='none';}else{o.animationIn='slide';}}if(o.durationIn===undefined){o.durationIn='medium';}if(o.animationOut===undefined){o.animationOut='fade';}if(o.durationOut===undefined){o.durationOut='fast';}if(o.animationIn=='random'){randomIn=true;}else{randomIn=false;}if(o.animationOut=='random'){randomOut=true;}else{randomOut=false;}if(o.separator!==undefined){var indexSep=alt.indexOf(o.separator);if(indexSep!=-1&&indexSep!=0&&indexSep!=alt.length-indexSep.length){$temp=$('<span />').addClass(o.titleClass).addClass('easy-caption-title').html(alt.substring(0,indexSep));if(o.titleStyle!==undefined)$temp.css(o.titleStyle);$temp.appendTo($fg);$temp=$('<span />').addClass(o.textClass).addClass('easy-caption-text').html(alt.substring(indexSep+o.separator.length));if(o.textStyle!==undefined)$temp.css(o.textStyle);$temp.appendTo($fg);}else{$temp=$('<span />').addClass(o.textClass).addClass('easy-caption-text').html(alt);if(o.textStyle!==undefined)$temp.css(o.textStyle);$temp.appendTo($fg);}}else{$temp=$('<span />').addClass(o.textClass).addClass('easy-caption-text').html(alt);if(o.textStyle!==undefined)$temp.css(o.textStyle);$temp.appendTo($fg);}$this.attr('alt','');$wrapper=$this.wrap('<div />').parent().addClass('easy-caption-wrapper').addClass(o.wrapperClass).css('overflow','hidden').width(image.width).height(image.height);if(!o.wrapping){$wrapper.css({'top':$offset.top,'left':$offset.left,'position':'absolute'});$this.insertBefore($wrapper);$bottomDiff=image.height*-1;}if(o.wrapperStyle!==undefined)$wrapper.css(o.wrapperStyle);$caption.appendTo($wrapper).width(image.width).addClass('easy-caption');$bg.appendTo($caption).width(image.width).addClass('easy-caption-background').addClass(o.backgroundClass);if(o.backgroundStyle!==undefined)$bg.css(o.backgroundStyle);$fg.appendTo($caption).width(image.width).addClass('easy-caption-foreground').addClass(o.foregroundClass);if(o.foregroundStyle!==undefined)$fg.css(o.foregroundStyle);height=$fg.outerHeight();if(o.button===true){if(o.closeSign===undefined)o.closeSign='X';$close.appendTo($caption).html(o.closeSign).addClass('easy-caption-close').addClass(o.closeClass);if(o.closeStyle!==undefined)$close.css(o.closeStyle);$close.css({position:'relative',cursor:'pointer',bottom:height*2+$close.outerHeight()-7,left:image.width-$close.outerWidth()-3});}$caption.css({position:'relative',bottom:height+$bottomDiff,height:height}).hide();$bg.css({position:'relative',height:height});if(o.opacity!==undefined)$bg.css({opacity:o.opacity});$fg.css({position:'relative',bottom:height,height:height});animations={names:new Array('none','fade','slide','bounce','gravity','zoom','racer','move'),cssNormal:{opacity:'',left:'',right:'',top:'',bottom:height+$bottomDiff,width:image.width,height:height},noneIn:{},noneOut:{},fadeIn:{css:{opacity:'0.0'},animate:new Array({css:{opacity:'1.0'},duration:o.durationIn})},fadeOut:{animate:new Array({css:{opacity:'0.0'},duration:o.durationOut})},slideIn:{css:{bottom:0+$bottomDiff},animate:new Array({css:{bottom:height+$bottomDiff},duration:o.durationIn})},slideOut:{animate:new Array({css:{bottom:0+$bottomDiff},duration:o.durationOut})},bounceIn:{css:{bottom:0},animate:new Array({css:{bottom:height+$bottomDiff},duration:o.durationIn},{css:{bottom:'-=10'},duration:200},{css:{bottom:'+=10'},duration:200})},bounceOut:{animate:new Array({css:{bottom:0+$bottomDiff},duration:o.durationOut},{css:{bottom:'+=10'},duration:200},{css:{bottom:'-=10'},duration:200})},gravityIn:{css:{bottom:image.height+height+$bottomDiff},animate:new Array({css:{bottom:height+$bottomDiff},duration:140},{css:{bottom:'+=15'},duration:120},{css:{bottom:'-=15'},duration:100},{css:{bottom:'+=8'},duration:80},{css:{bottom:'-=8'},duration:60},{css:{bottom:'+=3'},duration:40},{css:{bottom:'-=3'},duration:20})},gravityOut:{animate:new Array({css:{bottom:'+=3'},duration:20},{css:{bottom:'-=3'},duration:40},{css:{bottom:'+=8'},duration:60},{css:{bottom:'-=8'},duration:80},{css:{bottom:'+=15'},duration:100},{css:{bottom:'-=15'},duration:120},{css:{bottom:image.height+height+$bottomDiff},duration:140})},zoomIn:{css:{bottom:Math.floor(height/2)+$bottomDiff,left:Math.floor(image.width/2),height:0,width:0},animate:new Array({css:{bottom:height+$bottomDiff,left:0,height:height,width:image.width},duration:o.durationIn})},zoomOut:{animate:new Array({css:{bottom:Math.floor(height/2)+$bottomDiff,left:Math.floor(image.width/2),height:0,width:0},duration:o.durationOut})},racerIn:{css:{left:0-image.width},animate:new Array({css:{left:0},duration:o.durationIn})},racerOut:{animate:new Array({css:{left:image.width},duration:o.durationOut})},moveIn:{css:{left:image.width,bottom:image.height+3+$bottomDiff},animate:new Array({css:{left:0,bottom:image.height+3+$bottomDiff},duration:o.durationIn},{css:{left:0,bottom:height+$bottomDiff},duration:o.durationIn})},moveOut:{animate:new Array({css:{left:0,bottom:image.height+3+$bottomDiff},duration:o.durationOut},{css:{left:0-image.width,bottom:image.height+3+$bottomDiff},duration:o.durationOut})}};if(o.fixed===true){if(randomIn===true){o.animationIn=animations.names[Math.round(Math.random()*(animations.names.length-1))];}effect('in',o,$caption,animations);}if(o.button===true){$close.click(function(){if($caption.css('display')!=='none'){o.delay=0;if(randomOut===true){o.animationOut=animations.names[Math.round(Math.random()*(animations.names.length-1))];}effect('out',o,$caption,animations);}});}$wrapper.hover(function(){if(o.button!==true&&o.fixed!==true||o.button===true&&$caption.css('display')=='none'){if(randomIn===true){o.animationIn=animations.names[Math.round(Math.random()*(animations.names.length-1))];}effect('in',o,$caption,animations);}},function(){if(o.button!==true&&o.fixed!==true){if(randomOut===true){o.animationOut=animations.names[Math.round(Math.random()*(animations.names.length-1))];}effect('out',o,$caption,animations);}});}}function effect(inOut,o,$caption,animations){var css,animate;if(inOut=='in'){css=animations[o.animationIn+'In'].css;animate=animations[o.animationIn+'In'].animate;$caption.clearQueue().stop().css(animations.cssNormal).queue(function(){if(css!==undefined)$(this).css(css);$(this).dequeue();}).show().queue(function(){if(animate!==undefined)animation($caption,animate);$(this).dequeue();}).queue(function(){$(this).css(animations.cssNormal);$(this).dequeue();});}else{animate=animations[o.animationOut+'Out'].animate;$caption.clearQueue().stop().css(animations.cssNormal).show().delay(o.delay).queue(function(){if(animate!==undefined)animation($caption,animate);$(this).dequeue();}).queue(function(){$(this).queue(function(){$(this).hide();}).css(animations.cssNormal);$(this).dequeue();});}}function animation($caption,animate){for(var i=0;i<animate.length;i++){$caption.animate(animate[i].css,animate[i].duration);}}}})(jQuery);
