/* Script to add some fx to the references on max&partner */
/* (c) 2009 S. Teuber, Düsseldorf */

var maxpa = {

	// Show the reference image
	show : function (el) {
		// Get the id
		var myId = this.id.replace(/^mpref-link-/g, '');

		// Show the image
		if ($('mpref-' + myId)) {
			var myTween = new Fx.Morph($('mpref-' + myId));
			myTween.start({
				opacity: [0, 1]
			});
		}
	},

	// Hide the reference image
	hide : function (el) {
		// Get the id
		var myId = this.id.replace(/^mpref-link-/g, '');

		// Hide the image
		if ($('mpref-' + myId)) {
			var myTween = new Fx.Morph($('mpref-' + myId));
			myTween.start({
				opacity: [1, 0]
			});
		}
	},


	// Scan the page for reference links and prime them
	scanPage : function () {
		var myLinks = $$(document.links).filter(function(el) {
			return el.rel && el.rel.test(/^mpref/i);
		});

		for (var i = 0; i < myLinks.length; i++) {
			$(myLinks[i].id).addEvent('mouseover', maxpa.show);
			$(myLinks[i].id).addEvent('mouseout', maxpa.hide);
		}
	}
}

window.addEvent('domready', maxpa.scanPage);
