/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder = "buttons/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources = new Array("button1up.png","button2up.png","button3up.png","button4up.png","button5up.png","button6up.png","button7up.png","button8up.png");

overSources = new Array("button1over.png","button2over.png","button3over.png","button4over.png","button5over.png","button6over.png","button7over.png","button8over.png");

// SUB MENUS DECLARATION, YOU DONT NEED TO EDIT THIS
subInfo = new Array();
subInfo[1] = new Array();
subInfo[2] = new Array();
subInfo[3] = new Array();
subInfo[4] = new Array();
subInfo[5] = new Array();
subInfo[6] = new Array();
subInfo[7] = new Array();
subInfo[8] = new Array();


//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//
subInfo[1][1] = new Array("LA NICOTINE","soluce1.html","");
subInfo[1][2] = new Array("Son aspect","soluce1.html#aspect","");
subInfo[1][3] = new Array("Son action","soluce1.html#action","");
subInfo[1][4] = new Array("La 1ère conséquence","soluce1.html#frustrer","");
subInfo[1][5] = new Array("La 2ème conséquence","soluce1.html#droguer","");

subInfo[2][1] = new Array("LE CONDITIONNEMENT","soluce2.html","");
subInfo[2][2] = new Array("L'environnement","soluce2.html#environ","");
subInfo[2][3] = new Array("La vogue","soluce2.html#vogue","");
subInfo[2][4] = new Array("La publicité","soluce2.html#pub","");
subInfo[2][5] = new Array("L'État","soluce2.html#etat","");
subInfo[2][6] = new Array("De l'habitude au réflexe","soluce2.html#habitude","");
subInfo[2][7] = new Array("Une loi méconnue","soluce2.html#inconnue","");
subInfo[2][8] = new Array("Les erreurs de perception","soluce2.html#erreurs","");

subInfo[3][1] = new Array("L'ALIMENTATION","soluce3.html","");
subInfo[3][2] = new Array("Les engrenages","soluce3.html#engrenag","");
subInfo[3][3] = new Array("Accusés, levez-vous","soluce3.html#accuses","");
subInfo[3][4] = new Array("Le rôle des alcaloïdes","soluce3.html#role","");
subInfo[3][5] = new Array("Petite histoire du sucre","soluce3.html#sucre","");
subInfo[3][6] = new Array("Encore des explications","soluce3.html#encore","");

subInfo[4][1] = new Array("LE STRESS","soluce4.html","");
subInfo[4][2] = new Array("Les poussées d'adrénaline","soluce4.html#poussees","");
subInfo[4][3] = new Array("Quels stress ?","soluce4.html#lesquels","");
subInfo[4][4] = new Array("Stress occasionnels mais violents","soluce4.html#violent","");
subInfo[4][5] = new Array("Le stress au quotidien","soluce4.html#jourdhui","");
subInfo[4][6] = new Array("Le stress au féminin","soluce4.html#feminin","");

subInfo[5][1] = new Array("LES MAUVAISES TACTIQUES","soluce5.html","");
subInfo[5][2] = new Array("Exploiter votre force de volonté","soluce5.html#volonte","");
subInfo[5][3] = new Array("Vous motiver avec la santé","soluce5.html#sante","");
subInfo[5][4] = new Array("Être contraint d'arrêter de fumer","soluce5.html#obliger","");
subInfo[5][5] = new Array("Diminuer les doses","soluce5.html#diminuer","");
subInfo[5][6] = new Array("Fixer une date","soluce5.html#date","");
subInfo[5][7] = new Array("Vous en remettre à la fin d'une méthode ou d'un livre","soluce5.html#livre","");
subInfo[5][8] = new Array("Faire usage des substituts","soluce5.html#substitu","");
subInfo[5][9] = new Array("Escompter une fin définitive","soluce5.html#finitude","");

subInfo[6][1] = new Array("LE STYLE DE VIE","soluce6.html","");
subInfo[6][2] = new Array("L'alimentation","soluce6.html#manger","");
subInfo[6][3] = new Array("L'inactivité physique","soluce6.html#bouger","");
subInfo[6][4] = new Array("La fatigue","soluce6.html#dormir","");
subInfo[6][5] = new Array("L'état d'esprit","soluce6.html#imaginer","");

subInfo[7][1] = new Array("LES EFFETS DU MANQUE","soluce7.html","");
subInfo[7][2] = new Array("Le besoin de fumer","soluce7.html#besoin","");
subInfo[7][3] = new Array("L'irritabilité et la colère","soluce7.html#colere","");
subInfo[7][4] = new Array("L'anxiété","soluce7.html#anxiete","");
subInfo[7][5] = new Array("La faim","soluce7.html#faim","");
subInfo[7][6] = new Array("La fatigue et le manque d'énergie","soluce7.html#fatigue","");
subInfo[7][7] = new Array("Les rêves de fumerie","soluce7.html#reves","");
subInfo[7][8] = new Array("La sensation de vide","soluce7.html#vide","");
subInfo[7][9] = new Array("Les vertiges, les difficultés de concentration, la fébrilité, le sommeil perturbé, les maux de tête, la fièvre","soluce7.html#vertiges","");
subInfo[7][10] = new Array("La constipation","soluce7.html#constipe","");
subInfo[7][11] = new Array("La toux","soluce7.html#toux","");
subInfo[7][12] = new Array("Les crampes et les douleurs musculaires","soluce7.html#crampes","");
subInfo[7][13] = new Array("Les crises urinaires","soluce7.html#uriner","");
subInfo[7][14] = new Array("Les plaies aux lèvres, la peau malodorante","soluce7.html#plaies","");
subInfo[7][15] = new Array("L'ouïe aiguisée","soluce7.html#ouie","");

subInfo[8][1] = new Array("LES PIÈGES DE LA RECHUTE","soluce8.html","");
subInfo[8][2] = new Array("Trop facile","soluce8.html#facile","");
subInfo[8][3] = new Array("Changer d'avis","soluce8.html#changer","");
subInfo[8][4] = new Array("La curiosité","soluce8.html#curieux","");
subInfo[8][5] = new Array("Celles des autres","soluce8.html#autrui","");
subInfo[8][6] = new Array("Côtoyer les fumeurs","soluce8.html#fumeurs","");
subInfo[8][7] = new Array("Envier","soluce8.html#envier","");
subInfo[8][8] = new Array("L'appétit","soluce8.html#appetit","");
subInfo[8][9] = new Array("Les grandes occasions","soluce8.html#occasion","");
subInfo[8][10] = new Array("La fin des repas","soluce8.html#repas","");
subInfo[8][11] = new Array("L'ennui","soluce8.html#ennui","");
subInfo[8][12] = new Array("L'alcool","soluce8.html#alcool","");
subInfo[8][13] = new Array("Le style de vie","soluce8.html#style","");
subInfo[8][14] = new Array("Le travail","soluce8.html#travail","");
subInfo[8][15] = new Array("Les disputes, les contrariétés, les colères","soluce8.html#disputes","");
subInfo[8][16] = new Array("Les malheurs","soluce8.html#malheur","");
subInfo[8][17] = new Array("La dépression","soluce8.html#deprime","");


//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset = 280;
var ySubOffset = 0;



//*** NO MORE SETTINGS BEYOND THIS POINT ***//
var overSub = false;
var delay = 1000;
totalButtons = upSources.length;

// GENERATE SUB MENUS
for ( x=0; x<totalButtons; x++) {
	// SET EMPTY DIV FOR BUTTONS WITHOUT SUBMENU
	if ( subInfo[x+1].length < 1 ) { 
		document.write('<div id="submenu' + (x+1) + '">');
	// SET DIV FOR BUTTONS WITH SUBMENU
	} else {
		document.write('<div id="submenu' + (x+1) + '" class="dropmenu" ');
		document.write('onMouseOver="overSub=true;');
		document.write('setOverImg(\'' + (x+1) + '\',\'\');"');
		document.write('onMouseOut="overSub=false;');
		document.write('setTimeout(\'hideSubMenu(\\\'submenu' + (x+1) + '\\\')\',delay);');
		document.write('setOutImg(\'' + (x+1) + '\',\'\');">');


		document.write('<ul>');
		for ( k=0; k<subInfo[x+1].length-1; k++ ) {
			document.write('<li>');
			document.write('<a href="' + subInfo[x+1][k+1][1] + '" ');
			document.write('target="' + subInfo[x+1][k+1][2] + '">');
			document.write( subInfo[x+1][k+1][0] + '</a>');
			document.write('</li>');
		}
		document.write('</ul>');
	}
	document.write('</div>');
}





//*** MAIN BUTTONS FUNCTIONS ***//
// PRELOAD MAIN MENU BUTTON IMAGES
function preload() {
	for ( x=0; x<totalButtons; x++ ) {
		buttonUp = new Image();
		buttonUp.src = buttonFolder + upSources[x];
		buttonOver = new Image();
		buttonOver.src = buttonFolder + overSources[x];
	}
}

// SET MOUSEOVER BUTTON
function setOverImg(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder + overSources[But-1];
}

// SET MOUSEOUT BUTTON
function setOutImg(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder + upSources[But-1];
}



//*** SUB MENU FUNCTIONS ***//
// GET ELEMENT ID MULTI BROWSER
function getElement(id) {
	return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null; 
}

// GET X COORDINATE
function getRealLeft(id) { 
	var el = getElement(id);
	if (el) { 
		xPos = el.offsetLeft;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
			tempEl = tempEl.offsetParent;
		} 
		return xPos;
	} 
} 

// GET Y COORDINATE
function getRealTop(id) {
	var el = getElement(id);
	if (el) { 
		yPos = el.offsetTop;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
			tempEl = tempEl.offsetParent;
		}
		return yPos;
	}
}

// MOVE OBJECT TO COORDINATE
function moveObjectTo(objectID,x,y) {
	var el = getElement(objectID);
	el.style.left = x;
	el.style.top = y;
}

// MOVE SUBMENU TO CORRESPONDING BUTTON
function showSubMenu(subID, buttonID) {
	hideAllSubMenus();
	butX = getRealLeft(buttonID);
	butY = getRealTop(buttonID);
	moveObjectTo(subID,butX+xSubOffset, butY+ySubOffset);
}

// HIDE ALL SUB MENUS
function hideAllSubMenus() {
	for ( x=0; x<totalButtons; x++) {
		moveObjectTo("submenu" + (x+1) + "",-500, -500 );
	}
}

// HIDE ONE SUB MENU
function hideSubMenu(subID) {
	if ( overSub == false ) {
		moveObjectTo(subID,-500, -500);
	}
}



//preload();


