/*
 * 
 *
 * javascript.js v1.1
 */

/*
 * CONFIGURATION.
 */

// To create a new element in the menu, add a line like the following:
// menu[position in the menu] = new Array("text to display", "relative path of the page", "message to display in the status bar (optional : if null, the 'text to display' is used)");
// menu[0] is for the home page of the site. It's a link on the image.
// Please don't use HTML special caracters like &eacute; for example.
var menu = new Array();

menu[0] = new Array("Accueil", "index.htm");
menu[1] = new Array("Programme de conservation", "presentation_prog.html");
menu[2] = new Array("Les acteurs du réseau", "presentation_reseau_membres.html");
menu[3] = new Array("Les actions du réseau", "presentation_reseau_actions.html");
menu[4] = new Array("Nouvelles du mois <i><b>(new)</b></i>", "nouvelles.html");
menu[5] = new Array("Les tortues marines", "tortues.htm");
menu[6] = new Array("Photothèque ", "phototheque.html");
menu[7] = new Array("Bibliothèque <i><b>(new)</b></i>", "bibliotheque.html");
menu[8] = new Array("Pour agir ", "agir.html");
menu[9] = new Array("Questions/Réponses", "questionsreponses.html");
menu[10] = new Array("Fiches d'observation", "fiche_observation.html");
menu[11] = new Array("Jouez avec les tortues ", "jouez.html");
menu[12] = new Array("Suivez les tortues : <Br><u>projet ARGOS</u>", "suivez.html");
menu[13] = new Array("Nous contacter", "contacts.html");
menu[14] = new Array("Nos partenaires", "presentation_reseau_partenaires.htm");

var subMenu = new Array();

subMenu[2] = new Array();
subMenu[2][0] = new Array("les clubs de plongée", "presentation_reseau_clubs.htm");

subMenu[3] = new Array();
subMenu[3][0] = new Array("sensibilisation", "sensibilisation.html");
subMenu[3][1] = new Array("suivis de pontes", "suivis.html");
subMenu[3][2] = new Array("les études", "etudes.html");
subMenu[3][3] = new Array("suivis en alimentation", "suivis_alimentation.html");
subMenu[3][4] = new Array("les échouages", "echouages.html");

subMenu[4] = new Array();
subMenu[4][0] = new Array("Sophie Guilloux-Glorieux", "nouvelles.html#Sophie ");
subMenu[4][1] = new Array("Protocole <i><b>(new)</b></i>", "nouvelles.html#Protocole_2010_Nvelleversion ");
subMenu[4][2] = new Array("Nuit des tortues ", "nouvelles.html#NuitTMGaiac2010 ");
subMenu[4][3] = new Array("Imbriquée en difficulté ", "nouvelles.html#EiAnseMaurice");
subMenu[4][4] = new Array(" Formation à Petite-Terre ", "nouvelles.html#formationPT2010");
subMenu[4][5] = new Array(" Formation SP 2010 ", "nouvelles.html#formationSP2010");
subMenu[4][6] = new Array(" Imbriquée en bassin ", "nouvelles.html#EibassinvxBourgnov2009");
subMenu[4][7] = new Array(" Conférence Enseignants ", "nouvelles.html#jdtjdm");

subMenu[4][6] = new Array("Archives", "nouvelles_archives.html");


subMenu[5] = new Array();
subMenu[5][0] = new Array("Comment les reconnaître ?", "tortues_reconnaitre.htm");
subMenu[5][1] = new Array("le cycle de vie", "tortues_cycle.htm");
subMenu[5][2] = new Array("les menaces", "tortues_danger.htm");

subMenu[7] = new Array();
subMenu[7][0] = new Array("diaporamas ", "bibliotheque.html#diaporama");
subMenu[7][1] = new Array("documents disponibles ", "bibliotheque.html#doc_dispo");
subMenu[7][2] = new Array("références bibliographique ", "bibliotheque.html#ref"); 
subMenu[7][3] = new Array("liens", "bibliotheque.html#sites");


subMenu[11] = new Array();
subMenu[11][0] = new Array("sudototi", "sudoku.html");

// Message displayed in the status bar of the browser.
var defaultStatus = "Réseau des tortues marines de Guadeloupe";

// Title for the Web site.
var siteTitle = defaultStatus;

// Images to display at the head of the menu and at the left of the page's title ("relative path", "description", width, height);
var imgMenu = new Array("images/tortues/logo_reseau.gif", "Réseau des tortues marines de Guadeloupe", 120, 120);
//var imgTitle = new Array("img/title.gif", "NOT USED!", 109, 113);

// Widths (in pixels) of the menu and of the margin between the menu and the main page.180/40
var menuWidth = 180;
var marginWidth = 40;

// CSS styles used for the menu.
var styleMenu = "menu";
var styleMenuSelected = "menuSelected";
var styleSubMenu = "subMenu";
var styleSubMenuSelected = "subMenuSelected";

// Colors used for element focused (use "" to keep the default CSS color).
var colorTextMenu = "#FFFFFF";
var colorBackgroundMenu = "#003399";
var colorTextSubMenu = "#FFFFFF";
var colorBackgroundSubMenu = "#009999";

var myName;



/*
 * PLEASE DON'T MODIFY THE FOLLOWING CODE.
 */

function writeTop(title, subtitle) {

	self.status = defaultStatus;

	document.title = siteTitle;


	document.write("<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">");
	document.write("	<tr valign=\"top\">");
	document.write("		<td width=\""+(menuWidth + marginWidth)+"\">");

	writeMenu();

	document.write("		</td>");
	document.write("		<td>");
	document.write("			<table border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">");
	document.write("				<tr>");
	document.write("					<td align=\"left\" valign=\"middle\" width=\"119\" ></td>");
	document.write("					<td align=\"center\" valign=\"middle\">");
	document.write("						<h1>"+title+"</h1>");

	if (subtitle && subtitle != "") {
		document.write("						<h3>"+subtitle+"</h3>");
	}

	document.write("					</td>");
	document.write("				</tr>");
	document.write("			</table>");
}



//document.write("<h1>");
//document.write(title);
//document.write("</h1><h3>");
//document.write(subtitle);
//document.write("</h3><br>");

//document.write("</td></tr></table>");
//}


function writeBottom() {

		document.write("			<p align=\"center\"><a href=\"javascript:history.back();\" onMouseOver=\"self.status='Page précédente';return true;\" onMouseOut=\"self.status='"+defaultStatus+"';return true;\">&lt;&lt;</a> <img src=\"images/bottom.gif\" width=\"75\" height=\"75\" align=\"absmiddle\"> <a href=\"javascript:history.forward();\"  onMouseOver=\"self.status='Page suivante';return true;\" onMouseOut=\"self.status='"+defaultStatus+"';return true;\">&gt;&gt;</a></p>");

	if (getFileName() == menu[0][1]) {
		document.write("			<p style=\"color:#FFFFFF;font-size:9px;text-align:center;\">Site optimis&eacute; pour Internet Explorer et Mozilla Firefox.</p>");
	}

	document.write("		</td>");
	document.write("	</tr>");
	document.write("</table>");
}

function writeMenu() {

	var menuCode = detectMenuCode();

	var fileName = getFileName();

	var space = 8;

var imgSrc = imgMenu[0];
	var imgAlt = imgMenu[1];
	var imgWidth = imgMenu[2];
	var imgHeight = imgMenu[3];	

	document.write("<table border=\"0\" align=\"left\" width=\""+(menuWidth+marginWidth)+"\" height=\"100%\" cellspacing=\"0\" cellpadding=\"0\">");
	
	document.write("  <tr height=\""+space+"\"><td colspan=\"2\"></td></tr>");

	for (i = 0 ; i < menu.length ; i++) {
		if (menu[i]) {
			if (menu[i][2] == null || menu[i][2] == "") {
				menu[i][2] = menu[i][0].replace("<br>", " ").replace("\'", "\\\'").replace(/ +/gi, " ");
			}

			if (fileName == menu[i][1]) {
				document.title = siteTitle + " > " + menu[i][2].replace("\\\'", "'");
				document.write("  <tr>");
				document.write("    <td width=\""+menuWidth+"\">");
				document.write("      <span class=\""+styleMenuSelected+"\" onMouseOver=\"self.status='"+menu[i][2]+"';\" onMouseOut=\"self.status='"+defaultStatus+"';\"><font color=\"#FF0000\">&gt;</font> "+menu[i][0]+"</span>");
			} else {
				document.write("  <tr>");
				document.write("    <td width=\""+menuWidth+"\">");
				document.write("      <span class=\""+styleMenu+"\" onClick=\"document.location='"+menu[i][1]+"';\" onMouseOver=\"self.status='"+menu[i][2]+"';setColor(this, '"+colorTextMenu+"', '"+colorBackgroundMenu+"');\" onMouseOut=\"self.status='"+defaultStatus+"';setColor(this, '', '');\">"+menu[i][0]+"</a></span>");
			}

			if (menuCode == i && subMenu[i]) {
				for (j = 0 ; j < subMenu[i].length ; j++) {
					if (subMenu[i][j]) {
						if (subMenu[i][j][2] == null || subMenu[i][j][2] == "") {
							subMenu[i][j][2] = subMenu[i][j][0].replace("<br>", " ").replace("\'", "\\\'").replace(/ +/gi, " ");
						}

						if (fileName == subMenu[i][j][1]) {
							document.title = siteTitle + " > " + menu[i][2].replace("\\\'", "'") + " > " + subMenu[i][j][2].replace("\\\'", "'");
							document.write("      <br>&nbsp;&nbsp;<span class=\""+styleSubMenuSelected+"\" onMouseOver=\"self.status='"+subMenu[i][j][2]+"';\" onMouseOut=\"self.status='"+defaultStatus+"';\"><font color=\"#FF0000\">&gt;</font> "+subMenu[i][j][0]+"</span>");



						} else {
							document.write("      <br>&nbsp;&nbsp;<span class=\""+styleSubMenu+"\" onClick=\"document.location='"+subMenu[i][j][1]+"';\" onMouseOver=\"self.status='"+subMenu[i][j][2]+"';setColor(this, '"+colorTextSubMenu+"', '"+colorBackgroundSubMenu+"');\" onMouseOut=\"self.status='"+defaultStatus+"';setColor(this, '', '');\">-"+subMenu[i][j][0]+"</a></span>");

						}
					}
				}
			}

			document.write("    </td>");
			document.write("    <td>&nbsp;</td>");
			document.write("  </tr>");
			document.write("  <tr height=\""+space+"\"><td colspan=\"2\"></td></tr>");
		}
	}
document.write("    <td width=\""+menuWidth+"\" valign=\"middle\">");
	document.write("      <img src=\""+imgSrc+"\" alt=\""+imgAlt+"\" width=\""+imgWidth+"\" height=\""+imgHeight+"\" border=\"0\" onClick=\"document.location='"+menu[0][1]+"';\" onMouseOver=\"self.status='"+menu[0][0]+"';this.width='"+(imgWidth-3)+"';this.height='"+(imgHeight-3)+"';\" onMouseOut=\"self.status='"+defaultStatus+"';this.width='"+imgWidth+"';this.height='"+imgHeight+"';\">");
	document.write("    </td>");
	document.write("</table>");


}

function getFileName() {

	var fileName;
	fileName = document.location.toString();
	fileName = fileName.substring(fileName.lastIndexOf("\/")+1, fileName.length);

	return fileName;
}

function detectMenuCode() {

	var fileName = getFileName();

	for (i = 0 ; i < menu.length ; i++) {
		if (menu[i][1] == fileName) {
			return i;
		}
		if (subMenu[i]) {
			for (j = 0 ; j < subMenu[i].length ; j++) {
				if (subMenu[i][j][1] == fileName) {
					return i;
				}
			}
		}
	}
}

function setColor(obj, textColor, backgroundColor) {

	if (obj.style) {
		obj.style.color = textColor;
		obj.style.backgroundColor = backgroundColor;
	}
}

// Return a hidden list of all the links of the menu for the search robot like Google.
function writeLinks() {

	var allLinks = "<span style=\"font-size:0px;text-align:center;\">";

	for (i = 0 ; i < menu.length ; i++) {
		if (menu[i]) {
			allLinks += "<a href=\""+menu[i][1]+"\">x</a>";
		}
	}

	for (i = 0 ; i < subMenu.length ; i++) {
		if (subMenu[i]) {
			for (j = 1 ; j < subMenu[i].length ; j++) {
				if (subMenu[i][j]) {
					allLinks += "<a href=\""+subMenu[i][j][1]+"\">x</a>";
				}
			}
		}
	}

	allLinks += "</span>";
	
	return allLinks;
}

