
/* reflection.js for mootools v1.2 by Christophe Beyls (http://www.digitalia.be) - MIT-style license */
var Reflection={add:function(A,B){A=$(A);if(A.getTag()!="img"){return }B={arguments:[A,B]};if(window.ie){B.delay=50}A.preload=new Image();A.preload.onload=Reflection.reflect.create(B);A.preload.src=A.src},remove:function(A){A=$(A);if(A.preload){A.preload.onload=null}if((A.getTag()=="img")&&(A.className=="reflected")){A.className=A.parentNode.className;A.style.cssText=A.backupStyle;A.parentNode.replaceWith(A)}},reflect:function(A,D){D=$extend({height:0.33,opacity:0.5},D||{});Reflection.remove(A);var C,B=Math.floor(A.height*D.height);if(window.ie){C=new Element("img",{src:A.src,styles:{width:A.width,marginBottom:-A.height+B,filter:"flipv progid:DXImageTransform.Microsoft.Alpha(opacity="+(D.opacity*100)+", style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy="+(D.height*100)+")"}})}else{C=new Element("canvas",{styles:{width:A.width,height:B}});if(!C.getContext){return }}var G=new Element("div").injectAfter(A).adopt(A,C);G.className=A.className;G.style.cssText=A.backupStyle=A.style.cssText;G.removeClass("reflect").setStyles({width:A.width,height:B+A.height});A.style.cssText="vertical-align: bottom";A.className="reflected";if(window.ie){return }var E=C.setProperties({width:A.width,height:B}).getContext("2d");E.save();E.translate(0,A.height-1);E.scale(1,-1);E.drawImage(A,0,0,A.width,A.height);E.restore();E.globalCompositeOperation="destination-out";var F=E.createLinearGradient(0,0,0,B);F.addColorStop(0,"rgba(255, 255, 255, "+(1-D.opacity)+")");F.addColorStop(1,"rgba(255, 255, 255, 1.0)");E.fillStyle=F;E.rect(0,0,A.width,B);E.fill()},addFromClass:function(){$each(document.getElementsByTagName("img"),function(A){if($(A).hasClass("reflect")){Reflection.add(A)}})}};Element.extend({addReflection:function(A){Reflection.add(this,A);return this},removeReflection:function(A){Reflection.remove(this,A);return this}});Window.addEvent("domready",Reflection.addFromClass);