var a,b,c,d;
var page = location.href;

bitpage = page.split("/");
page = bitpage[bitpage.length - 1]; 
 
//alert(page); 

for(i in MENU_ITEMS)
{
	for(j in MENU_ITEMS[i])
	{
		if(page == MENU_ITEMS[i][j])
		{
			a = i;
			b = j;
			c = 0;
			d = 0;
			break;
		}		
		for(k in MENU_ITEMS[i][j])
		{
			if(page == MENU_ITEMS[i][j][k])
			{
				a = i;
				b = j;
				c = k;
				d = 0;
				break;
			}		
			for(l in MENU_ITEMS[i][j][k])
			{//use location.href
				if(page == MENU_ITEMS[i][j][k][l])
				{
					a = i;
					b = j;
					c = k;
					d = l;
					break;
				}		
			}
		}
	}
}

//alert(a + " " + b + " " + c + " " + d)

document.write("<font size=-1><a href='index.html'>Crazy Maths</a>");

var titlestr = "CWE - Crazy Maths";

if(a == undefined)
	{}
else
{
	//alert(MENU_ITEMS[a][0]);
	document.write(" -- <a href='" + MENU_ITEMS[a][1] + "'>" + MENU_ITEMS[a][0] + "</a>");
	titlestr += " - " + MENU_ITEMS[a][0];
	if(MENU_ITEMS[a][b][0] != undefined && MENU_ITEMS[a][b][0].length > 1)
	{
		//alert(MENU_ITEMS[a][b][0]);
		document.write(" -- <a href='" + MENU_ITEMS[a][b][1] + "'>" + MENU_ITEMS[a][b][0] + "</a>");
		titlestr += " - " + MENU_ITEMS[a][b][0];
	}
	if(c != 0 && MENU_ITEMS[a][b][c][0] != undefined  && MENU_ITEMS[a][b][c][0].length > 1)
	{
		//alert(MENU_ITEMS[a][b][c][0]);
		document.write(" -- <a href='" + MENU_ITEMS[a][b][c][1] + "'>" + MENU_ITEMS[a][b][c][0] + "</a>");
		titlestr += " - " + MENU_ITEMS[a][b][c][0];
	}
}

if(location.href == "http://www.coolwebeffects.net/cm/")
{
	titlestr = "CWE - Crazy Maths - Home";
	document.write("<a href='index.html'>Home</a>");
}

//add exceptions from special chars
titlestr = titlestr.replace("&frac12;","1/2");
titlestr = titlestr.replace("&rsquo;","'");

document.title = titlestr;

document.write("<BR></font>");
//alert(MENU_ITEMS[a][b][0])