var mxGM=false;var mxGMinit=null;function getGM(){if(!mxGMinit){mxGMinit=window.setTimeout("getGM().init()",50)}if(!mxGM){mxGM=new mxGalleryManager()}return mxGM}var mxGalleryManagerPrototype=mxGalleryManager.prototype;function mxGalleryManager(){this.DELAY=10;this.blocked=false;this.gallery_r=new Object();this.gallery_r_count=0;this.bgOpac=false}mxGalleryManagerPrototype.getBGOpac=function(){return this.bgOpac};mxGalleryManagerPrototype._create=function(d,b,f,e,a){var c=$$("div.gallery");this.gallery_r_count++;c[0].setAttribute("id","gallery"+this.gallery_r_count);this.create(this.gallery_r_count,d,b,f,e,a)};mxGalleryManagerPrototype._showPic=function(b,a,c){var d=/id=["]{0,1}thumbs([0-9]*)["]{0,1}/;d.exec(b.parentNode.innerHTML);this.showPic(RegExp.$1,a,c)};mxGalleryManagerPrototype.create=function(e,d,b,g,f,a,c){this.gallery_r[e]=new mxGallery(e,d,b,g,f,a,c)};mxGalleryManagerPrototype.init=function(){for(var a in this.gallery_r){this.gallery_r[a].init(true)}};mxGalleryManagerPrototype.hidePic=function(c,b){if(!this.gallery_r[c]||this.blocked){return}var a=this.getGallery(c);a.hidePic(a.current,b)};mxGalleryManagerPrototype.showPic=function(d,b,c){if(!this.gallery_r[d]||this.blocked){return}var a=this.getGallery(d);var e=this.getItem(d,b);if(typeof(c)=="undefined"){a.pause(e)}a.showPic(e,c)};mxGalleryManagerPrototype.slidePic=function(c,b){if(!this.gallery_r[c]||this.blocked){return}var a=this.getGallery(c);var d=this.getItem(c,b);a.showPic(d)};mxGalleryManagerPrototype.previous=function(a){if(!this.gallery_r[a]||this.blocked){return}this.gallery_r[a].previous()};mxGalleryManagerPrototype.next=function(a){if(!this.gallery_r[a]||this.blocked){return}this.gallery_r[a].next()};mxGalleryManagerPrototype.play=function(c,b){if(!this.gallery_r[c]||this.blocked){return}var a=this.getGallery(c);var d=this.getItem(c,b);a.play(d)};mxGalleryManagerPrototype.pause=function(a){if(!this.gallery_r[a]||this.blocked){return}this.getGallery(a).pause()};mxGalleryManagerPrototype.insert=function(b,c){if(!this.gallery_r[b]){return}this.blocked=true;c=c.split(",");var a=c.shift();if(a){this.gallery_r[b].insert(a);if(c.length){window.setTimeout("mxGM.insert('"+b+"','"+c.join(",")+"')",10)}else{this.blocked=false}}};mxGalleryManagerPrototype.index=function(e,b){if(!this.gallery_r[e]){return false}if(this.gallery_r[e].single){var a=this.singleGalleries();var g=a.length;if(g<=1){return}for(var c=0;c<g;c++){if(a[c]!=e){continue}var d=c+1;if(d==g){d=0}var f=c-1;if(f<0){f=g-1}return[[a[f],0],[a[d],0],[c,g]]}return false}var g=this.gallery_r[e].count;if(g==1){return}var d=b+1;if(d==g){d=0}var f=b-1;if(f<0){f=g-1}return[[e,f],[e,d],[b,g]]};mxGalleryManagerPrototype.singleGalleries=function(){if(!this.single_r){this.single_r=[];for(var a in this.gallery_r){if(!this.gallery_r[a].single){continue}this.single_r[this.single_r.length]=a}}return this.single_r};mxGalleryManagerPrototype.getGallery=function(b){if(!this.gallery_r[b].single){return this.gallery_r[b]}var a=this.singleGalleries();return this.gallery_r[a[0]]};mxGalleryManagerPrototype.getItem=function(b,a){return this.gallery_r[b].item_r[a]};var mxGalleryPrototype=mxGallery.prototype;function mxGallery(c,d,p,m,r,g,e){this.count=0;this.width=parseInt(d);this.height=parseInt(p);this.slide=g?parseInt(g):6;if(this.slide<1||this.slide>20){this.slide=6}this.slide*=1000;this.single=false;this.id=c;this.DELAY=650;this.DEFAULT_SIZE=128;if(!m){this.DELAY=450}var b=$("gallery"+c);if(!b){return}var k=b.getChildren("div");this.item_r=[];for(var f=0;f<k.length;f++){var a=k[f];if(!a){return}if(a.className=="galleryItem"){var c=this.item_r.length;var q=new mxGalleryItem(this,c,a);this.item_r[c]=q;if(!this.current){this.current=q}this.count++}if(a.className=="galleryHead"){this.head=a.innerHTML}}if(!this.count){return}var o=!m;if(!m){m=r=1}this.columns=parseInt(m);var r=parseInt(r);if(this.count<(r*this.columns)){r=Math.ceil(this.count/m)}this.limit=r*this.columns;this.start=0;this.head=null;this.current=null;this.step=this.columns;var j="gframe";if(this.count==1&&!e){this.single=true;j+=" single"}if(o){return}this.frame=new Element("div",{"class":j});b.parentNode.replaceChild(this.frame,b);if(this.head){this.frame.innerHTML="<h4>"+this.head+"</h4>"}var h=new Element("div",{"class":"gthumbs"});this.frame.appendChild(h);this.thumbs=new Element("div",{id:"thumbs"+c,"class":"ginner"});h.appendChild(this.thumbs);var l=new Element("div",{styles:{clear:"both"}});h.appendChild(l);this.tnav=new Element("div",{id:"thumbsnav"+c,"class":"gthumbsnav",styles:{display:"none"}});h.appendChild(this.tnav);var n=new Element("div",{"class":"garrows"});this.tnav.appendChild(n);this.a_show=new Element("div",{styles:{left:"0px"}});this.tnav.appendChild(this.a_show);this.a_prev=new Element("a",{html:'<img src="../static/img/gallery_up.gif" />'});n.appendChild(this.a_prev);this.a_next=new Element("a",{html:'<img src="../static/img/gallery_down.gif" />'});n.appendChild(this.a_next);var c=this.id;this.a_prev.href=".";this.a_prev.onclick=function(){getGM().previous(c);return false};this.a_next.href=".";this.a_next.onclick=function(){getGM().next(c);return false};h.style.width=(this.columns*this.thumbWidth())+"px"}mxGalleryPrototype.thumbWidth=function(){var a=this.width;if(!this.single){a+=3}return a};mxGalleryPrototype.thumbHeight=function(){var a=this.height;if(!this.single){a+=3}return a};mxGalleryPrototype.init=function(a,e){if(!this.count||!this.thumbs){return}var g=[];var f=this.start;if(typeof(e)!="undefined"){f+=e}else{e=0}var b=false;if(!a){b=this.thumbs.firstChild}for(var c=0;c<this.count;c++){var d=this.item_r[c];if(e>0){if(c<f){d.remove();continue}if(c<this.start+this.limit){continue}}else{if(e<0){if(c>=f+this.limit){d.remove();continue}if(c>=this.start){continue}if(c<f){continue}}}if(c>=f+this.limit){break}g[g.length]=c;d.createEmpty(b)}window.setTimeout("getGM().insert('"+this.id+"','"+g.join(",")+"')",100);this.start=f;end=this.start+this.limit;if(end>this.count){end=this.count}if(!end||this.start==end-1){this.a_show.innerHTML=end}else{this.a_show.innerHTML=(this.start+1)+" - "+end}this.a_show.innerHTML+=" / "+this.count;if(this.start==0){this.a_prev.style.visibility="hidden"}else{this.a_prev.style.visibility="visible"}if(this.start+this.limit>=this.count){this.a_next.style.visibility="hidden"}else{this.a_next.style.visibility="visible"}if(this.tnav.style.display!="none"){return}this.tnav.style.display="";new Fx.Morph(this.tnav.id,{duration:1000,transition:Fx.Transitions.Circ.easeIn}).start({opacity:[0,0.6]})};mxGalleryPrototype.insert=function(b,a){if(!this.item_r[b]){return}this.item_r[b].create($(a))};mxGalleryPrototype.hidePic=function(d,b){if(!this.bg){return}this.current=d;if(this.slideshow){this.pause()}if(typeof(b)!="undefined"){this.picframe.style.display="none";this.bg.style.display="none";return}var a=new Fx.Morph(this.picframe.id,{duration:this.DELAY,transition:Fx.Transitions.Circ.easeOut});var g=d.gallery.thumbs;if(g&&0){var f=mxOffsetPosition(g);var e=0;if(this.single){e=-10}a.start({top:f[1]+e,height:g.offsetHeight+e,left:f[0],width:g.offsetWidth+e})}else{a.start({opacity:0})}mxSwitchSelects(false);var c=new Fx.Morph(this.picture.id,{duration:this.DELAY,transition:Fx.Transitions.linear,onComplete:new Function("getGM().hidePic('"+this.id+"',1)")});c.start({opacity:0});new Fx.Morph(this.bg.id,{duration:this.DELAY,transition:Fx.Transitions.linear}).start({opacity:0});new Fx.Morph(this.label.id,{duration:this.DELAY,transition:Fx.Transitions.Circ.easeOut}).start({opacity:0})};mxGalleryPrototype.showPic=function(e,c){this.current=e;if(this.p_slider){this.p_slider.style.width="0px";this.p_slider.style.display="none"}var b=e.index();if(typeof(c)!="undefined"){if(this.slideshow){this.play(e)}this.label.innerHTML="";this.picture.appendChild(e.full);if(e.head){this.label.innerHTML+="<b>"+e.head+"</b>"}if(e.desc){this.label.innerHTML+="<div>"+e.desc+"</div>"}new Fx.Morph(this.label.id,{duration:this.DELAY,transition:Fx.Transitions.Circ.easeIn}).start({opacity:[0,1]});return}else{e.loadPicture()}if(this.label&&this.label.style.opacity){new Fx.Morph(this.label.id,{duration:this.DELAY/2,transition:Fx.Transitions.Circ.easeIn}).start({opacity:0})}if(!this.bg){this.bg=new Element("div",{id:"gbg"+this.id,"class":"gbackground",styles:{opacity:0}});this.bg.onclick=new Function("getGM().hidePic('"+this.id+"')");this.bg.inject($(document.body),"top");if(!Browser.ie6){this.bg.setStyle("position","fixed")}this.picframe=new Element("div",{id:"gpicframe"+this.id,"class":(b?"gpicture":"gpicture single"),styles:{display:"none"}});this.picframe.inject($(document.body),"top");this.picture=new Element("div",{id:"gpicture"+this.id,"class":"ginner"});this.picframe.appendChild(this.picture);var f=new Element("div",{"class":"close",html:'<a href="." onclick="getGM().hidePic(\''+this.id+'\');return false;"><img src="../static/img/gallery_close.gif" /></a>'});this.picframe.appendChild(f);this.nav=new Element("div",{id:"gnav"+this.id,"class":"gpicnav"});this.picframe.appendChild(this.nav);this.label=new Element("div",{id:"glabel"+this.id,"class":"glabel"});this.picframe.appendChild(this.label);this.p_show=new Element("div",{styles:{left:0}});this.nav.appendChild(this.p_show);this.p_prev=new Element("a",{html:'<img src="../static/img/gallery_left.gif" />'});this.nav.appendChild(this.p_prev);this.p_pause=new Element("a",{html:'<img src="../static/img/gallery_pause.gif" />'});this.nav.appendChild(this.p_pause);this.p_play=new Element("a",{html:'<img src="../static/img/gallery_play.gif" />'});this.nav.appendChild(this.p_play);this.p_next=new Element("a",{html:'<img src="../static/img/gallery_right.gif" />'});this.p_next.innerHTML='<img src="../static/img/gallery_right.gif" />';this.nav.appendChild(this.p_next);this.pause()}if(b){this.p_prev.onclick=function(){getGM().showPic(b[0][0],b[0][1]);return false};this.p_prev.setStyle("cursor","pointer");this.p_next.onclick=function(){getGM().showPic(b[1][0],b[1][1]);return false};this.p_next.setStyle("cursor","pointer")}else{this.nav.style.display="none"}new Fx.Morph(this.picture.id,{duration:this.DELAY,transition:Fx.Transitions.Circ.easeIn}).start({opacity:[0,1]});if(this.bg.getStyle("opacity")==0){if(getGM().getBGOpac()){new Fx.Morph(this.bg,{duration:this.DELAY,transition:Fx.Transitions.Circ.easeIn}).start({opacity:[0,getGM().getBGOpac()]})}else{this.bg.setStyle("opacity",0.01)}}if(b){this.p_show.innerHTML=(b[2][0]+1)+" / "+b[2][1]}var d=mxWinSize();var a=mxScrolled();this.bg.style.width=(d[0]+a[0])+"px";this.bg.style.height=(d[1]+a[1])+"px";mxSwitchSelects(true);e.fullsize(this);this.bg.style.display="block";this.picframe.style.display="block"};mxGalleryPrototype.pause=function(a){if(typeof(a)!="undefined"){this.current=a}this.slideshow=false;if(this.p_slider){this.p_slider.style.display="none";this.p_slider.style.width="0px"}if(this.timeout){this.timeout.cancel()}if(this.p_pause){this.p_pause.onclick=function(){return false};this.p_pause.setStyles({opacity:0.2,cursor:"default"})}if(this.p_play&&this.current.index()){var b=[this.current.gallery.id,this.current.id];this.p_play.onclick=function(){getGM().play(b[0],b[1]);return false};this.p_play.setStyles({opacity:1,cursor:"pointer"})}};mxGalleryPrototype.play=function(b){var a=b.index();if(!a){return}if(!this.slideshow){this.slideshow=true;var c=this.id;this.p_pause.onclick=function(){getGM().pause(c);return false};this.p_pause.setStyles({opacity:1,cursor:"pointer"});this.p_play.onclick=function(){return false};this.p_play.setStyles({opacity:0.2,cursor:"default"})}if(!this.p_slider){this.p_slider=new Element("a",{id:"gslider"+c,"class":"gslider"});this.picframe.appendChild(this.p_slider)}if(this.timeout){this.timeout.cancel()}this.p_slider.style.display="";getGM().gallery_r[a[1][0]].item_r[a[1][1]].loadPicture();this.timeout=new Fx.Morph(this.p_slider.id,{duration:this.slide,transition:Fx.Transitions.linear,onComplete:new Function("getGM().slidePic('"+a[1][0]+"',"+a[1][1]+")")});this.timeout.start({width:[0,this.picture.offsetWidth]})};mxGalleryPrototype.previous=function(){if(this.start==0){return}this.init(false,0-this.step)};mxGalleryPrototype.next=function(){if(this.start+this.limit>=this.item_r.length){return}this.init(true,this.step)};var mxGalleryItemPrototype=mxGalleryItem.prototype;function mxGalleryItem(a,g,f){f=$(f);this.id=g;this.gallery=a;this.visible=false;this.show_empty=false;var b=f.getElements("img");for(var c=0;c<b.length;c++){if(b[c].className=="full"){this.full=b[c]}else{if(b[c].className=="thumb"){this.thumb=b[c]}}}if(Browser.ie&&Browser.version<8){f.removeChild(this.full)}this.fwidth=this.full.getAttribute("width")-0;this.fheight=this.full.getAttribute("height")-0;if(this.thumb){f.removeChild(this.thumb);this.twidth=parseInt(this.thumb.getAttribute("width"));this.theight=parseInt(this.thumb.getAttribute("height"))}var d=f.getElements("h3");this.head=(d.length)?this.head=d[0].innerHTML:null;var e=f.getElements("p");this.desc=(e.length)?this.desc=e[0].innerHTML:null;f.dispose()}mxGalleryItemPrototype.create=function(d){if(this.visible||!this.thumb){return}if(!this.container){var a=this.gallery.thumbHeight();var f=this.gallery.thumbWidth();this.container=new Element("div",{"class":"gthumbnail",id:"g"+this.gallery.id+"thumb"+this.id,styles:{"float":"left",width:f,height:a}});this.inner=new Element("div");this.inner.className="ginner";var g=a-this.theight-3;var c=f-this.twidth-3;if(g<0){g=0}if(c<0){c=0}var b=Math.round(g/2);var e=Math.round(c/2);var h=[b,e,g-b,c-e];this.inner.setStyles({padding:h[0]+"px "+h[1]+"px "+h[2]+"px "+h[3]+"px"});this.container.appendChild(this.inner);this.inner.appendChild(this.load(this.thumb));this.inner.onclick=new Function("getGM().showPic('"+this.gallery.id+"',"+this.id+")")}this.visible=true;if(this.show_empty){this.gallery.thumbs.replaceChild(this.container,this.empty)}else{this.gallery.thumbs.appendChild(this.container)}new Fx.Morph(this.container.id,{duration:getGM().DELAY*2,transition:Fx.Transitions.Quad.easeIn}).start({opacity:[0,1]})};mxGalleryItemPrototype.loadPicture=function(){this.full=this.load(this.full)};mxGalleryItemPrototype.load=function(c){var d=c.getAttribute("mxsrc");if(d){if(Browser.ie&&Browser.version<8&&d.substr(d.length-3,3)=="png"){var a=new Element("span",{"class":c.className,styles:{width:c.getAttribute("width"),height:c.getAttribute("height"),display:"inline-block",background:"white",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+d+"',sizingMethod='scale',enabled=true)"}});if(c.parentNode){c.parentNode.replaceChild(a,c)}c=a}else{var b=[c.getAttribute("width"),c.getAttribute("height")];c.src=d;c.setAttribute("width",b[0]);c.setAttribute("height",b[1])}c.removeAttribute("mxsrc")}return c};mxGalleryItemPrototype.index=function(){if(typeof(this.picindex)=="undefined"){this.picindex=getGM().index(this.gallery.id,this.id)}return this.picindex};mxGalleryItemPrototype.fullsize=function(l){var j=this.index();if(!j){this.full.onclick=new Function("getGM().hidePic('"+this.gallery.id+"')");this.full.oncontextmenu=new Function("getGM().hidePic('"+this.gallery.id+"');return false;")}else{this.full.oncontextmenu=new Function("getGM().showPic('"+j[0][0]+"',"+j[0][1]+");return false;");this.full.onclick=new Function("getGM().showPic('"+j[1][0]+"',"+j[1][1]+")")}var d=l.picframe;var h=l.picture;var e=mxWinSize();var b=this.fwidth;var o=this.fheight;if(b<250){this.full.style.paddingLeft=Math.round((250-b)/2)+"px";b=250}if(o<200){this.full.style.paddingTop=Math.round((200-o)/2)+"px";o=200}var g=(e[0]-b)/2;var k=((e[1]-o)/2)-30;if(g<0){g=0}if(k<30){k=30}var m=mxScrolled();var i=0;if(this.gallery.single){i=-10}if(d.style.display=="none"){var f,p;if(this.gallery.thumbs&&0){f=mxOffsetPosition(this.gallery.thumbs);p=[this.gallery.thumbs.offsetWidth,this.gallery.thumbs.offsetHeight]}else{$(d).setStyle("opacity",0);var e=mxWinSize();var a=mxScrolled();f=[g+m[0],k+m[1]+i];p=[b,o]}d.setStyles({left:f[0],top:f[1],width:p[0],height:p[1]})}var c=h.firstChild;if(c){h.removeChild(c)}var n=new Fx.Morph(d.id,{duration:this.gallery.DELAY,transition:Fx.Transitions.Circ.easeOut,onComplete:new Function("getGM().showPic('"+this.gallery.id+"',"+this.id+",1)")});n.start({top:k+m[1]+i,height:o,left:g+m[0],width:b,opacity:1})};mxGalleryItemPrototype.createEmpty=function(a){if(!this.gallery.thumbs){return}this.show_empty=true;if(!this.empty){this.empty=new Element("div",{"class":"gthumbnail empty",id:"g"+this.gallery.id+"empty"+this.id,styles:{width:this.gallery.thumbWidth(),height:this.gallery.thumbHeight()}})}if(!a){this.empty.inject(this.gallery.thumbs)}else{this.empty.inject(a,"before")}};mxGalleryItemPrototype.remove=function(){if(!this.gallery.thumbs){return}if(!this.container||!this.visible){return}this.visible=false;new Fx.Morph(this.container.id,{duration:10,transition:Fx.Transitions.linear}).start({opacity:0});this.gallery.thumbs.removeChild(this.container)};
