
/***************************************************************************
 *                              showImage.js
 *                               ----------
 * [INFO]
 *	 AUTHOR				  : Kevin K. Nelson
 *   EMAIL                : knelson@taoti.com
 *   COPYRIGHT            : (C) 2006 Taoti Enterprises International, Inc.
 *                           -  ALL RIGHTS RESERVED
 *
 *   LAST UPDATED         : 2006-03-27
 *   CREATED              : 2004-12-07
 *   VERSION              : 1.0.1
 *
 *   PURPOSE              : pop-up image in center of screen without a pop-
 *                          up window.
 *
 *   DEPENDS ON           : common.js.php
 *
 * [TESTING NOTES]
 *  2006-03-27 - TESTED ON OPERA 8.51  (BUG: shows at bottom of screen)
 *               The bug in Opera is apparently only with HTML 4.01 Transitional
 *               DOCTYPE, or has to do with the URL being included in the DOCTYPE...
 *               Changing DOCTYPE to the following seems to fix it for time being:
 *               <!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
 *  2004-12-07 - TESTED ON OPERA 7.54  (works under IE scheme)
 *  2006-03-27 - TESTED ON FIREFOX 1.5 (continues to work fine)
 *  2004-12-07 - TESTED ON FIREFOX 1.0 (works under NETSCAPE scheme)
 *  2004-12-07 - TESTED ON NETSCAPE 7  (works under NETSCAPE scheme)
 *  2006-03-27 - TESTED ON IE 6.0.29   (continues to work fine)
 *  2004-12-07 - TESTED ON IE 6.0.2    (works under IE scheme)
 *
 * [UPDATE NOTES]
 *  2006-03-27 - v. 1.0.1: Relies on BASE_DIR variable created in 
 *               common.js.php, which is part of Library 2.0.
 *             - Add Version Number 1.0.1
 *  2004-12-07 - NETSCAPE scheme interprets offsetWidth as whole width
 *               including areas of page off screen, so needed "innerWidth".
 *               IE and Opera are both fine with offsetWidth property.
 *             - scrollLeft and scrollTop both work in Netscape 7, but it seems
 *               I've had problems with that in N6 in the past
 *             - IE scheme needs the getBody() method, because if it's in
 *               compatibility mode, it required document.body.scrollTop/Left to
 *               be document.body.parentNode.scrollTop/Left (compatibility mode
 *               is dependent on DOCTYPE of the HTML).
 *
 ***************************************************************************/

//debugWrite( document.body.parentNode.scrollTop );
if( IS_DYNAMIC_BROWSER ) {
    document.write("<div id='img_container' onclick='javascript:this.style.display=\"none\"' style='display:none;position:absolute;left:0px;top:0px;z-index:1;width:0px;height:0px;'> </div>");
}

function centerObjectOnPage( p_strID ) {
	arrPositions					= new Array();
    iPageWidth      				= IS_NETSCAPE ? window.innerWidth  : getBody().offsetWidth;
    iPageHeight     				= IS_NETSCAPE ? window.innerHeight : getBody().offsetHeight;
	iScrollTop						= IS_NETSCAPE ? window.pageYOffset : getBody().scrollTop;
	iScrollLeft						= IS_NETSCAPE ? window.pageXOffset : getBody().scrollLeft;
	
    iLeftPosition   				= (( iPageWidth  - parseInt(getTagByID(p_strID).style.width ) ) / 2) + iScrollLeft;
    iTopPosition    				= (( iPageHeight - parseInt(getTagByID(p_strID).style.height) ) / 2) + iScrollTop;

	arrPositions['left']			= iLeftPosition;
	arrPositions['top']				= iTopPosition;

    getTagByID(p_strID).style.left  = arrPositions['left'] + "px";
    getTagByID(p_strID).style.top   = arrPositions['top']  + "px";
	
	return( arrPositions );
}
function showImage( p_strURL, p_iWidth, p_iHeight ) {
	if( IS_DYNAMIC_BROWSER ) {
		getTagByID('img_container').style.width             = p_iWidth + "px";
		getTagByID('img_container').style.height            = p_iHeight + "px";
		arrLocation											= centerObjectOnPage('img_container');
		getTagByID('img_container').innerHTML				= "<img src='" + p_strURL + "' width='" + p_iWidth + "' height='" + p_iHeight + "' />";
		getTagByID('img_container').style.display           = "block";
	}
	else {
		alert("We're sorry, but your browser does not meet current JavaScript standards and is unable to pop-up the full-sized image.\n\nPlease upgrade to a current browser:\n - Internet Explorer 5+ (www.microsoft.com)\n - Netscape 7 (www.netscape.com)\n - FireFox 1+ (www.mozilla.com)\n - Opera 7 (www.opera.com)");
	}
}

