// -----------------------------------------------------------------------------------
//
//	Dock
//	by Jill-Jênn Vie - http://www.jill-jenn.net
//	Last Modification: 10/02/11
//
//	Licensed under the Creative Commons Attribution 3.0 License - http://creativecommons.org/licenses/by/3.0/
//  	- Free for use in both personal and commercial projects
//		- Attribution requires leaving author name, author link, and the license info intact.
//	
// -----------------------------------------------------------------------------------

noms = new Array("Sheet music", "Works", "YouTube videos", "YouNicode", "Favorite films", "Chemistry", "Dieux", "Prologin", "Eigaki", "About", "Contact");
n = noms.length;
tailleMin = 80;
tailleMax = 128;
occupe = 0;
agrandi = new Array(n);
for(i = 0 ; i < n ; i++)
	agrandi[i] = 0;

function reglerTaille(i, t) {
	document.getElementById("dock" + i).style.width = t + "px";
}

function afficherNom(i) {
	t = " ";
	if(i >= 0)
		t = noms[i];
	document.getElementById("nom").innerHTML = t;
}

function agrandir(i, taille, zoom) {
	if(agrandi[i] == 0 || (agrandi[i] == 0.33 && taille != tailleMin)) {
		agrandi[i] = 0.33;
		nouvelleTaille = taille + zoom;
		if(nouvelleTaille < tailleMax) {
			reglerTaille(i, nouvelleTaille);
			setTimeout("agrandir(" + i + ", " + nouvelleTaille + ", " + (zoom + 1) + ")", 25);
		} else {
			reglerTaille(i, tailleMax);
			agrandi[i] = 1;
			toutReduireSauf(i);
			afficherNom(i);
		}
	}
}

function reduire(i, taille, zoom, iAffiche) {
	if(agrandi[i] == 1 || (agrandi[i] == 0.67 && taille != tailleMax)) {
		agrandi[i] = 0.67;
		nouvelleTaille = taille + zoom;
		if(nouvelleTaille > tailleMin) {
			reglerTaille(i, nouvelleTaille);
			setTimeout("reduire(" + i + ", " + nouvelleTaille + ", " + (zoom - 1) + ", " + iAffiche + ")", 25);
		} else {
			reglerTaille(i, tailleMin);
			agrandi[i] = 0;
			afficherNom(iAffiche);
		}
	}
}

function toutReduireSauf(iSpecial) {
	for(i = 0 ; i < n ; i++)
		if(i != iSpecial)
			reduire(i, tailleMax, -1, iSpecial);
}

function verifierPosition(evt) {
	if(evt.clientY > 350)
		toutReduireSauf(-1);
}

function verifDock() {
	document.onmousemove = verifierPosition;
}
