// Animenu
// version 1.0.0 080929
// Copyright Artlogic www.artlogic.net

aniMenuOps = Object.extend({

	// Parameters you can set
	
	elementId: 	'navigation',
	tagName: 	'img',
	
	cssControl: 	'opacity',
	defaultState: 	'1',
	hoverState: 	'0',
	activeState: 	'1',
	animateSpeed: 	'0.4'
	
}, window.aniMenuOps || {});

var aniMenu = Class.create();

aniMenu.prototype = {
	initialize: function() {
		var els = document.getElementById(aniMenuOps.elementId).getElementsByTagName(aniMenuOps.tagName);
		var idCount = '1';
		for(var i=0; i<els.length; i++) {
			els[i].onmouseover = this.animChange;
			els[i].onmouseout = this.animRestore;
			if (els[i].id == '') {
				els[i].id = 'el' + idCount;
				idCount = parseInt(idCount) + parseInt('1');
			}
			if (els[i].className == 'active') {
				els[i].onmouseover = '';
				els[i].onmouseout = '';
				new Effect.Morph(els[i], {style: aniMenuOps.cssControl + ':' + aniMenuOps.activeState + ';',duration:0});
			}
		}
	},
	animChange: function() {
		var queue = Effect.Queues.get(this.id);
		queue.each(function(effect) { effect.cancel(); });
		new Effect.Morph(this, {style: aniMenuOps.cssControl + ':' + aniMenuOps.hoverState + ';',duration:(aniMenuOps.animateSpeed / 3), queue: { position: 'end', scope: this.id }});
	},
	animRestore: function() {
		new Effect.Morph(this, {style: aniMenuOps.cssControl + ':' + aniMenuOps.defaultState + ';',duration:aniMenuOps.animateSpeed, queue: { position: 'end', scope: this.id }});
	}
};

document.observe('dom:loaded', function () { new aniMenu(); });