// JavaScript Document

function SwitchMenu(newSection){
	if ((ie8_block)&&(newSection=="photo")){
		window.alert("Page Photos non-compatible avec Internet Explorer 7.x ou inferieur.\n Veuillez mettre a jour votre navigateur.");
		return;
	}

	// Fade-in main loader anim
	$('#load').show();

	// Manage pages
	if (!isDivSwitch){
		var loc = newSection+'.php';
		if (newSection=="accueil"){
			loc = location.pathname.substring(0,location.pathname.lastIndexOf("/"));
		};
		window.location.replace(loc);
		//window.alert("Relocate: "+newSection);
		return;
	}
	
	// Manage Divs
	$('div[id^="section_"]').hide();
	$('div[id^="section_"]').removeClass("section_selected");
	$('#section_'+newSection).addClass("section_selected");
	$('#section_'+newSection).fadeIn();
	$('#load').fadeOut('normal');
	LoadMenuCfg(newSection);
}


function LoadMenuCfg(newSection){
	// Manage Lasso
	var oldClass = $('#lasso').attr('class');
	//window.alert(newSection);
	if (oldClass != "lasso_"+newSection){
		$('#lasso').removeClass(oldClass);
		$('#lasso').addClass("lasso_"+newSection);
	}

	// Manage Helpers
	if (!agenda_helper && newSection=="agenda"){
		$('#section_'+newSection+'_help').animate({opacity: 0}, 2000).fadeIn(1000).animate({opacity: 0.85}, 3000).fadeOut(1000);
		//window.alert("Agenda Helper");
		agenda_helper = true;
	}
	
	// Manage Specific division to load on the fly
	if (newSection=="photo"){
		if (!photo_helper){
			$('#gallery').mbGallery({maskBgnd:'#f0f0f0', maskOpacity:.6, containment:'gallery_container', galleryTitle:"Jacques Bouniard - Ministere Des Finances - Juin 2006"});
			
			photo_helper = true;
		}
		$('#jcvd_container').fadeOut("fast");
	}
	
	if (newSection=="project"){
		$(".cover").animate({top:'180px'},{queue:false,duration:100});
	}

	if (newSection=="album"){

	}
	
	if (newSection=="cv"){
		var opts ={ align: 'top', labels: 'bc', loader: 'jquery', distance: 60, size: 48};
		$('#mus_menu').jqDock(opts);
	}
}
