function RicPage ()
{
var TheCookie="QL=",c,d,m;

m = PageFromAddr ();
a = GetMyCookie ();

if (a != "z")
	{
	for (b=0;b<100;b++)
		{
		c = a.substring (b*5,b*5+4);
		d = a.substring (b*5+4,b*5+5);
		if (c == "")
			break;

		if (c == m)
			m2=1;

		if ((d == "s") || (d == "S"))
			{
			if (c == m)
				c = c + ((d == "s")?"S":"s");
			else
				c = c + d;
			}
		else
			{
			if (c == m)
				c = c + "s"
			else
				c = c + "n"
			}

		TheCookie = TheCookie + c;
		}
	}

document.cookie=TheCookie+";path=/;";
window.location = window.location;
}

function PrintPage (page)
{
var a,s;

a = PageFromAddr ();
if (a == "#")
	return;

document.write (page+a+"&nbsp;");
}

function GetMyCookie ()
{
var a,b;

a = document.cookie;
b = a.indexOf ("QL=");
if (b == -1)
	return ("z");
a = a.substring (b+3,a.length);
b = a.indexOf (";");
if (b != -1)
	a = a.substring (0,b);

return (a);
}

function DoAllYouKnown (s1,s2)
{
var b;

if ((GetMyCookie () == 'z') || (AllSeen ()==0))
	{
	SetPageCookie ();
	document.write ('<table border=1 bordercolor=#FFFFFF cellpadding=1 cellspacing=0 WIDTH=100%>');
	document.write ('<TR valign=top>');
	document.write ('<TD width=150 rowspan=2>&nbsp;'+s1+'</TD>');
	PrintAddr (0);
	document.write ('<TR>');
	PrintAddr (1);
	document.write ('</TR></TABLE>');
	}
else
	{
	SetPageCookie ();
	document.write ('<table border=1 bordercolor=#FFFFFF cellpadding=1 cellspacing=0 WIDTH=100%>');
	document.write ('<TR valign=top>');
	document.write ('<TD width=150>&nbsp;'+s1+'</TD>');
	PrintPageSeen ("s");
	document.write ('</TR><TR valign=middle><TD width=150>&nbsp;'+s2+'</TD>');
	PrintPageSeen ("n");
	document.write ('</TR></TABLE>');
	}
}

function AllSeen ()
{
var a,b,c,d=0;

a = GetMyCookie ();

for (b=0;b<100;b++)
	{
	c = a.substring (b*5+4,b*5+5);
	if (c == "")
		break;
	if (c == "n")
		return (1);
	}

return (d);
}

function SetPageCookie ()
{
var TheCookie="QL=",c,d,m,m2=0;

m = PageFromAddr ();	// 0123
a = GetMyCookie ();	// 0123n0123s

if (a != "z")
	{
	for (b=0;b<100;b++)
		{
		c = a.substring (b*5,b*5+4);
		d = a.substring (b*5+4,b*5+5);
		if (c == "")
			break;

		if (c == m)
			m2 = 1;

		if ((d == "s") || (d == "S"))
			c = c + d;
		else
			{
			if (c == m)
				c = c + "s"
			else
				c = c + "n"
			}

		TheCookie = TheCookie + c;
		}
	}

if (m2 == 0)
	TheCookie = TheCookie + m + "s";

document.cookie=TheCookie+";path=/;";
}

function PrintAddr (b)
{
var a,c,d,e,n;

a = GetMyCookie ();
if (a == "z")
	{
	for (n=0;n<10;n++)
		document.write ('<TD width=35>&nbsp;</TD>');
	return;
	}

if (b == 1)
	a = a.substring (50,50+1000);

b = 10;
n = 0;
while (b--)
	{
	c = a.substring (n*5,n*5+4);
	e = a.substring (n*5+4,n*5+5);
	if (c == "")
		{
		document.write ('<TD width=35>&nbsp;</TD>');
		n++;
		continue;
		}

	d = AddrFromPage (c);

	document.write ('<TD width=35 align=center ');
	if (e == "S")
		document.write ('BGCOLOR="#FFFF00">');
	else
		document.write ('BGCOLOR="#FFFFFF">');
	document.write ('<A HREF="'+d+'" TARGET="_top">'+c+'</A></TD>');
	n++;
	}
}

function PrintPageSeen (str)
{
var a,c,d,e,n,m=0,n2,s2;

a = GetMyCookie ();
s2 = str.toUpperCase ();

n2=10;
for (n=0;n<n2;n++)
	{
	c = a.substring (n*5,n*5+4);
	e = a.substring (n*5+4,n*5+5);
	if (c == "")
		{
		document.write ("<TD width=35>&nbsp;</TD>");
		continue;
		}

	if ((e != str) && (e != s2))
		{
		n2++;
		continue;
		}

	d = AddrFromPage (c);

	document.write ('<TD width=35 align=center ');
	if (e == "S")
		document.write ('BGCOLOR="#FFFF00">');
	else
		document.write ('BGCOLOR="#FFFFFF">');
	document.write ('<A HREF="'+d+'" TARGET="_top">'+c+'</A></TD>');
	}

for (n=0;n<m;n++)
	document.write ("<TD width=35>&nbsp;</TD>");
}

