﻿var siteFolders = new Array("/biography/","/works/","/music/","/philosophy/","/culture/");
var navIDs = new Array("navBio","navWorks","navMusic","navPhilosophy","navCulture");
var pictureWindow;

function clearStatus()
{
	window.status = "";
	return true;
}

function framePictureWindow()
{
	if (pictureWindow !== void(0))
	{
		if (pictureWindow.closed)
		{
			pictureWindow = window.open(this.href,"showPicture","width=960,height=640,directories=no,menubar=no,resizable=no,status=no,toolbars=no");
		}
		else
		{
			pictureWindow.document.location = this.href;
			pictureWindow.focus();
		}
	}
	else
	{
		pictureWindow = window.open(this.href,"showPicture","width=960,height=640,directories=no,menubar=no,resizable=no,status=no,toolbars=no");
	}
	return false;
}

var culturePlace = /\/culture\/(newsletter|demo_)([01][0-9]|[0-9a-zA-Z_]*)\.php/;

function setEvents()
{
	for (var i = 0; i < document.getElementById("nav").getElementsByTagName("a").length; i++)
	{
		if (document.getElementById("nav").getElementsByTagName("a")[i].className == "current")
		{
			document.getElementById("nav").getElementsByTagName("a")[i].onmouseover = clearStatus;
			break;
		}
	}
	var w = document.getElementsByTagName("h1")[0].removeChild(document.getElementsByTagName("h1")[0].firstChild);
	var x = document.createElement("a");
	x.href = "/";
	x.appendChild(w);
	document.getElementsByTagName("h1")[0].appendChild(x);
	if ((document.location.pathname.indexOf("/works/") === 0) || (document.location.pathname.indexOf("/music/") === 0) || (culturePlace.test(document.location.href)))
	{
		if (document.getElementById("slideshow"))
		{
			populateSlideshow();
		}
	}
	if (document.location.href.indexOf("/philosophy/painting.php") != -1)
	{
		for (var i = 0; i < document.getElementById("bodyCopy").getElementsByTagName("a").length; i++)
		{
			if (document.getElementById("bodyCopy").getElementsByTagName("a")[i].href.indexOf(".jpg") != -1)
			{
				document.getElementById("bodyCopy").getElementsByTagName("a")[i].onclick = framePictureWindow;
			}
		}
	}
}

window.onload = setEvents;
