// Calques
function findObj(theObj, theDoc)
{
	var p, i, foundObj;  
	if(!theDoc) theDoc = document;
/*	// cas des frames
	if( (p = theObj.indexOf("?")) > 0 && parent.frames.length){
		theDoc = parent.frames[theObj.substring(p+1)].document;
		theObj = theObj.substring(0,p);}*/
	// IE5 et 6, NN 6-7 et autres
	if(document.getElementById)
		foundObj = document.getElementById(theObj);
	// IE4
	else if(!(foundObj = theDoc[theObj]) && theDoc.all) // enlever else pour tester Document.all sous IE
		foundObj = theDoc.all[theObj];
/*	// cas des forms
	for (i=0; !foundObj && i < theDoc.forms.length; i++)
		foundObj = theDoc.forms[i][theObj];*/
	// NN4
	for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)
		foundObj = findObj(theObj,theDoc.layers[i].document);
	return foundObj;
}
function dumpobj(obj){
	result="",i="";
	for (i in obj){result+=i+" = "+obj[i]+"-----";}
	return result;
}
function showHideLayers()
{ 
  var i, visStr, obj, args = showHideLayers.arguments;
  for (i=0; i<(args.length-1); i+=2){
    if ((obj = findObj(args[i])) != null){
      visStr = args[i+1];
      if (obj.style){
        obj = obj.style;
        if(visStr == 'show') visStr = 'visible';
        else if(visStr == 'hide') visStr = 'hidden';}
      obj.visibility = visStr;}
  }
}

function showcalq(calque){
	var i,visi,obj;
	for(i=0; i<calq.length; i++){
		visi=calq[i]==calque?'show':'hide';
	    if ((obj = findObj(calq[i])) != null){
	      	if (obj.style){
    	    	obj = obj.style;
				visi=calq[i]==calque?'visible':'hidden';}
			obj.visibility=visi;
		}
	}
}

function setLayerTop(calque,y)
{
	var obj;
	if ((obj = findObj(calque)) != null){
		if (obj.style) obj = obj.style;
		if (document.layers) obj.top=y;
		else obj.top = y+'px';
	}
}
function moveLayer(calque,x,y)
{
	var obj;
	if ((obj = findObj(calque)) != null){
		if (obj.style) obj = obj.style;
		if (document.layers) {obj.top=y;obj.left=x;}
		else {obj.top = y+'px';obj.left = x+'px';}
	}
}
function changeLayer(calque,txt)
{
	var x,i, contenu="";
	for (i=0;i<txt.length;i++)
	{
		switch(txt.charAt(i)){
		case 'é':
			contenu+='&eacute;';
			break;
		case 'è':
			contenu+='&egrave;';
			break;
		case 'à':
			contenu+='&agrave;';
			break;
		case 'ô':
			contenu+='&ocirc;';
			break;
		case '§':
			contenu+='l\'';
			break;
		default: contenu+=txt.charAt(i);
		}
	}
	if (document.getElementById){
		x = document.getElementById(calque);
		x.innerHTML = '';
		x.innerHTML = contenu;
	}else if (document.all){
		x = document.all[calque];
		x.innerHTML = contenu;
	}else if (document.layers){
		x = document.layers[calque];
		x.document.open();
		x.document.write('<p class="starstxt">'+contenu+'</p>');
		x.document.close();
	}
		if (x.style) x = x.style;
		if (x){
			x.color='#'+couleurstar;
			if (document.layers) x.fontSize= taillestar;
			else x.fontSize= taillestar+'px';
		}
		
}

var animtimeid=scrambletimeid=null;
var vitesseRappel=0.1;
var animcmptx=0;
var animcmpty=0;
var animflag=0;
var texte1=texte2="***************";
var change2do=0,changepos=99,changecpt;
var nbstars=texte1.length;
var i=0;
animcmptxadd=1/15;
animcmptyadd=1/20;
maxstars=16;
var interstar=6.28/maxstars;
var unefoissur4=0;
var couleurstar=couleurdefaut='994B22';
var taillestar='16';
var sx=new Array(),sy=new Array(),Sx=new Array(),Sy=new Array();

	// init et démarrage

	sx[0]=660;sy[0]=490;
	for (i=1;i<=maxstars;i++){
		document.write('<div id="star'+i+'" class="stars">'+(i<=nbstars?texte1.substring(i-1,i):' ')+'</div>');
		Sx[i]=sx[i]=sx[0];Sy[i]=sy[i]=sy[0];
	}
	animtimeid=setTimeout('anistars()',500);

function MouseBouge(e){
	if (!e) var e = window.event;
	if (e.pageX || e.pageY)
	{
		sx[0] = e.pageX;
		sy[0] = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		sx[0] = e.clientX;
		sy[0] = e.clientY;
	}
}

	if(document.layers){ //ns4
		window.captureEvents(Event.MOUSEMOVE);
		window.onMouseMove=MouseBouge;
	}else document.onmousemove=MouseBouge;

function anistars()
{
	if (!animflag++) {
		if(change2do){
			if (!--changecpt){
				texte1=texte2;
				changepos=0;
				change2do=0;
			}
		}
		
		if (!(unefoissur4++%4) && changepos<=texte1.length)
		{
			if(changepos==texte1.length)
			{
				if (changepos < nbstars)
				{
					changeLayer('star'+nbstars,' ');moveLayer('star'+nbstars,0,0);
					sx[i]=0;sy[i]=0;Sx[i]=0;Sy[i]=0;
					nbstars--;
					//interstar=6/nbstars;
				}else changepos++;
			}else{
				changepos++;
				if (changepos>nbstars){
					Sx[changepos]=sx[changepos]=sx[nbstars];Sy[changepos]=sy[changepos]=sy[nbstars];
					nbstars++;
				}
				changeLayer('star'+changepos,texte1.substring(changepos-1,changepos));
			}
		}

		for (i=1; i <= nbstars; i++){
			sx[i]=Math.round(Sx[i]+=(sx[i-1]-Sx[i])*vitesseRappel);
			sy[i]=Math.round(Sy[i]+=(sy[i-1]-Sy[i])*vitesseRappel);
		}
		animcmptx+=animcmptxadd;
		animcmpty+=animcmptyadd;
		for (i=1; i <= nbstars; i++){
			moveLayer('star'+i,sx[i]+Math.sin(animcmptx-i*interstar)*60,sy[i]+Math.cos(animcmpty-i*interstar)*40);
		}
		animtimeid=setTimeout('anistars()',25);
		animflag=0;
	}
}

function arome(texte,couleur,taille)
{
	if (texte == '*') texte='*******************';//.substring(0,texte1.length);
	if (texte.length > maxstars) texte=texte.substring(0,maxstars);
	if(taille) taillestar=taille;
	else taillestar='16';
	if(couleur) couleurstar=couleur;
	else couleurstar=couleurdefaut;
	if(texte!=texte2){
		texte2=texte;
		changecpt=20;
		change2do=1;
	}
}
function scramble(num)
{
	interstar=num;
	if (scrambletimeid) clearTimeout(scrambletimeid);
	scrambletimeid=setTimeout('descramble()',3000);
}
function descramble(num)
{
	interstar=6/maxstars;
}
function rien(){}
