/* MENU EXEMPLE

var menus = [
 ['name1','url1',
	[
		['child1.1','childUrl1.1'], 
		['child1.2','childUrl1.2']
	]
 ],
 ['name2','url2',
 	[
 		['child2.1','childUrl2.2']
 	]
 ]
];

*/

var menus = [
 ['À propos du Centre','a_propos.html','puce_section_a_propos_du_centre.gif',
	[
		['Mission','mission.html','puce_choix_menu.gif'], 
		['Historique','historique.html','puce_choix_menu.gif'],
		['Fonctionnement démocratique','fonctionnement.html','puce_choix_menu.gif'],
		['Dons','dons.html','puce_choix_menu.gif'],
		['Financement','financement.html','puce_choix_menu.gif']
	]
 ],
['Évènements à surveiller','evenements.html','puce_section_evenements_a_surveiller.gif',
 	[
		['Inscriptions','inscription.html','puce_choix_menu.gif'],
		['Fêtes et évènements','evenements.html','puce_choix_menu.gif'],
		['Lundis québecois','lundis.html', 'puce_choix_menu.gif'],
		['Salon-discussion informatique','salon-discussion_CACI.html','puce_choix_menu.gif'],
		['Info-alertes','alertes.html','puce_choix_menu.gif']
 	]
 ],
 ['Activités Familles','familles.html','puce_section_familles.gif',
 	[
 		['Jardin  pour enfants 2-5 ans','croquignoles.html','puce_choix_menu.gif'],
		['Sorties familiales','sorties.html','puce_choix_menu.gif'],
 		['Ça me dit en famille','ca_me_dit.html','puce_choix_menu.gif'],
 		['Ateliers parents-enfants','parents_enfants.html','puce_choix_menu.gif'],
 		['Parents en activité','parents.html','puce_choix_menu.gif'],
		['Projet Répit','repit.html','puce_choix_menu.gif']
 	]
 ],
 ['Activités Enfants','enfants.html','puce_section_enfants.gif',
 	[
 		['Activités pour 4-11 ans','enfants_4_11.html','puce_choix_menu.gif'],
		['Club 10-13 ans','club_10_13.html','puce_choix_menu.gif'],
		['Après école 9-11 ans','apres_ecole_9_11.html','puce_choix_menu.gif'],
		['Camp de la relâche 4-11 ans','cdj_relache.html','puce_choix_menu.gif'],
 		['Camp de jour estival 4-11 ans','camp4_11.html','puce_choix_menu.gif']
 	]
 ],
 ['Loisir Jeunesse','loisir_jeunesse.html','puce_section_loisir_jeunesse.gif',
 	[
		['Club 10-13 ans','club_10_13.html','puce_choix_menu.gif'],
		['12-18 ans','jeunesse_12_18.html','puce_choix_menu.gif'],
		['19-25 ans','jeunesse_19_25.html','puce_choix_menu.gif'],
		['Sorties et activités des 19-25 ans','sorties_jeunes.html','puce_choix_menu.gif'],
 		['Stage pour 16-25 ans','stage_jeunes.html','puce_choix_menu.gif'],
		['Camp de jour estival 12-15 ans','camp12_18.html','puce_choix_menu.gif']
 	]
 ],
 ['Activités Adultes','adultes.html','puce_section_adultes.gif',
 	[
 		['Arts et culture','art.html','puce_choix_menu.gif'],
 		['Sports et activités physiques','sports.html','puce_choix_menu.gif'],
 		['Cours de français','francais.html','puce_choix_menu.gif'],
		['Ateliers de conversation française','conversation.html','puce_choix_menu.gif'],
		['Jumelage: parlons français','parlonsfrancais.html','puce_choix_menu.gif'],
 		['Club informatique CACI','informatique.html','puce_choix_menu.gif'],
		['Salon-discussion informatique','salon-discussion_CACI.html','puce_choix_menu.gif'],
		['Club de marche de la Côte','clubmarche.html','puce_choix_menu.gif']
 	]
 ],
 ['Bénévolat','benevolat.html','puce_section_benevoles.gif',
 	[
		['Opportunité de bénévolat','opportunites.html', 'puce_choix_menu.gif'],
		['Formations pour bénévoles','formations_benevoles.html', 'puce_choix_menu.gif']	
 	]
 ],
 ['Rapprochement interculturel','rapprochement.html','puce_section_rapprochement_interculturel.gif',
 	[
 		['Lundis québecois','lundis.html', 'puce_choix_menu.gif'],
		['Formations interculturelles','construction.html', 'puce_choix_menu.gif'],
		['Ateliers de conversation française','conversation.html','puce_choix_menu.gif'],
		['Jumelage: parlons français','parlonsfrancais.html','puce_choix_menu.gif'],
		['Cours de français','francais.html','puce_choix_menu.gif']
	]
 ],
 ['Vie du Centre','vie_centre.html','puce_section_vie_au_centre.gif',
 	[
 		['Le journal du Centre','le_journal.html','puce_choix_menu.gif'],
		['Postes à combler','emplois.html','puce_choix_menu.gif'],
 		['Expositions','construction.html','puce_choix_menu.gif']
 	]
 ],
 ['Location de salles','locations.html','puce_section_a_propos_du_centre.gif',
 	[
 	]
 ]
];

var lastpos = window.location.href.lastIndexOf('/');
var currentPage = window.location.href.substring(lastpos+1);

function generateMenu(){
	
	var htmlmenu = '<table width="200" cellspacing="0" cellpadding="0" border="0" bgcolor="#ffffff">';
	
	var aClass;
	var isThisMenu;
	var i;
	var j;
	for(i=0;i<menus.length;i++){
		
		isThisMenu = false;
		for(j=0;j<menus[i][3].length;j++){
			if(currentPage == menus[i][3][j][1]){
				isThisMenu = true;
			}
		}
		
		htmlmenu += '<tr>';
		htmlmenu += '<td width="23" height="23">';
		
		if(currentPage == menus[i][1] || isThisMenu){
      htmlmenu += '<img " src="images/spacer.gif" width="5" height="10" alt="" border="0">';
			htmlmenu += '<img  id="imgHouse' + i + '" src="images/' + menus[i][2] + '" width="10" height="10" alt="" border="0">';
		} else {
      htmlmenu += '<img " src="images/spacer.gif" width="5" height="10" alt="" border="0">';
			htmlmenu += '<img id="imgHouse' + i + '" src="images/spacer.gif" width="10" height="10" alt="" border="0">';
		}
		
    htmlmenu += '</td>';
		htmlmenu += '<td valign="middle" width="210" height="23" align="left">';
		
		if(currentPage == menus[i][1] || isThisMenu){
			htmlmenu += '<a href="' + menus[i][1] + '" class="leftMenuBig">';
		} else {
			htmlmenu += '<a href="' + menus[i][1] + '" class="leftMenuBig" onmouseover="showHideHouse(imgHouse' + i + ',true,\'' + menus[i][2] + '\');" onmouseout="showHideHouse(imgHouse' + i + ',false, false);">';
		}

		htmlmenu += menus[i][0];
		htmlmenu += '</a></td>';
		htmlmenu += '<td valign="top" width="6" height="23">';
		htmlmenu += '<img src="images/spacer.gif" width="6" height="23" alt="" border="0"></td>';
		htmlmenu += '</tr>';
		
		if(currentPage != menus[i][1] && !isThisMenu){
			htmlmenu += '<tr>';
			htmlmenu += '<td></td>';
			htmlmenu += '<td bgcolor="#FF6600"><img src="images/spacer.gif" width="1" height="1" /></td>';
			htmlmenu += '<td></td>';
			htmlmenu += '</tr>';
		}
		
		

		
		if(currentPage == menus[i][1] || isThisMenu){
			for(j=0;j<menus[i][3].length;j++){
				
				if(menus[i][3][j][1] == currentPage){
					aClass = "leftMenuSmallPressed";
				} else {
					aClass = "leftMenuSmall";
				}
				
				htmlmenu += '<tr>';
				htmlmenu += '<td></td>';
				
				if(menus[i][3][j][1] == currentPage){
					htmlmenu += '<td align="left" height="10"><img src="images/' + menus[i][3][j][2] + '" width="10" height="10" alt="" border="0"><span class="blankSpace">&nbsp;</span><a href="' + menus[i][3][j][1] + '" class="' + aClass + '">' + menus[i][3][j][0] + '</a></td>';
				} else {
					htmlmenu += '<td align="left" height="10"><img id="imgHouseSmall' + i + '_' + j + '" src="images/spacer.gif" width="10" height="10" alt="" border="0"><span class="blankSpace">&nbsp;</span><a href="' + menus[i][3][j][1] + '" class="' + aClass + '" onmouseover="showHideHouse(imgHouseSmall' + i + '_' + j + ',true,\'' + menus[i][3][j][2] + '\');" onmouseout="showHideHouse(imgHouseSmall' + i + '_' + j + ',false, false);">' + menus[i][3][j][0] + '</a></td>';
				}
				
				htmlmenu += '<td></td>';
				htmlmenu += '</tr>';
			}
			
			if(j > 0){
				htmlmenu += '<tr>';
				htmlmenu += '<td height="5"></td>';
				htmlmenu += '</tr>';
				
				htmlmenu += '<tr>';
				htmlmenu += '<td></td>';
				htmlmenu += '<td bgcolor="#FF6600"><img src="images/spacer.gif" width="1" height="1" /></td>';
				htmlmenu += '<td></td>';
				htmlmenu += '</tr>';
			}
		}
	}
	
	htmlmenu += '</table>';
	
	document.write(htmlmenu);
}

// xGetElementById
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL
function xGetElementById(e)
{
  if(typeof(e)!='string') return e;
  if(document.getElementById) e=document.getElementById(e);
  else if(document.all) e=document.all[e];
  else e=null;
  return e;
}

function showHideHouse(imgId, show, imageFileName){
	if(show){
		xGetElementById(imgId).src = "images/" + imageFileName;
	} else {
		xGetElementById(imgId).src = "images/spacer.gif";
	}
}

// preloadImages for slow browser
if (document.images) {
	fleche = new Image();
	fleche.src = "images/fleche.gif";
}

generateMenu();