// Anchorizer Class
// Prototype Library needed (tested on 1.5.1)
// made by Bumbo

Anchorizer = Class.create();

Anchorizer.prototype = {
	mouseover: function(e) {
		Event.stop(e);

		this.anchor.addClassName('hover');
	},
	
	mouseout: function(e) {
		Event.stop(e);
		
		this.anchor.removeClassName('hover');
	},
	
	click: function(e) {
		window.location = this.link;
	},
	
	initialize: function(anchor) {
		this.anchor = anchor;
		this.link = this.anchor.down('a').href;
		
		if (this.link) {
			Event.observe(this.anchor, 'mouseover', this.mouseover.bindAsEventListener(this));
			Event.observe(this.anchor, 'mouseout', this.mouseout.bindAsEventListener(this));
			Event.observe(this.anchor, 'click', this.click.bindAsEventListener(this));
		}
	}
}

function initAnchorizers() {
	$$('.anchor').each(function(anchor) {
		var obj = new Anchorizer(anchor);
	});
}

/* using addDOMLoadEvent? */
if (typeof addDOMLoadEvent != "undefined") {
	addDOMLoadEvent(initAnchorizers);
} else {
	Event.observe(window, 'load', initAnchorizers, false);
}
