function openWindow(url, name, w, h) {
	newwin = window.open(url, name,"location=0,status=0,scrollbars=1,width=" + w + ",height=" + h + "");
	newwin.focus();
}

function ShowSelected (SectionToShow, NumSections) {
	for (x = 1; x <= NumSections; x++) {
		if (x != SectionToShow) {
			document.getElementById('Page' + x).style.display='none';
			//document.getElementById('Page' + x + 'Button').style.visibility='visible';
		} else {
			document.getElementById('Page' + x).style.display='block';
			//document.getElementById('Page' + x + 'Button').style.visibility='hidden';
		}
	}
	return true;
}

// ######## Used for "printer friendly" pages. ######## //
function resizeIframes() {
  try {
	iFramesArray = document.getElementsByTagName("IFRAME");
	for (var x=0; x<iFramesArray.length; x++) {
		id = "ifrm" + x;
	  	frame = document.getElementById(id);
	 	// Get the document within the frame. This is where you will fail with 'permission denied'
     	// if the document within the frame is not from the same domain as this document.
     	// Note: IE uses 'contentWindow', Opera uses 'contentDocument', Netscape uses either.
     	innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;

     	// Resize the style object, if it exists. Otherwise, resize the frame itself.
     	objToResize = (frame.style) ? frame.style : frame;

     	// Resize the object to the scroll height of the inner document body. You may still have 
     	// to add a 'fudge' factor to get rid of the scroll bar entirely. With a plain-vanilla 
     	// iframe, I found Netscape needs no fudge, IE needs 4 and Opera needs 5... 
     	// Of course, your mileage may vary.
     	objToResize.height = innerDoc.body.scrollHeight + 5;
		if (document.getElementById(id).contentDocument) { //Netscape
			document.getElementById(id).contentDocument.body.bgColor = "#FFFFFF";
		} else { //IE
			document.frames(id).document.bgColor = "#FFFFFF";
		}
  	} //for loop
  } catch (e) {
     window.status = e.message;
  }
}

// ######## Everything from here down is used to create the tool tips ######## //
// ### Example:
// ###	showToolTip('TEXT TO DISPLAY', 'OPTIONAL BACKGROUND COLOR', OPTIONAL TIP WIDTH)
// ###	onMouseover="showToolTip('Howdy y\'all','white', 300);"
// ### 	onMouseout="hideToolTip();"

var toolTipTextArray = new Array();
	toolTipTextArray[0] = "Click to view the full size image. ";
	toolTipTextArray[1] = "Click to view the video. ";
var offsetxpoint = -10;	 // ### Customize x offset of tooltip
var offsetypoint = 20;	 // ### Customize y offset of tooltip
var tipobj;
var ie = document.all;
var ns6 = document.getElementById && !document.all;
var enableTip = false;
var statusText = '';	// ### Displays in the status window

function getTipobj() {
	return tipobj = document.getElementById ? document.getElementById("tooltips") : "";
}

function ietruebody() {
	return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body
}

function showToolTip(thetext, thecolor, thewidth) {
	if (tipobj != "") {
		if (typeof thewidth != "undefined") {
			tipobj.style.width = thewidth + "px";
		}
		if (typeof thecolor != "undefined" && thecolor != "") {
			tipobj.style.backgroundColor = thecolor;
		}
		tipobj.innerHTML = thetext;
		if (ns6) {
			statusText = tipobj.innerHTML.replace(/<[^>]+>/g," ");
		} else {
			statusText = tipobj.innerText;
		}
		enableTip = true;
		return true;
	}
}

function positionToolTip(e) {
	if (enableTip) {
		var curX = (ns6) ? e.pageX : event.x + ietruebody().scrollLeft;
		var curY = (ns6) ? e.pageY : event.y + ietruebody().scrollTop;
		// ### Find out how close the mouse is to the corner of the window
		var rightedge = ie && !window.opera ? ietruebody().clientWidth - event.clientX - offsetxpoint : window.innerWidth - e.clientX - offsetxpoint - 20;
		var bottomedge = ie && !window.opera ? ietruebody().clientHeight - event.clientY - offsetypoint : window.innerHeight - e.clientY - offsetypoint - 20;
		var leftedge = (offsetxpoint < 0) ? offsetxpoint * (-1) : -1000;
		// ### if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge < tipobj.offsetWidth) {
			// ### move the horizontal position of the menu to the left by it's width
			tipobj.style.left = ie ? ietruebody().scrollLeft + event.clientX - tipobj.offsetWidth + "px" : window.pageXOffset + e.clientX - tipobj.offsetWidth + "px";
		} else if (curX < leftedge) {
			tipobj.style.left = "5px";
		} else {
			// ### position the horizontal position of the menu where the mouse is positioned
			tipobj.style.left = curX + offsetxpoint + "px";
		}
		// ### same concept with the vertical position
		if (bottomedge < tipobj.offsetHeight) {
			tipobj.style.top=ie ? ietruebody().scrollTop + event.clientY - tipobj.offsetHeight - offsetypoint + "px" : window.pageYOffset + e.clientY - tipobj.offsetHeight - offsetypoint + "px";
		} else {
			tipobj.style.top = curY + offsetypoint + "px";
		}
		tipobj.style.visibility = "visible";
	}
	window.status=statusText;
	return true;
}

function hideToolTip() {
	if ( tipobj != "" ) {
		enableTip = false;
		statusText='';
		tipobj.style.visibility = "hidden";
		tipobj.style.left = "-1000px";
		tipobj.style.backgroundColor = '';
		tipobj.style.width = '';
	}
}

document.onmousemove = positionToolTip;

// ######## end everything needed to create tool tips ######## //
