function openImage (picName, picFolder, width, height)

{

	var adjustment = 0.95;

	var maxWidth = 600;

	var maxHeight = 600;



	while (width > maxWidth)

	{

		width *= adjustment;

		height *= adjustment;

	}



	while (height > maxHeight)

	{

		width *= adjustment;

		height *= adjustment;

	}



	var xpos = 100;

	if (window.screenLeft)

		xpos = window.screenLeft + 100;

	else if (window.screenX)

		xpos = window.screenX + 100;



	if (screen.width && ((xpos + width) > screen.width))

		xpos = Math.max (0, screen.width - width - 100);



	var ypos = 100;

	if (window.screenTop)

		ypos = window.screenTop  + 100;

	else if (window.screenY)

		ypos = window.screenY + 100;



	if (screen.height && ((ypos + height) > screen.height))

		ypos = Math.max (0, screen.height - height - 100);



	window.open ('gi_pic.php?picName=' + picName + '&picFolder=' + picFolder + '&width=' + width + '&height=' + height, 'POPUP1', 'location=no,scrollbars=no,width=' + width + ',height=' + height + ',menubar=no,toolbar=no,directories=no,screenX=' + xpos + ',screenY=' + ypos + ',left=' + xpos + ',top=' + ypos);

}



function toggleDisplay (strName)

{

	var elem = getElement (strName);

	if (elem && elem.style)

	{

		if (elem.style.display == 'none')

			elem.style.display = 'block';

		else

			elem.style.display = 'none';

	}

}



function getElement (strName)

{

	var elem = null;

	if (document.all)

		elem = document.all[strName];

	if ((elem == null) && (document.getElementById))

		elem = document.getElementById (strName);

	if ((elem == null) && (document.getElementByName))

		elem = document.getElementByName (strName);

	return elem;

}

