// Cycles
// (c) 2007-2010
// http://www.thorgal-bd.fr/
// Partie "nuée d'albums" basée sur un script de Gérard Ferrandez - Juin 2006 - http://www.dhteumeuleu.com/

function m_position2(e){ // remplacée par la fonction du fichier commun.js
if(document.all){
gf.xm=window.event.clientX-document.body.scrollWidth/2;
gf.ym=window.event.clientY-document.body.scrollHeight/2;}
if(!document.all){
gf.xm=e.pageX-window.innerWidth/2;
gf.ym=e.pageY-window.innerHeight/2;}
}

//document.onmousemove=m_position2;

// partie spéciale cycles
// basée sur un script de Gérard Ferrandez - Juin 2006 - http://www.dhteumeuleu.com/

var albums=new Array ("","La Magicienne trahie","L&#8217;Ile des Mers gelées","Les trois Vieillards du Pays d&#8217;Aran","La Galère noire","Au-delà des Ombres","La Chute de Brek Zarith","L&#8217;Enfant des Etoiles","Alinoë","Les Archers","Le Pays Qâ","Les Yeux de Tanatloc","La Cité du Dieu perdu","Entre Terre et Lumière","Aaricia","Le Maître des Montagnes","Louve","La Gardienne des Clés","L&#8217;Epée-Soleil","La Forteresse invisible","La Marque des Bannis","La Couronne d&#8217;Ogotaï","Géants","La Cage","Arachnéa","Le Mal bleu","Le Royaume sous le Sable","Le Barbare","Kriss de Valnor","Le Sacrifice","Moi, Jolan","Le bouclier de Thor","La bataille d&#8217;Asgard");
var cycles=new Array ("","La Reine des Mers Gelées","Les Bienveillants","Brek Zarith","Les origines","Alinoë","Au Pays Qâ","Les origines","Vers le Nord","Shaïgan-sans-merci","Les voyages de Thorgal","Le dernier voyage","Le successeur");
var cycle_nb=new Array (0,1,1,2,3,3,3,4,5,6,6,6,6,6,7,8,8,8,9,9,9,9,9,9,10,10,10,11,11,11,12,12,12);

var gf = {
O:[],N:0,S:0,img:0,xm:0,ym:0,nh:0,cx:0,cy:0,x:0,y:0,z:-40000,xt:0,yt:0,zt:0,

CObj : function(n){
this.n=n;
this.x=.6*Math.random()*1600-800;
this.y=.6*Math.random()*gf.nh*2-gf.nh;
this.z=Math.round(n*(10000/gf.N));
this.obj=gf.img[n];
this.obj.parent=this;
this.obj.onclick=function(){this.parent.click();}
//this.obj.onmouseover=function(){self.status=albums[n+1].replace("&#8217;","'");return true;}
this.obj.style.zIndex=Math.round(1000000-this.z);

this.anim = function(){
var f=700+this.z-gf.z;
if(f>400){
var d=1000/f;
var X=400+((this.x-gf.x-gf.cx)*d);
var Y=gf.nh/2+((this.y-gf.y-gf.cy)*d);
var W=d*148*.7;
var H=d*200*.7;
this.obj.style.left=Math.round(X-W/2)+'px';
this.obj.style.top=Math.round(Y-H/2)+'px';
this.obj.style.width=Math.round(W)+'px';
this.obj.style.height=Math.round(H)+'px';
if((gf.zt-gf.z)<200){
if(document.all)document.all("panneau").style.visibility="visible";
if(!document.all)document.getElementById("panneau").style.visibility="visible";}
}else{
this.obj.style.left=-3000;
this.x=.6*Math.random()*1600-800;
this.y=.6*Math.random()*gf.nh*2-gf.nh;
this.z+=10000;
this.obj.style.zIndex=Math.round(1000000-this.z);}
}

this.click = function(){
var zero="";
if(this.n+1<=9)zero="0";
if(this.n==0){xieme="er";}else{xieme="ème";}
dedans='<a><table border="0" cellpadding="0" cellspacing="0" style="cursor:pointer;" onclick="document.location.href=\'thorgal_cycles_'+zero+(this.n+1)+'.php\'" onmouseover="self.status=\''+albums[this.n+1]+'\';return true;"><tr><td background="images/cycles/cadreaccueil.gif" width="400" height="100" align="center" valign="center"><font face="Tahoma" size="5" color="#402000"><b><i>'+albums[this.n+1]+'</i></b></font><br><font face="Arial" size="2" color="#303000"><b><i>'+cycles[cycle_nb[this.n+1]]+'</i></b></font><br><span class="moyen">'+(this.n+1)+xieme+' album</span></td></table></a>';
if(document.all){
document.all("panneau").style.visibility="hidden";
document.all("panneau").innerHTML=dedans;
}
if(!document.all){
document.getElementById("panneau").style.visibility="hidden";
document.getElementById("panneau").innerHTML=dedans;}
if(gf.S!=this){
gf.xt=this.x;
gf.yt=this.y;
gf.zt=this.z;
gf.S=this;
}else{
document.location.href="thorgal_cycles_"+zero+(this.n+1)+".php";}
}
},

init : function(){
gf.nh=420;
if(document.all)gf.img=document.all("biblio").getElementsByTagName("img");
if(!document.all)gf.img=document.getElementById("biblio").getElementsByTagName("img");
gf.cx=400;
gf.cy=gf.nh/2;
gf.N=gf.img.length;
for(i=0;i<gf.N;i++)gf.O[i]=new gf.CObj(i);
gf.run();
gf.O[0].click();
},

run : function(){
if(document.all){
xx=document.body.scrollWidth/2;
yy=document.body.scrollHeight/2;}
if(!document.all){
xx=window.innerWidth/2;
yy=window.innerHeight/2;}

if(thor.ym>130){
gf.cx+=(thor.xm-gf.cx-xx)/10;
gf.cy+=(thor.ym-gf.cy-yy)/10;
gf.x+=(gf.xt-gf.x)/5;
gf.y+=(gf.yt-gf.y)/5;
gf.z+=(gf.zt-gf.z)/5;
var i=gf.N;
while(i--)gf.O[i].anim();}
setTimeout(gf.run,16);}
}