// JavaScript Document tangram AUVRAYG  auvrayg@la-borne.com
// production UGG prod

var planche=0;
var num_planche=0;
var attend;
var depche="";
var nom_img="poule1";
var soluce=0;

var compte=0;
var lecalque;
var code="";
var sens="";
var pour_z="";

var ad_tj="tangram/triangle_jaune/triangle_j";
var num_tj=1;

var ad_tv="tangram/triangle_violet/triangle_violet";
var num_tv=7;

var ad_ca="tangram/carre/carre";
var num_ca=2;

var ad_tb="tangram/tiangle_bleu/tri_bleu";
var num_tb=1;

var ad_lr="";
var num_lr=1;
var dir_lo=0;

var ad_tm="tangram/triangle_maron/triangle-m";
var num_tm=1;

var ad_tvv="tangram/triangle_vert/triangle-v";
var num_tvv=7;

function tourne(code, sens)
{
if (code=="tj")	{
				num_tj=num_tj+sens;
				if (num_tj==9 && sens==1){num_tj=1}
				if (num_tj==0 && sens==-1){num_tj=8}
				document.tri_jau.src=ad_tj + num_tj + ".gif";
				pour_index(2);
				}
if (code=="tv")	{
				num_tv=num_tv+sens;
				if (num_tv==9 && sens==1){num_tv=1}
				if (num_tv==0 && sens==-1){num_tv=8}
				document.tri_vio.src=ad_tv + num_tv + ".gif";
				pour_index(3);
				}
if (code=="ca")	{
				num_ca=num_ca+sens;
				if (num_ca==3 && sens==1){num_ca=1}
				if (num_ca==0 && sens==-1){num_ca=2}
				document.carre.src=ad_ca + num_ca + ".gif";
				pour_index(4);
				}
if (code=="tb")	{
				num_tb=num_tb+sens;
				if (num_tb==9 && sens==1){num_tb=1}
				if (num_tb==0 && sens==-1){num_tb=8}
				document.tri_bleu.src=ad_tb + num_tb + ".gif";
				pour_index(5);
				}
if (code=="lr")	{
				if (dir_lo==0){sens=-sens}//permet que le sens de tournage soit bon
				num_lr=num_lr+sens;
				if (num_lr==5 && sens==1){num_lr=1}
				if (num_lr==0 && sens==-1){num_lr=4}
				if (dir_lo==0){ad_lr="tangram/losange/los_rou";
								document.loser.src="tangram/losange/los_rou3.gif";
								document.loser2.src="tangram/losange/los_rou3.gif";
								}
				if (dir_lo==1){ad_lr="tangram/losange/losan_rouge";
								document.loser.src="tangram/losange/losan_rouge3.gif";
								document.loser2.src="tangram/losange/losan_rouge3.gif";
								}				
				document.losan.src=ad_lr + num_lr + ".gif";//  los_rou3.gif
				pour_index(6);
				} 
if (code=="tm")	{
				num_tm=num_tm+sens;
				if (num_tm==9 && sens==1){num_tm=1}
				if (num_tm==0 && sens==-1){num_tm=8}
				document.tri_mar.src=ad_tm + num_tm + ".gif";
				pour_index(7);
				}
if (code=="tvv")	{//alert();
				num_tvv=num_tvv+sens;
				if (num_tvv==9 && sens==1){num_tvv=1}
				if (num_tvv==0 && sens==-1){num_tvv=8}
				document.tri_ver.src=ad_tvv + num_tvv + ".gif";
				pour_index(8);
				}				
}
function inverse()
{
if (dir_lo==1){dir_lo=dir_lo+1}
if (dir_lo==0){dir_lo=dir_lo+1}
if (dir_lo==2){dir_lo=0}
tourne("lr", 0);
compte=1
}
function pour_index (pour_z)// fait passer le calque devant
{
//document.getElementById('E2').style="z-index:9;";
with (e2 = document.getElementById('E2').cbe) {zIndex(3);}
with (e3 = document.getElementById('E3').cbe) {zIndex(4);}
with (e4 = document.getElementById('E4').cbe) {zIndex(5);}
with (e5 = document.getElementById('E5').cbe) {zIndex(6);}
with (e6 = document.getElementById('E6').cbe) {zIndex(7);}
with (e7 = document.getElementById('E7').cbe) {zIndex(8);}
with (e8 = document.getElementById('E8').cbe) {zIndex(9);}
/*
with (p1 = document.getElementById('P1').cbe) {zIndex(15);}
with (p2 = document.getElementById('P2').cbe) {zIndex(15);}
with (p3 = document.getElementById('P3').cbe) {zIndex(15);}
*/
lecalque="e" + pour_z;
//alert(lecalque)
with (lecalque = document.getElementById('E' + pour_z).cbe) {zIndex(11);}
}
function ouvrir(planche)
{
num_planche=planche;
clearTimeout (attend);
if (planche==1){
				with (p1){show()};
				with (p2){hide()};
				with (p3){hide()};
				with (p4){hide()};
				with (p5){hide()};
				}
if (planche==2){with (p2){show()};
				with (p1){hide()};
				with (p3){hide()};
				with (p4){hide()};
				with (p5){hide()};
				}
if (planche==3){with (p3){show()};
				with (p1){hide()};
				with (p2){hide()};
				with (p4){hide()};
				with (p5){hide()};
				}
if (planche==4){with (p4){show()};
				with (p1){hide()};
				with (p2){hide()};
				with (p3){hide()};
				with (p5){hide()};
				}
if (planche==5){with (p5){show()};
				with (p1){hide()};
				with (p2){hide()};
				with (p3){hide()};
				with (p4){hide()};
				}
if (planche==0){with (p1){hide()};
				with (p2){hide()};
				with (p3){hide()};
				with (p4){hide()};
				with (p5){hide()};
				}									
}
function ferme ()
{
if (num_planche==1){attend= setTimeout ("with (p1){hide()}", 100);}
if (num_planche==2){attend= setTimeout ("with (p2){hide()}", 100);}
if (num_planche==3){attend= setTimeout ("with (p3){hide()}", 100);}
if (num_planche==4){attend= setTimeout ("with (p4){hide()}", 100);}
if (num_planche==5){attend= setTimeout ("with (p5){hide()}", 100);}

}
function solution(soluce)
{
if (soluce==1)	{
				document.la_sol.src="pour_modele/s_" + nom_img + ".jpg";
				with (s1){show()};
				}
if (soluce==0)	{with (s1){hide()};}
}
function aide(soluce)
{
if (soluce==1)	{with (a1){show()};}
if (soluce==0)	{with (a1){hide()};}
}