<!-- Begin

/*
 * Main idea and DHTML code by X-TROLL ! thanks !
 * Modifications by Shazz
 */


// ----------------------------------
// inits, variables, fill tables,...
// ----------------------------------

var n = (document.layers) ? 1:0; 
var ie = (document.all) ? 1:0; 

var range = ""; 
var styleObj = ""; 
var x = 0; 
var y = 0; 
var count = 0; 
var total = 11;
var docWidth;
var docHeight;
var maxWidth;
var minWidth;


docWidth = getWidth();
docHeight = getHeight();
maxWidth = docWidth/3;
minWidth = docWidth/8;


// PROFILER
var stepSpriteloop = 1000;
var totalTimeSprite = 0;
var avgTimeSprite =0;
var avgTotalSprite = 0;
// END PROFILER


var count = new Array(total);
for (i=0; i<=total-1; i++) { 
  count[i] = 0; 
}

var ycenter = new Array(total);
for (i=0; i<=total-1; i++) { 
  ycenter[i] = docHeight/2-100; 
}

var xcenter = new Array(total);
for (i=0; i<=total-1; i++) { 
  xcenter[i] = docWidth/2; 
}

var ytheta = new Array(total);
for (i=0; i<=total-1; i++) { 
  ytheta[i] = Math.PI; 
}

var xtheta = new Array(total);
for (i=0; i<=total-1; i++) { 
  xtheta[i] = Math.PI; 
}


xspin = Math.sin(0.03);
yspin = Math.sin(0.05);


var yradius = new Array(total);
for (i=0; i<=total-1; i++) { 
  yradius[i] = docHeight/4; 
}

var xradius = new Array(total);
for (i=0; i<=total-1; i++) { 
  xradius[i] = docWidth/4; 
}

var xpander = new Array(total);
for (i=0; i<=total-1; i++) { 
  xpander[i] = 1; 
}

var spritesTable = new Array(total);
var letter = new Array(total);
for (i=0; i<=total-1; i++) { 
  	letter[i] 	= "b" + i; 
}


if (ie) { styleObj = ".style"; } 


  
// ----------------------------------
// functions ..
// ----------------------------------
  
// init, set the different sprites to a specific interval
function initVectors2D() {
	for (i=0; i<=total-1; i++) {  
  		spritesTable[i] = (document.getElementById(letter[i])).style;
	}
	
  	for (i=0; i<=total-1; i++) {
    		window.setTimeout("parabola(" + i + ")",550*i); 
  	}
  	 
}

var pasx2 = -400;
  
// compute new coords per sprite, called for each sprite 
function parabola(num) { 

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

	//not used for optimization
	//var theObj = getObject(letter[num]); 
	
	// Ugly ! And slow !
	//var theObj = eval("document.getElementById(\"" + letter[num] + "\")" + styleObj);
	
	// Nice but a table of pointers is faster !
	//var theObj = document.getElementById(letter[num]);
	
	// Get pointers from the table
	var theObj = spritesTable[num]; 

	x = (xradius[num]*Math.cos(xtheta[num])) + xcenter[num]; 
	y = (yradius[num]*Math.sin(ytheta[num])) + ycenter[num]; 

	//shiftTo(theObj, x, y); //uncomment to support Mozilla
	theObj.pixelLeft = x + pasx2; 
	theObj.pixelTop = y; 

	if (xpander[num]) { 
		if (count[num] % 7 == 0) { 
			yradius[num]++; 
			xradius[num]++; 
		} 
		if (xradius[num] >= maxWidth) xpander[num] = 0; 
	} 
	else { 
		if (count[num] % 7 == 0) { 
			yradius[num]--; 
			xradius[num]--; 
		} 
		if (xradius[num] <= minWidth) xpander[num] = 1; 
	 } 


	xtheta[num] = xtheta[num] + xspin; 
	ytheta[num] = ytheta[num] + yspin; 
	
	// each frame, translate to the rifgt until the middle of the screen
	if(num == 9 && pasx2 < 0) pasx2 += 2;
	
	// PROFILER
	//endTimeSprite = new Date();
	
	//stepSpriteloop--;
	//totalTimeSprite = totalTimeSprite + (endTimeSprite-startTimeSprite);
	
	//if(stepSpriteloop == 0){
	//	avgTimeSprite = avgTimeSprite + totalTimeSprite;
	//	avgTotalSprite++;
	//	stepSpriteloop = 1000;
	//	window.status = "Temps d'execution " + stepSpriteloop + " Parabola() = " + totalTimeSprite + " ms (avg = " + Math.floor(avgTimeSprite/avgTotalSprite) + " ms)";
	//	totalTimeSprite = 0;
	//}
	// END PROFILE		
	
	// recall !
	window.setTimeout("parabola(" + num + ")",0); // recall immediatly

} 



// ----------------------------------
// not used functions .. specific to 
// use different navigators
// ----------------------------------



// bypassed, should be used to support plotting whatever the navigator  
function shiftTo(theObj, x, y) { 
   if (n) { 
   	theObj.moveTo(x,y); 
  } 
  else { 
   	theObj.pixelLeft = x; 
   	theObj.pixelTop = y; 
  } 
}   
  
function getObject(obj) { 
	// var theObj = eval("document." + range + obj + styleObj); 
	// document.all.name.style
	var theObj = eval("document.getElementById(\"" + obj + "\")" + styleObj);
	return theObj; 
}  

// END -->