UIPopup = {
	popup : null,
	type : null,
	getInstance : function()
	{
		if(!this.popup){
			try { this.popup = window.createPopup(); this.type = "POPUP"; }
			catch(e){ this.popup = new UIDivPopup(); this.type = "DIV"; }
			this.onInit();
		}
		return this.popup;
	},
	onInit : function (){}
};

function UIDivPopup(){
	this.document = document.createElement("DIV");	
	this.document.style.position = "absolute";
	this.document.style.display = "none";
	this.isOpen = false;
	document.body.appendChild(this.document);
};
UIDivPopup.prototype.show = function(l,t,w,h,el){
	var apos = __getAbsolutePos(el);
	this.document.style.top = apos.y + t + "px";
	this.document.style.left = apos.x + "px";
	this.document.style.display = "block";
	this.isOpen = true;
};
UIDivPopup.prototype.hide = function(){
	this.document.style.display = "none";
	this.isOpen = false;
};

function __getAbsolutePos(el)
{
	var SL = 0, ST = 0;
	var is_div = /^div$/i.test(el.tagName);
	if (is_div && el.scrollLeft)
		SL = el.scrollLeft;
	if (is_div && el.scrollTop)
		ST = el.scrollTop;
	var r = { x: el.offsetLeft - SL, y: el.offsetTop - ST };
	if (el.offsetParent) {
		var tmp = __getAbsolutePos(el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	}
	return r;
}