﻿var tabMenu = new Array();
tabMenu[0] = new Array('Accueil|../accueilNew.aspx',null)
tabMenu[1] = new Array('Formation',new Array('Catalogue|parent.window.document.location=\'../formation/default.aspx?section=0\'','Recherche|parent.window.document.location=\'../formation/default.aspx?section=1\'','Financement|parent.window.document.location=\'../formation/default.aspx?section=2\'','Cursus|parent.window.document.location=\'../formation/default.aspx?section=3\''));
tabMenu[2] = new Array('Société',new Array('L\'équipe|parent.window.document.location=\'../evolution/equipe.aspx\'','Nos locaux|parent.window.document.location=\'../evolution/visite.aspx\'','Plan d\'accès|parent.window.document.location=\'../evolution/acces.aspx\''));
//tabMenu[3] = new Array('Recrutement|../recrutement/recrutement.aspx',null);
tabMenu[3] = new Array('Contacts',new Array('Commercial|mailUS(\'info\');','Webmaster|mailUS(\'webmaster\');'));

var separatorWidth = '1';
var container;
var mainMenuHeight = 20;

function getRadical(OBJECT){
	switch (OBJECT.tagName){
		case "TD":
			return OBJECT.id.substring(4,OBJECT.id.length);
		break;
		case "IFRAME":
			return OBJECT.id.substring(3,OBJECT.id.length);
		break;
	}	
}

function displayMenu(evt){
	var o;
	if (document.all) o = window.event.srcElement;
	else o = evt.target;
	var radical = getRadical(o);
	document.getElementById("menu" + radical).className = 'TopMenuOver';
	if (document.getElementById("ifr" + radical) != null) document.getElementById("ifr" + radical).style.visibility = 'visible';
}

function hideMenu(evt){
	var o;
	if (document.all) o = window.event.srcElement;
	else o = evt.target;
	var radical = getRadical(o);
	document.getElementById("menu" + radical).className = 'TopMenu';
	if (document.getElementById("ifr" + radical) != null) document.getElementById("ifr" + radical).style.visibility = 'hidden';
}

function loadMenu(CONTAINER){
	container = document.getElementById(CONTAINER);
	container.innerHTML = '';
	var spanWidth = ((container.offsetWidth - (tabMenu.length + 1) * separatorWidth )/ tabMenu.length);
	var imgHTML = "<td><IMG width=1 height=" + mainMenuHeight + " src=\"../images/decors/newSeparateur2.gif\" border=0 /></td>";
	var HTML =  "<table cellpading=0 cellspacing=0 border=0><tr>" + imgHTML;
	for (var i=0;i<tabMenu.length;i++){		
		var thisLink, thisLabel, thisTabHref;		
		if (tabMenu[i][1] != null){
			thisTabHref = tabMenu[i][0].toString().split('|');
			thisLink = null;
			thisLabel = tabMenu[i][0];
		}
		else {
			thisTabHref = tabMenu[i][0].toString().split('|');
			thisLink = thisTabHref[1];
			thisLabel = thisTabHref[0];
		}
		var strTD = "<td id=menu" + thisLabel + " width=" + Math.round(spanWidth) + " height=" + mainMenuHeight + " class=TopMenu" +
					" onmouseover='displayMenu(event);' onmouseout='hideMenu(event);' "  +				
					((thisLink!=null)?" onclick=\"document.location='" + thisLink + "';\"":"")  +
					">&#0183 " + thisLabel + " &#0183</td>";
		HTML += strTD + imgHTML;		
	}
	HTML += "</TR></TABLE>";
	container.innerHTML = HTML;
	//Construction du sous menu apres insertion du menu principal
	for (var i=0;i<tabMenu.length;i++){	
		if (tabMenu[i][1] != null){
			var thisTD = document.getElementById('menu' + tabMenu[i][0]);
			var topPosition = 0;
			var leftPosition = 0;
			var myElem = thisTD;
			var coeff = 1.15;
			while (myElem.tagName != 'BODY'){
				topPosition += myElem.offsetTop;
				leftPosition += myElem.offsetLeft;
				myElem = myElem.offsetParent;
			}
			topPosition += thisTD.height*1 + 1;
			
			if (document.getElementById('ifr' + tabMenu[i][0]) == null){
				var myFrame = document.createElement('IFRAME');
				myFrame.id = "ifr" + tabMenu[i][0];			
				myFrame.onmouseover = displayMenu;
				myFrame.onmouseout = hideMenu;				
				myFrame.src = "../include/sousmenu.htm?indice=" + i;
				myFrame.frameBorder = 0;
				myFrame.scrolling = 'no';
				myFrame.marginHeight = 0;
				myFrame.marginWidth = 0;
				myFrame.align = 'left';
				myFrame.style.visibility = 'hidden';
				myFrame.style.position = 'absolute';
				myFrame.style.top = topPosition + "px";
				myFrame.style.left = leftPosition+ "px";
				myFrame.style.width = thisTD.offsetWidth * coeff + "px";
				document.body.appendChild(myFrame);
			}
			else{
				var myFrame = document.getElementById('ifr' + tabMenu[i][0]);
				myFrame.style.top = topPosition + 'px';
				myFrame.style.left = leftPosition + 'px';
				myFrame.style.width = (thisTD.offsetWidth * coeff) + 'px';
			}
		}
	}
	
	//Page  l'EQUIPE
	if (document.getElementById('teamIMG') != null){
		calcDynamicXY();
	}
}



function checkSearch(){
	if (document.getElementById('txtSearchHead').value.length > 0){
		var myDocument;
		if (document.all) myDocument = document.frames['frSearch'].document;
		else myDocument = document.getElementById('frSearch').contentDocument;
		myDocument.getElementById('txtSearch').value = document.getElementById('txtSearchHead').value;
		myDocument.forms[0].submit();
	}
	else{
		alert('Vous devez remplir le champ correspondant afin d\'effectuer une recherche dans nos plans de cours.')
		document.getElementById('txtSearchHead').focus();
	}
}

function submitSearchHeader(e){
	var key = e.keyCode * 1;
	if (key == 13) {
		if (e.preventDefault) e.preventDefault();
		e.returnValue = false;
		e.cancelBubble = true;		
		checkSearch();
	}
}

//variable pour l'@ mail
var domaine = 'evolutionmm.com';
