window.onload = init;

function init() {
	picTitlesInit();
}

function picTitlesInit() {
	var imgs = document.getElementsByTagName('img');
	for (c=0; c<imgs.length; c++) {
		imgs[c].onmouseover = picTitles;
		imgs[c].onmouseout = picTitlesClear;
	}
}

function picTitles() {
	var title = this.getAttribute("alt");
	var id = this.parentNode.getAttribute("id") + "_pic";
	var div = document.createElement("p");
	div.setAttribute("class", "popTitle");
	div.setAttribute("id", id);
	var text = document.createTextNode(title);
	div.appendChild(text);
	this.parentNode.appendChild(div);
}

function picTitlesClear() {
	var id = this.parentNode.getAttribute("id") + "_pic";
	var toDelete = document.getElementById(id);
	this.parentNode.removeChild(toDelete);
}
