/** Copyright (C) 2009  Simon ANDRE
 *
 *   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 3 of the License, or
 *    (at your option) 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, see <http://www.gnu.org/licenses/>.
 */


/** Ce framework est fait par moi même afin de bien comprendre les mecanisme 
 * 	des autres framework javascript. Si vous avez des amelioration, des idées, des recommandations n'hesitez
 * 	à me les faire parvenir à elsilent.hunter[at]gmail.com
 * merçi
 */

/*
* opacDiv est une fonction de changement d'opacité
* d'objet html div. Les argument quel prend sont
* id: reference vers la div que l'on veut changer
* originOpac: l'opacité original 
* targetOpac: l'opacité à atteindre
* vitess rapidite du mouvenent
* amort un chiffre en virgule flotante entre 0 et 2
* si >1 acceleration
* si <1 decceleration
* si =1 mouvement lineaire
*/
var opacObj = function(id,originOpac,targetOpac,vitess,amort){
	//nom de la div qui bouge
	this.div = id;
	//this.id = id;
	//But du trajet
	this.vitess = vitess;
	this.targetOpac = targetOpac;
	this.amort = amort;
	//recuperation dom de la div
	//this.div = $(id);
	//Recuperation des coordonnes de la div
	this.originOpac = originOpac;
	this.goOpac =this.originOpac;
	this.doOpac(); /*preparation du redimensionement*/
};
opacObj.prototype.opac = function (){	
	if( this.stepOpac > 0)
	{
		if(this.goOpac < this.targetOpac )
		{
			this.goOpac += this.stepOpac;
			setOpacity(this.div,this.goOpac );
			return true;
		}
		else
		{
			return false;
		}
	}else
	{
		if(this.goOpac > this.targetOpac )
		{
			this.goOpac += this.stepOpac;
			setOpacity(this.div,this.goOpac);
			return true;
		}
		else
		{
			return false;
		}
	}
	
};
opacObj.prototype.action = function (){	
	this.stepOpac =  this.stepOpac * this.amort;
	var o= this.opac();
	if(!o){return false;}else{return true;}
	
};
opacObj.prototype.init = function (){	
	
	
};
opacObj.prototype.doOpac = function()
{
   // Check if reference to menu was lost due
   // to ajax manipulations  #FIXME 
  /* if (!this.div)
   {
       div = $(id);
   }*/
   this.stepOpac = parseFloat((this.targetOpac - this.originOpac)/ this.vitess) ;


};

