
		function fSlideToggle(inID, inSpeed){
			$('#' + inID).slideToggle(inSpeed);
		}

	function fCheckToggle(toBeOpened, toBeClosed){
		if($('#' + toBeClosed).is(':visible')){
			$("#" + toBeClosed).slideToggle('slow', function(){
				$("#" + toBeOpened).slideToggle('slow');								 
			});
			
		}else{
			fSlideToggle(toBeOpened, 'slow');
		}
	}
	function fOpenSection(inSection){
		if( $("#portfolio").is(":visible")) {
			document.getElementById("h1_portfolio").style.display="none";
	    	$("#portfolio").fadeOut("slow", function(){
				$("#" + inSection).fadeIn('slow', function(){
					$("#li_portfolio").removeClass("current_page_item");
					$("#li_" + inSection).addClass("current_page_item");
					document.getElementById("h1_" + inSection).style.display="block";
				});
			});
		}
		if( $("#nouvelles").is(":visible") ) {
	    	document.getElementById("h1_nouvelles").style.display="none";
			$("#nouvelles").fadeOut("slow", function(){
				$("#" + inSection).fadeIn('slow', function(){
					$("#li_nouvelles").removeClass("current_page_item");
					$("#li_" + inSection).addClass("current_page_item");
					document.getElementById("h1_" + inSection).style.display="block";
				});
			});
		}
		if( $("#entreprise").is(":visible") ) {
	    	document.getElementById("h1_entreprise").style.display="none";			
			$("#entreprise").fadeOut("slow", function(){
				$("#" + inSection).fadeIn('slow', function(){
					$("#li_entreprise").removeClass("current_page_item");
					$("#li_" + inSection).addClass("current_page_item");
					document.getElementById("h1_" + inSection).style.display="block";
				});
			});
		}
		if( $("#services").is(":visible") ) {
	    	document.getElementById("h1_services").style.display="none";
			$("#services").fadeOut("slow", function(){
				$("#" + inSection).fadeIn('slow', function(){
					$("#li_services").removeClass("current_page_item");
					$("#li_" + inSection).addClass("current_page_item");
					document.getElementById("h1_" + inSection).style.display="block";
				});
			});
		}
		if( $("#realisations").is(":visible")) {
			document.getElementById("h1_realisations").style.display="none";
	    	$("#realisations").fadeOut("slow", function(){
				$("#" + inSection).fadeIn('slow', function(){
					$("#li_realisations").removeClass("current_page_item");
					$("#li_" + inSection).addClass("current_page_item");
					document.getElementById("h1_" + inSection).style.display="block";
				});
			});
		}
		if( $("#contact").is(":visible") ) {
	    	document.getElementById("h1_contact").style.display="none";
			$("#contact").fadeOut("slow", function(){
				$("#" + inSection).fadeIn('slow', function(){
					$("#li_contact").removeClass("current_page_item");
					$("#li_" + inSection).addClass("current_page_item");
					document.getElementById("h1_" + inSection).style.display="block";
				});
			});
		}
	
	}
	$(document).ready(function(){
		var $el, leftPos, newWidth,
        $mainNav = $("#example-one"),
        $mainNav2 = $("#example-two");
    
    /*
        EXAMPLE ONE
    */
    $mainNav.append("<li id='magic-line'></li>");
    
    var $magicLine = $("#magic-line");
    
    $magicLine
        .width($(".current_page_item a").width())
        .css("left", $(".current_page_item a").position().left)
        .data("origLeft", $magicLine.position().left)
        .data("origWidth", $magicLine.width());
        
    $("#example-one li").find("a").hover(function() {
        $el = $(this);
        leftPos = $el.position().left;
        newWidth = $el.width();
        
        $magicLine.stop().animate({
            left: leftPos,
            width: newWidth
        });
    }, function() {
        $magicLine.stop().animate({
            left: $magicLine.data("origLeft"),
            width: $magicLine.data("origWidth")
        });    
    });
		
		$(".main_image .desc").show(); //Show Banner
		$(".main_image .block").animate({ opacity: 0.85 }, 1 ); //Set Opacity
		$(".image_thumb ul li:first").addClass('active'); //Add the active class (highlights the very first list item by default)
		$(".image_thumb ul li").click(function(){
			//Set Variables
			var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
			var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL
			var imgDesc = $(this).find('.block').html();  //Get HTML of the "block" container
			var imgDescHeight = $(".main_image").find('.block').height(); //Find the height of the "block"
		
			if ($(this).is(".active")) {  //If the list item is active/selected, then...
				return false; // Don't click through - Prevents repetitive animations on active/selected list-item
			} else { //If not active then...
				//Animate the Description
				$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() { //Pull the block down (negative bottom margin of its own height)
					$(".main_image .block").html(imgDesc).animate({ opacity: 0.85,  marginBottom: "0" }, 250 ); //swap the html of the block, then pull the block container back up and set opacity
					$(".main_image img").attr({ src: imgTitle , alt: imgAlt}); //Switch the main image (URL + alt tag)
				});
			}
		//Show active list-item
			$(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all list-items
			$(this).addClass('active');  //Add class of 'active' on the selected list
			return false;

			}) .hover(function(){ //Hover effects on list-item
				$(this).addClass('hover'); //Add class "hover" on hover
				}, function() {
				$(this).removeClass('hover'); //Remove class "hover" on hover out
		});
		$("a.collapse").click(function(){
			$(".main_image .block").slideToggle(); //Toggle the description (slide up and down)
			$("a.collapse").toggleClass("show"); //Toggle the class name of "show" (the hide/show tab)
		});
			
	});

function fOpenLightbox(inID) {
		// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
		$( "#" + inID + ":ui-dialog" ).dialog( "destroy" );
	
		$( "#" + inID ).dialog({
			modal: true,
			resizable: false,
			minWidth : 760,
			minHeight : 400
		});
		$( ".close", "#" + inID ).button();
		$( ".close" ).click(function() { $( "#" + inID + ":ui-dialog" ).dialog( "destroy" ); });
	
	}
function fOpenLightbox2(inID) {
		// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
		$( "#" + inID ).dialog({
			modal: true,
			resizable: false,
			width : 'auto',
			minHeight : 400
		});
		$( ".close", "#" + inID ).button();
		$( ".close" ).click(function() { $( "#" + inID + ":ui-dialog" ).dialog( "destroy" ); });
	
	}


