/**
 * Section link initialiser
 *
 * Initialises the links to major site sections by applying an
 * onclick event to <p> elements within #section-links.
 *
 * Also applies an onmouseover event to simulate :hover for IE
 *
 * @author scampbell
 */

window.onload = init_section_links;

function init_section_links() {
	var sectionLinksHolder = document.getElementById('section-links');
	if (!sectionLinksHolder) {
		return;
	}

	var sectionLinks = sectionLinksHolder.getElementsByTagName('p');
	for (var ii = 0; ii < sectionLinks.length; ii++) {
		var sectionLink = sectionLinks[ii];

		//get the target of the link contained in each <p>
		var innerLink = sectionLink.getElementsByTagName('a').item(0);
		sectionLink.href = innerLink.href;

		//create an onclick event for each <p>
		sectionLink.onclick = function() {
			window.location.href = this.href;
		}

		//modify style to give visual 'clickable' cue
		sectionLink.style.cursor = 'pointer';

		//IE only: add 'fake' hover status to each <p>
		if (document.getElementById && document.all) {
			sectionLink.onmouseover = function() {
				this.className += ' hover';
			}
			sectionLink.onmouseout = function() {
				this.className = this.className.replace(' hover', '');
			}
		}
	}
}