

var ie5 = document.all;
function showBig(imgUrl,e) {

	if (document.getElementById('tempImgDiv')===null) {
		var dv = document.createElement('div');
		dv.className="zoomdiv";
		dv.setAttribute("id","tempImgDiv");
		dv.style.position = "absolute";
		document.getElementsByTagName('body')[0].appendChild(dv);
	}
	document.getElementById('tempImgDiv').style.display="block";
	document.getElementById('tempImgDiv').innerHTML = '<img src="'+imgUrl+'" />';
	setPositions(document.getElementById('tempImgDiv'),e);


}

function hideBig() {

	document.getElementById('tempImgDiv').style.display="none";

}

function setPositions(elem,e) {
    var rightedge;
    if (ie5) {
        rightedge = document.body.clientWidth-event.clientX;
    } else {
        rightedge = window.innerWidth-e.clientX;
    }
    var bottomedge;
    if (ie5) {
        bottomedge = document.body.clientHeight-event.clientY;
    } else {
        bottomedge = window.innerHeight-e.clientY;
    }

    //if the horizontal distance isn't enough to accomodate the width of the context menu
    if (rightedge < elem.offsetWidth) {
        //move the horizontal position of the menu to the left by it''s width
        if(ie5) {
            elem.style.left = ""+(document.body.scrollLeft+event.clientX-elem.offsetWidth-2)+"px";
        } else {
            elem.style.left = ""+(window.pageXOffset+e.clientX-elem.offsetWidth-2)+"px";
        }
    } else {
        //position the horizontal position of the menu where the mouse was clicked
        if (ie5) {
            elem.style.left = ""+(document.body.scrollLeft+event.clientX+2)+"px";
        } else {
            elem.style.left = ""+(window.pageXOffset+e.clientX+2)+"px";
        }
    }
    //same concept with the vertical position
    if (bottomedge < elem.offsetHeight) {
        if (ie5) {
            elem.style.top = ""+(document.body.scrollTop+event.clientY-elem.offsetHeight-2)+"px";
        } else {
            elem.style.top = ""+(window.pageYOffset+e.clientY-elem.offsetHeight-2)+"px";
        }
    } else {
        if (ie5) {
            elem.style.top = ""+(document.body.scrollTop+event.clientY+2)+"px";
        } else {
            elem.style.top = ""+(window.pageYOffset+e.clientY+2)+"px";
        }
    }
}
