function popup() 
{
	var functionOnClose;
	
	this.Initiate = function()
	{
		this.wrapper = document.getElementById("popup_wrapper");
		this.title   = document.getElementById("popup_title");
		this.content = document.getElementById("popup_content");
		
		
		/*
		  Source: http://andylangton.co.uk/articles/javascript/get-viewport-size-javascript/
		*/
		if(typeof window.innerWidth != 'undefined')
		{
			this.viewportwidth = window.innerWidth,
			this.viewportheight = window.innerHeight
		}
		else if(typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
		{
			this.viewportwidth = document.documentElement.clientWidth,
			this.viewportheight = document.documentElement.clientHeight
	    }
		else
		{
			this.viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
			this.viewportheight = document.getElementsByTagName('body')[0].clientHeight
		}
		/* End Source */
	}
	
	this.Load = function(titleTxt, width, height, loadWhat, data)
	{
		this.wrapper.style.display = "block";
		this.wrapper.style.width   = width + "px";
		this.wrapper.style.height  = height + "px";
		
		this.title.innerHTML       = titleTxt;
		
		var spaceLeft = (this.viewportwidth - width) / 2;
		var spaceTop  = (this.viewportheight - height) / 2;
		
		this.wrapper.style.left = spaceLeft + "px";
		this.wrapper.style.top  = (spaceTop + document.documentElement.scrollTop) + "px";
		
		this.content.style.height = height - (24 + 16) + "px";
		this.content.innerHTML    = "<div style='margin-top:20px;' align='center'>" + images['loading'] + "<br />Loading...</div>";
		
		data['ajax_key'] = ajax.Key();
		
		//alert(home_url + "index.php?popup=" + loadWhat);
		
		ajax.Run(home_url + "index.php?popup=" + loadWhat, data, popup.SetContent);
	}
	
	this.SetContent = function(cont)
	{
		if(!cont)
		{
			popup.Close();
			return;
		}
		
		popup.content.innerHTML = cont;
	}
	
	this.Close = function()
	{
		this.wrapper.style.display = "none";
	}
}

var popup = new popup();
