Effect.Squish = function(element) {  return new Effect.Scale(element, window.opera ? 1 : 0,    Object.extend({ restoreAfterFinish: true,      beforeSetup: function(effect) {        effect.element.makeClipping(effect.element); },      afterFinishInternal: function(effect) {        effect.element.hide(effect.element);        effect.element.undoClipping(effect.element); }    }, arguments[1] || {})  );};/* * Gallery Class * @author: Daniel Auener <daniel@internetavdelningen.se> */var Gallery = Class.create({ 	initialize: function(galleryElement,galleryConfig) { 			this.galleryElement = galleryElement;			this.galleryConfig = galleryConfig;		this.list = this.galleryElement.select("li");		if (this.list.size() > 0) {			this.galleryElement.up(".clsGalleryWrapper").setStyle({display:"block"});		}		this.iterator = 0;		this.effect = galleryConfig.down("input#idGalleryEffect") ? galleryConfig.down("input#idGalleryEffect").value : "fade";		this.effects = new Array("fade","blind","slide","fold","drop","puff","shrink","squish");		this.changing = false;	},		change: function() {						if (!this.changing) {						this.changing = true;						// get direction					var direction = ($A(arguments).size() > 1) ? $A(arguments)[1] : null;			var stopPe = ($A(arguments).size() > 2) ? $A(arguments)[2] : null;						if (stopPe) this.pe.stop();						// save current index			var current = this.iterator;				// adjust layer level			this.list[current].setStyle({zIndex:"2"});				// increase iterator			if (direction == "prev") this.iterator = (this.iterator-1 < 0) ? this.list.size()-1 : this.iterator-1;			else this.iterator = (this.iterator+1 >= this.list.size()) ? 0 : this.iterator+1;				this.list[this.iterator].setStyle({display:"block",zIndex:"1"});				var effect = (this.effect != "random") ? this.effect : this.effects[Math.ceil(Math.random()*this.effects.size())-1];						// use effect to change the image			switch (effect) {				case "fade": new Effect.Fade(this.list[current],{afterFinish:function() {this.changing = false;}.bind(this)}); break;				case "blind": new Effect.BlindUp(this.list[current],{afterFinish:function() {this.changing = false;}.bind(this)}); break;				case "slide": new Effect.SlideUp(this.list[current],{afterFinish:function() {this.changing = false;}.bind(this)}); break;				case "fold": new Effect.Fold(this.list[current],{afterFinish:function() {this.changing = false;}.bind(this)}); break;							case "drop": new Effect.DropOut(this.list[current],{afterFinish:function() {this.changing = false;}.bind(this)}); break;				case "puff": new Effect.Puff(this.list[current],{afterFinish:function() {this.changing = false;}.bind(this)}); break;										case "shrink": new Effect.Shrink(this.list[current],{afterFinish:function() {this.changing = false;}.bind(this)}); break;										case "squish": new Effect.Squish(this.list[current],{afterFinish:function() {this.changing = false;}.bind(this)}); break;										default: new Effect.Fade(this.list[current],{afterFinish:function() {this.changing = false;}.bind(this)}); break;			}				}	},			changeToIndex: function(index) {						if (!this.changing) {						if (this.iterator != index) {								this.changing = true;								// save current index				var current = this.iterator;								// adjust layer level				this.list[current].setStyle({zIndex:"2"});						// increase iterator				this.iterator = index;						this.list[this.iterator].setStyle({display:"block",zIndex:"1"});						var effect = (this.effect != "random") ? this.effect : this.effects[Math.ceil(Math.random()*this.effects.size())-1];								// use effect to change the image				switch (effect) {					case "fade": new Effect.Fade(this.list[current],{afterFinish:function() {this.changing = false;}.bind(this)}); break;					case "blind": new Effect.BlindUp(this.list[current],{afterFinish:function() {this.changing = false;}.bind(this)}); break;					case "slide": new Effect.SlideUp(this.list[current],{afterFinish:function() {this.changing = false;}.bind(this)}); break;					case "fold": new Effect.Fold(this.list[current],{afterFinish:function() {this.changing = false;}.bind(this)}); break;								case "drop": new Effect.DropOut(this.list[current],{afterFinish:function() {this.changing = false;}.bind(this)}); break;					case "puff": new Effect.Puff(this.list[current],{afterFinish:function() {this.changing = false;}.bind(this)}); break;											case "shrink": new Effect.Shrink(this.list[current],{afterFinish:function() {this.changing = false;}.bind(this)}); break;											case "squish": new Effect.Squish(this.list[current],{afterFinish:function() {this.changing = false;}.bind(this)}); break;											default: new Effect.Fade(this.list[current],{afterFinish:function() {this.changing = false;}.bind(this)}); break;				}					}		}	}	});/* * GalleryAutoChange Class * @author: Daniel Auener <daniel@internetavdelningen.se> */var GalleryAutoChange = Class.create(Gallery, { 	initialize: function($super,galleryElement,galleryConfig) { 					$super(galleryElement,galleryConfig);				this.startIntervall = this.galleryConfig.down("input#idGalleryStartIntervall") ? this.galleryConfig.down("input#idGalleryStartIntervall").value : 2;		this.changeIntervall = this.galleryConfig.down("input#idGalleryChangeIntervall") ? this.galleryConfig.down("input#idGalleryChangeIntervall").value : 2;					// position settings for picturefader		if (this.list.size() > 1) {			new PeriodicalExecuter(function(pe) {				new PeriodicalExecuter(this.change.bind(this), this.changeIntervall);				this.change();				pe.stop();			}.bind(this), this.startIntervall);		}	}	});/* * GalleryClickChange Class * @author: Daniel Auener <daniel@internetavdelningen.se> */var GalleryClickChange = Class.create(Gallery, { 	initialize: function($super,galleryElement,galleryConfig) { 							$super(galleryElement,galleryConfig);		this.nextElement = this.galleryElement.up(".clsGalleryWrapper").down(".clsNext");		this.prevElement = this.galleryElement.up(".clsGalleryWrapper").down(".clsPrev");				// position settings for picturefader		if (this.list.size() > 1 && this.nextElement && this.prevElement) {			this.nextElement.observe("click",this.change.bindAsEventListener(this,"next"));					this.prevElement.observe("click",this.change.bindAsEventListener(this,"prev"));				}	}	});/* * GalleryAutoClickChange Class * @author: Daniel Auener <daniel@internetavdelningen.se> */var GalleryAutoClickChange = Class.create(Gallery, { 	initialize: function($super,galleryElement,galleryConfig) { 					$super(galleryElement,galleryConfig);		this.nextElement = this.galleryElement.up(".clsGalleryWrapper").down(".clsNext");		this.prevElement = this.galleryElement.up(".clsGalleryWrapper").down(".clsPrev");				this.startIntervall = this.galleryConfig.down("input#idGalleryStartIntervall") ? this.galleryConfig.down("input#idGalleryStartIntervall").value : 2;		this.changeIntervall = this.galleryConfig.down("input#idGalleryChangeIntervall") ? this.galleryConfig.down("input#idGalleryChangeIntervall").value : 2;					// position settings for picturefader		if (this.list.size() > 1) {			this.pe = new PeriodicalExecuter(function(pe) {				this.pe = new PeriodicalExecuter(this.change.bind(this), this.changeIntervall);				this.change();				pe.stop();			}.bind(this), this.startIntervall);		}						// position settings for picturefader		if (this.list.size() > 1 && this.nextElement && this.prevElement) {			this.nextElement.observe("click",this.change.bindAsEventListener(this,"next",true));					this.prevElement.observe("click",this.change.bindAsEventListener(this,"prev",true));			}	}	});/* * GalleryAutoClickChange Class * @author: Daniel Auener <daniel@internetavdelningen.se> */var GalleryThumbChange = Class.create(Gallery, { 	initialize: function($super,galleryElement,galleryConfig) { 							$super(galleryElement,galleryConfig);				this.thumbs = galleryElement.previous(".clsGalleryThumbs").select(".clsThumb");				this.thumbs.each(function(thumb,index) {			this.thumbs[index].setStyle({opacity:0.6,cursor:"pointer"});			this.thumbs[index].observe("mouseover",function(event) {				this.thumbs[index].setStyle({opacity:1});			}.bind(this));			this.thumbs[index].observe("mouseout",function(event) {				this.thumbs[index].setStyle({opacity:0.6});			}.bind(this));			this.thumbs[index].observe("click",function(event) {				this.changeToIndex(index);			}.bind(this));		}.bind(this));			}	});/* * Inits and controlls all galleries on the website. * @author: Daniel Auener <daniel@internetavdelningen.se> */var GalleryController = Class.create({ 	initialize: function(selectorClass) { 				// get all galleries with selectorClass		this.galleryElements = $$("ul."+selectorClass);		this.galleries = new Array();					// initialize all galleries		this.galleryElements.each(function(gallery) {			var galleryConfig = gallery.previous(".clsGalleryConfig");			var galleryInstance = null;			var galleryType = galleryConfig.down("input#idGalleryType") ? galleryConfig.down("input#idGalleryType").value : "";			switch (galleryType) {				case "autoChange" : galleryInstance = new GalleryAutoChange(gallery,galleryConfig); break;				case "clickChange" : galleryInstance = new GalleryClickChange(gallery,galleryConfig); break;				case "autoClickChange" : galleryInstance = new GalleryAutoClickChange(gallery,galleryConfig); break;				case "thumbChange" : galleryInstance = new GalleryThumbChange(gallery,galleryConfig); break;				default: galleryInstance = new GalleryAutoChange(gallery,galleryConfig); break;			}			this.galleries.push(galleryInstance);		}.bind(this));			}});
