function popShow(img, caption)
{
	var oThumb = document.getElementById("img" + img);
	var oPopup = document.getElementById("dPopup");
	var oImg = document.getElementById("dImg");
	var oCaption = document.getElementById("dCaption");
	var oPos = getObjPos(oThumb);
	var sPos = getScreenPos();
	// var str = caption.replace(/&/g,'%26');
	var str = caption;
	var xPos = 0;
	var yPos = 0;
	oImg.src = "/images/gallery/" + img + ".jpg";
	oCaption.innerHTML = str.replace(/\*!\*/g,"'");
	// oCaption.innerHTML = caption.replace(/&/g,'%26');
	if (oPos[0] < sPos[4])
	{
		xPos = oPos[0] + 50;
		/*
		while (xPos > sPos[2])
		{
			xPos = xPos - 10;
		}
		*/
	}
	else
	{
		xPos = oPos[0] - (oImg.width + 10)
		while (xPos < 10)
		{
			xPos = xPos + 10;
		}
	}
	yPos = sPos[1] - 10;
	while (yPos < 50)
	{
		yPos = yPos + 10;
	}
	oPopup.style.left = xPos + 'px';
	// oPopup.style.top = yPos + 'px';
	oPopup.style.top = (50 + sPos[3]) + "px";
	oPopup.style.visibility = "Visible";
	// window.status = oPos[0] + "/" + oPos[1] + " ~ " + oImg.width + "/" + oImg.height + " ~ " + sPos[2] + "/" + sPos[3] + " ~ " + sPos[0] + "/" + sPos[1] + " ~ " + sPos[4] + "/" + sPos[5];
	// Img X/Y ~ Img H/W ~ Win X/Y ~ Scroll X/Y ~ 1/2Way X/Y
}

function popHide()
{
 oPopup = document.getElementById("dPopup");
 oDetail = document.getElementById("dImg");
 oCaption = document.getElementById("dCaption");
 oPopup.style.visibility = "Hidden";
 oPopup.style.top = "0px";
 oCaption.innerHTML = "";
 self.status = "";
};

function getScreenPos()
{
	/*
	0 = Window Width
	1 = Window Height
	2 = Amount of X Scroll
	3 = Amount of Y Scroll
	4 = X Half-way point (takeing scroll into account)
	5 = Y Half-way point (taking scroll into account)
	*/
	var W;
	var H;
	var posX = window.scrollX;
	var posY = window.scrollY;
	if (typeof window.innerWidth != 'undefined')
	{
	  W = window.innerWidth;
	  H = window.innerHeight;
	}
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
	{
	   W = document.documentElement.clientWidth;
	   H = document.documentElement.clientHeight;
	}
	else
	{
	   W = document.getElementsByTagName('body')[0].clientWidth;
	   H = document.getElementsByTagName('body')[0].clientHeight;
	}
	return [W,H,posX,posY,(Math.abs(W-posX)/2),(Math.abs(H-posY)/2)];
}

function isIE()
{
	return (document.all) ? true : false;
}

function getObjPos(obj)
{
	var objPos = {x:0,y:0};
	while (obj)
	{
		objPos.x += obj.offsetLeft;
		objPos.y += obj.offsetTop;
		obj = obj.offsetParent;
	}

	if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft))
	{
		objPos.x -= document.documentElement.scrollLeft;
		objPos.y -= document.documentElement.scrollTop;
	}
	else if (document.body && (document.body.scrollTop || document.body.scrollLeft))
	{
		objPos.x -= document.body.scrollLeft;
		objPos.y -= document.bodt.scrollTop;
	}
	else if (window.pageXOffset || window.pageYOffset)
	{
		objPos.x -= window.pageXOffset;
		objPos.y -= window.pageYOffset;
	}
	return [objPos.x,objPos.y];
}