

function ALERT(value) { alert(value); return value; }

isMSIE = false;
if (navigator && navigator.userAgent) {
	var ua = navigator.userAgent.toUpperCase().toLowerCase();
	if ((ua.indexOf("msie") >= 0) ||
		(ua.indexOf("internet explorer") >= 0))
		{ isMSIE = true; }
}

DIGITS = [
	"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B",
	"C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
	"O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
];

JAN =  0; FEB =  1; MAR =  2; APR =  3; MAY =  4; JUN =  5;
JUL =  6; AUG =  7; SEP =  8; OCT =  9; NOV = 10; DEC = 11;

SUN = 0; MON = 1; TUE = 2; WED = 3; THU = 4; FRI = 5; SAT = 6;

MONTHS = [
	"January", "February", "March", "April", "May", "June",
	"July", "August", "September", "October", "November", "December"
];

MON = [
	"Jan", "Feb", "Mar", "Apr", "May", "Jun",
	"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
];

WEEKDAYS = [
	"Sunday", "Monday", "Tuesday", "Wednesday",
	"Thursday", "Friday", "Saturday"
];

WDY = [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ];

d = document;
d.w = d.write;
d.wl = d.writeln;

function imask(n) { return n & 0xFFFFFFFF; }
function iadd(a, b) { return imask(imask(a) + imask(b)); }
function isub(a, b) { return imask(imask(a) - imask(b)); }
function ineg(n) { return imask(-imask(n)); }
function imul(a, b) { return imask(imask(a) * imask(b)); }
function idiv(a, b) { return imask(imask(a) / imask(b)); }
function imod(a, b) { return imask(imask(a) % imask(b)); }

function randomBoolean() { return Math.random() < 0.5; }

__WHITESPACE = "" +
	"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" +
	"\u0008\u0009\u000A\u000B\u000C\u000D\u000E\u000F" +
	"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" +
	"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F\u0020" +
	"\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006" +
	"\u2008\u2009\u200A\u200B\u2028\u2029\u205F\u3000";

function strcmp(a, b) {
	var length, index, diff;
	length = (a.length < b.length) ? a.length : b.length;
	for (index = 0; index < length; index++) {
		diff = a.charCodeAt(index) - b.charCodeAt(index);
		if (diff)
			return diff;
	}
	return a.length - b.length;
}

function strcasecmp(a, b) { return strcmp(a.toUC().toLC(), b.toUC().toLC()); }

function strcmp2(a, b) { return strcasecmp(a, b) || strcmp(a, b); }

function numcmp(a, b) { return (a < b) ? -1 : (a > b) ? 1 : 0; }

String.prototype.toUC = function() {
	var uc = this.__UPPERCASE;
	if (!uc) {
		uc = this.toUpperCase();
		if (uc == this)
			uc = this;
		this.__UPPERCASE = uc.__UPPERCASE = uc;
	}
	return uc;
};

String.prototype.toLC = function() {
	var lc = this.__LOWERCASE;
	if (!lc) {
		lc = this.toLowerCase();
		if (lc == this)
			lc = this;
		this.__LOWERCASE = lc.__LOWERCASE = lc;
	}
	return lc;
};

String.prototype.trim = function() {
	var trimmed, begin, end;
	trimmed = this.__TRIMMED;
	if (!trimmed) {
		begin = 0;
		while (begin < this.length) {
			if (__WHITESPACE.indexOf(this.charAt(begin)) < 0)
				break;
			begin++;
		}
		end = this.length;
		while (end > begin) {
			if (__WHITESPACE.indexOf(this.charAt(end - 1)) < 0)
				break;
			end--;
		}
		trimmed = (begin == end) ? "" :
			(begin == 0 && end == this.length) ? this :
			(trimmed == this) ? this :
			this.substring(begin, end);
		this.__TRIMMED = trimmed.__TRIMMED = trimmed;
	}
	return trimmed;
};

String.prototype.toHash = function() {
	var code, index;
	code = this.__HASHCODE;
	if (!code) {
		code = 0;
		for (index = 0; index < this.length; index++)
			code = iadd(imul(code, 31), this.charCodeAt(index));
		this.__HASHCODE = code;
	}
	return code;
};

if (!String.prototype.hashCode)
	String.prototype.hashCode = String.prototype.toHash;

String.prototype.toUTF8 = function() {
	var str, index, code;
	str = this.__TO_UTF8;
	if (!str) {
		str = "";
		for (index = 0; index < this.length; index++) {
			code = this.charCodeAt(index) & 0x1FFFFF;
			if (code < 0x80) {
				str += String.fromCharCode(code);
			} else if (code < 0x800) {
				str += String.fromCharCode(
					0xC0 | (code >> 6),
					0x80 | (code & 0x3F)
				);
			} else if (code < 0x10000) {
				str += String.fromCharCode(
					0xE0 | (code >> 12),
					0x80 | ((code >> 6) & 0x3F),
					0x80 | (code & 0x3F)
				);
			} else {
				str += String.fromCharCode(
					0xF0 | (code >> 18),
					0x80 | ((code >> 12) & 0x3F),
					0x80 | ((code >> 6) & 0x3F),
					0x80 | (code & 0x3F)
				);
			}
		}
		if (str.length == this.length)
			str = this;
		this.__TO_UTF8 = str;
		str.__FROM_UTF8 = this;
	}
	return str;
};

String.prototype.fromUTF8 = function() {
	var str, index, c, d, e, f;
	str = this.__FROM_UTF8;
	if (!str) {
		str = "";
		index = 0;
		while (index < this.length) {
			c = this.charCodeAt(index++) & 0xFF;
			if (c < 0x80) {
				str += String.fromCharCode(c);
			} else if (c < 0xC0) {
				continue;
			} else if (c < 0xE0) {
				if (index <= this.length - 1) {
					d = this.charCodeAt(index++) & 0xFF;
					str += String.fromCharCode(
						((c & 0x1F) << 6) |
						(d & 0x3F)
					);
				} else {
					break;
				}
			} else if (c < 0xF0) {
				if (index <= this.length - 2) {
					d = this.charCodeAt(index++) & 0xFF;
					e = this.charCodeAt(index++) & 0xFF;
					str += String.fromCharCode(
						((c & 0x0F) << 12) |
						((d & 0x3F) << 6) |
						(e & 0x3F)
					);
				} else {
					break;
				}
			} else {
				if (index <= this.length - 3) {
					d = this.charCodeAt(index++) & 0xFF;
					e = this.charCodeAt(index++) & 0xFF;
					f = this.charCodeAt(index++) & 0xFF;
					str += String.fromCharCode(
						((c & 0x07) << 18) |
						((d & 0x3F) << 12) |
						((e & 0x3F) << 6) |
						(f & 0x3F)
					);
				} else {
					break;
				}
			}
		}
		if (str.length == this.length)
			str = this;
		this.__FROM_UTF8 = str;
	}
	return str;
};

String.prototype.encode = function() {
	var utf8, str, index, code;
	str = this.__ENCODED;
	if (!str) {
		utf8 = this.toUTF8();
		str = "";
		for (index = 0; index < utf8.length; index++) {
			code = utf8.charCodeAt(index) & 0xFF;
			if (code == 0x20) {
				str += '+';
			} else if (code == 0x2D || code == 0x2E ||
				(code >= 0x30 && code <= 0x39) ||
				(code >= 0x41 && code <= 0x5A) ||
				code == 0x5F ||
				(code >= 0x61 && code <= 0x7A)
			) {
				str += String.fromCharCode(code);
			} else {
				str += '%' +
					DIGITS[code >> 4] +
					DIGITS[code & 0xF];
			}
		}
		if (str == utf8)
			str = utf8;
		this.__ENCODED = str;
		str.__DECODED = this;
	}
	return str;
};

String.prototype.decode = function() {
	var str, index, c, d, e, a, b;
	str = this.__DECODED;
	if (!str) {
		str = "";
		index = 0;
		while (index < this.length) {
			c = this.charCodeAt(index++);
			if (c == 0x2B) {
				str += ' ';
			} else if (c == 0x25 && index <= this.length - 2) {
				d = this.charCodeAt(index++);
				if (d >= 0x30 && d <= 0x39) {
					a = d - 0x30;
				} else if (d >= 0x41 && d <= 0x47) {
					a = d - 0x37;
				} else if (d >= 0x61 && d <= 0x67) {
					a = d - 0x57;
				} else {
					a = -1;
				}
				e = this.charCodeAt(index++);
				if (e >= 0x30 && e <= 0x39) {
					b = e - 0x30;
				} else if (e >= 0x41 && e <= 0x47) {
					b = e - 0x37;
				} else if (e >= 0x61 && e <= 0x67) {
					b = e - 0x57;
				} else {
					b = -1;
				}
				if ((a | b) < 0) {
					str += '%' +
						String.fromCharCode(d) +
						String.fromCharCode(e);
				} else {
					str += String.fromCharCode((a<<4)|b);
				}
			} else {
				str += String.fromCharCode(c);
			}
		}
		str = str.fromUTF8();
		if (str == this)
			str = this;
		this.__DECODED = str;
	}
	return str;
};

String.prototype.toHashtable = function() {
	var table, offset, index, index2, index3, token, key, value;
	table = new Object();
	offset = 0;
	while (offset < this.length) {
		index = this.indexOf('&', offset);
		if (index < 0)
			index = this.length;
		index2 = this.indexOf(';', offset);
		if (index2 < 0)
			index2 = this.length;
		if (index > index2)
			index = index2;
		token = this.substring(offset, index).trim();
		if (token) {
			index2 = token.indexOf(':');
			if (index2 < 0)
				index2 = token.length;
			index3 = token.indexOf('=');
			if (index3 < 0)
				index3 = token.length;
			if (index2 > index3)
				index2 = index3;
			if (index2 == token.length) {
				key = token.decode();
				value = true;
			} else {
				key = token.substring(0, index2
					).trim().decode();
				value = token.substring(index2 + 1
					).trim().decode();
			}
			table[key] = value;
		}
		offset = index + 1;
	}
	return table;
};

function maxList(list) {
	var max, length, index;
	max = 0;
	length = list.length;
	for (index = 0; index < length; index++) {
		var value = list[index];
		if (max < value)
			max = value;
	}
	return max;
}

function arraycopy(a, aOff, b, bOff, len) {
	aOff |= 0;
	bOff |= 0;
	len |= 0;
	if (!a || !b || len < 0 ||
		aOff < 0 || bOff < 0 ||
		aOff + len > a.length || bOff + len > b.length)
		{ return false; }
	while (len > 0) {
		b[bOff++] = a[aOff++];
		len--;
	}
	return true;
}

if (!Array.prototype.clone) {
	Array.prototype.clone =
		function() { return this.slice(0, this.length); };
}

if (!Array.prototype.shuffle) {
	Array.prototype.shuffle = function() {
		var index;
		for (index = 1; index < this.length; index++) {
			var e = this.splice(index, 1)[0];
			this.splice(imask(Math.random() * (index + 1)), 0, e);
		}
		return this;
	};
}

Array.prototype.random =
	function() { return this[imask(Math.random() * this.length)]; };

function isDate(time, mon, date) {
	return (time.getMonth() == mon) && (time.getDate() == date);
}

function isWesternChristmas(time) {
	return isDate(time, DEC, 25);
}

function isOrthodoxChristmas(time) {
	return isDate(time, JAN, 7);
}

function isChristmas(time) {
	return isWesternChristmas(time) || isOrthodoxChristmas(time);
}

function isEaster(time) {
	return isDate(time, APR, 6);
}

function isLaNaomhPadraig(time) {
	return isDate(time, MAR, 17);
}

function isWinterSolstice(time) {
	return isDate(time, DEC, 21);
}

function isSummerSolstice(time) {
	return isDate(time, JUN, 21);
}

function isSolstice(time) {
	return isWinterSolstice(time) || isSummerSolstice(time);
}

function isSpringEquinox(time) {
	return isDate(time, MAR, 21);
}

function isAutumnEquinox(time) {
	return isDate(time, SEP, 23);
}

function isEquinox(time) {
	return isSpringEquinox(time) || isAutumnEquinox(time);
}

Date.fromTime = function(time) {
	var date = new Date();
	date.setTime(time);
	return date;
};

Date.prototype.toCookieDate = function() {
	// Wdy, DD-Mon-YY HH:MM:SS GMT
	var string, value;
	string = WDY[this.getUTCDay()];
	string += ', ';
	value = this.getUTCDate();
	if (value < 10)
		string += '0';
	string += value;
	string += '-';
	string += MON[this.getUTCMonth()];
	string += '-';
	value = '' + this.getUTCFullYear();
	if (value.length > 2)
		value = value.substring(value.length - 2, value.length);
	string += value;
	string += ' ';
	value = this.getUTCHours();
	if (value < 10)
		string += '0';
	string += value;
	string += ':';
	value = this.getUTCMinutes();
	if (value < 10)
		string += '0';
	string += value;
	string += ':';
	value = this.getUTCSeconds();
	if (value < 10)
		string += '0';
	string += value;
	string += ' GMT';
	return string;
};

function toDateString(time) {
	var date, str, n;
	date = Date.fromTime(time);
	n = date.getUTCFullYear();
	str = String(n) + '.';
	n = String(date.getUTCMonth() + 1);
	while (n.length < 2)
		n = "0" + n;
	str += n + '.';
	n = String(date.getUTCDate());
	while (n.length < 2)
		n = "0" + n;
	str += n;
	return str;
}

function randomBool() { return imask(Math.random() * 2); }

LOCATION = location.href || "";
QUERY_STRING = "";
if (LOCATION) {
	LOCATION = String(LOCATION);
	var index = LOCATION.indexOf('?');
	if (index >= 0) {
		QUERY_STRING = LOCATION.substring(index + 1);
		LOCATION = LOCATION.substring(0, index);
	}
}
QUERY = QUERY_STRING.toHashtable();
COOKIE = document.cookie ? document.cookie.toHashtable() : new Object();

function setCookie(key, value, expires) {
	var string = key.encode() + '=' + value.encode();
	if (expires)
		string += '; expires=' + expires.toCookieDate();
	document.cookie = string;
	COOKIE[key] = String(value);
	return string;
}

function setYearCookie(key, value) {
	setCookie(key, value, Date.fromTime(NOWMILLIS + (365 * 24 * 60 * 60 * 1000)));
}

NOW = new Date();
NOWMILLIS = NOW.getTime();
NOW_HOUR = NOW.getHours();

function chat(right, file, name, text, width) {
	var align = right ? "right" : "left";
	width = width || 1;
	return '<td class="t3" colspan="' + width + '" align="' + align + '" valign="top">' +
		'<img src="' + file + '_' + align + '.gif" alt="" ' +
		'align="' + align + '" />' + name + '<br/>' + text +
		'</td>\n';
}

function chat_dermot_left(text, width)
	{ return chat(false, 'dermot', "Dermot", text, width); }
function chat_dermot_right(text, width)
	{ return chat(true, 'dermot', "Dermot", text, width); }
function chat_arf_left(text, width)
	{ return chat(false, 'arf', "Arf", text, width); }
function chat_arf_right(text, width)
	{ return chat(true, 'arf', "Arf", text, width); }
function chat_bauske_left(text, width)
	{ return chat(false, 'bauske', "Bauske", text, width); }
function chat_bauske_right(text, width)
	{ return chat(true, 'bauske', "Bauske", text, width); }
function chat_brad_left(text, width)
	{ return chat(false, 'brad', "Brad", text, width); }
function chat_brad_right(text, width)
	{ return chat(true, 'brad', "Brad", text, width); }
function chat_captain_left(text, width)
	{ return chat(false, 'captain', "Tammûz Captain", text, width); }
function chat_captain_right(text, width)
	{ return chat(true, 'captain', "Tammûz Captain", text, width); }
function chat_crouton_left(text, width)
	{ return chat(false, 'crouton', "Crouton", text, width); }
function chat_crouton_right(text, width)
	{ return chat(true, 'crouton', "Crouton", text, width); }
function chat_exz_left(text, width)
	{ return chat(false, 'exz', "EXZ", text, width); }
function chat_exz_right(text, width)
	{ return chat(true, 'exz', "EXZ", text, width); }
function chat_gruff_left(text, width)
	{ return chat(false, 'gruff', "Gruff", text, width); }
function chat_gruff_right(text, width)
	{ return chat(true, 'gruff', "Gruff", text, width); }
function chat_hammer_left(text, width)
	{ return chat(false, 'hammer', "Hammer", text, width); }
function chat_hammer_right(text, width)
	{ return chat(true, 'hammer', "Hammer", text, width); }
function chat_kensuke_left(text, width)
	{ return chat(false, 'kensuke', "Kensuke", text, width); }
function chat_kensuke_right(text, width)
	{ return chat(true, 'kensuke', "Kensuke", text, width); }
function chat_msakaji_left(text, width)
	{ return chat(false, 'msakaji', "Msakaji", text, width); }
function chat_msakaji_right(text, width)
	{ return chat(true, 'msakaji', "Msakaji", text, width); }
function chat_once_left(text, width)
	{ return chat(false, 'once', "Once", text, width); }
function chat_once_right(text, width)
	{ return chat(true, 'once', "Once", text, width); }
function chat_rask_left(text, width)
	{ return chat(false, 'rask', "Rask", text, width); }
function chat_rask_right(text, width)
	{ return chat(true, 'rask', "Rask", text, width); }
function chat_rico_left(text, width)
	{ return chat(false, 'rico', "Rico", text, width); }
function chat_rico_right(text, width)
	{ return chat(true, 'rico', "Rico", text, width); }
function chat_rusty_left(text, width)
	{ return chat(false, 'rusty', "Rusty", text, width); }
function chat_rusty_right(text, width)
	{ return chat(true, 'rusty', "Rusty", text, width); }
function chat_scias_left(text, width)
	{ return chat(false, 'scias', "Scias", text, width); }
function chat_scias_right(text, width)
	{ return chat(true, 'scias', "Scias", text, width); }
function chat_seno_left(text, width)
	{ return chat(false, 'seno', "Seno", text, width); }
function chat_seno_right(text, width)
	{ return chat(true, 'seno', "Seno", text, width); }
function chat_shitan_left(text, width)
	{ return chat(false, 'shitan', "Shitan", text, width); }
function chat_shitan_right(text, width)
	{ return chat(true, 'shitan', "Shitan", text, width); }
function chat_wolfstar_left(text, width)
	{ return chat(false, 'wolfstar', "Wolfstar", text, width); }
function chat_wolfstar_right(text, width)
	{ return chat(true, 'wolfstar', "Wolfstar", text, width); }
function chat_zoah_left(text, width)
	{ return chat(false, 'zoah', "ZOAH", text, width); }
function chat_zoah_right(text, width)
	{ return chat(true, 'zoah', "ZOAH", text, width); }

function TR(text) { return '<tr>\n' + text + '</tr>\n'; }

QL = '\u00AB';
QR = '\u00BB';
LAPOS = '<span class="safe">\u2018</span>';
RAPOS = APOS = '<span class="safe">\u2019</span>';
MDOT = '<span class="safe">\u00B7</span>';
HEART = '<span class="safe">♡</span>';
SING = '<span class="safe">♪</span>';

function onLoad() {}

