/*###############################################################
			Pop-open Picture Function
input: the picture name,
       the element calling this function,
       the text displayed below the picture.

output: nothing
        (appends body to html, no need for output)

###############################################################*/
function openBig(picture, element, txt){
	/*###########  Creating Image Div  ###########*/
	var image=document.createElement('div');
	var height, width;
	image.appendChild(eval(picture));
	height=eval(picture).height;
	width=eval(picture).width;
	image.style.height = height+"px";

	/* ###########  Creating Text Div  ########### */
	var text=document.createElement('div');
	text.style.backgroundColor='#fff';
	var titleText = txt.split(" - ");
	var name=document.createElement('p');
	name.className="popoutText";
	name.innerHTML=titleText[0];
	text.appendChild(name);

	/* ###########  Creating Main Container Div  ########### */
	var content=document.createElement('div');
	content.id = "mouseover-image";
	content.style.border = "3px solid #67573E";
	content.style.position = "absolute";
	content.style.zIndex = "2";
	content.style.width = width+"px";

	if (navigator.userAgent.match('MSIE')){
		if (element.offsetParent) {
			var curleft = element.offsetLeft, curtop = element.offsetTop;
			var newEl = element;
			while (newEl = newEl.offsetParent) {
				curleft += newEl.offsetLeft;
				curtop += newEl.offsetTop;
				if (!newEl.offsetParent)
					break;
			}
		}
	} else if (navigator.userAgent.match('Chrome') || navigator.userAgent.match('Safari')){
		if (element.offsetParent) {
			var curleft = element.offsetLeft, curtop = element.offsetTop;
		}
	}

	if (navigator.userAgent.match('MSIE') || navigator.userAgent.match('Chrome') || navigator.userAgent.match('Safari')){
		content.style.top = (curtop + element.height)+"px";
		content.style.left = (curleft - (width/2) + (element.width/2))+"px";
	}else{
		content.style.left = (element.offsetLeft - (width/2) + (element.width/2))+"px";
	}

	/* ###########  Appending Divs Together  ########### */
	content.appendChild(image);
	content.appendChild(text);

	/* ###########    Inserting into Page    ########### */
	if (navigator.userAgent.match('MSIE')){
		document.body.appendChild(content);
	}else{
		element.parentNode.appendChild(content);
	}
}

function closeBig(){
	/* ###########  Removing pop-open from page  ########### */
	var pic = document.getElementById('mouseover-image');
	pic.parentNode.removeChild(pic);
}
