var last_popup = null;

function Popup(link, name, settings)
{
	if (name == null) {
		var day = new Date();
		name = day.getTime();
	}
	if (settings == null)
		settings = "toolbar=no,scrollbars=yes,location=no,statusbar=yes,menubar=no," +
				   "resizable=yes,width=500,height=590,left=200,top=50"
	last_popup = window.open(link.getAttribute('href'), name, settings);
	if (last_popup.opener == null)
		last_popup.opener = self;
	if (last_popup.focus)
		last_popup.focus();
	return false;
}

function FullsizeImage(link)
{
	return Popup(link, null, "toolbar=no,scrollbars=no,location=no,statusbar=yes,menubar=no," +
							 "resizable=yes,width=800,height=600,left=20,top=20");
}

function ImageManager(link)
{
	return Popup(link, null, "toolbar=no,scrollbars=yes,location=no,statusbar=yes,menubar=no," +
							 "resizable=yes,width=350,height=400,left=200,top=90");
}

function PreviewImage(link)
{
	if (document.getElementById && link.getAttribute && link.setAttribute) {
		var images = document.getElementById('images');
		if (images) {
			var image_links = images.getElementsByTagName('a');
			var image = images.getElementsByTagName('img');
			var new_image = link.getElementsByTagName('img');
			if (image_links && image && new_image) {
				image[0].src = new_image[0].src;
				var old_link = image_links[0].getAttribute('href');
				var new_link = link.getAttribute('href');
				image_links[0].setAttribute('href', old_link.replace(/\&img=.*$/, new_link.match(/\&img=.*$/)[0]));
				return false;
			}
		}
	}
	return true;
}

function BackButton()
{
	document.write("<div id='close'><input type='button' value='Back' onclick='history.go(-1);' /></div>");
}

function RefreshButton(title)
{
	document.write("<div id='refresh'><input type='button' value='" + title + "' onclick='location.reload(true);' /></div>");
}

