//--- Image swapping class
var imageSwap = Fx.Base.extend({

	getOptions: function(){
		return {
			action: "click" ,
			linkOnClass: "linkOn",
			linkOffClass: "linkOff"
		};
	},

	initialize: function(blocks, links, options){
		this.setOptions(this.getOptions(), options);
		this.currentBlock = -1 ;
		this.blocks = $$(blocks);
		this.links = $$(links);

		// entirely possible for blocks and activating links not to match up!
		if (this.blocks.length != this.links.length) return ;

		this.links.each(function(link, i){
			link.addEvent(this.options.action, this.display.bind(this, i));
		}, this);

		this.effects = new Fx.Elements(this.blocks, {duration: 2000});
		this.blocks.each(function(el){
			el.setStyle('opacity',0);
		});
		this.display(0);
	},

	display: function(iToShow){
		action = {} ;
		this.blocks.each(function(el, idx){
			if (idx == iToShow){	// show
				$(this.links[idx]).removeClass(this.options.linkOffClass).addClass(this.options.linkOnClass);
				action[idx.toString()] = {'opacity': [1]};
			} else {
				$(this.links[idx]).removeClass(this.options.linkOnClass).addClass(this.options.linkOffClass);
				action[idx.toString()] = {'opacity': [0]};
			}
		}, this);
		this.currentBlock = iToShow;
		this.effects.start(action);

		// set height of containing element (bigshadow) to that of currentBlock
		//var height = this.blocks[iToShow].getStyle('height').toInt();
		//$$('.bigshadow').setStyle('height',height+'px');

	}

});
