function hidePop() {
	var pop = get('popImg');
	pop.style.display = 'none';
}

function get(eid) {
	var d = document;
	var r = d.getElementById(eid);
	return r;
}

function popImg(iref) {
	var theimg = iref.src;
	theimg = theimg.replace('.jpg','_bg.jpg');
	thestart = theimg.search(/images\//);
	theimg = theimg.substring(thestart,theimg.length);
	myImage = new Image();
	myImage.src = theimg;
	checkIt(myImage);
}
function checkIt(myImage) {
	if (myImage.width > 1) {
		newpopImg(myImage);
	} else {
		setTimeout('checkIt(myImage)',15);
	}
}

function newpopImg(myImage) {
	var img = '<div onmousedown="hidePop();" style="cursor: pointer; position:absolute; top: 10px; left: 0px; width:' + (myImage.width - 15) + 'px; text-align:right; color:#7f7f7f; font-size:14px;">Click to Close</div><img src="' + myImage.src + '" onmousedown="hidePop();" width="' + myImage.width + '" style="cursor: pointer; border:1px solid #444;" />';

	var d = document;
	if (null == get('popImg')) {
		var pop = d.createElement('DIV');
		pop.id = 'popImg';
		pop.style.position = 'absolute';
		pop.style.zIndex = '20';
		pop.style.width = myImage.width + "px";
		pop.style.height = myImage.height + "px";
		
		bodytext = d.body.innerHTML;
		d.body.innerHTML = '';
		d.body.appendChild(pop);
		d.body.innerHTML += bodytext;
	}
	
	var pop = get('popImg');
	pop.innerHTML = img;
	
	box = get('container');
	var top = Math.round((box.offsetHeight/2) + 40 - (myImage.height/2));
	var left = Math.round((document.documentElement.clientWidth/2) - (myImage.width/2));
	pop.style.top = top + "px";
	pop.style.left = left + "px";
	pop.style.display = 'block';
}
