// Fonctions communes
// (c) Stéphane Hardy 2007-2011
// http://www.thorgal-bd.fr/

window.defaultStatus="Thorgal-BD - Le Deuxième Monde";
window.onresize=new Function('setTimeout("window.location.reload()",0)');

function c_nav(qui){
if(document.all)return document.all(qui);
if(!document.all)return document.getElementById(qui);
}
function c_top(qui,quoi){
if(document.all)document.all(qui).style.pixelTop=quoi;
if(!document.all)document.getElementById(qui).style.top=quoi+"px";
}
function c_left(qui,quoi){
if(document.all)document.all(qui).style.pixelLeft=quoi;
if(!document.all)document.getElementById(qui).style.left=quoi+"px";
}
function c_bottom(qui,quoi){
if(document.all)document.all(qui).style.pixelBottom=quoi;
if(!document.all)document.getElementById(qui).style.bottom=quoi+"px";
}
function c_right(qui,quoi){
if(document.all)document.all(qui).style.pixelRight=quoi;
if(!document.all)document.getElementById(qui).style.right=quoi+"px";
}
function c_opacity(qui,op){
if(document.all)document.all(qui).filters.alpha.opacity=op;
if(!document.all){
document.getElementById(qui).style.setProperty("-moz-opacity",op/100,"");
document.getElementById(qui).style.opacity=op/100;}
}

function ouvrirbib(bqui,bw,bh){
var contenu='<iframe src="../biblio/thorgal_auteurs_'+bqui+'.php" frameborder="0" width="'+bw+'" height="'+bh+'" onclick="cacher()" style="border:10px solid black;cursor:pointer"></iframe><br><span align="center" class="petit" style="color:white;cursor:pointer" onclick="cacher()">Fermer</span>';
c_nav("photo").style.visibility="hidden";
c_nav("photo").innerHTML=contenu;
c_nav("photo").style.visibility="visible";
c_top("masque_photo",0);
c_top("cadre_photo",0);
}

function aff_tour(qui,quoi){
var action = new Array ("visible","hidden");
c_nav(qui).style.visibility=action[quoi];
thor.sur=1;
}

function aff_cadre(qui,quoi){
var nom = new Array ("aff_cadre0","aff_cadre1","aff_cadre2");
var action = new Array ("visible","hidden");
c_nav(nom[qui]).style.visibility=action[quoi];
}

function fenetre_albums(titre,larg,haut){
gauch=(screen.availWidth-larg)/2;
var alb;
alb=window.open("../biblio/thorgal_auteurs_"+titre+".php","","width="+larg+",height="+haut+",left="+gauch+",top=100");}


// Nouveau bandeau

thorg_bandeau=new Object;
thorg_bandeau.vuoupas=0;
thorg_bandeau.sens=1;

var b_desc=new Array("tout le site Thorgal-BD","l'actualité de la série, de ses auteurs et du site","les albums, cycle par cycle","les héros de la saga","tirages spéciaux, multimédia, objets, musique","le monde de Thorgal, ses héros, ses mythes et ses mystères","la légende de Thorgal, dévoilée par la Gardienne des clés","Grzegorz Rosinski, Jean Van Hamme, Yves Sente et Graza","l'espace jeu et détente !","les galeries des visiteurs, textes, dessins et photos","les classements des albums","la communauté de fans","quoi de neuf aujourd'hui ?");
var b_vis=new Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0);

function anim_thorgbandeau(){
if(thorg_bandeau.sens==1&&thorg_bandeau.vuoupas>=10){thorg_bandeau.vuoupas-=10;}
if(thorg_bandeau.sens==0&&thorg_bandeau.vuoupas<=90){thorg_bandeau.vuoupas+=10;}
	c_opacity("bandeaumarron",thorg_bandeau.vuoupas);
for(i=0;i<=13;i++){
	if(i!=thorg_bandeau.spot&&b_vis[i]>=10){b_vis[i]-=10;c_opacity("bandeau"+i,b_vis[i]);}
	if(i==thorg_bandeau.spot&&b_vis[i]<=90){b_vis[i]+=10;c_opacity("bandeau"+i,b_vis[i]);}
}
if(b_vis[13]==0)c_nav("bandeau13").style.visibility="hidden";
setTimeout("anim_thorgbandeau()",24);
}

function aff_thorgbandeau(qui){
thorg_bandeau.spot=qui;
c_nav("bandeau_txt").innerHTML=b_desc[qui];
c_nav("bandeau_txt2").innerHTML=b_desc[qui];
c_nav("bandeau_barre").style.visibility="visible";
}

function aff_actus(quoi){
if(quoi==1){
	c_nav("bandeau13").style.visibility="visible";
	thorg_bandeau.spot=13;
}else{
	thorg_bandeau.spot=thorg_bandeau.qui;
}}

function eff_thorgbandeau(){
if(thorg_bandeau.spot==13)return;
thorg_bandeau.spot=thorg_bandeau.qui;
c_nav("bandeau_txt").innerHTML="";
c_nav("bandeau_txt2").innerHTML="";
c_nav("bandeau_barre").style.visibility="hidden";
}


// Ancien tourniquet

thor=new Object;

thor.xm=0;
thor.ym=0;
thor.varx=0;
thor.tr=50;
var larg=new Array;
var haut=new Array;
var t_ou=new Array;

function m_tourne(){
if(thor.sur==1)thor.varx=(Math.round(((-thor.xm+document.body.offsetWidth/2)/40)*10))/20;
if(thor.sur==0){
if(thor.varx>0)thor.varx=(Math.round((thor.varx-.2)*10))/10;
if(thor.varx<0)thor.varx=(Math.round((thor.varx+.2)*10))/10;
if(Math.abs(thor.varx)<=.5)thor.varx=0;
}
if(thor.varx>=8)thor.varx=8;
if(thor.varx<=-8)thor.varx=-8;
var sin=Math.sin(thor.varx*Math.PI/180);
var cos=Math.cos(thor.varx*Math.PI/180);

for(i=0;i<=12;i++){
x=t_ou[i*2]*cos-t_ou[i*2+1]*sin;
z=t_ou[i*2+1]*cos+t_ou[i*2]*sin;
var op=thor.tr-(z/2);
c_top("i"+i,Math.round((900/(6+z/100))-170));
c_left("i"+i,Math.round(400+(10*x/(5+z/100))-38));
c_opacity("i"+i,op);
if(document.all)document.all("i"+i).style.zIndex=Math.round(10000-z);
if(!document.all)document.getElementById("i"+i).style.zIndex=Math.round(10000-z);
t_ou[i*2]=x;
t_ou[i*2+1]=z;
if(thor.sur==0&&z<77)c_opacity("i"+i,10);
}
if(thor.sur==0&&thor.varx==0){setTimeout("m_tourne()",500);}else{setTimeout("m_tourne()",25);}
}

function m_position(e){
if(document.all){
thor.xm=window.event.clientX;
thor.ym=window.event.clientY;}
if(!document.all){
thor.xm=e.pageX;
thor.ym=e.pageY;}
if(thor.ym>130||thor.ym<5)thor.sur=0;
}

function m_depart(partie){
t_ou[26]=0;
t_ou[27]=0;

// pour 13 icônes
var t_ou_prov=new Array(0,-110,49,-98,89,-64,108,-14,102,37,74,80,28,106,-27,107,-72,83,-104,39,-109,-13,-89,-64,-52,-97,0,-110,49,-98,89,-64,108,-14,102,37,74,80,28,106,-27,107,-72,83,-104,39,-109,-13,-89,-64,-52,-97);

// pour 12 icônes : (60,-100,100,-60,110,0,100,60,60,100,0,110,-60,100,-100,60,-110,0,-100,-60,-60,-100,0,-110,60,-100,100,-60,110,0,100,60,60,100,0,110,-60,100,-100,60,-110,0,-100,-60,-60,-100,0,-110)

for(i=0;i<=12;i++){
t_ou[i*2]=t_ou_prov[(i*2)+24-(partie*2)];
t_ou[(i*2)+1]=t_ou_prov[(i*2)+1+24-(partie*2)];
}
document.onmousemove=m_position;
thor.sur=0;
m_tourne();
}

function ouvrir(pqui,pquoi){
c_nav("photo").style.visibility="hidden";
c_nav("photo").innerHTML="<img src='../"+pqui+"' border='2' style='cursor:pointer;' onclick='javascript:cacher();'><br><span class='petit'><font color='white'>"+pquoi+"</font></span>";
c_top("masque_photo",0);
c_top("cadre_photo",0);
c_nav("photo").style.visibility="visible";
}

function cacher(){
c_top("masque_photo",-5000);
c_top("cadre_photo",-5000);
}

function antispam(quoi){
if(quoi==1){location.href='mailto:webmestre@thorgal-bd.fr?subject=A propos du site Thorgal-BD';}else{document.write('<a href="mailto:webmestre@thorgal-bd.fr?subject=A propos du site Thorgal-BD" onmouseover="self.status=\'Ecrire un message\';return true;" onfocus="blur();">');}
}
