/* ------------------------ */
/* Endev Javascript Library */
/* ------------------------ */

/* clicks the button and cancels the event when the user hits the enter key */
function trapKeyDown(btn, event)
{
	if (!event) return true;
	
	var keyCode = event.keyCode ? event.keyCode : event.which;
	
	if (keyCode == 13)
	{
		event.returnValue = false;
		event.cancel = true;
		btn.click();
	}
}

/* allows inputs to be styled on focus with a .efocus class */
eFocus = function()
{
	var sfEls = document.getElementsByTagName("INPUT");
	
	for (var i=0; i<sfEls.length; i++)
	{
		sfEls[i].onfocus=function()
		{
			this.className+=" efocus";
		}
		
		sfEls[i].onblur=function()
		{
			this.className=this.className.replace(new RegExp(" efocus\\b"), "");
		}
	}
}

if (window.attachEvent) window.attachEvent("onload", eFocus);


function ShowPopup(url, name, width, height)
{
	// Default sizes
	if (!width) width = 500;
	if (!height) height = 550;

	// Center popup
	var left = (screen.width - width)/2;
	var top = (screen.height - height)/2;

  	var popupWindow = window.open(url, name, "width=" + width + ",height=" + height + ",status=no,resizable=yes,scrollbars=yes,top=" + top + ",left=" + left + "");
	popupWindow.focus();
	popupWindow.opener = window;
	return false;
}


function ShowPhotoPopup(url, name, width, height)
{
	width += 200;
	height += 150;

	var MIN_WIDTH = 750;
	if (width < MIN_WIDTH) width = MIN_WIDTH;
	
	return ShowPopup(url, name, width, height);
}
