
// fonctions d'anim
function zoneInit(id) {
 var zone = eval("z"+id+"['id']");
 var width = eval("z"+id+"['width']");
 var height = eval("z"+id+"['height']");
 var left = eval("z"+id+"['left']");
 var top = eval("z"+id+"['top']");
 var div = document.getElementById(zone);
 div.style.width = width;
 div.style.height = height;
 div.style.left = left;
 div.style.top = top;
}

function kelZone(id) {
var z;
switch(id) {
case 1 :
z = "pic1";
break;
case 2 :
z = "pic2";
break;
case 3 :
z = "pic3";
break;
case 4 :
z = "pic4";
break;
case 5 :
z = "pic5";
break;
case 6 :
z = "pic6";
break;
case 7 :
z = "bigpic";
break;
}
return z;
}

function hide(nom) {
 var div = document.getElementById(nom);
 div.style.visibility="hidden";
}

function show(nom) {
 var div = document.getElementById(nom);
 div.style.visibility="visible";
}

function init(zone,x,left,axe,sens,speed) {
show(zone);
move(zone,x,left,axe,sens,speed);
}

function growt(img,w,h) {

var step = 5;
var coef = w/h;
var div = document.getElementById(img).style;

var ow = div.width;
var oh = div.height;

var nw = ow+step;
var nh = oh+(step/coef);
alert(ow);
div.width = nw+"px";
div.height = nh+"px";
var gw = div.width;
var gh = div.height;

if ( gh > h-1) {
 return;
 }
else {
 	setTimeout("growt('"+img+"',"+w+","+h+")",1);
	}

}

function grow(img,w,h) {

var step = 10;
var coef = w/h;
var div = document.getElementById(img);

var ow = div.width;
var oh = div.height;
var nw = ow+step;

//var nh = oh+(step/coef);
var nh = (nw/4)*3;

div.width = nw;
div.height = nh;
var gw = div.width;
var gh = div.height;

if ( gh > h-1) {
 return;
 }
else {
 	setTimeout("grow('"+img+"',"+w+","+h+")",1);
	}

}

function grow2(img,w,h,step,sens) {

var coef = w/h;
var div = document.getElementById(img);
var ow = div.width;
var oh = div.height;

	if (sens == "+") {
	var nw = ow+step;
	var nh = oh+(step/coef);
	}
	else {
	var nw = ow-step;
	var nh = oh-(step/coef);
	}

div.width = nw;
div.height = nh;
var gw = div.width;
var gh = div.height;

	if (sens == "+") {
		if ( gw > w-1) {
		return;
		}
		else {
		setTimeout("grow2('"+img+"',"+w+","+h+","+step+",'"+sens+"')",1);
		}
 	}
	else {
		if ( gw < w+1) {
		return;
		}
		else {
		setTimeout("grow2('"+img+"',"+w+","+h+","+step+",'"+sens+"')",1);
		}
	}
}

function swap(id,w,h,l,t,left,top) {
 var img = "p"+id;
 var zone = "pic"+id;
 var vig = "vig"+id;
 show(vig);
// document.getElementById(vig).style.border="2px solid red";
 var div = kelZone(id);
document.getElementById(zone).style.zIndex="3";
mTo(zone,l,t,left,top,'-',10);
setTimeout("grow('"+img+"','"+w+"','"+h+"')",500);
}

function clearDiv() {
 		 for (var i=1; i < 7; i++) {
		 var zone = kelZone(i);
		// hide(zone);
		 }

 		 for (var i=1; i < 7; i++) {
		 //zoneInit(i);
		 }

		 for (var i=1; i < 7; i++) {
		 var zone = kelZone(i);
		 show(zone);
		 }
show('bigpic');
}

function reset1() {
 clearTimeout(mvl);
 clearTimeout(mvt);
 clearTimeout(a1);
 clearTimeout(a2);
 clearTimeout(a3);
 clearTimeout(a4);
 clearTimeout(a2b);
 clearTimeout(a3b);
 clearTimeout(a4b);

 clearTimeout(a5);
 clearTimeout(a6);
 clearTimeout(a7);

 clearTimeout(a8);
 clearTimeout(a9);
 clearTimeout(a10);
 clearTimeout(a11);
// clearTimeout(t1);
}

function reset(pp) {
 reset1();
	if (loopMode == "loop") {
		if (pp > 0) {
		resizePics(pp);
		}
 	startAnim();
  	}
	else {
 	location.reload();
 	}
}

function resizePics(pp) {
if (pp > 0) {
zoneInit(1);
hide("vig1");
var rs1 = document.getElementById('p1');
rs1.width = z1['width'];
rs1.height = z1['height'];
var div1 = document.getElementById('pic1');
div1.style.left = z1['left'];
div1.style.top = z1['top'];
}
if (pp > 1) {
zoneInit(2);
hide("vig2");
var rs2 = document.getElementById('p2');
rs2.width = z2['width'];
rs2.height = z2['height'];
var div2 = document.getElementById('pic2');
div2.style.left = z2['left'];
div2.style.top = z2['top'];
}
if (pp > 2) {
zoneInit(3);
hide("vig3");
var rs3 = document.getElementById('p3');
rs3.width = z3['width'];
rs3.height = z3['height'];
var div3 = document.getElementById('pic3');
div3.style.left = z3['left'];
div3.style.top = z3['top'];
}
if (pp > 3) {
zoneInit(4);
hide("vig4");
var rs4 = document.getElementById('p4');
rs4.width = z4['width'];
rs4.height = z4['height'];
var div4 = document.getElementById('pic4');
div4.style.left = z4['left'];
div4.style.top = z4['top'];
}
if (pp > 4) {
zoneInit(5);
hide("vig5");
var rs5 = document.getElementById('p5');
rs5.width = z5['width'];
rs5.height = z5['height'];
var div5 = document.getElementById('pic5');
div5.style.left = z5['left'];
div5.style.top = z5['top'];
}
if (pp > 5) {
zoneInit(6);
hide("vig6");
var rs6 = document.getElementById('p6');
rs6.width = z6['width'];
rs6.height = z6['height'];
var div6 = document.getElementById('pic6');
div6.style.left = z6['left'];
div6.style.top = z6['top'];
}
//zoneInit(7);
show('p7');
//grow2('p7',400,300,20,'+');
}



