var divHeight = 0;

function getY( oElement )
{
var iReturnValue = 0;
while( oElement != null ) {
iReturnValue += oElement.offsetTop;
oElement = oElement.offsetParent;
}
return iReturnValue;
}

function getX( oElement )
{
var iReturnValue = 0;
while( oElement != null ) {
iReturnValue += oElement.offsetLeft;
oElement = oElement.offsetParent;
}
return iReturnValue;
}

function bigImg(topLeftIndex, topRightIndex, bottomLeftIndex, element) {
	
	divHeight = document.getElementById("galleryContainer").offsetHeight;
	var fn = element.src;
	fn = fn.substring(0,fn.length-7)+".jpg";
	var topLeftImage = document.getElementById("galimg"+topLeftIndex);
	var topRightImage = document.getElementById("galimg"+topRightIndex);
	var bottomLeftImage = document.getElementById("galimg"+bottomLeftIndex);
	var top = getY(topLeftImage);
	var left = getX(topLeftImage)-1;
	var width = (getX(topRightImage)+topRightImage.width)-left;
	var height =(getY(bottomLeftImage)+topLeftImage.height)-top;
	var div = document.createElement('div');	
	div.setAttribute("id", "largeImgDiv");
	div.innerHTML = "<table width=100% cellpadding=0 cellspacing=0 border=0 style='border: 1px solid #aaaaaa;'><tr><td align=right><a href=javascript:closeBigImg(); style='font-family: arial, helvetica, sans-serif; font-size: 8pt;'><smallcaps>close</smallcaps> X</a>&nbsp;</td></tr><tr><td align=center><img id=innerImg src='"+fn+"' /></td></tr><tr><td align=right>&nbsp;</td></tr></table><a id=marker></a>";
	document.getElementById("galleryContainer").appendChild(div);
	div.style.position = "relative";
	div.style.top = -(height)+"px";
	div.setAttribute("align", "center");
	div.style.backgroundColor = "#ffffff";
	div.style.width = width+'px';
	div.style.minHeight = height+'px';
	//document.write("Current Height: "+document.getElementById("galleryContainer").offsetHeight);
	//document.write("Insert Height: "+document.getElementById("largeImgDiv").offsetHeight);
	//document.write("Original Height: "+divHeight);
	document.getElementById("galleryContainer").style.height = divHeight+'px';
	//document.getElementById("galleryContainer").style.height = document.getElementById("largeImgDiv").offsetHeight+'px';
	
}

function closeBigImg() {
	var divInSitu = document.getElementById("largeImgDiv");
	document.getElementById("galleryContainer").removeChild(divInSitu);
	document.getElementById("galleryContainer").style.height = divHeight+'px';

	
	
}