// PARTIE LOGO

if (window.addEventListener){
  window.addEventListener('load', signLogo, false);
} else if (window.attachEvent) { // IE
  window.attachEvent('onload', signLogo);
}

var url = '';

/**
* Fonction permettant d'ajouter la signature au logo
**/
function signLogo() {
	var logo = document.getElementById('logo');
	logo.style.cursor = 'pointer';
	url = 'http://www.antoinefriteau.fr';
	if (logo.addEventListener){
	  logo.addEventListener('click', assignURL, false);
	} else if (logo.attachEvent) { // IE
	  logo.attachEvent('onclick', assignURL);
	}
}


/**
* Fonction permettant d'effectuer une redirection en fonction de l'URL précédemment sélectionnée
**/
function assignURL() {
	window.location = url;
}






// PARTIE MENU

if (window.addEventListener){
  window.addEventListener('load', activateNavigation, false);
} else if (window.attachEvent) { // IE
  window.attachEvent('onload', activateNavigation);
}


/**
* Fonction gerant l'action de rollover sur les menus
**/
function activateNavigation() {
	var menu = document.getElementById('lesmenus');
	var lesmenus = menu.getElementsByTagName("li");
	
	for(var i=0; i<lesmenus.length; i++) {
		if (window.addEventListener){
		  lesmenus[i].addEventListener('mouseover', rolloverMenu, false);
		  lesmenus[i].addEventListener('mouseout', rolloverOutMenu, false);
		} else if (window.attachEvent) { // IE
		  lesmenus[i].attachEvent('mouseover', rolloverMenu);
		  lesmenus[i].attachEvent('mouseout', rolloverOutMenu);
		}
	}
}


/**
* Fonction affectant l'action sur les rollover des ,menus
**/
function rolloverMenu() {
	if(this.className.indexOf("selected") == -1) {
		var img = this.firstChild.firstChild; // on selectionne la balise img
		var oldSRC = img.src;
		oldSRC = oldSRC.split("_normal");
		var newSRC = oldSRC[0]+"_hover"+oldSRC[1];
		img.src = newSRC;
	}
}


/**
* Fonction affectant l'action sur les rollover des ,menus
**/
function rolloverOutMenu() {
	if(this.className.indexOf("selected") == -1) {
		var img = this.firstChild.firstChild; // on selectionne la balise img
		var oldSRC = img.src;
		oldSRC = oldSRC.split("_hover");
		var newSRC = oldSRC[0]+"_normal"+oldSRC[1];
		img.src = newSRC;
	}
}
