// pageZoom.js
//
// Copyright (c) 2008 creativesync
//
/******************************************************************************

pageZoom.js
This script will change the CSS font-size (in % - or other units) on the body of the document.
If the layout of the document is em-based, it will effectively "zoom" the page.

*******************************************************************************/


// This is the starting zoom value.
// Set currentZoom to the value of the CSS font-size in the body element.
var currentZoom = 85;


function zoomOut()
{
	// these zoom multipliers are designed to step up & down through the same values - hence the precision
	var newZoom = (currentZoom * 0.935);

	switch (newZoom<74.0) // this sets the minimum zoom value
	{
		case true:
			break; //exits if the minimum zoom has been reached
		default:
			document.getElementsByTagName('body')[0].style.fontSize=(newZoom + "%"); // any unit should work
			currentZoom=newZoom;
	}
}


function zoomIn()
{
	// these zoom multipliers are designed to step up & down through the same values - hence the precision
	var newZoom = (currentZoom * 1.0695187);
	document.getElementsByTagName('body')[0].style.fontSize=(newZoom + "%"); // any unit should work
	currentZoom=newZoom;
}


// sets the trigger elements
function startZoom()
{
document.getElementById('zoom').style.display='block';  // makes sure the zoom div is showing since js is active
// The elements that trigger the zoomOut & zoomIn must have a CSS id of "minus" & "plus" respectively. 
document.getElementById('minus').onclick = zoomOut;
document.getElementById('plus').onclick = zoomIn;
}


window.onload = startZoom;


