/**
* Authors	: Samuel Birch
* Licence	: Open Source MIT Licence
*/
var ImageMenu=new Class({getOptions:function(){return{onOpen:false,onClose:Class.empty,openWidth:200,transition:Fx.Transitions.quadOut,duration:400,open:null,border:0}},initialize:function(b,a){this.setOptions(this.getOptions(),a);this.elements=$$("#"+b+" a");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(d,c){d.addClass("nasconditesto");d.addEvent("mouseenter",function(f){new Event(f).stop();this.reset(c)}.bind(this));d.addEvent("mouseleave",function(f){new Event(f).stop();this.reset(this.options.open)}.bind(this));var e=this;d.addEvent("click",function(f){if(e.options.onOpen){new Event(f).stop();if(e.options.open==c){e.options.open=null;e.options.onClose(this.href,c)}else{e.options.open=c;e.options.onOpen(this.href,c)}}})}.bind(this));if(this.options.open){if($type(this.options.open)=="number"){this.reset(this.options.open)}else{this.elements.each(function(d,c){if(d.id==this.options.open){this.reset(c)}},this)}}},reset:function(a){if($type(a)=="number"){var b=this.widths.openOthers}else{var b=this.widths.closed}var c={};this.elements.each(function(f,e){var d=b;if(e==this.elements.length-1){d=b+5}c[e]={width:d}}.bind(this));if($type(a)=="number"){c[a]={width:this.widths.openSelected}}this.fx.start(c)}});ImageMenu.implement(new Options);ImageMenu.implement(new Events);
