var speed=150;
var pas=2;
var width=150;
var height=200;
var x=0;
var y=0;
var epaisseur_contour=1;
var pos=height;

var arret=false;
function Scrollbox()
{
	pos=pos-pas;
  if(pos<=-(msg.length*12)/width*8) scrollit();
  else
  {
    elm.style.top=pos;
    time_out = setTimeout("Scrollbox()",speed);
  }
}
function scrollit()
{
	elm=document.getElementById("scroll");
	msg=elm.innerHTML;
	pos=height;
	Scrollbox();
}

function stop_defile()
{
	if(!arret)
	{
		arret = true;
		clearTimeout(time_out);
	}
	else
	{
		arret=false;
		Scrollbox();
	}
}


var indfeu = true
var TId=0 
//Pre-load your image below!
//4=the number of images listed below
grphcs=new Array(4)

//PRELOAD the involved images (extend or contract variables according to # of images used)
Image0=new Image();
Image0.src=grphcs[0]="medias/images/crocheb.gif"
Image1=new Image();
Image1.src=grphcs[1]="medias/images/crocheh.gif"
Image2=new Image();
Image2.src=grphcs[2]="medias/images/crochedb.gif"
Image3=new Image();
Image3.src=grphcs[3]="medias/images/crochedh.gif"

//SPECIFY number of images to randomly display concurrently from list above. Less the more efficient
Amount=10; 
Ypos=new Array();
Xpos=new Array();
Zpos=new Array();
ScrXpos=new Array();
ScrYpos=new Array();
Speed=new Array();
Size=new Array();
Step=new Array();

    document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');
    for (i = 0; i < Amount; i++)
    	{
         document.write('<img id="si'+i+'" src="'+grphcs[Math.round((i+1)*(grphcs.length-1)/Amount)]+'"style="position:absolute;top:0px;left:0px">');
        }
    document.write('</div></div>');

     for (i=0; i < Amount; i++)
     {
				Speed[i]=0;
        Xpos[i] = 0;
        Ypos[i] = 0;
        Zpos[i] = 0;
        ScrXpos[i]=0;
        ScrYpos[i]=0;

		     document.getElementById("si"+i).style.left=-100;
		     document.getElementById("si"+i).style.top=-100;

     }


function fly()
	{
       var WinHeight=window.document.body.clientHeight-100;
       var WinWidth=window.document.body.clientWidth-100;
 
			 /***************en attendant****************/
			 //var xBasePos = WinWidth/2 + WinWidth/4;
			 //var yBasePos = WinHeight/2 + WinHeight/4;
			 var xBasePos = WinWidth/2 + WinWidth/4 + WinWidth/8;
			 var yBasePos = WinHeight/2 + WinHeight/4;

       for (i=0; i < Amount; i++)
          {
              Zpos[i]-=Speed[i];
              if (ScrXpos[i]>WinWidth || ScrXpos[i]<0 || ScrYpos[i]>WinHeight || ScrYpos[i]<0 || Zpos[i]<=0) 
              	{ //generate new stars
                   Speed[i]=(i+1)*6/Amount+4; //speed range from 4 to 10
                   Xpos[i] = Math.random()*WinWidth-WinWidth/2;
                   Ypos[i] = Math.random()*WinHeight-WinHeight/2;
                   Zpos[i] = Math.random()*800+200;
                }
              ScrXpos[i]=Xpos[i]/Zpos[i]*100 + xBasePos;
              ScrYpos[i]=Ypos[i]/Zpos[i]*100 + yBasePos;

              document.getElementById("si"+i).style.left=ScrXpos[i];
              document.getElementById("si"+i).style.top=ScrYpos[i];
       	  }
       TId=setTimeout('fly()',30);     // redémarre toutes les 5 millisecondes
	}

function feu()
{
	if (indfeu)
	{
		//PlayMusique();
		fly();
		indfeu = false;
	}
	else
	{
		clearTimeout(TId);  // soit on arrete le timer
		indfeu = true;
		// on met les images en position invisible  (-100)
		for (i=0; i < Amount; i++)
		{
			document.getElementById("si"+i).style.left=-100;
			document.getElementById("si"+i).style.top=-100;
		}
	}
}

