var hr = location.href;
var hom = (hr.indexOf("/index_new.html") != -1 || hr.indexOf("/index.html") != -1 || hr.lastIndexOf("/") == hr.length - 1);

// parse
var b = undefined;
var varstring = location.href;
var i = varstring.indexOf("?");
if(i != -1 && varstring.indexOf("/image.html") == -1){
	varstring = varstring.substr(i + 1);
	var vararray = varstring.split("&");
		
	i = 0;
	while(i < vararray.length){
		eval("var " + vararray[i].substr(0, vararray[i].indexOf("=")) + 
				 " = '" + vararray[i].substr(vararray[i++].indexOf("=") + 1) + "';");
	}
}

// random document title
if(hom){
	q = [
		"Bring out the gimp",
		"Cutting up tongues",
		"Enjoy monoculture",
		"Failed attempt at greatness",
		"Four out of five gods agree",
		"Free afternoon enema",
		"Human dairy farm",
		"Meat hooks",
		"Minimalistic bliss",
		"Mutilation with electric drills",
		"Put in and left there",
            "Saving the world's asshole",
		"Sex dwarf training camp",
		"Tentacle-porn",
		"Turnstyle pornbuckle",
		"Unwashed by necessity"
	];	
	document.title += " - " + q[Math.round(Math.random()*(q.length-1))];
}

function onpage(l){

	return !(location.href.indexOf(l) == -1 && location.href.indexOf(l.split('.html').join('_new.html')) == -1);
}

function shead(t, l, w){

	var dim = !onpage(l);
	var img = '<img ' + (!dim ? ' class="undim"' : '') + 'src="/images/' + t + '.png" width="' + w + '" height="16" border="0" alt="' + t + '" />';
	document.write(dim ? '<a class="dim" href="' + l + '">' + img + '</a>' : img);
}

function writeHead(){

	document.write('<!--[if gte IE 5.5]><link rel="stylesheet" type="text/css" href="/css/mezzstyle_ie.css" /><![endif]--><!--[if lt IE 7]><script defer type="text/javascript" src="/js/pngfix.js"></script><![endif]-->');

	if(hom) return;

//	document.write('<div id="head"><div id="logo"><h1>Mezzanine Stairs</h1></div>\n');

	// title image
	document.write('<div id="head"><div id="logo"><h1>Mezzanine Stairs</h1><a class="hide" href="/index.html"><img src="/images/home.png" width="64" height="16" alt="Mezzanine Stairs" /></a></div><div id="subhead">');

	// sub-nav
	shead("audio", "/audio.html", 80);
	shead("forum", "/bord/viewforum.php?f=2", 80);
	shead("links", "/links.html", 80);
	shead("etc", "/etc.html", 48);
	document.write('</div></div>');
}


function togglePane(pane, val){

	document.getElementById(pane).className = (val ? 'on' : 'off');
	document.getElementById(pane + '_closed').className = 'closed ' + (val ? 'off' : 'on');
}

function showPane(pane){ togglePane(pane, true); }
function hidePane(pane){ togglePane(pane, false); }

writeHead();

