var Menu = {
	effects: $H(),
	colors: ["#fc2600"],
	cancelEffect: function(className) {
		if (this.effects.get(className)) {
			this.effects.get(className).cancel();
		}
	},
	initialize: function(id, property, dflt) {
	    var skip = property == "color";
	    if (!$(id)) return;
	    $(id).select("a").each(function(link, i) {
		    Menu.effects.set(i, null);
		
		    link.observe("mouseover", function() {
			    Menu.cancelEffect(i);
			    if (link.hasClassName("currentpage")) return;			    
			    var color = skip ? "" : "; color: #fff";
			    var effect = new Effect.Morph(link, {
				    style: property + ":" + Menu.colors[i%Menu.colors.length] + color,
				    duration: 0.3
			    });
			    Menu.effects.set(i, effect);
		    });
		
		    link.observe("mouseout", function() {
			    Menu.cancelEffect(i);
			    if (link.hasClassName("currentpage")) return;
			    var color = skip ? "" : (";color: " + link.hasClassName("currentpage") ? Menu.colors[i%Menu.colors.length] : "#fff");
			    var effect = new Effect.Morph(link, {
				    style: property + ":" + dflt + color,
				    duration:  0.4
			    });
			    Menu.effects.set(i, effect);
		    });
	    });
	}
};

document.observe("dom:loaded", function() {
    Menu.initialize("bar-holder", "color", "#beb29b");
});

