/* --------------------------------------------------------
	Author:		Guilhem Soulas
	Website:	gs-consultant-internet.com
/* -------------------------------------------------------- */
// Check if browser is IE
function vIE(){
	return (navigator.appName=='Microsoft Internet Explorer')?parseFloat((new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})")).exec(navigator.userAgent)[1]):-1;	
};

// JQuery fade in
function fadeInDiv(show) {
	$(document.getElementById(show)).fadeIn(300);
};

// JQuery fade out
function fadeOutDiv(hide) {
	$(document.getElementById(hide)).fadeOut(300);
};

// Determines the state (fadeIn or fadeOut) of the 3-cols graph depending on the mouse position
function FadeInOut(choice) {
	switch (choice){
	case 1: // Mouse over 1
		fadeInDiv('graph1over');
		fadeOutDiv('graph2over');
		break;
	case 2: // Mouse over 2
		fadeInDiv('graph2over');
		fadeOutDiv('graph1over');
		fadeOutDiv('graph3over');
		break;
	case 3: // Mouse over 3
		fadeInDiv('graph3over');
		fadeOutDiv('graph2over');
		break;
	case 99: // Mouse out
	default:
		fadeOutDiv('graph1over');
		fadeOutDiv('graph2over');
		fadeOutDiv('graph3over');
	}
};
/* --------------------------------------------------------
/* Operations on the separators (background image) of the main menu
/* Menu IDs as below
Accueil		: mMenu12
Prestations	: mMenu16
Réalisations: mMenu17
Blog		: mMenu18
Profil		: mMenu15
Contact		: mMenu14
/* -------------------------------------------------------- */
// main_menu separator disappears on mouse over
function changeMenuBackgroundOver(menuId1, menuId2) {
	var urlSeparator="assets/templates/gs1/images/menu_separator_alt.png";
	if (menuId1!='xxx'){
		document.getElementById(menuId1).style.backgroundImage="url("+urlSeparator+")";
		document.getElementById(menuId1).style.backgroundRepeat="repeat-y";
	}
	if (menuId2!='xxx'){
		document.getElementById(menuId2).style.backgroundImage="url("+urlSeparator+")";
		document.getElementById(menuId2).style.backgroundRepeat="repeat-y";
	}
};

// main_menu separator reappears on mouse out
function changeMenuBackgroundOut(menuId1, menuId2) {
	var urlSeparator="assets/templates/gs1/images/menu_separator.png";
	if (menuId1!='xxx'){
		document.getElementById(menuId1).style.backgroundImage="url("+urlSeparator+")";
		document.getElementById(menuId1).style.backgroundRepeat="no-repeat";
	}
	if (menuId2!='xxx'){
		document.getElementById(menuId2).style.backgroundImage="url("+urlSeparator+")";
		document.getElementById(menuId2).style.backgroundRepeat="no-repeat";
	}
};

// true if the element determined by his id is of classe "active"
function isClassActive(id){
	if(document.getElementById(id).className.match("active")){return true;}
	else return false;
}

// on load, in the main menu
// removes the separator of the item just before the active item
function init(){
	if(isClassActive("mMenu16")){document.getElementById("mMenu12").style.backgroundImage="none";}
	if(isClassActive("mMenu17")){document.getElementById("mMenu16").style.backgroundImage="none";}
	if(isClassActive("mMenu18")){document.getElementById("mMenu17").style.backgroundImage="none";}
	if(isClassActive("mMenu15")){document.getElementById("mMenu18").style.backgroundImage="none";}
	if(isClassActive("mMenu14")){document.getElementById("mMenu15").style.backgroundImage="none";}
	if(document.getElementById("menu2")) document.getElementById("main_column_content").style.borderTop = "none";
}

// functions called on event on the main menu
// they change the separator of the previous item
// if the item or the previous one is active, nothing happens
function prestationsOver(){ if (!isClassActive("mMenu16") && !isClassActive("mMenu12")) changeMenuBackgroundOver("mMenu12", "xxx"); }
function prestationsOut(){ if (!isClassActive("mMenu16") && !isClassActive("mMenu12")) changeMenuBackgroundOut("mMenu12", "xxx"); }

function realisationsOver(){ if (!isClassActive("mMenu17") && !isClassActive("mMenu16")) changeMenuBackgroundOver("mMenu16", "xxx"); }
function realisationsOut(){ if (!isClassActive("mMenu17") && !isClassActive("mMenu16")) changeMenuBackgroundOut("mMenu16", "xxx"); }

function blogOver(){ if (!isClassActive("mMenu18") && !isClassActive("mMenu17")) changeMenuBackgroundOver("mMenu17", "xxx"); }
function blogOut(){ if (!isClassActive("mMenu18") && !isClassActive("mMenu17")) changeMenuBackgroundOut("mMenu17", "xxx"); }

function profilOver(){ if (!isClassActive("mMenu15") && !isClassActive("mMenu18")) changeMenuBackgroundOver("mMenu18", "xxx"); }
function profilOut(){ if (!isClassActive("mMenu15") && !isClassActive("mMenu18")) changeMenuBackgroundOut("mMenu18", "xxx"); }

function contactOver(){ if (!isClassActive("mMenu14") && !isClassActive("mMenu15")) changeMenuBackgroundOver("mMenu15", "xxx"); }
function contactOut(){ if (!isClassActive("mMenu14") && !isClassActive("mMenu15")) changeMenuBackgroundOut("mMenu15", "xxx"); }

function eventFadeOutDiv(){ FadeInOut(99); }

/*
<script type="text/javascript">
	init();

	var menuPrestations = document.getElementById("mMenu16");
	menuPrestations.onmouseover = prestationsOver;
	menuPrestations.onmouseout = prestationsOut;

	var menuRealisations = document.getElementById("mMenu17");
	menuRealisations.onmouseover = realisationsOver;
	menuRealisations.onmouseout = realisationsOut;

	var menuBlog = document.getElementById("mMenu18");
	menuBlog.onmouseover = blogOver;
	menuBlog.onmouseout = blogOut;

	var menuProfil = document.getElementById("mMenu15");
	menuProfil.onmouseover = profilOver;
	menuProfil.onmouseout = profilOut;

	var menuContact = document.getElementById("mMenu14");
	menuContact.onmouseover = contactOver;
	menuContact.onmouseout = contactOut;
	
	around_graph1.onmouseover = fadeOutDiv;
	around_graph2.onmouseover = fadeOutDiv;
	around_graph3.onmouseover = fadeOutDiv;
</script>
*/
