function __image_viewer(name)
{
	this.__name = name;
	this.__show_errors = true;
	this.__use_popup_window_fallback = true;
	this.__resize_images_to_fit = true;

	this.show = function(id, path)
	{
		var __o = document.getElementById(id);

		if(__o == null)
		{
			return;
		}

		var __div = document.createElement("DIV");
		var __img = document.createElement("IMG");
		var __a = document.createElement("A");

		__div.id = id + "_hold";
		__img.id = id + "_img";

		__a.appendChild(document.createTextNode('Close'));

		__a.href = "javascript:void(0);"
		add_onclick(__a, this.__name + ".close(\"" + id + "\");", false);

		__div.className = "imgPopup";
		__div.appendChild(__img);
		__div.appendChild(__a);
		__o.parentNode.appendChild(__div);

		add_onload(__img, this.__name + ".load_callback(\"" + id + "\");", false);
		add_onerror(__img, this.__name + ".error_callback(\"" + id + "\");", false);

		__img.src = path;

		return false;
	}

	this.close = function(id)
	{
		var __div = document.getElementById(id + "_hold");
		
		__div.parentNode.removeChild(__div);
	}

	this.load_callback = function(id)
	{
		var __div = document.getElementById(id + "_hold");
		var __img = document.getElementById(id + "_img");

		__div.className = "imgPopupTrans";

		__div.style.left = (document.documentElement.scrollLeft + (document.documentElement.clientWidth - __img.width) / 2) + "px";
		__div.style.top = (document.documentElement.scrollTop + (document.documentElement.clientHeight - __img.height) / 2) + "px";

		__div.className = "imgPopupOn";
	}

	this.error_callback = function(id)
	{
		alert('Error!');
	}

	this.attach_events = function(id, path)
	{
		var __o = document.getElementById(id);

		add_onclick(__o, this.__name + ".show(\"" + id + "\", \"" + path + "\");", true);

	}

}
///
var image_viewer = new __image_viewer('image_viewer');