if (typeof VALSPLAT == 'undefined') {
	var VALSPLAT = {}
}

VALSPLAT.hoverBlocks = {

	/**
	 * Initialize the mouseover effects for all the hoverblocks
	 */
	init: function () {
		$$('div.hover-block').each(VALSPLAT.hoverBlocks.attachEvents);		
	},

	/**
	 * attach eventhandlers for the events
	 */
	attachEvents: function (el) {
		el.getChildren()[0].addEvents({
			'mouseover': VALSPLAT.hoverBlocks.mouseOver,
			'mouseout': VALSPLAT.hoverBlocks.mouseOut,
			'click': VALSPLAT.hoverBlocks.click
		});
	},

	/**
	 * Switch the classes around on mouseover
	 */
	mouseOver: function () {
		this.getParent().removeClass('hover-block');
		this.getParent().addClass('mouseover');

		window.status = this.getElement('a.block-link').get('href');
	},

	/**
	 * Switch the classes around on mouseout
	 */
	mouseOut: function () {
		this.getParent().removeClass('mouseover');
		this.getParent().addClass('hover-block');

		window.status = '';
	},

	/**
	 * Redirect the page based on the href of the designated link
	 */
	click: function (e) {
		if (!(e.target.nodeName.toLowerCase() == 'div' && e.target.className == 'mouseover')) {
			document.location.href = this.getElement('a.block-link').get('href');
		}
	}
}

window.addEvent('domready', VALSPLAT.hoverBlocks.init);