function PhotoPopup (url,windowname,w,h) {
	window.open(url,windowname,'width='+(w+16)+',height='+(h+16)+',toolbar=no,location=no,status=no,menubar=yes,resizable=yes,scrollbars=yes');
}

function MenuToggle (section) {
	if (document.getElementById('menuitems_'+section) && document.getElementById('menutoggle_'+section)) {
		block = document.getElementById('menuitems_'+section);
		icon = document.getElementById('menutoggle_'+section);
		open_icon = 'menutoggle_open.gif';
		closed_icon = 'menutoggle_closed.gif';
		if (icon.src.toString().indexOf('_closed') > -1) {
			icon.src = icon.src.toString().replace(closed_icon,open_icon);
		} else {
			icon.src = icon.src.toString().replace(open_icon,closed_icon);
		}
		block.style.display = (block.style.display == 'none') ? 'block' : 'none';
		icon.blur();
		return true;
	}
}








// FLOATING "TOOLTIPS" WITH ARBITRARY HTML CODE
// From http://www.freejavascriptkit.com/free_javascripts/tooltip_hint/dhtml_mouseover_tooltip.html


var html_tooltip_x_offset = 0; // Customize x offset of tooltip
var html_tooltip_y_offset = 20; // Customize y offset of tooltip
var html_tooltip_ie = document.all;
var html_tooltip_ns6 = document.getElementById && !document.all;
var html_tooltip_enabled = false;
var html_tooltip_object = null;
function HTML_Tooltip_IETrueBody() { return (document.compatMode && document.compatMode!="BackCompat") ? document.documentElement : document.body; }

function HTML_Tooltip_Initialize() {
	if (!document.getElementById('html_tooltip') && document.body) {
		var tooltip_div = document.createElement('div'); tooltip_div.id = 'html_tooltip'; tooltip_div.innerHTML = '';
		document.body.appendChild(tooltip_div);
	}
	if (html_tooltip_ie||html_tooltip_ns6) {
		html_tooltip_object = (document.all) ? document.all['html_tooltip'] : document.getElementById ? document.getElementById('html_tooltip') : "";
	}
	document.onmousemove = HTML_Tooltip_Position;
}

function HTML_Tooltip_Create(thetext, thecolor, thewidth){
	if ((html_tooltip_ns6||html_tooltip_ie) && self.html_tooltip_object){
		if (typeof thewidth!="undefined") { html_tooltip_object.style.width=thewidth+"px"; }
		if (typeof thecolor!="undefined" && thecolor!="") { html_tooltip_object.style.backgroundColor = thecolor; }
		html_tooltip_object.innerHTML = thetext;
		html_tooltip_enabled = true;
		return false;
	}
}

function HTML_Tooltip_Position(e){
	if (html_tooltip_enabled && self.html_tooltip_object) {
		var curX = (html_tooltip_ns6) ? e.pageX : event.clientX+HTML_Tooltip_IETrueBody().scrollLeft;
		var curY = (html_tooltip_ns6) ? e.pageY : event.clientY+HTML_Tooltip_IETrueBody().scrollTop;
		// Find out how close the mouse is to the corner of the window
		var rightedge = (html_tooltip_ie && !window.opera) ? HTML_Tooltip_IETrueBody().clientWidth-event.clientX-html_tooltip_x_offset : window.innerWidth - e.clientX - html_tooltip_x_offset - 20;
		var bottomedge = (html_tooltip_ie && !window.opera) ? HTML_Tooltip_IETrueBody().clientHeight-event.clientY-html_tooltip_y_offset : window.innerHeight - e.clientY - html_tooltip_y_offset - 20;
		var leftedge = (html_tooltip_x_offset < 0) ? html_tooltip_x_offset*(-1) : -1000;
		
		// If the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge<html_tooltip_object.offsetWidth) {
			//move the horizontal position of the menu to the left by it's width
			html_tooltip_object.style.left = (html_tooltip_ie) ? HTML_Tooltip_IETrueBody().scrollLeft+event.clientX-html_tooltip_object.offsetWidth+"px" : window.pageXOffset+e.clientX-html_tooltip_object.offsetWidth+"px";
		} else if (curX<leftedge) {
			html_tooltip_object.style.left = '5px';
		} else {
			html_tooltip_object.style.left = curX+html_tooltip_x_offset+'px'; // position the horizontal position of the menu where the mouse is positioned
		}
		
		//same concept with the vertical position
		if (bottomedge < html_tooltip_object.offsetHeight) {
			html_tooltip_object.style.top = (html_tooltip_ie) ? HTML_Tooltip_IETrueBody().scrollTop+event.clientY-html_tooltip_object.offsetHeight-html_tooltip_y_offset+"px" : (window.pageYOffset+e.clientY-html_tooltip_object.offsetHeight*0.75-html_tooltip_y_offset)+"px";
		} else {
			html_tooltip_object.style.top = curY+html_tooltip_y_offset+"px";
		}
		html_tooltip_object.style.visibility = 'visible';
	}
}

function HTML_Tooltip_Hide(){
	if ((html_tooltip_ns6||html_tooltip_ie) && self.html_tooltip_object) {
		html_tooltip_object.style.visibility = 'hidden';
		html_tooltip_object.style.left = '-1000px';
		html_tooltip_object.style.backgroundColor = '';
		html_tooltip_object.style.width = '';
		html_tooltip_enabled = false;
	}
}



