<!-- Begin


a=0
b=0
c=0
p=60
per=256
pasx=getWidth();
var tb1 = new Array(p,p,p);
var tb2 = new Array(p,-p,p);
var tb3 = new Array(-p,p,p);
var tb4 = new Array(-p,-p,p);
var tb5 = new Array(p,p,-p);
var tb6 = new Array(p,-p,-p);
var tb7 = new Array(-p,p,-p);
var tb8 = new Array(-p,-p,-p);
var tb9 = new Array(0,-2.3*p,0);
var tb10 = new Array(0,2.3*p,0);

var tb1b  = new Array(p+(150*Math.cos(0*(2*Math.PI)/10)),p+(150*Math.sin(0*(2*Math.PI)/10)),-p);
var tb2b  = new Array(p+(150*Math.cos(1*(2*Math.PI)/10)),p+(150*Math.sin(1*(2*Math.PI)/10)),-p);
var tb3b  = new Array(p+(150*Math.cos(2*(2*Math.PI)/10)),p+(150*Math.sin(2*(2*Math.PI)/10)),-p);
var tb4b  = new Array(p+(150*Math.cos(3*(2*Math.PI)/10)),p+(150*Math.sin(3*(2*Math.PI)/10)),-p);
var tb5b  = new Array(p+(150*Math.cos(4*(2*Math.PI)/10)),p+(150*Math.sin(4*(2*Math.PI)/10)),-p);
var tb6b  = new Array(p+(150*Math.cos(5*(2*Math.PI)/10)),p+(150*Math.sin(5*(2*Math.PI)/10)),-p);
var tb7b  = new Array(p+(150*Math.cos(6*(2*Math.PI)/10)),p+(150*Math.sin(6*(2*Math.PI)/10)),-p);
var tb8b  = new Array(p+(150*Math.cos(7*(2*Math.PI)/10)),p+(150*Math.sin(7*(2*Math.PI)/10)),-p);
var tb9b  = new Array(p+(150*Math.cos(8*(2*Math.PI)/10)),p+(150*Math.sin(8*(2*Math.PI)/10)),-p);
var tb10b = new Array(p+(150*Math.cos(9*(2*Math.PI)/10)),p+(150*Math.sin(9*(2*Math.PI)/10)),-p);

step=64

var p1x=(tb1b[0] - tb1[0]) / step
var p1y=(tb1b[1] - tb1[1]) / step
var p1z=(tb1b[2] - tb1[2]) / step
var p2x=(tb2b[0] - tb2[0]) / step
var p2y=(tb2b[1] - tb2[1]) / step
var p2z=(tb2b[2] - tb2[2]) / step
var p3x=(tb3b[0] - tb3[0]) / step
var p3y=(tb3b[1] - tb3[1]) / step
var p3z=(tb3b[2] - tb3[2]) / step
var p4x=(tb4b[0] - tb4[0]) / step
var p4y=(tb4b[1] - tb4[1]) / step
var p4z=(tb4b[2] - tb4[2]) / step
var p5x=(tb5b[0] - tb5[0]) / step
var p5y=(tb5b[1] - tb5[1]) / step
var p5z=(tb5b[2] - tb5[2]) / step
var p6x=(tb6b[0] - tb6[0]) / step
var p6y=(tb6b[1] - tb6[1]) / step
var p6z=(tb6b[2] - tb6[2]) / step
var p7x=(tb7b[0] - tb7[0]) / step
var p7y=(tb7b[1] - tb7[1]) / step
var p7z=(tb7b[2] - tb7[2]) / step
var p8x=(tb8b[0] - tb8[0]) / step
var p8y=(tb8b[1] - tb8[1]) / step
var p8z=(tb8b[2] - tb8[2]) / step
var p9x=(tb9b[0] - tb9[0]) / step
var p9y=(tb9b[1] - tb9[1]) / step
var p9z=(tb9b[2] - tb9[2]) / step
var p10x=(tb10b[0] - tb10[0]) / step
var p10y=(tb10b[1] - tb10[1]) / step
var p10z=(tb10b[2] - tb10[2]) / step

// use for rotate
var CurrentObject;
var incVec = 5;
var screenWidth=getWidth()+200;
var transfWay = 1;
var morphtime3D = 8000;
var nbPass = 0;

function start3DVectors(){

	//run main loop
	setTimeout ("loop3DVectors()",1);
	
	//run morph
	setTimeout ("morph3DVectors()",morphtime3D);

}

function loop3DVectors()
{
	rotate();
	if (pasx < -300 || pasx > screenWidth){ 
		if(nbPass < 4){
			incVec = -incVec;
			nbPass++;
		}
		else{
			incVec = 0;
			setTimeout("morphVectorballs()",10); // morph in 30s
		}
	}
	pasx -= incVec;


	a+=3;
	b+=6;
	c+=2;

	// recall !
	setTimeout (currentVectorLoop,1)
}

// PROFILER
//var countloop = 50;
//var totalTimeRotate = 0;
//var avgTime =0;
//var avgTotal = 0;

//  END PROFILER

function rotate() {

	// PROFILER
	//startTimeRotate = new Date();
	// END PROFILE	
	

	rotation3d(tb1[0],tb1[1],tb1[2],a,b,c); projection();
	CurrentObject = eval(document.getElementById("b1").style);
	CurrentObject.zIndex = rotzz+1000;
	CurrentObject.left = rotxx+pasx;
	CurrentObject.top = rotyy+300;

	rotation3d(tb2[0],tb2[1],tb2[2],a,b,c); projection();
	CurrentObject = eval(document.getElementById("b2").style);
	CurrentObject.zIndex = rotzz+1000;
	CurrentObject.left = rotxx+pasx;
	CurrentObject.top = rotyy+300;

	rotation3d(tb3[0],tb3[1],tb3[2],a,b,c); projection();
	CurrentObject = eval(document.getElementById("b3").style);
	CurrentObject.zIndex = rotzz+1000;
	CurrentObject.left = rotxx+pasx;
	CurrentObject.top = rotyy+300;
	
	rotation3d(tb4[0],tb4[1],tb4[2],a,b,c); projection();
	CurrentObject = eval(document.getElementById("b4").style);
	CurrentObject.zIndex = rotzz+1000;
	CurrentObject.left = rotxx+pasx;
	CurrentObject.top = rotyy+300;

	rotation3d(tb5[0],tb5[1],tb5[2],a,b,c); projection();
	CurrentObject = eval(document.getElementById("b5").style);
	CurrentObject.zIndex = rotzz+1000;
	CurrentObject.left = rotxx+pasx;
	CurrentObject.top = rotyy+300;

	rotation3d(tb6[0],tb6[1],tb6[2],a,b,c); projection();
	CurrentObject = eval(document.getElementById("b6").style);
	CurrentObject.zIndex = rotzz+1000;
	CurrentObject.left = rotxx+pasx;
	CurrentObject.top = rotyy+300;

	rotation3d(tb7[0],tb7[1],tb7[2],a,b,c); projection();
	CurrentObject = eval(document.getElementById("b7").style);
	CurrentObject.zIndex = rotzz+1000;
	CurrentObject.left = rotxx+pasx;
	CurrentObject.top = rotyy+300;
	
	rotation3d(tb8[0],tb8[1],tb8[2],a,b,c); projection();
	CurrentObject = eval(document.getElementById("b8").style);
	CurrentObject.zIndex = rotzz+1000;
	CurrentObject.left = rotxx+pasx;
	CurrentObject.top = rotyy+300;

	rotation3d(tb9[0],tb9[1],tb9[2],a,b,c); projection();
	CurrentObject = eval(document.getElementById("b9").style);
	CurrentObject.zIndex = rotzz+1000;
	CurrentObject.left = rotxx+pasx;
	CurrentObject.top = rotyy+300;
	
	rotation3d(tb10[0],tb10[1],tb10[2],a,b,c); projection();
	CurrentObject = eval(document.getElementById("b10").style);
	CurrentObject.zIndex = rotzz+1000;
	CurrentObject.left = rotxx+pasx;
	CurrentObject.top = rotyy+300;	
	
	// PROFILER
	//countloop--;
	//endTimeRotate = new Date();
	
	//totalTimeRotate = totalTimeRotate + (endTimeRotate-startTimeRotate);
	//if(countloop == 0){
	//	avgTime = avgTime + totalTimeRotate;
	//	avgTotal++;
	//	countloop = 50;
	//	window.status = "Temps d'execution " + countloop + " Rotate() = " + totalTimeRotate + " ms (avg = " + Math.floor(avgTime/avgTotal) + " ms)";
	//	totalTimeRotate = 0;
	//}
	// END PROFILE		
}

function morph3DVectors() {
	if (step>0) {
	
		step--;
		
		tb1[0] = tb1[0] + transfWay*p1x;
		tb1[1] = tb1[1] + transfWay*p1y;
		tb1[2] = tb1[2] + transfWay*p1z;
		tb2[0] = tb2[0] + transfWay*p2x;
		tb2[1] = tb2[1] + transfWay*p2y;
		tb2[2] = tb2[2] + transfWay*p2z;
		tb3[0] = tb3[0] + transfWay*p3x;
		tb3[1] = tb3[1] + transfWay*p3y;
		tb3[2] = tb3[2] + transfWay*p3z;
		tb4[0] = tb4[0] + transfWay*p4x;
		tb4[1] = tb4[1] + transfWay*p4y;
		tb4[2] = tb4[2] + transfWay*p4z;
		tb5[0] = tb5[0] + transfWay*p5x;
		tb5[1] = tb5[1] + transfWay*p5y;
		tb5[2] = tb5[2] + transfWay*p5z;
		tb6[0] = tb6[0] + transfWay*p6x;
		tb6[1] = tb6[1] + transfWay*p6y;
		tb6[2] = tb6[2] + transfWay*p6z;
		tb7[0] = tb7[0] + transfWay*p7x;
		tb7[1] = tb7[1] + transfWay*p7y;
		tb7[2] = tb7[2] + transfWay*p7z;
		tb8[0] = tb8[0] + transfWay*p8x;
		tb8[1] = tb8[1] + transfWay*p8y;
		tb8[2] = tb8[2] + transfWay*p8z;	
		tb9[0] = tb9[0] + transfWay*p9x;
		tb9[1] = tb9[1] + transfWay*p9y;
		tb9[2] = tb9[2] + transfWay*p9z;	
		tb10[0] = tb10[0] + transfWay*p10x;
		tb10[1] = tb10[1] + transfWay*p10y;
		tb10[2] = tb10[2] + transfWay*p10z;			

		setTimeout ("morph3DVectors()",1);
		//window.status = "morphing!!!!";
	}
	else{
		step = 64;
		transfWay = -transfWay;
		setTimeout ("morph3DVectors()",morphtime3D);
	}
	

}

// END -->