function hoverPanel(display, availability, image, name, description) {
	if (display) {
		$('gridhoverpanel').update('<div class="imgwrapper"><img src="'+image+'" alt="" /></div><p><span>'+name+'</span>'+description+'</p>');
		document.observe('mousemove', function(event) {
			var x = Event.pointerX(event) + 15;
			var y = Event.pointerY(event) - 173;
			$('gridhoverpanel').setStyle({
				'left':x+'px',
				'top':y+'px'
			});
		});
		$('gridhoverpanel').className = availability;
		$('gridhoverpanel').setStyle({'display':'block'});
	} else {
		document.stopObserving('mousemove');
		$('gridhoverpanel').setStyle({
			'display':'none',
			'left':'-500px'
		});
	}
}

function addIntroToggle(){
	$('toggleintro').writeAttribute('href', '#');
	$('toggleintro').observe('click', function(event) {
		toggleIntroduction();
		event.stop();
	});
}

function toggleIntroduction() {
	if ($('intro').getStyle('display') == 'none') {
		$('intro').setStyle({'display':'block'});
		$('toggleintro').writeAttribute('title', 'Hide introduction');
		$('toggleintro').firstDescendant().writeAttribute('alt', 'Hide introduction');
		$('toggleintro').firstDescendant().writeAttribute('src', '/images/minusblocks/orange.png');
		deleteCookie('hidehomepageintroduction');
	} else {
		$('intro').setStyle({'display':'none'});
		$('toggleintro').writeAttribute('title', 'Show introduction');
		$('toggleintro').firstDescendant().writeAttribute('alt', 'Show introduction');
		$('toggleintro').firstDescendant().writeAttribute('src', '/images/plusblocks/orange.png');
		setCookie('hidehomepageintroduction', '1', 365);
	}
}

function setCookie(name, value, days) {
	var date = new Date();
	date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
	document.cookie = name+'='+value+'; expires='+date.toGMTString()+'; path=/';
}

function deleteCookie(name) {
	setCookie(name, '', -1);
}
