//



var xw = screen.width/2;
var yw = screen.height/2;

var nav=(document.all) ? false : true;
var posx=0;
var posy=0;
var dra_drag=true;//déplacer
var dra2_drag=false;//dimensionner
var drag_dx=0;
var drag_dy=0;
var drag_w=0;
var drag_dw=0;
var drag_d=0;
var posit_x=0;
var posit_y=0;

if (nav) {document.captureEvents(Event.MOUSEMOVE);}
document.onmousemove=position_souris;


var que_deplacer="commandes_";


function position_souris(e){
	posx=(nav)?e.pageX:window.event.x;
	posy=(nav)?e.pageY:window.event.y
	if (dra_drag) {return;}
	setTimeout("deplacer_()",50);
}
function deplacer_(){
	if (dra2_drag) {
	drag_w+=posx-drag_dw;drag_dw=posx;
	if (drag_w<150) {drag_w=150;}
	if (drag_w>xw) {drag_w=xw;}
	document.getElementById(que_deplacer).style.width=drag_w.toString()+"px";
	return;
	}

	document.getElementById(que_deplacer).style.left=(posx-drag_dx).toString()+"px";
	document.getElementById(que_deplacer).style.top=(posy-drag_dy).toString()+"px";
	return;
}
function prend_(o){
	que_deplacer=o;
	dra_drag=false;
	document.getElementById("sur_tout").style.left="0px";
	i=document.getElementById(o).style.top;
	drag_dy=posy-parseInt(i);
	i=document.getElementById(o).style.left;
	drag_dx=posx-parseInt(i);
	drag_w=parseInt(document.getElementById(o).style.width);
	drag_dw=posx;
	return;
}
function lache_(){
	dra_drag=true;
	dra2_drag=false;
	document.getElementById("sur_tout").style.left="-5000px";
	return;
}




///bulle d'aide mobile
///bulle d'aide
var largeur_doc=screen.width/2;
var hauteur_doc=screen.height-150;
var hauteur_aide=0;
function mets_pre_aide(o){
	p=document.getElementById("g_"+o).firstChild.nodeValue;
	mets_aide(p,"");
	return;
}
function mets_aide(o,r){
	hauteur_aide=(o+r).length/1.4+20;

	p=(largeur_doc>posx)? posx+20 : posx-180;
	q=(hauteur_doc-posy>hauteur_aide)? posy-10 : posy-hauteur_aide+(hauteur_doc-posy)/2; //hauteur_doc-hauteur_aide;

	document.getElementById("aide_").firstChild.nodeValue=o;//innerHTML=o;

	document.getElementById("aide_2").firstChild.nodeValue=r;
	document.getElementById("aide_").style.top=q.toString()+"px";
	document.getElementById("aide_").style.left=p.toString()+"px";
	return;
}
function enleve_aide(){
	document.getElementById("aide_").style.top="-1000px";
	document.getElementById("aide_").style.left="-1000px";
	return;
}

////////diaporama

var nombre_legendes=0;
var no_photo=0;
var test_id="";
var test_id_dra=false;

function pas_a_pas(o){
	no_photo=(no_photo+o+nombre_legendes)%nombre_legendes;
	clic_(no_photo);
	return;
}

function continu_(){
	if (test_id_dra) {return;}
	test_id_dra=true;
	test_id = setInterval("continu_2();",5000);
	document.getElementById("icone_continu").src="photos/s3_continu2.gif";
	continu_2();
	return;
}

function continu_2(){
	no_photo=(no_photo+1+nombre_legendes)%nombre_legendes;
	clic_(no_photo);
	return;
}

function continu_stop(){
	clearInterval(test_id);
	test_id_dra=false;
	document.getElementById("icone_continu").src="photos/s3_continu.gif";
	return;
}


/////bulle d'aide fixe
function aide_fixe(o){
	document.getElementById("les_remarques").firstChild.nodeValue = document.getElementById("e_"+o).firstChild.nodeValue;
	return;
}
function non_aide_fixe(o){
	document.getElementById("les_remarques").firstChild.nodeValue="";
	return;
}

var le_doc = new Array(100);


////variables



////bulles
var bulle_clic="";
function bulle_(o){o=le_doc[o];
	bb=document.getElementById("d_"+o).firstChild.nodeValue;
	if (bb=="0") {return;}
	cc=(document.getElementById("infos_"+o).firstChild.nodeValue=="0")?"11":"12";
	dd=document.getElementById("e_"+cc).firstChild.nodeValue;

	aide_fixe(cc);
	mets_aide(bb,dd);//innerHTML;
	return;
}
function nonbulle_(o){
	non_aide_fixe();
	enleve_aide();
/*
document.getElementById("le_zoom_cible").style.top="0px";
document.getElementById("le_zoom_cible").style.left="0px";
	document.getElementById("a"+o).style.backgroundColor="rgb(255,255,255)";
*/
	return;
}

///info
function clic2_(o){
	continu_stop();
	clic_(o);
	return;
}
function clic_(o){
	//if (o==0) {continu_stop();}
	no_photo=o;
	met_info(le_doc[o],o);
	return;
}
var info_mem=0;//pour photo
var info_mem2=0;//pour index
function met_info(o,p){
	document.getElementById("f_"+info_mem2).style.backgroundColor="transparent";
	document.getElementById("f_"+p).style.backgroundColor="yellow";
	info_mem2=p;
if (document.getElementById("infos_"+o).firstChild.nodeValue=="0") {return;}

	document.getElementById("im").src=document.getElementById("photos_"+o).firstChild.nodeValue;

	document.getElementById("infos_"+info_mem).style.top="-3000px";
	info_mem=o.toString();
	document.getElementById("infos_"+info_mem).style.top="0px";

	return;
}



function pointe_(xx,yy,zz,tt){
	mets_aide(document.getElementById("e_"+tt).firstChild.nodeValue,"");
	angle=0.392695*angle_memo;
	x=y*Math.sin(angle);
	z=y*Math.cos(angle);
	xx=xx*coefx
	yy=yy*coefy
	zz=zz*coefz
	denom=-x*xx+y*yy+z*zz-d*y*Math.SQRT2;
	xim=(250+((Math.SQRT2)*d*(z*xx+x*zz)/denom)*e)*zoom;
	yim=(260+(d*(x*xx+y*yy-z*zz)/denom)*f)*zoom;
	document.getElementById("pointeur_").style.top=yim.toString()+"px";
	document.getElementById("pointeur_").style.left=xim.toString()+"px";
	document.getElementById("le_zoom_cible").style.top=(yim/zoom/4-8).toString()+"px";
	document.getElementById("le_zoom_cible").style.left=(xim/zoom/4-8).toString()+"px";
	return;
}
function pointe_fin(){
	enleve_aide();
	document.getElementById("pointeur_").style.top="0px";
	document.getElementById("pointeur_").style.left="-20px";
	document.getElementById("le_zoom_cible").style.top="0px";
	document.getElementById("le_zoom_cible").style.left="0px";
	return;
}

////animation

/*
var detail = new Array(15);
for (i=0; i<=15; i++) {detail[i] = new Image; detail[i].src = "photos/hopk_"+i+".gif";}

var test_id2=""
var dra_video=false;
function depart_anim(){
	if (dra_video) {return;}
	dra_video=true; test_id2 = setInterval("animation();",120);
	return;
}
var num_video=0;
function animation(){
	if (num_video>=15) {clearInterval(test_id2);dra_video=false;num_video=0;
		return;
		}
	num_video=num_video+1;
	document.getElementById("im_hopk").setAttribute("src",detail[num_video].src);//image_hopkinson
	document.getElementById("im").setAttribute("src",detail[num_video].src);//image_hopkinson
	return;
}
function initialise_anim(){//inutilisé ici
	num_video=0;
	document.getElementById("im_hopk").setAttribute("src",detail[num_video].src);
	document.getElementById("im").setAttribute("src",detail[num_video].src);
	return;
}

*/

///fin animation

function tra_charge(o){
	aa=o+"?"+tra_deri;
aa+="_gen_,"+parseInt(document.getElementById("index_").style.left)+","+parseInt(document.getElementById("infos_").style.left)+","+parseInt(document.getElementById("infos_").style.width);
	document.location.href=aa;
	return;
}

function depart(){


	//légendes noms, n°
	aaa=document.getElementById("data_0").firstChild.nodeValue.split(";");
	nombre_legendes=aaa.length;
	for (i=0; i<nombre_legendes; i++) {
	bbb=aaa[i].split(",");
	le_doc[i]=eval(bbb[0]);
	document.getElementById("f_"+i).firstChild.nodeValue=bbb[1];
	}


	//divers
	aaa=document.getElementById("data_1").firstChild.nodeValue.split("_");
	for (i=0; i<=aaa.length-1; i++) {
	document.getElementById("gene_"+i).firstChild.nodeValue=aaa[i];
	}

	//tra_deri
	tra_deri_action("_gen_");

	if (tra_deri_pour_ici!="") {
		bb=tra_deri_pour_ici.split(",");
		if (bb.length==4) {
		document.getElementById("index_").style.left=bb[1]+"px";
		document.getElementById("infos_").style.left=bb[2]+"px";
		document.getElementById("infos_").style.width=bb[3]+"px";
		}}


	clic_(1);

	return;
}
