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 bigPic(myImage) {
	if (myImage == 1) { back = 18; } else { back = myImage-1; }
	if (myImage == 18) { next = 1; } else { next = myImage+1; }
	var img = '<img src="images/samples/' + myImage + 'bg.jpg" style="width:720px;height:486px;border:1px solid #444;" /><div style="position:relative; top:-20px; margin-bottom:-20px; border:1px solid #444; border-top:0px; padding:5px 0px; width:100%; background:#efefef; text-align:center;"><a style="padding:3px;" onclick="bigPic(' + back + ');">Back</a> &mdash; <a style="padding:3px;" onclick="hidePop();">Close</a> &mdash; <a style="padding:3px;" onclick="bigPic(' + next + ');">Next</a></div>';

	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 = "720px";
		pop.style.height = "475px";
		pop.style.background = "#fff";
		
		bodytext = d.body.innerHTML;
		d.body.innerHTML = '';
		d.body.appendChild(pop);
		d.body.innerHTML += bodytext;
	}
	
	var pop = get('popImg');
	pop.innerHTML = img;
	
	if (self.innerHeight) {
		box = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth) {
		 box = document.documentElement.clientHeight;
	}
	else if (document.body) {
		 box = document.body.clientHeight;
	}
	//alert(box);
	var top = Math.round((box/2) - 243);
	var left = Math.round((document.documentElement.clientWidth/2) - 360);
	pop.style.top = top + "px";
	pop.style.left = left + "px";
	pop.style.display = 'block';
}
