/**
*license: MIT-Style License (http://mifjs.net/license.txt)
*copyright: Anton Samoylov (http://mifjs.net)
*authors: Anton Samoylov (http://mifjs.net)
*requires: core:1.2.4:*
*provides: Zoomer
*contao Modifikation:
*Tobias Kiefl - 2ama.com
**/
window.addEvent('domready',function(){var Zoomer=new Class({version:'1.8',Implements:[Options],options:{smooth:6},initialize:function(element,options){this.setOptions(options);this.small=document.id(element);if(!this.small.complete){this.small.addEvent('load',function(){this.prepareSmall();}.bind(this));}else{this.prepareSmall();}var src=this.options.big||this.small.get('big');this.big=new Element('img',{src:src,styles:{position:'absolute',top:0,left:0,opacity:0,cursor:'crosshair'}});if(!this.big.complete){this.big.addEvent('load',function(){this.prepareBig();}.bind(this));}else{this.prepareBig();}},prepareSmall:function(){this.wrapper=new Element('div',{'class':'zoomer-wrapper'}).wraps(this.small);['margin','left','top','bottom','right','float','clear','border','padding'].each(function(p){var style=this.small.getStyle(p);var dflt='auto';if(['float','clear','border'].contains(p))dflt='none';if(p=='padding')dflt='0';try{this.small.setStyle(p,dflt);this.wrapper.setStyle(p,style);}catch(e){};},this);this.wrapper.setStyles({width:this.small.offsetWidth,height:this.small.offsetHeight,position:'relative',overflow:'hidden'});this.smallSize={width:this.small.width,height:this.small.height};if(this.bigPrepared){this.ready();}else{this.smallPrepared=true;}},prepareBig:function(){this.bigSize={width:this.big.width,height:this.big.height};if(this.smallPrepared){this.ready();}else{this.bigPrepared=true;}},ready:function(){this.big.inject(this.wrapper);this.bigWrapper=new Element('div',{'class':'zoomer-wrapper-big',styles:{position:'absolute',overflow:'hidden',width:this.small.offsetWidth,height:this.small.offsetHeight,background:'url(files/hannes_roether/img/blank.gif)'},events:{mouseenter:this.startZoom.bind(this),mouseleave:this.stopZoom.bind(this),mousemove:this.move.bind(this)}}).wraps(this.big);},move:function(event){this.dstPos=event.page;},startZoom:function(){this.position=this.small.getPosition();this.ratio={x:1-this.bigSize.width/this.smallSize.width,y:1-this.bigSize.height/this.smallSize.height};this.current={left:this.big.getStyle('left').toInt(),top:this.big.getStyle('top').toInt()};this.timer=this.zoom.periodical(10,this);this.big.fade('in');if($('lupe').getStyle('visibility')=='visible')$('lupe').morph({'opacity':'0'});},stopZoom:function(){$clear(this.timer);this.big.fade('out');},zoom:function(){if(!this.dstPos)return;var steps=this.options.smooth;var dst={left:parseInt((this.dstPos.x-this.position.x)*this.ratio.x),top:parseInt((this.dstPos.y-this.position.y)*this.ratio.y)};this.current.left-=(this.current.left-dst.left)/steps;this.current.top-=(this.current.top-dst.top)/steps;this.big.setStyles(this.current);}});new Zoomer('bigpic',{smooth:10});$('progress').set('html','...');var allPics=$('gal_a').getElements('img').getProperty('alt');var PicNames=$('gal_a').getElements('img').getProperty('src');var smpics=$('gal_a').getElements('img');var allText=$('gal_a').getElements('img').getProperty('title');var images=[];var img_paths=[];var starttext=[];var smallimages=[];allPics.each(function(item){if(item){img_paths.push(item)};});allText.each(function(itext){starttext.push(itext);});smpics.each(function(picitem,imindex){PicNames.each(function(imindex,nitem){if(picitem.getProperty('src')==imindex){var picbig=picitem.getProperty('alt');var pictext=picitem.getProperty('title');picitem.set({styles:{opacity:1},events:{click:function(){newzoomimage(picbig,pictext);}}});smpics.set('opacity','0.3');}});});var loader=new Asset.images(img_paths,{onProgress:function(counter,index){$('progress').set('html','lade '+(counter+1)*Math.round((100/img_paths.length))+' %');smpics.each(function(){smpics[counter].morph({'opacity':'1'});});},onComplete:function(){$('progress').set('opacity',0);$('progress_bar').set('opacity',0);smpics.morph({'opacity':1});img_paths.each(function(im){images[im]=new Element('img',{'id':'bigpic','src':im,'big':im,'styles':{'visibility':'hidden','opacity':'0','border':'none'}});});img_paths.each(function(im){smallimages[im]=new Element('img',{'id':'bigpic','src':im,'big':im,'styles':{'visibility':'hidden','opacity':'0','border':'none','width':306+'px','height':431+'px'}});});$('cpic').empty();var pictext=starttext[0];smallimages[img_paths[0]].inject($('cpic')).fade(1);new Zoomer('bigpic',{smooth:10,big:img_paths[0]});$('lupe').morph({'opacity':'1'});$('hrtext').set('html',pictext);smpics[0].morph({'opacity':'0.4'});smpics[0].setStyles({cursor:'default'});}});function newzoomimage(pic,pictext){var newsmall=new Element('img',{'id':'bigpic','src':pic,'big':pic,'styles':{'visibility':'hidden','opacity':'0','border':'none','width':306+'px','height':431+'px','z-index':'1000'}});$('cpic').empty();newsmall.inject($('cpic')).fade(1);new Zoomer('bigpic',{smooth:10,big:pic});$('hrtext').setStyles({color:'#525156'});$('hrtext').set('html',pictext);$('hrtext').morph({'color':'#bdbdbd'});}var tabs=$('gal_a').getElements('img');tabs.addEvent('click',function(){tabs.morph({'opacity':'1'});tabs.setStyles({cursor:'pointer'});this.morph({'opacity':'0.4'});this.setStyles({cursor:'default'});});});
