/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Vic Phillips :: http://www.vicsjavascripts.org.uk */

// where 'zxcZoomText(this,14,20,500)' :
// parameter 0 = the element object or unique ID name (object or string)
// parameter 1 = start text size                      (digits)
// parameter 2 = finish text size                     (digits)
// parameter 3 = the speed of change                  (digits/lower number is faster)

// Functional Code - NO NEED to Change

var zxcOOPCnt=0;

function jZoomText(obj,delta,direction,spd)
{
 	if (typeof(obj)=='string')
		obj=document.getElementById(obj);


 	if (!obj.oopct)
	{
  		spd=spd||100;
  		obj.oopct=new zxcOOPTxtZoom(obj,delta,direction,spd);
 	}
	else
	{
		if (direction == 1)
		{
			obj.oopct.minmax[1]+= delta;
			obj.oopct.minmax[2]+= delta;
		}
		else if (direction == -1)
		{
			obj.oopct.minmax[1] -= delta;
			obj.oopct.minmax[2] -= delta;
		}
		else if (direction == 0)
		{
			//TO DO Fix this bit.
			obj.oopct.minmax[1] = 14;
			obj.oopct.minmax[2] = 24;
		}
	}
 	clearTimeout(obj.oopct.to);
 	obj.oopct.minmax[4]=direction; //used to be -1 toggle
 	obj.oopct.cngtxt();
}

function zxcOOPTxtZoom(zxcobj,delta,direction,spd)
{
 	this.obj=zxcobj;
 	this.ref='zxcoopct'+zxcOOPCnt++;
 	window[this.ref]=this;
	target = parseInt(this.obj.style.fontSize);
 	this.minmax=[ target, Math.min(target, target+(delta*direction)), Math.max(target, target+(delta*direction)), spd, direction];
 	this.to=null;
}

zxcOOPTxtZoom.prototype.cngtxt=function()
{
 	if ( (this.minmax[4] > 0 && this.minmax[0] < this.minmax[2]) 
             || (this.minmax[4] < 0 && this.minmax[0] > this.minmax[1]) )
	{
  		this.obj.style.fontSize=(this.minmax[0]+=this.minmax[4])+'px';
  		this.obj.style.lineHeight=(this.minmax[0]+=this.minmax[4])+'px';
  		this.to=this.setTimeOut('cngtxt();',this.minmax[3]);
 	}
}

zxcOOPTxtZoom.prototype.setTimeOut=function(zxcf,zxcd)
{
	this.to=setTimeout('window.'+this.ref+'.'+zxcf,zxcd);
}
