window.onload = function () {
	var x = document.getElementsByTagName('a');
	var regEx = new RegExp('^http:\/\/' + escapeRegEx(window.location.host) + '\/bildeserier\/.+$');

	for (var i=0;i<x.length;i++)
	{
		if (regEx.test(x[i].href))
			x[i].href = 'javascript:openGallery(\'' + x[i].href + '\');';
	}
}

function openGallery (URL)
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=1070,height=700');");
}

function escapeRegEx (text) {
  if (!arguments.callee.sRE) {
    var specials = [
      '/', '.', '*', '+', '?', '|',
      '(', ')', '[', ']', '{', '}', '\\'
    ];
    arguments.callee.sRE = new RegExp(
      '(\\' + specials.join('|\\') + ')', 'g'
    );
  }
  return text.replace(arguments.callee.sRE, '\\$1');
}