
// displays the popup
function openPU (img) {
	var id = 'popUp'; // the ID of the popup DIV
	var imgID = 'popUpImage';
	var popupOffset = 317;
	var popupHeight = 440;
	
	
	if (document.getElementById) {
		var popDiv = document.getElementById(id);
		var popImg = document.getElementById(imgID);
	} else if (document.all) {
		var popDiv = document.all[id];
		var popImg = document.all[imgID];
	} else if (document.layers) {
		var popDiv = document.layers[id];
		var popImg = document.layers[imgID];
	}
	
	// get the windows viewable height
	var windowHeight;
	if (self.innerHeight) // all except Explorer
	{
		windowHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		windowHeight = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		windowHeight = document.body.clientHeight;
	}
	//alert('Window Height: '+windowHeight);
	
	// get the scolled amount of the window
	var intOffsetY;
	if (self.pageYOffset) // all except Explorer
	{
		intOffsetY = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		intOffsetY = document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		intOffsetY = document.body.scrollTop;
	}
	//alert('scroll position: '+intOffsetX+', '+intOffsetY);
	
	popDiv.style.display = 'block';
	
	// compare scroll height to offset
		// if larger, set height to difference
		//if smaller use 0
		
		
	
	if (intOffsetY > popupOffset) { // top of the screen is past the starting point for the popup
		var offset = (intOffsetY - popupOffset) + ((windowHeight-popupHeight)/2);
		// make sure the offset is not negative
		if (offset < 0) {
			offset = 0;
		}
	} else {
		var offset = 0;
	}
	popDiv.style.top = offset + 'px';
	popImg.src = img;

}

// closes the popup
function closePU () {
	var id = 'popUp';
	
	if (document.getElementById)
		var popDiv = document.getElementById(id);
	else if (document.all)
		var popDiv = document.all[id];
	else if (document.layers)
		var popDiv = document.layers[id];
	
	popDiv.style.display = 'none';
}

// gets me the position of the object relative to the top left corner of the window
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
