function isEmail(email) {
	var re = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;

	if (!re.test(email))
		return false;

	return true;
}

function popup(url, name, width, height) {
	var left = (screen.width - width) / 2;
	if(left < 0)
		left = 0;
	var top = (screen.height - height) / 2;
	if(top < 0)
		top = 0;
	
	window.open(url, name, "width=" + width + ",height=" + height + ",top=" +
			top + ",left=" + left);
}

function hidePicture() {
	var body = document.getElementsByTagName("body")[0];
	body.removeChild(document.getElementById("popupPic"));
	body.removeChild(document.getElementById("popupBg"));
	return false;
}

function showPicture(title, pic, closeText) {
	if (document.getElementById("popupBg") != null)
		return;

	var div = document.createElement("div");
	div.setAttribute("id", "popupPic");
	
	var bg = document.createElement("div");
	bg.setAttribute("id", "popupBg");
	
	var header = document.createElement("div");
	header.setAttribute("class", "popupHeader");
	header.setAttribute("className", "popupHeader");
	div.appendChild(header);
	
	var close = document.createElement("a");
	close.setAttribute("href", "#");
	close.appendChild(document.createTextNode(closeText));
	close.onclick = hidePicture;
	header.appendChild(close);
	
	var h1 = document.createElement("h1");
	h1.appendChild(document.createTextNode(title));
	header.appendChild(h1);
	
	var img = document.createElement("img");
	img.setAttribute("src", "/data/images/" + pic);
	img.setAttribute("alt", title);
	div.appendChild(img);
	
	var body = document.getElementsByTagName("body")[0];
	body.insertBefore(bg, body.firstChild);
	body.insertBefore(div, body.firstChild);
}