function versionInfo() {
	popUp('/whichVersion.html', 'which', 550, 520);
}
function terms() {
	popUp('/subscribeTerms.html', 'terms', 450, 400);
}

function popUp(url, name, height, width) {
	window.open(url, name, "width=" + width + ",height=" + height + ",menubar=no,scrollbars=yes,toolbar=no,status=no,location=no");
}

function rollover(el, state) {
	if (el) {
		var undsc_pos = el.src.lastIndexOf("_");
		if (undsc_pos == -1) return;

		var dot_pos = el.src.lastIndexOf(".");
		if (dot_pos == -1) return;

		var img_prefix = el.src.substring(0, undsc_pos);
		var extension = el.src.substring(dot_pos);

		el.src = img_prefix + "_" + state + extension;
	}
}

function preload(el, state) {
	if (el) {
		var undsc_pos = el.src.lastIndexOf("_");
		if (undsc_pos == -1) return;

		var dot_pos = el.src.lastIndexOf(".");
		if (dot_pos == -1) return;

		var img_prefix = el.src.substring(0, undsc_pos);
		var extension = el.src.substring(dot_pos);

		var img = new Image(el.width, el.height);
		img.src = img_prefix + "_" + state + extension;
	}
}

var menutimeout;
var myrules = {
	'img.rollover' : function(el) {
		preload(el, "on");

		el.onmouseover = function() {
			rollover(this, "on");
		}
		el.onmouseout = function() {
			rollover(this, "off");
		}
		el = null;
	},
	'img.rollover_archive' : function(el) {
		preload(el, "over");

		el.onmouseover = function() {
			rollover(this, "over");
		}
		el.onmouseout = function() {
			rollover(this, "off");
		}
		el = null;
	},
	'div#editions div#cities a' : function(el) {
		el.onmouseover = function() {
			Element.setStyle(this, { 'background-color':'#67999A','color':'#fff' });
		}
		el.onmouseout = function() {
			Element.setStyle(this, { 'background-color':'#E4F1D5','color':'#000' });
		}
		el = null;
	},
	'div#editions div#edition_menu' : function(el) {
		el.onmouseover = function() {
			clearTimeout(menutimeout);
			Element.show('cities');
		}
		el.onmouseout = function() {
			menutimeout = setTimeout(function() { Element.hide('cities'); }, 150);
		}
		el = null;
	}
};

Behaviour.register(myrules);