var currentPoint = '';
var animEnCours  = 0;
var extPoint = "png";

	function showById (id) {
		var node = document.getElementById(id);
		if (node) {
			node.style.display='block';
			}
		else { return false; }
	}

	function hideById (id) {
		var node = document.getElementById(id);
		if (node) {
			node.style.display='none' ;
		}
		else { return false; }
	}

	/*function showById (id) {
		if ($("#"+id)) {
			$("#"+id).show("slow") ;
		}else { return false; }
	}

	function hideById (id) {
		if ($("#"+id)) {
			$("#"+id).hide("slow") ;
		}else { return false; }
	}*/

	function newWin(elt) {
		window.open(elt.href);
		return false;
	}

	//Operation units
	function fadeInMap(){
		if($("#map")){
      		$("#map").fadeIn({ duration: 1500, easing: 'easeOutQuad', complete: function(){fadeInPoint();}});
      	}
	}

	function fadeInPoint(){
		if($(".point")){
      		$(".point").fadeIn({ duration: 500, easing: 'easeInExpo'});
      	}
	}

	function fadeOutInfo(namePoint){
		var tmpCurrentPoint = "";
		if(currentPoint != '' && $("#info-"+currentPoint)){
			$("#info-"+currentPoint).animate({"width":"100px"}, {duration: 750, easing: 'easeInOutBack', complete: function(){fadeInInfo(namePoint);}});
			tmpCurrentPoint = currentPoint;
		}else{
			fadeInInfo(namePoint);
		}
		currentPoint = namePoint;
		point_over(currentPoint);
		if(tmpCurrentPoint != ""){
			point_out(tmpCurrentPoint);
		}
	}

	function fadeInInfo(namePoint){
		if($("#info-"+namePoint)){
			$("#info-"+namePoint).animate({"width":"734px"}, {duration: 500, easing: 'easeInQuart', complete: function(){animEnCours = 0;}});
		}
	}

	function viewInfo(namePoint){
		if($("#"+namePoint) && animEnCours != 1){
			animEnCours = 1;
			var cpt1 = 0;
			$("#"+namePoint).effect("bounce", { times: 2, distance: 15, direction : 'up'}, 100, function(){
				cpt1++;
				if($("#info-"+namePoint) && cpt1 == 1){
					var positionMap = $("#map").position();
					if(positionMap.left>25){
						var cpt2 =0;
						$("#map").animate({"left": "25px"}, {duration: 500, easing: 'easeInOutBack', complete: function(){cpt2++;if(cpt2 == 1){fadeOutInfo(namePoint);}}});
					}else{
						fadeOutInfo(namePoint);
					}
				}
			});
		}
	}

	function point_over(point){
		$("#"+point+" img").attr('src','/carbone-wordpress/wp-content/themes/new_theme/images/ope_unit/'+point+'-pt-over.'+extPoint);
	}

	function point_out(point){
		if(currentPoint != point){$("#"+point+" img").attr('src','/carbone-wordpress/wp-content/themes/new_theme/images/ope_unit/'+point+'-pt.'+extPoint);}
	}

	//Success Story
	function fadeInStory(){
		if($("#story")){
      		$("#story").fadeIn({ duration: 1500, easing: 'easeOutQuad', complete: function(){fadeInDate();}});
      	}
	}

	function fadeInDate(){
		if($(".date")){
      		$(".date").fadeIn({ duration: 500, easing: 'easeInExpo'});
      	}
	}

	function fadeOutInfoStory(namePoint){
		var tmpCurrentPoint = "";
		if(currentPoint != '' && $("#info-"+currentPoint)){
			if($("#info-"+currentPoint).css('overflow-y') == 'scroll'){
				var cssObj = {
					'visibility' : 'hidden'
				}
				$("#info-"+currentPoint).css(cssObj);
			}
			$("#info-"+currentPoint).animate({"width":"100px"}, {duration: 750, easing: 'easeInOutBack', complete: function(){
				fadeInInfoStory(namePoint);
			}});
			tmpCurrentPoint = currentPoint;
		}else{
			fadeInInfoStory(namePoint);
		}
		currentPoint = namePoint;
	}

	function fadeInInfoStory(namePoint){
		if($("#info-"+namePoint)){
			if($("#info-"+namePoint).css('overflow-y') == 'scroll'){
				var cssObj = {
					'visibility' : 'visible'
				}
				$("#info-"+namePoint).css(cssObj);
			}
			$("#info-"+namePoint).animate({"width":"600px"}, {duration: 500, easing: 'easeInQuart', complete: function(){animEnCours = 0;}});
		}
	}

	function viewInfoStory(namePoint){
		if($("#"+namePoint) && animEnCours != 1){
			animEnCours = 1;
			var cpt1 = 0;
			$("#"+namePoint).effect("bounce", { times: 2, distance: 15, direction : 'up'}, 100, function(){
				cpt1++;
				if($("#info-"+namePoint) && cpt1 == 1){
					var positionStory = $("#story").position();
					if(positionStory.left>25){
						var cpt2 =0;
						$("#story").animate({"left": "419px"}, {duration: 500, easing: 'easeInOutBack', complete: function(){cpt2++;if(cpt2 == 1){fadeOutInfoStory(namePoint);}}});
					}else{
						fadeOutInfoStory(namePoint);
					}
				}
			});
		}
	}

	$(document).ready(function () {
		if($("#animateMap")){
			if($("#map")){
				var cssObj = {
					'background-image' : 'url(/carbone-wordpress/wp-content/themes/new_theme/images/map-operations-units.gif)'
				}
				$("#map").css(cssObj);
      			$("#animateMap").slideDown({ duration: 750, easing: 'easeInExpo', complete: function(){fadeInMap();}});

      			//survol point
      			if($("#ol") && $("#ol img") && currentPoint != 'ol'){
      				$("#ol").hover(function(){point_over('ol')},function(){point_out('ol')});
      			}
      			if($("#al") && $("#al img") && currentPoint != 'al'){
      				$("#al").hover(function(){point_over('al')},function(){point_out('al')});
      			}
      			if($("#su") && $("#su img") && currentPoint != 'su'){
      				$("#su").hover(function(){point_over('su')},function(){point_out('su')});
      			}
			}
      	}
		if($("#animateStory")){
			if($("#story")){
				var cssObj = {
					'background-image' : 'url(/carbone-wordpress/wp-content/themes/new_theme/images/frise-success-story.jpg)'
				}
				$("#story").css(cssObj);
      			$("#animateStory").slideDown({ duration: 750, easing: 'easeInExpo', complete: function(){fadeInStory();}});
			}
      	}
    });

function loadParam(param){

		$('.description').css('display','none');
		if(param== 1)
		{
			$("#description_Charley_Liere").slideDown("slow");
		}
		else if(param== 2)
			{
				$("#description_Benoit_Feve").slideDown("slow");
			}
			else if(param== 3)
				{
					$("#description_Frederic_Hummel").slideDown("slow");
				}
				else if(param== 4)
					{
						$("#description_Lorene_Fort").slideDown("slow");
					}
					else if(param== 5)
					{
						$("#description_Matthieu_Casasole").slideDown("slow");
					}
						else if(param== 6)
						{
							$("#description_Charley_Lorene").slideDown("slow");
						}
							else if(param== 7)
							{
								$("#description_Frederic_Lorene").slideDown("slow");
							}
}
