/*******************************
 * Global Variable Definations *
 *******************************/
   var ZoomImageOriginalWidth;
   var ZoomImageOriginalHeight;
   var ZoomImageZoomed;

function Test()
/*************************************************
 * Stub Function to test if a call is being made. *
 *************************************************/
   {
      alert('Test Function');
      return true;
   }

function GetBrowserWidth()
/*
 * Get Browser Width
 *
 * Modified by: Joe Terrell (Joe@JoeTerrell.com)
 * Date Written: 13 August 2011
 *
 * Determine the width of the browser window compensating for old browsers and
 * compensating of non-standard implementations in Internet Explorer.
 *
 * Inputs:  		NONE 	
 * 
 * Return:			Width of the Browser in pixels
 *
 * Dependencies:  NONE
 */
{
	var winW = 630;
	if (document.body && document.body.offsetWidth) {
		winW = document.body.offsetWidth;
	}
	if (document.compatMode=='CSS1Compat' &&
		document.documentElement &&
		document.documentElement.offsetWidth ) {
		winW = document.documentElement.offsetWidth;
	}
	if (window.innerWidth && window.innerHeight) {
 		winW = window.innerWidth;
	}
   return winW;
}

function GetBrowserHeight()
/*
 * Get Browser Height
 *
 * Modified by: Joe Terrell (Joe@JoeTerrell.com)
 * Date Written: 13 August 2011
 *
 * Determine the height of the browser window compensating for old browsers and
 * compensating of non-standard implementations in Internet Explorer.
 *
 * Inputs:  		NONE 	
 * 
 * Return:			Height of the Browser in pixels
 *
 * Dependencies:  NONE
 */
{
	var winH = 460;
	if (document.body && document.body.offsetWidth) {
		winH = document.body.offsetHeight;
	}
	if (document.compatMode=='CSS1Compat' &&
		document.documentElement &&
		document.documentElement.offsetWidth ) {
		winH = document.documentElement.offsetHeight;
	}
	if (window.innerWidth && window.innerHeight) {
 		winH = window.innerHeight;
	}
	return winH;
}

function ZoomImage(id,factor)
/*
 * Zoom IN Image
 *
 * Written by: Joe Terrell (Joe@JoeTerrell.com)
 * Date Written: 26 March 2011
 *
 * If the image is not zoomed, then zoom in.  Otherwise zoom out to orginal size.
 *
 * Inputs: 	id		Object ID of the image to zoom
 *		[factor]	Zoom Factor (Percent to increase) - Must be in decimal form.
 * 
 * Return:			Always returns TRUE
 *
 * Dependencies:  Must have three global variables defined outside the function in order to 
 *                retain the original width, original height, and zoom toggle status from
 *                one call of the function to the next.
 *
 *                      var ZoomImageOriginalWidth;
 *                      var ZoomImageOriginalHeight;
 *                      var ZoomImageZoomed;
 *
 */

{
   var width,height,incw,inch,zoomfactor;
   var image = document.getElementById(id);
   var width = image.width;
   var height = image.height;
   var defaultzoomfactor = 0.5;

   if (factor == null) {
      zoomfactor = defaultzoomfactor;
   }
   else {
      zoomfactor = factor;
   }   

   if (ZoomImageZoomed == false || ZoomImageZoomed == null) {
      ZoomImageOriginalWidth = width;
      ZoomImageOriginalHeight = height;
      incw = width * zoomfactor;
      inch = height * zoomfactor;
      width += incw;
      height += inch;
      image.width = width;
      image.height = height;
      ZoomImageZoomed = true;
   }
   else {
      image.width = ZoomImageOriginalWidth;
      image.height = ZoomImageOriginalHeight;
      ZoomImageZoomed = false;
   }

   image.style.zIndex = 250;
   image.scrollIntoView(true);
   return true;
}



function ZoomInImage(id, tagwidth, tagheight, factor)
/*
 * Zoom IN Image
 *
 * Written by: Joe Terrell (Joe@JoeTerrell.com)
 * Date Written: 25 March 2011
 *
 * If the image is not zoomed, then zoom in.  Otherwise zoom out to orginal size.
 * However, user is required to define the original width, original height, and desired zoom factor.
 *
 * Inputs: 	id		Object ID of the image to zoom
 *		tagwidth	User defined original width of the image
 *		tagheight	User defined original height of the image
 *		factor		Zoom Factor (Percent to increase) - Must be in decimal form.
 * 
 * Return:			Always returns TRUE
 *
 * Dependencies:	None
 *
 */
{
   var newwidth;
   var newheight;
   var incw,inch;
   var zoomed;

   var image = document.getElementById(id); 
   var originalwidth = tagwidth;
   var originalheight = tagheight;
   var zoomfactor = factor;
   var currentwidth = image.width;
   var currentheight = image.height;

   if (originalwidth == currentwidth) {
      newwidth = currentwidth;
      newheight = currentheight;
      incw = newwidth * zoomfactor;
      inch = newheight * zoomfactor;
      newwidth += incw;
      newheight += inch;
      image.width = newwidth;
      image.height = newheight;
   }
   else
   {
      image.width = originalwidth;
      image.height = originalheight;
   }
   image.style.zIndex = 250;
   image.scrollIntoView(true);
   return true;
}



