function zoomDiv(id) {
	
	this.id = id;
	
	window["zoomDiv"+id] = this;
}

// Settings

zoomDiv.prototype.includeCaption  = 1;                           // Turn on the "caption" feature, and write out the caption HTML
zoomDiv.prototype.zoomTime        = 5;                           // Milliseconds between frames of zoom animation
zoomDiv.prototype.zoomSteps       = 15;                          // Number of zoom animation frames
zoomDiv.prototype.fade            = 1;                           // Fade images in / out
zoomDiv.prototype.minBorder       = 90;                          // Amount of padding between large, scaled down images, and the window edges
zoomDiv.prototype.shadowOpacity   = 50;                          // opacity of shadow div
zoomDiv.prototype.shadowPadding   = { l:20, r:20, t:20, b:20 };  // amount of padding between shadow div and contents
zoomDiv.prototype.shadowFadeSteps = 5;                           // number of steps for shadow & clode but fade
zoomDiv.prototype.hideObjects     = false;                       // will hide object and embed tags on zoom to avoid overlay, not needed if Flash wmode set to opaque

zoomDiv.prototype.zoomImageURI   = '/media/'; // Location of the zoom images

zoomDiv.prototype.htmlFunc   = 'insertZoomHTML'; // js function called to insert html

// Init. Do not add anything below this line, unless it's something awesome.

zoomDiv.prototype.myWidth = 0;
zoomDiv.prototype.myHeight = 0;
zoomDiv.prototype.myScroll = 0;
zoomDiv.prototype.myScrollWidth = 0;
zoomDiv.prototype.myScrollHeight = 0;
zoomDiv.prototype.zoomOpen = false;
zoomDiv.prototype.preloadFrame = 1;
zoomDiv.prototype.preloadActive = false;
zoomDiv.prototype.preloadTime = 0;
zoomDiv.prototype.imgPreload = new Image();

zoomDiv.prototype.zoomActive = new Array();
zoomDiv.prototype.zoomTimer  = new Array(); 
zoomDiv.prototype.zoomOrigW  = new Array();
zoomDiv.prototype.zoomOrigH  = new Array();
zoomDiv.prototype.zoomOrigX  = new Array();
zoomDiv.prototype.zoomOrigY  = new Array();

zoomDiv.prototype.zoomID    = "ZoomBox";
zoomDiv.prototype.theID     = "ZoomImage";
zoomDiv.prototype.theCap    = "ZoomCaption";
zoomDiv.prototype.theCapDiv = "ZoomCapDiv";
zoomDiv.prototype.shadowDiv = "ShadowBox";
zoomDiv.prototype.closeDiv = "ZoomClose";
zoomDiv.prototype.spinImage = "SpinImage";
zoomDiv.prototype.spinDiv = "ZoomSpin";

// used to limit a zoom: rewrites to certain divs incase multiple zoomDiv instances on one page
zoomDiv.prototype.parentImageDiv = "";

// Zoom: Setup The Page! Called onLoad();

zoomDiv.prototype.init = function() {
	this.onClickHandlers();
	eval(this.htmlFunc+"();");
	this.zoomdiv = document.getElementById(this.zoomID);  
	this.zoomimg = document.getElementById(this.theID);
}

// Zoom: Inject Javascript functions into zoomable href's, one by one.
// This is done at page load time via an onLoad() handler.

zoomDiv.prototype.onClickHandlers = function() {

	if (! document.getElementsByTagName) {
		return;
	}
	
	if (this.parentImageDiv == "") {
	
		var links = document.getElementsByTagName("a");
	}
	else {
		var parentDiv = document.getElementById(this.parentImageDiv);
		var links = parentDiv.getElementsByTagName("a")
	}
		
	for (i = 0; i < links.length; i++) {
		if (links[i].getAttribute("href") && (links[i].getAttribute("rel"))) {
			if (links[i].getAttribute("rel").indexOf("zoom:") == 0) {
				str = "zoomDiv"+this.id;
				links[i].onclick = function () { window[str].zoomClick(this); return false; };
				links[i].onmouseover = function () { window[str].zoomPreload(this); };
			}
		}
	}
}

// Zoom: Preload a zoom image when hovering over the thumbnail, then set the image once the preload is complete.
// Preloaded image is stored in imgPreload() and swapped out in the zoom function.

zoomDiv.prototype.zoomPreload = function(from) {

	var theimage = from.getAttribute("href");
	//alert("PRELOAD START: "+theimage);

	// Only preload if we have to, i.e. the image isn't this image already
	
	if (this.imgPreload.src.indexOf(from.getAttribute("href").substr(from.getAttribute("href").lastIndexOf("/"))) == -1) {
		
		
		
		this.preloadActive = true;
		this.imgPreload = new Image();
      
		// Set a function to fire when the preload is complete, setting flags along the way.
   		
   		str = "zoomDiv"+this.id;
   		
		this.imgPreload.onload = function() {
			// console.log("PRELOAD END");
			window[str].preloadActive = false;
		}

		// Load it!
		this.imgPreload.src = theimage;
	}
}

// Zoom: Start the preloading animation cycle.

zoomDiv.prototype.preloadAnimStart = function() {
	this.preloadTime = new Date();
	document.getElementById(this.spinDiv).style.left = (this.myWidth / 2) + 'px';
	document.getElementById(this.spinDiv).style.top = ((this.myHeight / 2) + this.myScroll) + 'px';
	document.getElementById(this.spinDiv).style.visibility = "visible";	
	this.preloadFrame = 1;
	document.getElementById(this.spinImage).src = this.zoomImageURI+'zoom-spin-'+this.preloadFrame+'.png';
	this.preloadAnimTimer = window.setInterval("window.zoomDiv"+this.id+".preloadAnim()", 100);
}

// Until we've been preloading for one second, just chill out in here.
// 
// function preloadAnimPending(from) {
// 	if (preloadActive != false) {
// 		if ((new Date() - preloadTime) > 1000) {
// 			document.getElementById("ZoomSpin").style.visibility = "visible";
// 			clearInterval(preloadAnimTimer);
// 			preloadAnimTimer = setInterval("preloadAnim()", 100);
// 		}
// 		else {
// 			// Stay in this loop and don't do anything while we wait one second
// 		}
// 	} else {
// 		clearInterval(preloadAnimTimer);
// 		zoomIn(preloadFrom);
// 	}
// } 

// Zoom: Display and ANIMATE the jibber jabber widget. Once preloadActive is false, bail and zoom it up!

zoomDiv.prototype.preloadAnim = function(from) {
	if (this.preloadActive != false) {
		document.getElementById(this.spinImage).src = this.zoomImageURI+'zoom-spin-'+this.preloadFrame+'.png';
		this.preloadFrame++;
		if (this.preloadFrame > 12) this.preloadFrame = 1;
	} else {
		document.getElementById(this.spinDiv).style.visibility = "hidden";    
		clearInterval(this.preloadAnimTimer);
		this.zoomIn(this.preloadFrom);
	}
}

// Zoom: We got a click! Should we do the zoom? Or wait for the preload to complete?

zoomDiv.prototype.zoomClick = function(from) {

	// TODO: Double check that imgPreload src = clicked src
	
	if (this.hideObjects) {
	
		var objs = document.getElementsByTagName("object");
		for (i=0; i<objs.length; i++) {
			objs[i].style.visibility = "hidden";
		}
		
		var objs = document.getElementsByTagName("embed");
		for (i=0; i<objs.length; i++) {
			objs[i].style.visibility = "hidden";
		}
	}
	

	// Get browser dimensions
	this.getSize();
	
	if (this.preloadActive == true) {
		// Preloading is otherwise still going on. So wait.
		this.preloadFrom = from;
		this.preloadAnimStart();
	} else {
		// Otherwise, we're loaded: do the zoom!
		this.zoomIn(from);
	}
}

// Zoom: Move an element in to endH endW, using zoomHost as a starting point.
// "from" is an object reference to the href that spawned the zoom.

zoomDiv.prototype.zoomIn = function(from) {

	this.zoomimg.src = from.getAttribute("href");

	// Determine the zoom settings from where we came from, the element in the <a>.
	// If there's no element in the <a>, or we can't get the width, make stuff up

	if (from.childNodes[0].width) {
		startW = from.childNodes[0].width;
		startH = from.childNodes[0].height;
		startPos = this.findElementPos(from.childNodes[0]);
	} else {
		startW = 50;
		startH = 12;
		startPos = this.findElementPos(from);
	}
		    
	hostX = startPos[0];
	hostY = startPos[1];

	// Make up for a scrolled containing div.
	// TODO: This HAS to move into findElementPos.
	
	/*if (document.getElementById('scroller')) {
		hostX = hostX - document.getElementById('scroller').scrollLeft;
	}*/

	// Determine the target zoom settings

	endW = this.imgPreload.width;
	endH = this.imgPreload.height;
	
	// TODO: need to get "rollover" setting somehow.
  
	// Don't act if we're already doing something.
  
	if (this.zoomActive[this.theID] != true) {
  
		// Clear everything out just in case something is already open
     
		document.getElementById(this.shadowDiv).style.visibility = 'hidden';
		document.getElementById(this.closeDiv).style.visibility = 'hidden';     
     
		// Set the CAPTION if turned on
  
		if (this.includeCaption == 1) {
			zoomcap  = document.getElementById(this.theCap);
			zoomcapd = document.getElementById(this.theCapDiv);
       
			if (from.getAttribute('title') && this.includeCaption == 1) {
				zoomcap.innerHTML = from.getAttribute('title');
			} else {
				zoomcapd.style.display = 'none';
			}
       
		}   
     
		// Store original position in an array for future zoomOut.

		this.zoomOrigW[this.theID] = startW;
		this.zoomOrigH[this.theID] = startH;
		this.zoomOrigX[this.theID] = hostX;
		this.zoomOrigY[this.theID] = hostY;
     	
		// Now set the starting dimensions
     
		this.zoomimg.style.width = startW + 'px';
		this.zoomimg.style.height = startH + 'px';
		this.zoomdiv.style.left = hostX + 'px';
		this.zoomdiv.style.top = hostY + 'px';
     
		// Show the zoom box, make it invisible
     
		if (this.fade == 1) {
			this.setOpacity(0, this.zoomID);
		}
		this.zoomdiv.style.visibility = "visible";
  
		// If it's too big to fit in the window, shrink the width and height to fit (with ratio).
  
		sizeRatio = endW / endH;
		if (endW > this.myWidth - this.minBorder) {
			endW = this.myWidth - this.minBorder;
			endH = endW / sizeRatio;
		}
		if (endH > this.myHeight - this.minBorder) {
			endH = this.myHeight - this.minBorder;
			endW = endH * sizeRatio;
		}

		zoomChangeX = ((this.myWidth / 2) - (endW / 2) - hostX);
		zoomChangeY = (((this.myHeight / 2) - (endH / 2) - hostY) + this.myScroll);
		zoomChangeW = (endW - startW);
		zoomChangeH = (endH - startH);
		
		// console.log("X: "+zoomChangeX+" Y: "+zoomChangeY+" W: "+zoomChangeW+" H: "+zoomChangeH);

		// Setup Zoom
     
		zoomCurrent = 0;
     
		// Setup Fade with Zoom, If Requested
     
		if (this.fade == 1) {
			fadeCurrent = 0;
			fadeAmount = (0 - 100) / this.zoomSteps;
		} else {
			fadeAmount = 0;
		}
       
		// Do It!
		
		this.zoomTimer[this.theID] = setInterval("window.zoomDiv"+this.id+".zoomElement('"+this.zoomID+"', '"+this.theID+"', "+zoomCurrent+", "+startW+", "+zoomChangeW+", "+startH+", "+zoomChangeH+", "+hostX+", "+zoomChangeX+", "+hostY+", "+zoomChangeY+", "+this.zoomSteps+", "+this.fade+", "+fadeAmount+", 'this.zoomDoneIn(this.zoomID)')", this.zoomTime);		
		this.zoomActive[this.theID] = true; 
	}
}

// Zoom it back out.

zoomDiv.prototype.zoomOut = function() {

	// Check to see if something is happening/open
  
	if (this.zoomActive[this.theID] != true) {
     
		// First, get rid of the shadow if necessary
     
		document.getElementById(this.shadowDiv).style.visibility = "hidden";
		document.getElementById(this.closeDiv).style.visibility = "hidden";  
		document.getElementById(this.theCapDiv).style.visibility = "hidden";  
     
		// Now, figure out where we came from, to get back there

		startX = parseInt(this.zoomdiv.style.left);
		startY = parseInt(this.zoomdiv.style.top);
		startW = this.zoomimg.width;
		startH = this.zoomimg.height;
		zoomChangeX = this.zoomOrigX[this.theID] - startX;
		zoomChangeY = this.zoomOrigY[this.theID] - startY;
		zoomChangeW = this.zoomOrigW[this.theID] - startW;
		zoomChangeH = this.zoomOrigH[this.theID] - startH;
    
		// Setup Zoom
	   
		zoomCurrent = 0;
     
		// Setup Fade with Zoom, If Requested
     
		if (this.fade == 1) {
			fadeCurrent = 0;
			fadeAmount = (100 - 0) / this.zoomSteps;
		} else {
			fadeAmount = 0;
		}
     
		// Do It!

		this.zoomTimer[this.theID] = setInterval("window.zoomDiv"+this.id+".zoomElement('"+this.zoomID+"', '"+this.theID+"', "+zoomCurrent+", "+startW+", "+zoomChangeW+", "+startH+", "+zoomChangeH+", "+startX+", "+zoomChangeX+", "+startY+", "+zoomChangeY+", "+this.zoomSteps+", "+this.fade+", "+fadeAmount+", 'this.zoomDone(this.zoomID, this.theID)')", this.zoomTime);	
		this.zoomActive[this.theID] = true;
   }
}

// Finished Zooming In

zoomDiv.prototype.zoomDoneIn = function(zoomdiv, theID) {

	// Note that it's open
  
	this.zoomOpen = true;

	// Make sure they are gone

	this.setOpacity(0, this.shadowDiv);
	this.setOpacity(0, this.closeDiv);

	// Position the shadow behind the zoomed in image.

	zoomdiv = document.getElementById(zoomdiv);
	shadowdiv = document.getElementById(this.shadowDiv);
	closediv = document.getElementById(this.closeDiv);
	thecapdiv = document.getElementById(this.theCapDiv);
 
	shadowLeft = parseInt(zoomdiv.style.left) - this.shadowPadding.l;
	shadowTop = parseInt(zoomdiv.style.top) - this.shadowPadding.t;
	shadowWidth = zoomdiv.offsetWidth + this.shadowPadding.l + this.shadowPadding.r;
	shadowHeight = zoomdiv.offsetHeight + this.shadowPadding.t + this.shadowPadding.b;
	
	closeLeft = parseInt(zoomdiv.style.left) - 10;
	closeTop = parseInt(zoomdiv.style.top) - 10;
	
	capLeft = parseInt(zoomdiv.style.left);
	capTop = parseInt(zoomdiv.style.top);

	shadowdiv.style.width = shadowWidth + 'px';
	shadowdiv.style.height = shadowHeight + 'px';
	shadowdiv.style.left = shadowLeft + 'px';
	shadowdiv.style.top = shadowTop + 'px';
	
	closediv.style.left = closeLeft + 'px';
	closediv.style.top = closeTop + 'px';
	
	thecapdiv.style.left = capLeft + 'px';
	thecapdiv.style.top = capTop + 'px';
  
	// Display Shadow and Zoom
  
	document.getElementById(this.shadowDiv).style.visibility = "visible";
	this.fadeElementSetup(this.shadowDiv, 0, this.shadowOpacity, this.shadowFadeSteps);
	document.getElementById(this.closeDiv).style.visibility = "visible";
	this.fadeElementSetup(this.closeDiv, 0, 100, this.shadowFadeSteps);
	document.getElementById(this.theCapDiv).style.visibility = "visible";
	this.fadeElementSetup(this.theCapDiv, 0, 100, this.shadowFadeSteps);
  
}

// Finished Zooming Out

zoomDiv.prototype.zoomDone = function(zoomdiv, theID) {

	// No longer open
  
	this.zoomOpen = false;

	// Clear stuff out, clean up

	this.zoomOrigH[theID] = "";
	this.zoomOrigW[theID] = "";
	document.getElementById(zoomdiv).style.visibility = "hidden";
	document.getElementById(zoomdiv).style.left = "-1000px";
	document.getElementById(this.shadowDiv).style.visibility = "hidden";
	document.getElementById(this.shadowDiv).style.left = "-1000px";
	document.getElementById(this.closeDiv).style.visibility = "hidden";
	document.getElementById(this.closeDiv).style.left = "-1000px";
	document.getElementById(this.theCapDiv).style.visibility = "hidden";
	document.getElementById(this.theCapDiv).style.left = "-1000px";
	this.zoomActive[theID] == false;
	
	if (this.hideObjects) {
	
		var objs = document.getElementsByTagName("object");
		for (i=0; i<objs.length; i++) {
			objs[i].style.visibility = 'visible';
		}
		
		var objs = document.getElementsByTagName("embed");
		for (i=0; i<objs.length; i++) {
			objs[i].style.visibility = 'visible';
		}
	}
}

// Actually zoom the element

zoomDiv.prototype.zoomElement = function(zoomdiv, theID, zoomCurrent, zoomStartW, zoomChangeW, zoomStartH, zoomChangeH, zoomStartX, zoomChangeX, zoomStartY, zoomChangeY, zoomSteps, fade, fadeAmount, execWhenDone) {

	// console.log("Zooming Step #"+zoomCurrent+ " of "+zoomSteps+" (zoom " + zoomStartW + "/" + zoomChangeW + ") (zoom " + zoomStartH + "/" + zoomChangeH + ")  (zoom " + zoomStartX + "/" + zoomChangeX + ")  (zoom " + zoomStartY + "/" + zoomChangeY + ") Fade: "+fadeAmount);
    
	// Test if we're done, or if we continue

	if (zoomCurrent == (zoomSteps + 1)) {
		this.zoomActive[theID] = false;
		clearInterval(this.zoomTimer[theID]);

		if (execWhenDone != "") {
			eval(execWhenDone);
		}
	} else {
	
		// Do the Fade!
	  
		if (fade != 0) {
			if (fadeAmount < 0) {
				this.setOpacity(Math.abs(zoomCurrent * fadeAmount), zoomdiv);
			} else {
				this.setOpacity(100 - (zoomCurrent * fadeAmount), zoomdiv);
			}
		}
	  
		// Calculate this step's difference, and move it!
		
		moveW = this.cubicInOut(zoomCurrent, zoomStartW, zoomChangeW, zoomSteps);
		moveH = this.cubicInOut(zoomCurrent, zoomStartH, zoomChangeH, zoomSteps);
		moveX = this.cubicInOut(zoomCurrent, zoomStartX, zoomChangeX, zoomSteps);
		moveY = this.cubicInOut(zoomCurrent, zoomStartY, zoomChangeY, zoomSteps);
	
		document.getElementById(zoomdiv).style.left = moveX + 'px';
		document.getElementById(zoomdiv).style.top = moveY + 'px';
		this.zoomimg.style.width = moveW + 'px';
		this.zoomimg.style.height = moveH + 'px';
	
		zoomCurrent++;
		
		clearInterval(this.zoomTimer[theID]);
		this.zoomTimer[theID] = setInterval("window.zoomDiv"+this.id+".zoomElement('"+zoomdiv+"', '"+theID+"', "+zoomCurrent+", "+zoomStartW+", "+zoomChangeW+", "+zoomStartH+", "+zoomChangeH+", "+zoomStartX+", "+zoomChangeX+", "+zoomStartY+", "+zoomChangeY+", "+zoomSteps+", "+fade+", "+fadeAmount+", '"+execWhenDone+"')", this.zoomTime);
	}
}

// Zoom Rollover Functions
// To be re-added

zoomDiv.prototype.zoomMouseOver = function() {
//  if (rollOverImg) {
//     if (document.getElementById("ZoomImage").src != rollOverImg) {
//        document.getElementById("ZoomImage").src = rollOverImg;
//     }
//  }
}

zoomDiv.prototype.zoomMouseOut = function() {
//  if (rollOverImg) {
//     if (document.getElementById("ZoomImage").src != image) {
//        document.getElementById("ZoomImage").src = image;
//     }
//  }
}

////////////////////////////
//
// FADE Functions
//

zoomDiv.prototype.fadeOut = function(elem) {
	if (elem.id) {
		this.fadeElementSetup(elem.id, 100, 0, 10);
	}
}

zoomDiv.prototype.fadeIn = function(elem) {
	if (elem.id) {
		this.fadeElementSetup(elem.id, 0, 100, 10);	
	}
}

// Fade: Initialize the fade function

zoomDiv.prototype.fadeActive = new Array();
zoomDiv.prototype.fadeQueue  = new Array();
zoomDiv.prototype.fadeTimer  = new Array();
zoomDiv.prototype.fadeClose  = new Array();

zoomDiv.prototype.fadeElementSetup = function(theID, fdStart, fdEnd, fdSteps, fdClose) {

	if (this.fadeActive[theID] == true) {
		// Already animating, queue up this command
		this.fadeQueue[theID] = new Array(theID, fdStart, fdEnd, fdSteps);
	} else {
		fadeSteps = fdSteps;
		fadeCurrent = 0;
		fadeAmount = (fdStart - fdEnd) / fadeSteps;
		this.fadeTimer[theID] = setInterval("window.zoomDiv"+this.id+".fadeElement('"+theID+"', '"+fadeCurrent+"', '"+fadeAmount+"', '"+fadeSteps+"')", 15);
		this.fadeActive[theID] = true;
		if (fdClose == 1) {
			this.fadeClose[theID] = true;
		} else {
			this.fadeClose[theID] = false;
		}
	}
}

// Fade: Do the fade. This function will call itself, modifying the parameters, so
// many instances can run concurrently.

zoomDiv.prototype.fadeElement = function(theID, fadeCurrent, fadeAmount, fadeSteps) {
  
	if (fadeCurrent == fadeSteps) {

	    // We're done, so clear.
	    clearInterval(this.fadeTimer[theID]);
	    this.fadeActive[theID] = false;
	    
	    // Should we close it?
	    
	    if (this.fadeClose[theID] == true) {
	    	document.getElementById(theID).style.visibility = "hidden";
	    }
	    
	    // Hang on.. did a command queue while we were working? If so, make it happen now
	    
	    if (this.fadeQueue[theID] && this.fadeQueue[theID] != false) {
	    	this.fadeElementSetup(this.fadeQueue[theID][0], this.fadeQueue[theID][1], this.fadeQueue[theID][2], this.fadeQueue[theID][3]);
	    	this.fadeQueue[theID] = false;
	    }  
  
	} else {
  
		fadeCurrent++;
		
		// Set the opacity depending on if we're adding or subtracting (pos or neg)
		if (fadeAmount < 0) {
			this.setOpacity(Math.abs(fadeCurrent * fadeAmount), theID);
		} else {
			this.setOpacity(100 - (fadeCurrent * fadeAmount), theID);
		}
		
		// Keep going, and send myself the updated variables
		clearInterval(this.fadeTimer[theID]);
		this.fadeTimer[theID] = setInterval("window.zoomDiv"+this.id+".fadeElement('"+theID+"', '"+fadeCurrent+"', '"+fadeAmount+"', '"+fadeSteps+"')", 15);
	}
}

////////////////////////////
//
// UTILITY functions
//

// Utility: Set the opacity, compatible with a number of browsers. Value from 0 to 100.

zoomDiv.prototype.setOpacity = function(opacity, theID) {

	var object = document.getElementById(theID).style;

	// If it's 100, set it to 99 for Firefox.

	if (navigator.userAgent.indexOf("Firefox") != -1) {
		if (opacity == 100) { opacity = 99.9999; } // This is majorly retarded
	}

	// Multi-browser opacity setting

	object.filter = "alpha(opacity=" + opacity + ")"; // IE/Win
	//object.KhtmlOpacity = (opacity / 100);            // Safari 1.1 or lower, Konqueror
	//object.MozOpacity = (opacity / 100);              // Older Mozilla+Firefox
	object.opacity = (opacity / 100);                 // Safari 1.2, Firefox+Mozilla

}

zoomDiv.prototype.setOpac = function(obj, opacity) {

	opacity = (opacity == 100)?99.999:opacity;
	
	// IE/Win
	obj.style.filter = "alpha(opacity="+opacity+")";
	
	//alert(obj.style.filter);
	
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}

zoomDiv.prototype.cubicInOut = function(t, b, c, d)
{
	if ((t/=d/2) < 1) return c/2*t*t*t + b;
	return c/2*((t-=2)*t*t + 2) + b;
}

zoomDiv.prototype.getSize = function() {
	if (document.all) {
		// IE4+ or IE6+ in standards compliant 
		this.myWidth  = (document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.clientWidth;
		this.myHeight = (document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight;
		this.myScroll = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
	} else {
		// Non-IE
		this.myWidth = window.innerWidth;
		this.myHeight = window.innerHeight;
		this.myScroll = window.pageYOffset;
	}
	
	// Core code from - quirksmode.org
    if (window.innerHeight && window.scrollMaxY) {	
        this.myScrollWidth = document.body.scrollWidth;
		this.myScrollHeight = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
		this.myScrollWidth = document.body.scrollWidth;
		this.myScrollHeight = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		this.myScrollWidth = document.body.offsetWidth;
		this.myScrollHeight = document.body.offsetHeight;
	}
}

// Utility: Find the Y position of an element on a page. Return Y and X as an array

zoomDiv.prototype.findElementPos = function(elemFind)
{
	var elemX = 0;
	var elemY = 0;
	do {
		elemX += elemFind.offsetLeft;
		elemY += elemFind.offsetTop;
	} while ( elemFind = elemFind.offsetParent )

	//console.log("Found element "+elemFind+" at "+elemY+"/"+elemX);

	return Array(elemX, elemY);
}