loadimg = new Image();
loadimg.src = 'http://www.impactfolios.com/templates/loading.gif';
document.getElementById("largeimg").src = loadimg.src;
var glo_curimg = 0; 

function loadImg(i) {
	
	glo_curimg = i;

	document.getElementById("imagebox").style.visibility = 'visible';
	//document.getElementById("imagedrop").style.visibility = 'visible';
	document.getElementById("largeimg").src = lg[i];
	document.getElementById("imgtitle").innerHTML = mtitle[i];
	document.getElementById("copyright").innerHTML = cpy[i];
	document.getElementById("imgcaption").innerHTML = mcap[i];
	/*document.getElementById("imagebox").style.left = '100px';
	document.getElementById("imagedrop").style.left = '103px';
	document.getElementById("imagebox").style.top = '65px';
	document.getElementById("imagedrop").style.top = '65px';*/
	if (hasSalesItems[i] == 1)  {
		document.getElementById("imgpurchase").style.display = 'block';
	} else {
		document.getElementById("imgpurchase").style.display = 'none';	
	}
	/*
	This doesn't work:
	bLeft = findPosX(document.getElementById("imageContainer"));
	bTop = findPosY(document.getElementById("imageContainer"));										 
	document.getElementById("imagebox").style.left = bLeft+'px';
	document.getElementById("imagedrop").style.left = bLeft+3+'px';
	document.getElementById("imagebox").style.top = bTop+'px';
	document.getElementById("imagedrop").style.top = bTop+3+'px';
	*/

}
	
function popPurchase() {
	document.location = './index.htm?purchase='+mediaid[glo_curimg];	
}

function closeImg() {
	document.getElementById("imagebox").style.visibility = 'hidden';
	//document.getElementById("imagedrop").style.visibility = 'hidden';
	document.getElementById("imgtitle").innerHTML = '';
	document.getElementById("copyright").innerHTML = '';
	document.getElementById("imgcaption").innerHTML = '';
	document.getElementById("largeimg").src = loadimg.src;

}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}
function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

