﻿addLoadEvent(function() {
	lookzListBehaviour();
});

function lookzListBehaviour() {
	var lookzList = $('lookz_list');
	if (!lookzList) return;

	// Get all <li>s in list and loop through them.
	var items = lookzList.getElementsByTagName('li');
	for (var i = 0; i < items.length; i++) {

		// Ensure pointer cursor is displayed on <li> hover.
		items[i].style.cursor = 'pointer';

		// When the <li> is hovered upon, add 'hover' class.
		items[i].onmouseover = function() {
			addClass(this, 'hover');
		};

		// When the <li> is moused off of, remove 'hover' class.
		items[i].onmouseout = function() {
			removeClass(this, 'hover');
		};

		// When the <li> is clicked, determine URL and go to it.
		items[i].onclick = function() {
			var url = this.getElementsByTagName('a')[0].getAttribute('href');
			window.location = url;
		};
	}
}
