//////////////////    animation

/*********  reserve qui marche ****************
******************   fin réserve qui marche   ***********************/



var node;
var nblay = 5;                   // nombre de layeurs
var initposx = 320;               // position initiale en x.
var initposy = 140;               // position initiale en y.
var initfontsize_amilog = 70;
var initfontsize_autre = 45;

//var cqueue    = new Array('EEEEFF','FFEEEE','EEFFEE','EEEEEE','EEEEFF','FFEEEE','EEFFEE');
//var ctete     = new Array('FFAAAA','88FF88','AAAAFF','999999','FFAAAA','88FF88','AAAAFF');
var cqueue    = new Array('990000','009900','000099','555555');
var ctete     = new Array('FFEEEE','EEFFEE','EEEEFF','DDDDDD');

var ct = new Array(ctete.length);
function initLogoDynColor() {
  for (i=0; i<cqueue.length; i++) {
    ct[i] = new Array(2);
    ct[i][0] = new Array(3);  // couleurs de départ  ( -> queue)
    ct[i][1] = new Array(3);  // offset de couleur.
    qqq = cqueue[i];
    ttt = ctete[i];
    for (k=0; k<3; k++) {
      qd = HexaToDec(qqq.substring(k*2,k*2+2));
      td = HexaToDec(ttt.substring(k*2,k*2+2));
      ct[i][0][k] =   qd;
      ct[i][1][k] =  (td - qd) / nblay; 
    }
  }
}
var al='';
/*
for (i=0; i<cqueue.length; i++) {
  for (k=0; k<3; k++) {
    al = al + 'c='+ct[i][0][k]+' o:'+ct[i][1][k]+'   ';
  }
  al = al +"\n";
}
*/
//alert(al);
function csuiv(i,text,do_increment_color) {
  result = 'xxx';
  col = DecToHexa(ct[i][0][0])+DecToHexa(ct[i][0][1])+DecToHexa(ct[i][0][2]);
  result = '<font color="#'+DecToHexa(ct[i][0][0])+DecToHexa(ct[i][0][1])+DecToHexa(ct[i][0][2])+'">'+text+'</font>';
  if (do_increment_color == 1) {
    ct[i][0][0] = ct[i][0][0] + ct[i][1][0];
    ct[i][0][1] = ct[i][0][1] + ct[i][1][1];
    ct[i][0][2] = ct[i][0][2] + ct[i][1][2];
  }
  //alert(ct[i][0][2]);
  //alert(DecToHexa(ct[i][0][0])+DecToHexa(ct[i][0][1])+DecToHexa(ct[i][0][2]));
  return result;
}
//alert(csuiv(0,'a'));
function q1(logo) {
  initLogoDynColor();
  defaultString="amilog";
  
  fontsize= logo=='amilog'? initfontsize_amilog : initfontsize_autre;		// Initial font size. 
  offsetsize = 2;
  posleft=initposx;		// Initial left position. 
  postop=initposy;		// Initial top position. 
  
  // For statement to create nblay div elements, each one with a text 
  // inside. 
  //
  for(i=0;i<nblay;i++) {
    
    // Gets the object of the area div element. 
    node=document.getElementById(logo);
    
    // Creates a new div element. 
    beforediv=document.createElement("DIV");
    
    // Creates the style attribute string using:
    // postop, posleft, gfx1, gfx2 and fontsize.
    str="position:absolute;top:"+postop+"px;left:"+posleft+"px;font-size:"+fontsize+"pt;";

    // Sets the style attribute with the created string. 
    if (navigator.userAgent.indexOf("Gecko")>-1)
      beforediv.setAttribute("style",str);
    else
      beforediv.style.cssText = str;

    // Sets the id attribute. 
    beforediv.setAttribute("id",logo+i);

    //beforediv.innerHTML = Degrade2(Math.floor(crd),Math.floor(cvd),Math.floor(cbd),Math.floor(crf),Math.floor(cvf),Math.floor(cbf),defaultString);
    //beforediv.innerHTML = Degrade2(255,150,150,150,255,150,defaultString);
    
    //beforediv.innerHTML = '<i>'+csuiv(0,'a')+csuiv(1,'m')+csuiv(2,'i')+csuiv(3,'log')+'</i>';
    if (logo == 'amicompta') {
      dhtml = '<i>'+csuiv(0,'A',0)+csuiv(1,'m',0)+csuiv(2,'i',0)+csuiv(3,'Com',1)+csuiv(0,'p',1)+csuiv(1,'t',1)+csuiv(2,'a&nbsp;&nbsp;',1)+ '</i>';
    } else {
      dhtml = '<i>'+csuiv(0,'a',1)+csuiv(1,'m',1)+csuiv(2,'i',1)+csuiv(3,'log&nbsp;&nbsp;',1)+'</i>';
    }
    beforediv.innerHTML = dhtml;

    // Appends the new div element in the node object (div id=logo). 
    node.appendChild(beforediv);

    // Sets attributes to the next iteration. 
    fontsize+=offsetsize;
    posleft+=5;
    postop-=(3-((i/20)*2));

  }

  node.style.visibility='hidden';
	
}

////////////////////////////////////////////////////////////////////////////////////////
// Variables used as parameters for the a3danimation function. 
//	

ox=initposx;		// Reference parameter for the initial left position. 
oy=initposy;		// Reference parameter for the initial top position. 
pi=3.141516*2;		// Approximation of the PI value. 
ccounter=0;		// Animation counter. 
ww=1;			// Animation parameter. 
do_stop = 1;
var etat = 0;

// Animation has 350 steps. In the end the animation starts again - see else 
// statement...
//
function a3danimation(logo) {
  node=document.getElementById(logo);
  node.style.visibility='visible';

  ww+=.05;		// ww parameter decreases slowly. 
  ccounter++;	// counter increases by one. 

		// It's a 70 steps animation. In the end the animation starts again - see else 
		// statement...
		//
  if(ccounter<70 ) {
    // This for statement changes the position of the nblay div areas that contain the text.
    for(i=0;i<nblay;i++) {

      // Calculates the posx and posy position based on sine and cosine functions and
      // pi, ccounter, i and ww parameters. 
      //
      pis=pi*(ccounter/70);
      ll=(Math.sin(pis))*30*((i-10)/ww);
      tt=(Math.cos(pis))*40*((i-1)/ww);
      posx=ox+ll-i*5;
      posy=oy+tt+i;

      // Sets the left and top position for each object based on i value. 
      document.getElementById(logo+i).style.left=posx+"px";
      document.getElementById(logo+i).style.top=posy+"px";
    }
    // Call animate again...
    if (do_stop == 0) {
      setTimeout("a3danimation('"+logo+"')",30);
    }
    else {
      ox=initposx;			// Reference parameter for the initial left position. 
      oy=initposy;			// Reference parameter for the initial top position. 
      ccounter=0;		// Animation counter. 
      ww=1;			// Animation parameter. 

      node.style.visibility='hidden';
    }
  }
  else {
    ccounter=0;
    // Call animate again...
    setTimeout("a3danimation('"+logo+"')",30);
  }
}

function stopanim(logo) {
  do_stop = 1;
  node.style.visibility='hidden';
}

function startanim(logo) {
  if (do_stop == 1) {
    do_stop = 0;
    a3danimation(logo);
  }
}

