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

var imgCaroussel = function()
{
	//le tableau multidimensionnelle qui contiendra les effects
	this.clean = function(){
		if(this.state == false){
			
			//this.init();
			for(var i=0;i< this.effect.length;i++)
			{
				this.effect[i] = null;
			}

		}};
};
imgCaroussel.prototype.init = function(array)
{
	this.imageArray = array;
	this.effect = new Array();
	this.index = 0;
};

imgCaroussel.prototype.after = function()
{
	var loader=0;
	if(this.effect.length>=1)
	{
		for(var i=0;i< this.effect[0].length;i++)
		{
			var nextB = this.effect[0][i].action();
			if(!nextB)loader++;
		}

	if(loader == this.effect[0].length)
	{
		this.effect.shift();
		if(this.effect.length>=1)
		{
			for(var i=0;i< this.effect[0].length;i++)
			{
				this.effect[0][i].init();
			}
		}else
		{
			this.clean();
		}
	}
	}
};
imgCaroussel.prototype.next = function()
{
	if(this.effect.length <= 1)
	{	
	this.index++;
	var ex;
	var anim = new Array();
	for(var e=0;e<7;e++)
	{
		if(this.index==7)this.index = 0;
		
		var a = e+ this.index;
		if(a>=7)a = a-7;
		anim.push(new animDiv(this.imageArray[e],parseInt(coordAnimBase[a].top),parseInt(coordAnimBase[a].left),50,1));
		if(a==3||a==4)
			{
				anim.push(new resizeDiv(this.imageArray[e],coordAnimBase[a].width,coordAnimBase[a].height,50,1.00));
			}
		if(a==0){
			ex = e;
		}
		
	}
	
	


		anim.push(new opacObj(this.imageArray[ex],100,0,10,1));
	this.effect.push(anim);
	this.effect.push(new Array(new opacObj(this.imageArray[ex],0,100,25,1)));

		//this.effect.push(new Array(new opacObj(this.imageArray[ex],0,100,100,1)));
	}
	
};
imgCaroussel.prototype.previous = function()
{
	if(this.effect.length <= 1)
	{	
	this.index--;
	var ex;
	var anim = new Array();
	for(var e=0;e<7;e++)
	{
		if(this.index==-1)this.index = 6;
		
		var a = e+ this.index;
		if(a>=7)a = a-7;
		anim.push(new animDiv(this.imageArray[e],parseInt(coordAnimBase[a].top),parseInt(coordAnimBase[a].left),50,1));
		if(a==2||a==3)
		{
			anim.push(new resizeDiv(this.imageArray[e],coordAnimBase[a].width,coordAnimBase[a].height,50,1.00));
		}
		if(a==6){
			ex = e;
		}
		
	}
	
	


	anim.push(new opacObj(this.imageArray[ex],100,0,10,1));
	this.effect.push(anim);
	this.effect.push(new Array(new opacObj(this.imageArray[ex],0,100,25,1)));

		//this.effect.push(new Array(new opacObj(this.imageArray[ex],0,100,100,1)));
	}

};
imgCaroussel.prototype.getMove = function()
{
	
};


