Hoverblocks = {
	init: function () {
		$$('.hoverblock').each(Hoverblocks.addEventHandlers);
	},

	// only if the div.hoverblock has an a.hoverlink add eventhandlers for various events
	addEventHandlers: function (el) {
		if (el.getElement('a.blocklink')) {
			el.addEvent('mouseover', Hoverblocks.mouseOverHandler);
			el.addEvent('mouseout', Hoverblocks.mouseOutHandler);
			el.addEvent('click', Hoverblocks.clickHandler);
		}
	},

	//swap classes on mouseover
	mouseOverHandler: function () {
		if (this.hasClass('videoitem-left')) {
			this.getParent().addClass('hoverblock-over-left');
		} else {
			this.getParent().addClass('hoverblock-over-right');
		}
	},

	//swap classes on mouseout
	mouseOutHandler: function () {
		this.getParent().removeClass('hoverblock-over-left');
		this.getParent().removeClass('hoverblock-over-right');
	},

	//redirect to the href value of the link designated with the class blocklink
	clickHandler: function () {
		document.location.href = this.getElement('.blocklink').get('href');
	}
}

window.addEvent('domready', Hoverblocks.init);