game/js/infos.js

62 lines
1.8 KiB
JavaScript

function first(nombre){
for(i = 1; i <= nombre; i++) {
var object = document.getElementById('quadri' + i).style;
object.opacity = (0);
object.MozOpacity = (0);
object.KhtmlOpacity = (0);
object.filter = "alpha(opacity=" + 0 + ")";
}
if (nombre > 0) setTimeout("appel('-1','" + nombre + "')",(10000/nombre));
}
function appel(num, max) {
num++;
if (num >= max) {
numb = 0;
numa = max;
num = -1;
}
else {
numa = num;
numb = num + 1;
}
if (max > 0) {
opacity('quadri' + numa, 'quadri' + numb, 100, 0, 1000);
setTimeout("appel(" + num + ",'" + max + "')",(10000/max));
}
}
function opacity(id, idd, opacStart, opacEnd, millisec) {
//speed for each frame
var speed = Math.round(millisec / 100);
var timer = 0;
//determine the direction for the blending, if start and end are the same nothing happens
if(opacStart > opacEnd) {
for(i = opacStart; i >= opacEnd; i--) {
setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
j = opacStart - i;
setTimeout("changeOpac(" + j + ",'" + idd + "')",(timer * speed));
timer++;
}
} else if(opacStart < opacEnd) {
for(i = opacStart; i <= opacEnd; i++)
{
setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
j = opacEnd - i;
setTimeout("changeOpac(" + j + ",'" + idd + "')",(timer * speed));
timer++;
}
}
}
//change the opacity for different browsers
function changeOpac(opacity, id) {
var object = document.getElementById(id).style;
object.opacity = (opacity / 100);
object.MozOpacity = (opacity / 100);
object.KhtmlOpacity = (opacity / 100);
object.filter = "alpha(opacity=" + opacity + ")";
}