var navigationRules = {
	'.navigation:mouseover':function(el,ev) {
		if (el.src.indexOf('-alt.jpg') == -1) {
			el.src = el.src.replace(/.jpg/, '-alt.jpg');
		}
	},
	'.navigation:mouseout':function(el,ev) {
		if (el.src.indexOf('-alt.jpg') >= 0) {
			if (currentPage(el)) {
				// leave selected
			}
			else {
				el.src = el.src.replace(/-alt.jpg/, '.jpg');
			}
		}
	},
	'.navigation':function(el) {
		if (currentPage(el)) {
			el.src = el.src.replace(/.jpg/, '-alt.jpg');
		}
	},
	'.iotd':function(el) {
		var _images = new Array();
		var _now = new Date();
		var _src = el.src.substring(0, el.src.lastIndexOf('/') + 1);
		_images[0] = 'iotd-0.jpg';
		_images[1] = 'iotd-1.jpg';
		_images[2] = 'iotd-2.jpg';
		_images[3] = 'iotd-3.jpg';
		_images[4] = 'iotd-4.jpg';
		_images[5] = 'iotd-5.jpg';
		_images[6] = 'iotd-6.jpg';
		_images[7] = 'iotd-7.jpg';
		el.src = _src + _images[_now.getMinutes() % _images.length];
	},
	'.offsite:click':function(el,ev) {
/*		Event.stop(ev);
		console.log("ev = " + el.href);
		openConfirm("You are following a link to a site that may not be affiliated with the Kalsbeek family.");
*/	}
}
function currentPage(el) {
	var _ret = false;
	var _filename = el.src.substring(el.src.lastIndexOf('/') + 1, el.src.indexOf('.', el.src.lastIndexOf('/') + 1)).toLowerCase();
	_filename = _filename.replace(/-alt/, '').replace(/nav-/, '');
	var _pagename = location.pathname.substring(1, location.pathname.lastIndexOf('.')).toLowerCase();
	if (_pagename == '/' || _pagename == 'index') {
		_pagename = 'home'
	}
	if (_filename == _pagename) {
		_ret = true;
	}
	var _tld = '';
	if (_pagename.indexOf('/') > 0) {
		_tld = _pagename.substring(0, _pagename.indexOf('/'));
	}
	if (_filename == _tld) {
		_ret = true
	}
	return _ret;
}
function openConfirm(msg) {
	Dialog.confirm(msg, 
			   {className: "alphacube", okLabel: "Yes", cancelLabel:"No"})
}
function openAlert(msg) {
	Dialog.alert(msg, {windowParameters: {className: "alphacube"}})
}
