// $Id: GachaGachaEntry.js,v 1.2 2004/08/02 03:01:50 okamura Exp $
// Copyright (C) 2004 OKAMURA Yuji

function GachaGachaEntry() {
	// for Safari
	{
		var	n = new Date();
		var	i;

		n = n.getSeconds();
		for (i = 0; i < n; i++) {
			Math.random();
		}
	}

	var	entryUUID = entryUUIDsList[Math.floor(Math.random() * entryUUIDsList.length)];
	var	categoryUUID = getCategoryUUIDForEntry(entryUUID);
	var	base = String(location.href);

	if (base.match(/^(.*)#[^\/?]*$/)) {
		base = RegExp.$1;
	}

	if (base.match(/^(.*)\/(C\d+)\/(E\d+)\/(index\.html)?$/)) {
		base = RegExp.$1;
	}
	else if (base.match(/^(.*)\/(C\d+)\/(index\.html)?$/)) {
		base = RegExp.$1;
	}
	else if (base.match(/^(.*)\/(\d{4})\/([1-9]|1[0-2])\/([1-9]|[12]\d|3[01])\/(index\.html)?$/)) {
		base = RegExp.$1;
	}
	else if (base.match(/^(.*)\/(\d{4})\/(index\.html)?$/)) {
		base = RegExp.$1;
	}
	else if (base.match(/^(.*)\/(index\.html|archive\.html)?$/)) {
		base = RegExp.$1;
	}
	else {
		return false;
	}

	location.href = base + '/' + categoryUUID + '/' + entryUUID + '/index.html';
	return true;
}
