
evt = function(d_e) {

	this.but = (this.e = d_e || window.event).which || this.e.button || 0;

	this.x = mgr.Int(this.e.pageX || this.e.clientX || 0);
	this.y = mgr.Int(this.e.pageY || this.e.clientY || 0);
	if (mgr.ie) {
		this.x += mgr.getScrollX() - (mgr.ie && !mgr.iemac)*1;
		this.y += mgr.getScrollY() - (mgr.ie && !mgr.iemac)*1;
	}
	
	this.button = (this.e.type == 'mousedown')? this.but
		: (mgr.e && mgr.e.button)? mgr.e.button
		: 0;
	this.src = this.e.target || this.e.srcElement || null;
	if(!this.src) return;
	
	while(this.src != null && (this.src.id==null || this.src.id=='')) {
		this.src = this.src.parentNode;
	}
	if(!this.src) return;

	this.tag = this.src.tag = ("" + (this.src.tagName || this.src)).toLowerCase();
	this.id = this.src.id;
	this.modifKey = this.e.modifiers? this.e.modifiers&Event.CTRL_MASK : (this.e.ctrlKey || false);
};




function MANAGER()
{
	this.n = navigator.userAgent.toLowerCase();
	this.db = (document.compatMode && document.compatMode.toLowerCase() != "backcompat")?
		document.documentElement
		: (document.body || null);
	this.op = !!(window.opera && document.getElementById);
	this.op6 = !!(this.op && !(this.db && this.db.innerHTML));
	if (this.op && !this.op6) document.onmousedown = new Function('e',
		'if (((e = e || window.event).target || e.srcElement).tagName == "IMAGE") return false;');
	this.ie = !!(this.n.indexOf("msie") >= 0 && document.all /* && this.db */&& !this.op);
	this.iemac = !!(this.ie && this.n.indexOf("mac") >= 0);
	this.ie4 = !!(this.ie && !document.getElementById);
	this.n4 = !!(document.layers && typeof document.classes != "undefined");
	this.n6 = !!(typeof window.getComputedStyle != "undefined" && typeof document.createRange != "undefined");
	this.w3c = !!(!this.op && !this.ie && !this.n6 && document.getElementById);
	this.ce = !!(document.captureEvents && document.releaseEvents);
	this.px = (this.n4 || this.op6)? '' : 'px';
	this.tiv = this.w3c? 40 : 10;
	this.locked = false;

	this.TITLE_HEIGHT = 19;
	this.COLUMNS = new Array(10,220,530,740);
	this.VGAP = 8;
	this.HGAP = 9;
	this.VHEADER = 60;
	this.HHEADER = 60;
	
	this.gz = 1;
}

MANAGER.prototype.Int = function(d_x, d_y)
{
	return isNaN(d_y = parseInt(d_x))? 0 : d_y;
};

MANAGER.prototype.getWndW = function()
{
	return this.Int(
		(this.db && !this.op && !this.w3c && this.db.clientWidth)? this.db.clientWidth
		: (window.innerWidth || 0)
	);
};

MANAGER.prototype.getWndH = function()
{
	return this.Int(
		(this.db && !this.op && !this.w3c && this.db.clientHeight)? this.db.clientHeight
		: (window.innerHeight || 0)
	);
};

MANAGER.prototype.getScrollX = function()
{
	return this.Int(window.pageXOffset || (this.db? this.db.scrollLeft : 0));
};

MANAGER.prototype.getScrollY = function()
{
	return this.Int(window.pageYOffset || (this.db? this.db.scrollTop : 0));
};


MANAGER.prototype.maxOffX = function(d_x, d_y)
{
	return (
		(this.obj.maxoffl+1 && (d_y = this.obj.defx-this.obj.maxoffl)-d_x > 0
		|| this.obj.maxoffr+1 && (d_y = this.obj.defx+this.obj.maxoffr)-d_x < 0)? d_y
		: d_x
	);
};

MANAGER.prototype.maxOffY = function(d_x, d_y)
{
	return (
		(this.obj.maxofft+1 && (d_y = this.obj.defy-this.obj.maxofft)-d_x > 0
		|| this.obj.maxoffb+1 && (d_y = this.obj.defy+this.obj.maxoffb)-d_x < 0)? d_y
		: d_x
	);
};

MANAGER.prototype.inWndW = function(d_x, d_y)
{
	var d_wx = this.getScrollX(),
	d_ww = this.getWndW();
	return (
		((d_y = d_wx+2)-d_x > 0) || ((d_y = d_wx+d_ww+this.obj.w-2)-d_x < 0)? d_y
		: d_x
	);
};

MANAGER.prototype.inWndH = function(d_x, d_y)
{
	var d_wy = this.getScrollY(),
	d_wh = this.getWndH();
	return (
		((d_y = d_wy+2)-d_x > 0) || ((d_y = d_wy+d_wh+this.obj.h-2)-d_x < 0)? d_y
		: d_x
	);
};

MANAGER.prototype.getPageXY = function(d_o)
{
	if (this.n4 && d_o)
	{
		this.x = d_o.pageX || 0;
		this.y = d_o.pageY || 0;
	}
	else
	{
		this.x = this.y = 0; //global helper vars
		while (d_o)
		{
			this.x += this.Int(d_o.offsetLeft);
			this.y += this.Int(d_o.offsetTop);
			d_o = d_o.offsetParent || null;
		}
	}
};
mgr = new MANAGER();




var pop;

function drawPopup() {
	var x = 100; var y = 100; var w = 400; var h = 300; var gz = 1000;
	document.write('<div id="popup" class="popupframe" style="z-index: '+(gz++)+
			'; left: '+x+'px; top: '+y+'px; width: '+w+'px; height: '+h+'px;">');

	document.write('<div id="popuptitle" class="popuptitle" style="z-index: '+(gz++)+
			'; width: 100%; height: 14px;">'+"this is the title"+'</div>');

	document.write('<img href="" id="popupcontent" class="popupcontent" style="z-index: '+(gz++)+
			'; left: 0px; top: 0px;">');

	document.write('</div>');
	
	pop = new popup();
	pop.hide();
	
}

function popup() {
	this.frame = document.getElementById("popup");
	this.title = document.getElementById("popuptitle");
	this.content = document.getElementById("popupcontent");
	
	this.title.onmousedown = startMove;
	this.title.onmouseup = stopMove;
	
	this.x = 100;
	this.y = 100;
	this.visible = true;
	this.caption = "";
	this.src = "";
	this.moving = false;
}

popup.prototype.moveBy = function(d_x,d_y) {
	this.tempX = this.x+d_x;
	this.tempY = this.y+d_y;
	this.frame.style.left = (this.x+d_x)+mgr.px;
	this.frame.style.top = (this.y+d_y)+mgr.px;
}


popup.prototype.close = function() {
}

popup.prototype.hide = function() {
	this.frame.style.visibility = "hidden";
	this.visible = false;
};

popup.prototype.show = function() {
	this.frame.style.visibility = "visible";
	this.visible = true;
	};
	
popup.prototype.toggle = function() {
	this.visible?this.hide():this.show();
};

popup.prototype.sizeToFit = function() {
	this.frame.style.width = (this.content.width+4)+"px";
	this.frame.style.height = (this.content.height+20)+"px";
};



popup.prototype.load = function(src,caption) {
	this.src = src;
	this.caption = caption;
	this.title.innerHTML = '<a href="javascript:pop.hide()" border="0" class="popupclose">[CLOSE]</a> ' + caption;
	var globalthing = new Image();
	globalthing.src = src;
	if(globalthing.width && globalthing.width > 0) {
		this.content.src = src;
		this.sizeToFit();
		this.show();
	} else {
		globalthing.onload = function() { 
			pop.content.src = this.src;
			pop.sizeToFit();
			pop.show();
			};
	}
};






function startMove(e) {
	e = new evt(e);
	pop.startX = e.x;
	pop.startY = e.y;
	pop.moving = true;
};

function stopMove() {
	pop.x = pop.tempX;
	pop.y = pop.tempY;	
	pop.moving = false;
}


function checkMove(e) {
	if(pop && pop.moving) {
		e = new evt(e);
		pop.moveBy((e.x-pop.startX),(e.y-pop.startY));
	}
}

document.onmousemove = checkMove;

