/******************************************************************************
 *                                                                            *
 * Copyright (C) 2005  Robert Silve                                           *
 *                                                                            *
 * This program is free software; you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by       *
 * the Free Software Foundation; either version 2 of the License, or          *
 * any later version.                                                         *
 *                                                                            *
 *  This program is distributed in the hope that it will be useful,           *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of            *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
 *  GNU General Public License for more details.                              *
 *                                                                            *
 *  You should have received a copy of the GNU General Public License         *
 *  along with this program; if not, write to the Free Software               *
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *
 *                                                                            *
 *****************************************************************************/


/* ------------ AnimEffect Part -------------------------------------------- */

function AnimEffect() {
	this.duration = 20;
	
	this.timerID = 0;
	this.lock = false;

	this.toString = function() { return "[AnimEffect Object]" };
	this.onstart = function() {};
	this.onstep = function() { return false };
	this.onend = function() {};
}

function AnimEffect_run(name) {
	var object = eval(name);
	if (object.lock) {
		clearTimeout(this.timerID);
		object.timerID = 0;
		object.lock = false;
		object.current = 0;
	}
	object.lock = true;	
	object.onstart();
	_AnimEffect_next(name);	
}


function _AnimEffect_next(name) {
	var object = eval(name);
        if (object.lock && object.onstep()) {
		object.timerID = setTimeout("_AnimEffect_next('"+name+"')", object.duration);	
	} else {
		object.onend();
	}
}


/* ------------ End AnimEffect Part -------------------------------------------- */

function LateralMvt(name, min, max) {
	this.name = name;
	this.min = min; 
	this.max = max;
	this.ltr = true; 
	this.padding = this.min;
	this.anim = new AnimEffect();
	this.anim.parent = this;
	this.anim.onstep = function() {
var name = this.parent.name;
var obj = document.all ? eval("document.all."+name) : document.getElementById(name);
this.parent.padding += this.parent.ltr ? 1 : -1;
if (this.parent.padding <= this.parent.min || this.parent.padding >= this.parent.max) 
	return false;
obj.style.paddingLeft = this.parent.padding + "px";
return true;
	};	

	this.anim.onend = function() {
if (this.parent.padding < this.parent.min)
	this.parent.padding = min;
if (this.parent.padding > this.parent.max) 
	this.parent.padding = max;
	};	

}

function LateralMvt_toRight(name) {
	var obj = eval(name);
	obj.ltr = true;
	AnimEffect_run(name+".anim");
}

function LateralMvt_toLeft(name) {
	var obj = eval(name);
	obj.ltr = false;
	AnimEffect_run(name+".anim");
}






