// JavaScript Document

var PAGE_HASH = location.hash.substr(1);
var PAGE_LEFT;
var PAGINATION_LEFT;
var PAGE_BOTTOM;
var _shadowWi = 30;
var _allowRESIZE = true;
var _allowSLIDE = true;
var _allowCREATEBTN = true;
var _curGalerie = 0;
var _curIMG = 0;
var _lastIMG = 0;
var _nextIMG_CACHE = 1;
var _timerBIND = null;
var _timerMAP = null;
var old_id_bottom = 'none';
var _bufferSLIDE = null;

var _curVID = 0;
var _maxVID = 0;

var currentDetail = 0;

function IsNumeric(input)
{
   return (input - 0) == input && input.length > 0;
}

function parseHash() {
	var params = PAGE_HASH.split('!');
	PAGE_BOTTOM = params[1];
	var left_params = params[0].split('/');
	PAGE_LEFT = left_params[0];
	PAGINATION_LEFT = left_params[1];
}
function setHash() {
	if (PAGINATION_LEFT != undefined && PAGINATION_LEFT != '') {
		if (PAGE_BOTTOM != undefined && PAGE_BOTTOM != '') {
			PAGE_HASH = PAGE_LEFT+'/'+PAGINATION_LEFT+'!'+PAGE_BOTTOM;
		} else {
			PAGE_HASH = PAGE_LEFT+'/'+PAGINATION_LEFT;
		}
	} else {
		if (PAGE_BOTTOM != undefined && PAGE_BOTTOM != '') {
			PAGE_HASH = PAGE_LEFT+'!'+PAGE_BOTTOM;
		} else {
			PAGE_HASH = PAGE_LEFT;
		}
	}
	location.hash = PAGE_HASH;
}

function initSYS(){
	parseHash();
	if (PAGE_LEFT.length > 0) {
		openPAGE(PAGE_LEFT+'.php');
	}
	old_id_bottom = 'none';
	switch (PAGE_BOTTOM) {
		case 'contact':
			openPageBOTTOM('btn_contact');
		break;
		case 'nos-sites':
			openPageBOTTOM('btn_sites-web');
		break;
		case 'our-websites':
			openPageBOTTOM('btn_sites-web');
		break;
	}

	var _refBTN = $('#btn_contact');
	var _totalWI = $(window).width();
	var _totalHEI = $(window).height();
	var _centerX = Math.floor(_totalWI/2);




	var _CLEFT = $('#cLEFT');
	var _CRIGHT = $('#cRIGHT');
	var _CONTENT_LEFT = $('#contentLEFT');

	$('#bottomMENU').find('a').bind('click',function(){
		var _IDBOTTOMCONTENT = $(this).attr('id');
		if(_IDBOTTOMCONTENT!='lang' && _IDBOTTOMCONTENT!='btn_close'){
			openPageBOTTOM(_IDBOTTOMCONTENT);
			return false;
		}
	});



	//$('#BGIMG').css({height:_totalHEI+'px'});

	_CLEFT.css({width:_totalWI+_shadowWi+5+'px', height:_totalHEI+'px',right:_centerX-_shadowWi+'px'});
	_CONTENT_LEFT.css({width:_totalWI+5+'px', height:_totalHEI*2+'px'});

	_CRIGHT.css({width:Math.floor(_totalWI/2)+'px', height:_totalHEI+'px'});

	_CLEFT.prepend('<div id="mainLOAD" style="display:none"></div>');
	$('body').prepend('<div id="navGALERIE" style="display:none"><a href="javascript:void(0);" id="galeriePREV">Précédent</a><a href="javascript:void(0);" id="galerieNEXT">Suivant</a></div>');


	var _NAVGALERIE = $('#navGALERIE');
	_NAVGALERIE.css({width:Math.floor(_totalWI/2)-5+'px'});

	var _BOTTOM_MENU = $('#bottomMENU');
	_BOTTOM_MENU.css({right:(_totalWI/2)+45+'px'});

	var _refLEFT = _refBTN.offset();
	var _decalBOTTOM = _refLEFT.left;
	$('#bottomCONTENT').find('.content').css({marginLeft:_decalBOTTOM+'px'});
	adjustIMG();
	checkScroll();
	//initBACKBTN();
	//deleteBACKBTN();
	initLINK();
	initFORM();
	initMAINMENU();
	$(window).resize(function(){
	adjustSITE();
	adjustIMG();
	checkScroll();
	});

}

function initFORM() {
	$('#formulaire form').submit(function() {
		var contact_url = 'contact-form.php';
		if (LANG_CODE == 'en') {
			contact_url = "contact-form-en.php";
		}
		var societe = $('#formulaire form input[name=societe]').val();
		var mail = $('#formulaire form input[name=mail]').val();
		var tel = $('#formulaire form input[name=tel]').val();
		var message = $('#formulaire form textarea[name=message]').val();
		var form_data = {
				'societe': societe,
				'mail': mail,
				'tel': tel,
				'message': message,
				'submitFormContact': $(this).children('input[name=submitFormContact]').first().val()
			};
		$('#btn_contact_content').load(contact_url,form_data,formLoaded);
		PAGE_HASH = 'contact';
		location.hash = 'contact'; 
		return false;
	});
}

function formLoaded() {
	var _newHEI = $('#btn_contact_content').height()+30;
	var _speed = 600;
	$('#bottomCONTENT').stop();
	$('#bottomMENU').stop();
	$('#bottomCONTENT').animate({height:_newHEI+'px'},_speed,'easeOutCirc');
	$('#bottomMENU').animate({bottom:_newHEI-6+'px'},_speed,'easeOutCirc');
	initFORM();
}

function adjustSITE(){
	var _refBTN = $('#btn_contact');
	var _totalWI = $(window).width();
	var _totalHEI = $(window).height();
	var _centerX = Math.floor(_totalWI/2);

	centerCONTENT2();
	resizePlan();

	var _CLEFT = $('#cLEFT');
	var _CRIGHT = $('#cRIGHT');
	var _CONTENT_LEFT = $('#contentLEFT');
	var _NAVGALERIE = $('#navGALERIE');
	var _NAVGALERIEBTN = _NAVGALERIE.find('a');
	_NAVGALERIEBTN.stop();

	_CRIGHT.stop();	

	_totalHEI = $(window).height();
	_totalWI = $(window).width();
	_centerX = Math.floor(_totalWI/2);

	var _BOTTOM_MENU = $('#bottomMENU');
	_BOTTOM_MENU.stop();
	_BOTTOM_MENU.animate({right:(_totalWI/2)+45+'px'},600,'easeOutCirc',function(){

	//$('#BGIMG').css({height:_totalHEI+'px'});



	var _refLEFT = _refBTN.offset();
	var _decalBOTTOM = _refLEFT.left;
	$('#bottomCONTENT').find('.content').stop();
	$('#bottomCONTENT').find('.content').animate({marginLeft:_decalBOTTOM+'px'},600,'easeOutCirc');

	});




	_CLEFT.css({width:_totalWI+_shadowWi+5+'px', height:_totalHEI+'px'});
	_CRIGHT.css({height:_totalHEI+'px'});


	_CRIGHT.animate({width:Math.floor(_totalWI/2)+'px'},600,'easeOutCirc');

	_NAVGALERIE.css({width:Math.floor(_totalWI/2)-5+'px'});




	_CONTENT_LEFT.css({width:_totalWI+5+'px', height:_totalHEI*2+'px'});

	if(_allowRESIZE==true){
	_CLEFT.stop();		
	_CLEFT.animate({right:_centerX-_shadowWi+'px'},600,'easeOutCirc');
	}

}



function initBACKBTN(){
	var home_file = 'home.php';
	if (LANG_CODE == 'en') {
		home_file = 'home-en.php';
	}
	if(_allowCREATEBTN==true){
	_allowCREATEBTN = false;
	$('body').prepend('<a id="backMENU" href="'+home_file+'" onclick="return false;" style="display:none;">Retour au menu</a>');
	var _BACK_BTN = $('#backMENU');
	var _fixY = Math.floor($(window).height()*0.5)-Math.floor(_BACK_BTN.height()*0.5);
	_BACK_BTN.css({top:_fixY+'px'});
	_BACK_BTN.fadeIn(200);
	_BACK_BTN.bind('mouseenter',function(){
		_BACK_BTN.stop();								 
		_BACK_BTN.animate({left:0},250,'easeOutCirc');
	});
	
	_BACK_BTN.bind('mouseleave',function(){
		_fixY = Math.floor($(window).height()*0.5)-Math.floor(_BACK_BTN.height()*0.5);									 
		_BACK_BTN.stop();											 
		_BACK_BTN.animate({left:'-25px',top:_fixY+'px'},250,'easeOutCirc');
	});
	
	$(window).resize(function(){
		_fixY = Math.floor($(window).height()*0.5)-Math.floor(_BACK_BTN.height()*0.5);									 
		_BACK_BTN.stop();											 
		_BACK_BTN.animate({left:'-25px',top:_fixY+'px'},300);
	})
	
	
	
	
	_BACK_BTN.bind('click',function(){
			_BACK_BTN.fadeOut(100);
			_BACK_BTN.unbind();
			var _HREF = _BACK_BTN.attr('href');
			PAGE_LEFT = '';
			PAGINATION_LEFT = '';
			setHash();
			openPAGE(_HREF);
	});

}	
}

function deleteBACKBTN(){
	_allowCREATEBTN = true;	
	$('#backMENU').unbind();
	$('#backMENU').fadeOut(300,function(){$(this).remove()});	
}


function initMAINMENU(){
	$('#menuHOME').find('span.hover').css({opacity:0});

	_linkMENU =$('#menuHOME').find('a');

	_linkMENU.bind('mouseover',function(){
			var _thisHOVER = $(this).find('span.hover');
			_thisHOVER.stop();								 
			_thisHOVER.animate({width:'70%',opacity:1},400,'easeOutCirc');	
	});


	_linkMENU.bind('mouseout',function(){
			var _thisHOVER = $(this).find('span.hover');												  
			_thisHOVER.stop();								 
			_thisHOVER.animate({width:'0px',opacity:0},400,'easeInCirc');	
	});


}


function initLINK(){
	var _allLINKS = $('body').find('a.openPage');
	_allLINKS.unbind('click');
	_allLINKS.bind('click',function(){
		var _HREF = $(this).attr('href');
		openPAGE(_HREF);
		_positionFichier = _HREF.lastIndexOf('/')+1;
		_positionFormat = _HREF.indexOf('.php');
		_newHash = _HREF.substring(_positionFichier,_positionFormat);
		//_newHash += _HREF.substr(_positionFormat+4);
		PAGE_LEFT = _newHash;
		PAGINATION_LEFT = '';
		setHash();
		return false;
	});
}


function openPAGE(_HREF){
closeBulle();	
clearTimeout(_bufferSLIDE);	
_curGalerie = 0;	
_allowRESIZE = false;
var _timerANIM = Math.floor($(window).width()/3);
var _LOADLEFT = $('#loadLEFT');
var _LOADER = $('#mainLOAD');
currentDetail = 0;
$('#navGALERIE').hide();


_LOADLEFT.fadeOut(200,function(){
_LOADER.show();
closeBulle();	
});


var _CLEFT = $('#cLEFT');

_CLEFT.stop();
_CLEFT.animate({right:'-'+_shadowWi+'px'},_timerANIM,'easeOutCirc');

var _timer = setTimeout(function(){

_LOADLEFT.load(_HREF,{contentOnly:1},function(){
	initLINK();
	$('.removing').remove();
	//if(_HREF=='home.php'){slidePage(0);} else {slidePage(1);}

});

},_timerANIM);

}


function slidePage(_BCKBTN){
if(_BCKBTN>0){initBACKBTN();} else { deleteBACKBTN(); initMAINMENU(); }
	

_allowRESIZE = true;	
var _LOADLEFT = $('#loadLEFT');
var _LOADER = $('#mainLOAD');

_LOADER.hide();
_LOADLEFT.fadeIn(200);


var _totalWI = $(window).width();
var _timerANIM = Math.floor(_totalWI/2);
var _centerX = Math.floor(_totalWI/2);

var _CLEFT = $('#cLEFT');

_CLEFT.stop();
_CLEFT.animate({right:_centerX-_shadowWi+'px'},_timerANIM,'easeOutCirc');

var thisTiming = setTimeout(function(){adjustIMG();},_timerANIM);



centerCONTENT();

checkScroll();


}





function centerCONTENT(){
$('.centering').stop();
$('.centering').each(function(){
var _objectHEI = $(this).height();
var _totalHEI = $(window).height();
var _newY = Math.floor((_totalHEI*0.5)-(_objectHEI*0.5));
if(_newY<130){_newY=130;}
$(this).css({top:_newY+'px'});
$('.centering2').css({top:_newY+'px'});
});
}

function centerCONTENT2(){
$('.centering').stop();	
$('.centering').each(function(){
var _objectHEI = $(this).height();
var _totalHEI = $(window).height();
$(this).stop();
$('.centering2').stop();
var _newY = Math.floor((_totalHEI*0.5)-(_objectHEI*0.5));
if(_newY<130){_newY=130;}
$(this).animate({top:_newY+'px'},300);
$('.centering2').animate({top:_newY+'px'},300);
});
}


function openPAGERIGHT(_HREF,_BCKBTN){
	var _CRIGHT = $('#cRIGHT');
	_CRIGHT.load(_HREF,{contentOnly:1},function(){
		var numberofBG = $('.IMGLOADER').size();
		if(numberofBG>0){
			$('.IMGLOADER').load(function(){
			slidePage(_BCKBTN);
			adjustIMG();
			});
		} else {
			slidePage(_BCKBTN);
			adjustIMG();
		}
	});
}



function initNAVGALERIE(_HREF,_BCKBTN,_type) {
	clearTimeout(_bufferSLIDE);

	_GALLINKS = $('#galerie').find('a');
	
	_GALLINKS.bind('mouseover',function(){
		$(this).find('img').stop();
		$(this).find('img').animate({width:'120px',height:'120px',margin:'-12px'},200,'easeOutCirc');
	});
	
	_GALLINKS.bind('mouseout',function(){
		$(this).find('img').stop();
		$(this).find('img').animate({width:'100px',height:'100px',margin:'0'},200,'easeInCirc');
	});
	
	
	_GALLINKS.bind('click',function(){
		clearTimeout(_bufferSLIDE);
		_GALLINKS.removeClass('actif');
		$('#currentGalerie').html($(this).find('img').attr('alt'));
		$(this).addClass('actif');
		var _hrefCurr = $(this).attr('href');
		var _positionID = _hrefCurr.lastIndexOf('id=')+3;
		PAGINATION_LEFT = _hrefCurr.substring(_positionID);
		setHash();
		loadGALERIE(_hrefCurr);
	});
	var _CRIGHT = $('#cRIGHT');
	_CRIGHT.load(_HREF,{contentOnly:1},function(){
		if (_type != 'home') {
			if (PAGINATION_LEFT != undefined && PAGINATION_LEFT != '') {
				var _askedGalerie = $('#gal-link-'+PAGINATION_LEFT);
				if (_askedGalerie.size() == 1) {
					clearTimeout(_bufferSLIDE);
					_GALLINKS.removeClass('actif');
					$('#currentGalerie').html($(_askedGalerie).find('img').attr('alt'));
					$(_askedGalerie).addClass('actif');
					loadGALERIE($(_askedGalerie).attr('href'));
				} else {
					loadGALERIE($('#li-gal-0 a').attr('href'));
					PAGINATION_LEFT = '';
					setHash();
				}
			} else {
				loadGALERIE($('#li-gal-0 a').attr('href'));
				PAGINATION_LEFT = '';
				setHash();
			}
		}
		var numberofBG = $('.IMGLOADER').size();
		if(numberofBG>0){
			$('.IMGLOADER').load(function(){
			slidePage(_BCKBTN);
			adjustIMG();
			});
		} else {
			slidePage(_BCKBTN);
			adjustIMG();
		}
	});
}


function goGALERIE(){
$('#loadGalerie').stop();
$('#timerSTATUS').stop();
clearTimeout(_bufferSLIDE);
adjustIMG();
$('#loadGalerie').animate({opacity:0},400,function(){$(this).hide();adjustIMG();});


$('#navGALERIE').show();


$('#BTN_CONTROLE').unbind();
$('#BTN_CONTROLE').bind('click',function(){controlTIMER();});


$('#legendary').css({opacity:0.75});
/*$('#alertZOOM').css({opacity:0});
$('#zoomIMG').bind('mouseover',function(){
	$('#alertZOOM').stop();
	$('#alertZOOM').animate({top:'50%',opacity:0.7},600,'easeOutCirc');
});
$('#zoomIMG').bind('mouseout',function(){
	$('#alertZOOM').stop();
	$('#alertZOOM').animate({top:'-80px',opacity:0},500,'easeOutCirc');
});*/


$('#zoomIMG').bind('click',function(){
	openIMAGE();
});


_curIMG = 0;
_nextIMG_CACHE = 1;
_lastIMG = ($('.GALERIE_IMAGE').size()-1);
$('#galeriePREV').unbind('click');
$('#galeriePREV').bind('click',function(){swichImage(_lastIMG,'prev');})
$('#galerieNEXT').unbind('click');
$('#galerieNEXT').bind('click',function(){swichImage(_curIMG+1,'next');})

if(_allowSLIDE==true){
timerSLIDE(1);
}
else
{
$('#BTN_CONTROLE').addClass('pause');	
}


}


function timerSLIDE(num){
$('#timerSTATUS').stop();
clearTimeout(_bufferSLIDE);
clearTimeout(_timerBIND);

$('#timerSTATUS').css({width:'0%'});
$('#timerSTATUS').animate({width:'100%'},10000,'linear',function(){
	$('#timerSTATUS').css({width:'0%'});
});

_bufferSLIDE = setTimeout(function(){
$('#galeriePREV').unbind('click');
$('#galerieNEXT').unbind('click');
swichImage(num,'next');},10000);

}



function controlTIMER(){

if(_allowSLIDE==true){
_allowSLIDE = false;
$('#BTN_CONTROLE').addClass('pause');
$('#timerSTATUS').stop();
$('#timerSTATUS').css({width:0});
clearTimeout(_bufferSLIDE);
}
else
{
$('#BTN_CONTROLE').removeClass('pause');
_allowSLIDE = true;	

timerSLIDE(_nextIMG_CACHE);

}

};


function swichImage(num,_type){
adjustIMG();	
$('#galeriePREV').unbind('click');
$('#galerieNEXT').unbind('click');
clearTimeout(_timerBIND);
clearTimeout(_bufferSLIDE);
$('#legendary').stop();
$('#legendary').css({bottom:'-80px'});
$('#legendary').html($('#LEGENDE_'+num).html());
$('#legendary').animate({bottom:'0'},500,'easeOutCirc');
var _prevIMG = num-1;
var _nextIMG = num+1;

if(_nextIMG>_lastIMG){_nextIMG = 0;}
if(_prevIMG<0){_prevIMG = _lastIMG;}

var _CUROBJ = $('#NUM_'+_curIMG);
var _NEWOBJ = $('#NUM_'+num);

_CUROBJ.removeClass('ACTIVE_IMAGE');
_NEWOBJ.addClass('ACTIVE_IMAGE');

_CUROBJ.stop();

_curIMG = num;



$('#countGALERIE').find('strong').html(num+1);

if(_type=='prev'){
	
_NEWOBJ.css({zIndex:2,opacity:1,left:0,display:'block'});
_CUROBJ.css({zIndex:3});
var _decalIMG = (_CUROBJ.width())*-1;

_CUROBJ.animate({left:_decalIMG+'px'},800,'easeOutCirc');

_timerBIND = setTimeout(function(){
									 
_CUROBJ.hide();
if(_allowSLIDE==true){
timerSLIDE(_nextIMG);
}

$('#galeriePREV').bind('click',function(){clearTimeout(_bufferSLIDE);
$('#timerSTATUS').stop();	swichImage(_prevIMG,'prev');})
$('#galerieNEXT').bind('click',function(){
clearTimeout(_bufferSLIDE);
$('#timerSTATUS').stop(); swichImage(_nextIMG,'next');})

},700);



}

else

{

var _decalIMG = (_CUROBJ.width())*-1;
_NEWOBJ.css({zIndex:3,opacity:1,left:_decalIMG,display:'block'});
_CUROBJ.css({zIndex:2});


_NEWOBJ.animate({left:'0px'},800,'easeOutCirc');
														
_timerBIND = setTimeout(function(){
_CUROBJ.hide();

if(_allowSLIDE==true){
timerSLIDE(_nextIMG);
}

$('#galeriePREV').bind('click',function(){clearTimeout(_bufferSLIDE);$('#timerSTATUS').stop();  swichImage(_prevIMG,'prev');})
$('#galerieNEXT').bind('click',function(){clearTimeout(_bufferSLIDE);$('#timerSTATUS').stop(); swichImage(_nextIMG,'next');})
},700);


	
}













	
}





function openIMAGE(){

controlTIMER();
var _SRC_IMAGE = $('.ACTIVE_IMAGE').attr('src');
$('body').prepend('<div id="OVERFLOWBG" style="display:none;" class="closerZOOM"></div><img src="'+_SRC_IMAGE+'" id="OPENIMAGE" class="closerZOOM"><div id="closeZOOM" class="closerZOOM"></div>');




var _OPENIMAGE = $('#OPENIMAGE');
var _OVERFLOWBG = $('#OVERFLOWBG');

_OVERFLOWBG.css({opacity:0.8});
_OPENIMAGE.css({opacity:0});

_OVERFLOWBG.fadeIn(400,function(){
_OPENIMAGE.animate({opacity:1},400);
});

var _imgHEI = _OPENIMAGE.height();
var _imgWI = _OPENIMAGE.width();

var _initHEI = _imgHEI;
var _initWI = _imgWI;

var _totalHEI = $(window).height();
var _totalWI = $(window).width();

var _ratioSCREEN = _totalHEI/_totalWI;
var _ratioIMG = _imgHEI/_imgWI;



if(_ratioSCREEN<_ratioIMG){
var _new_HEI = _totalHEI;
if(_new_HEI>_imgHEI){_new_HEI=_imgHEI;}
_imgWI = 	Math.floor(_imgWI*(_new_HEI)/_imgHEI);
var _yPOS = Math.floor((_totalHEI*0.5) - (_new_HEI*0.5));
var _xPOS = Math.floor((_totalWI*0.5) - (_imgWI*0.5));	
_OPENIMAGE.css({height:_new_HEI+'px',top:_yPOS+'px', left:_xPOS+'px'});	
}
else
{
var _new_WI = _totalWI;

if(_new_WI>_imgWI){_new_WI=_imgWI;}

_imgHEI = 	Math.floor(_imgHEI*(_new_WI)/_imgWI);

var _yPOS = Math.floor((_totalHEI*0.5) - (_imgHEI*0.5));
var _xPOS = Math.floor((_totalWI*0.5) - (_new_WI*0.5));	
_OPENIMAGE.css({width:_new_WI+'px',top:_yPOS+'px', left:_xPOS+'px'});	
}



$('.closerZOOM').bind('click',function(){
$('.closerZOOM').remove();
controlTIMER();
});






$(window).resize(function(){


 _imgHEI = _initHEI;
 _imgWI = _initWI;

 _totalHEI = $(window).height();
 _totalWI = $(window).width();

 _ratioSCREEN = _totalHEI/_totalWI;
 _ratioIMG = _imgHEI/_imgWI;

_OPENIMAGE.stop();

if(_ratioSCREEN<_ratioIMG){
 _new_HEI = _totalHEI;
if(_new_HEI>_imgHEI){_new_HEI=_imgHEI;}
_imgWI = 	Math.floor(_imgWI*(_new_HEI)/_imgHEI);
 _yPOS = Math.floor((_totalHEI*0.5) - (_new_HEI*0.5));
 _xPOS = Math.floor((_totalWI*0.5) - (_imgWI*0.5));	
_OPENIMAGE.animate({height:_new_HEI+'px',width:_imgWI+'px',top:_yPOS+'px', left:_xPOS+'px'},800,'easeOutCirc');	
}
else
{
 _new_WI = _totalWI;

if(_new_WI>_imgWI){_new_WI=_imgWI;}

_imgHEI = 	Math.floor(_imgHEI*(_new_WI)/_imgWI);

 _yPOS = Math.floor((_totalHEI*0.5) - (_imgHEI*0.5));
 _xPOS = Math.floor((_totalWI*0.5) - (_new_WI*0.5));	
_OPENIMAGE.animate({width:_new_WI+'px',height:_imgHEI+'px',top:_yPOS+'px', left:_xPOS+'px'},800,'easeOutCirc');	
}


});









};


function loadGALERIE(_HREF,_navig){
	if(_HREF!=_curGalerie){
		_nextIMG_CACHE = 1;
		$('#galeriePREV').unbind('click');
		$('#galerieNEXT').unbind('click');
		clearTimeout(_bufferSLIDE);	
		clearTimeout(_timerBIND);
		$('#contentGALERIE').find('*').stop();
		$('#contentGALERIE').find('*').remove();
		$('#navGALERIE').hide();
		$('#navGALERIE').css({top:'-100px'});
		$('#navGALERIE').stop();
		$('#navGALERIE').animate({top:'50%'},800);		


		if(_navig==false){
			$('#galeriePREV').hide();
			$('#galerieNEXT').hide();
		} else {
			$('#galeriePREV').show();
			$('#galerieNEXT').show();	
		}

				
		$('#loadGalerie').stop();
		$('#loadGalerie').show();
		$('#loadGalerie').animate({opacity:1},200);
		_curGalerie = _HREF;
			
		$('#contentGALERIE').load(_HREF,{contentOnly:1},function(){
			$('#NUM_0').load(function(){
				goGALERIE();
			});
		});
	}
	
}







 function openBulle(text) {
        $("#infoBulle").html('<div id="topBulle"></div>'+text);
        
		var maxDecal = parseInt($(window).width()) - parseInt($("#infoBulle").width());
        var decalLeft = null;
		
        $("*").bind("mousemove", function (e) {maxDecal = parseInt($(window).width()) - parseInt($("#infoBulle").width())-8;decalLeft = e.pageX;if (decalLeft > maxDecal) {decalLeft = maxDecal;}$("#infoBulle").css({top: parseInt(e.pageY) +34 + "px", left: parseInt(decalLeft) - 6 + "px"}); 
	$("#infoBulle").show();																																																																  $("#topBulle").css({marginLeft: (e.pageX - decalLeft) + "px"}); 
																																																																	
																																																																	  });
    }




    function closeBulle() {
        $("#infoBulle").hide();
        $("#infoBulle").html("");
        $("*").unbind("mousemove");
    }

var _timerOPACITYNEW = null;

function initNEWS(){
	var numNEWS = $('.newsCONTENT').size();	
	var number = 0;
	var _curNEW = 1;
	$('.newsCONTENT').each(function(){
		number++;
		$('#navigACTU').append('<li><a href="javascript:void(0);" class="a_'+number+'">'+number+'</a></li>');
	});
	
	if ($('#navigACTU').find('.a_'+PAGINATION_LEFT).size() == 1) {
		slideNEWS(PAGINATION_LEFT);
	} else {
		PAGINATION_LEFT = '';
		setHash();
		$('#slideNews').find('.newsCONTENT').css({opacity:0.3});
		$('#new_1').css({opacity:1});
		$('#navigACTU').find('.a_1').parent('li').addClass('actif');
	}
	
	$('#navigACTU').find('a').bind('mouseenter',function(){
		var _thisPOS = 	$(this).html();													 
		openBulle($('#new_'+_thisPOS).find('h3').html());										
											
	});
		
	$('#navigACTU').find('a').bind('mouseleave',function(){			
		closeBulle();												
	});
	
	$('#navigACTU').find('a').bind('click',function(){
		slideNEWS(parseInt($(this).html()));
	});
	
	function slideNEWS(_POS){
		if (_POS < 1 || _POS > number || _POS == undefined) {
			PAGINATION_LEFT = '';
			_POS = 1;
			setHash();
		} else {
			if(_POS!=_curNEW){
				if(numNEWS == _POS){var _coeff = 5; } else {var _coeff = 4;}
				
				if( (numNEWS == _POS && numNEWS-1 == _curNEW) || (numNEWS-1 == _POS && numNEWS == _curNEW) ){ var _timeANIM = 0;} else { _timeANIM = 70;}
				
				_timeANIM = _timeANIM * (_POS-_curNEW);
				if(_timeANIM<0){_timeANIM=_timeANIM*(-1);}
				
				if(_timeANIM>0){_timeANIM = _timeANIM+330;}
				
				
				$('#navigACTU').find('li.actif').removeClass('actif');
				$('a.a_'+_POS).parent('li').addClass('actif');
				$('#slideNews').find('actif').removeClass('actif');
				
				$('#new_'+_curNEW).stop();
				$('#new_'+_curNEW).css({opacity:0.3});
				_curNEW = _POS;
				PAGINATION_LEFT = _curNEW;
				setHash();
				clearTimeout(_timerOPACITYNEW);	
				$('#slideNews').stop();
				var _newMargin = (_POS-_coeff) * 195 *-1;
				$('#slideNews').animate({marginLeft:_newMargin+'px'},_timeANIM);
				_timerOPACITYNEW = setTimeout(function(){$('#new_'+_POS).fadeTo(400,1);},_timeANIM);
			}
		}
	}
	
}








function initJOBS(_HREF,_BCKBTN){
	var numNEWS = $('.newsCONTENT').size();	
	var number = 0;
	var _curNEW = 1;
	$('.newsCONTENT').each(function(){
		number++;
		$('#navigACTU').append('<li><a href="javascript:void(0);" class="a_'+number+'">'+number+'</a></li>');
	});
	$('#slideNews').find('.newsCONTENT').css({opacity:0.3});
	$('#new_1').css({opacity:1});
	$('#navigACTU').find('.a_1').parent('li').addClass('actif');
	var _CRIGHT = $('#cRIGHT');
	_CRIGHT.load(_HREF,{contentOnly:1},function(){
		if (PAGINATION_LEFT != undefined) {
			var _askedJobDetail = $('#detail-'+PAGINATION_LEFT);
			if (_askedJobDetail.size() == 1) {
				var _askedPage = _askedJobDetail.parent('.newsCONTENT');
				var _newPage = $('.newsCONTENT').index(_askedPage)+1;
				slideJOBS(_newPage);
				jobDetails(PAGINATION_LEFT);
			} else {
				PAGINATION_LEFT = '';
				setHash();
			}
		}
		var numberofBG = $('.IMGLOADER').size();
		if(numberofBG>0){
			$('.IMGLOADER').load(function(){
			slidePage(_BCKBTN);
			adjustIMG();
			});
		} else {
			slidePage(_BCKBTN);
			adjustIMG();
		}
	});
	
	$('#navigACTU').find('a').bind('click',function(){
		slideJOBS(parseInt($(this).html()));
	});
	
	function slideJOBS(_POS){
		if (_POS < 1 || _POS > number || _POS == undefined) {
			PAGINATION_LEFT = '';
			setHash();
		} else {
			if (_POS!=_curNEW) {
				var  _timeANIM = 70;
				_timeANIM = _timeANIM * (_POS-_curNEW);
				if(_timeANIM<0){_timeANIM=_timeANIM*(-1);}
				if(_timeANIM>0){_timeANIM = _timeANIM+330;}
				$('#navigACTU').find('li.actif').removeClass('actif');
				$('a.a_'+_POS).parent('li').addClass('actif');
				$('#slideNews').find('actif').removeClass('actif');
				
				$('#new_'+_curNEW).stop();
				$('#new_'+_curNEW).css({opacity:0.3});	
				_curNEW = _POS;
				clearTimeout(_timerOPACITYNEW);	
				$('#slideNews').stop();
				var _newMargin = ((_POS-1) * 375 *-1)+585;
				$('#slideNews').animate({marginLeft:_newMargin+'px'},_timeANIM);
				_timerOPACITYNEW = setTimeout(function(){$('#new_'+_POS).fadeTo(400,1);},_timeANIM);
		
			}
		}
	}
}






function jobDetails(id){
	
	if(id!=currentDetail){
	currentDetail=id;
	PAGINATION_LEFT = currentDetail;
	setHash();
	$('.newsCONTENT').find('a').removeClass('actif');
	$('#link-detail-'+id).addClass('actif');
	$('#job-detail').html($('#detail-'+id).html());

	}
	
}

function initLienInfosCles() {
	$('.liste-points-clefs').find('li > a').click(function() {
		openInfosCles($(this).next('div.content').html());
		return false;
	});
}

function openInfosCles(contenu){
	
	//$('.newsCONTENT').find('a').removeClass('actif');
	//$('#link-detail-'+id).addClass('actif');
	$('#points-cles-details').html('<div class="centering">'+contenu+'</div>');
	checkScrollPointsCles();
	centerCONTENT2();
}

function checkScrollPointsCles() {
	/**** Agenda ****/
	var scrollContent = $('#points-cles-details .centering .content-details');
	
	//build slider
	if ( scrollContent.height() > 235) { //scrollPane.height() ) {
		scrollContent.wrap('<div class="scroll-container" />');
		var scrollPane = $('#points-cles-details .scroll-container');
		scrollPane.append('<div class="scroll-bar" />');
		var scrollbar = $( "#points-cles-details .scroll-bar" ).slider({
				orientation: 'vertical',
				value: 0,
				max: 0,
				min: -100,
				slide: function( event, ui ) {
					if ( scrollContent.height() > scrollPane.height() ) {
						scrollContent.css( "margin-top", Math.round(
							ui.value / -100 * ( scrollPane.height() - scrollContent.height() )
						) + "px" );
					} else {
						scrollContent.css( "margin-top", 0 );
					}
				}
			});
	}
}



function openPageBOTTOM(id){
	if(id != old_id_bottom){
		var _content = $('#'+id+'_content');
		var _speed = 600;
		
		PAGE_BOTTOM = $('#'+id).attr('href').substr(1);
		setHash();
		
		
		if(old_id_bottom=='none'){
			$('body').prepend('<div id="OVERFLOWBOTTOM" class="removeBOTTOM"></div>');
			$('#OVERFLOWBOTTOM').css({opacity:0});
			$('#OVERFLOWBOTTOM').animate({opacity:0.7},500);
			$('#bottomMENU').append('<li id="licloser"><a href="#" class="close closerBOTTOM removeBOTTOM" id="btn_close">Fermer</a></li>');

			$('.closerBOTTOM').unbind();
			$('.closerBOTTOM').bind('click',function(){
				closeBOTTOM();
				return false;
			});
		} else {
			$('#'+old_id_bottom+'_content').hide();
		}

		old_id_bottom = id;
		_content.show();
		var _newHEI = _content.height()+30;

		$('#bottomCONTENT').stop();
		$('#bottomMENU').stop();

		$('#bottomCONTENT').animate({height:_newHEI+'px'},_speed,'easeOutCirc');
		$('#bottomMENU').animate({bottom:_newHEI-6+'px'},_speed,'easeOutCirc');
	} else {
		closeBOTTOM();
	}
}



function closeBOTTOM(){
	var _newHEI = 6;
	old_id_bottom = 'none';
	var _speed = 300;
	PAGE_BOTTOM = '';
	setHash();
	$('#OVERFLOWBOTTOM').stop();
	$('#OVERFLOWBOTTOM').fadeOut(150,function(){
		$('.removeBOTTOM').remove();
		$('#bottomCONTENT').find('.content').hide();
	});
	$('#bottomCONTENT').animate({height:_newHEI+'px'},_speed,'easeOutCirc');
	$('#bottomMENU').animate({bottom:_newHEI-6+'px'},_speed,'easeOutCirc');	
}




function adjustIMG(){
	
	
	
	
	var _totalWI = Math.floor($(window).width()*0.5);
	var _totalHEI = $(window).height();
	
$('#cRIGHT').find('img.BGIMG').each(function(){	

var _imgWI = $(this).width();
var _imgHEI = $(this).height();
var _ratioSCREEN = _totalHEI/_totalWI;
var _ratioIMG = _imgHEI/_imgWI;


if(_imgWI>100){
if(_ratioSCREEN>_ratioIMG){
var _new_HEI = _totalHEI;
_imgWI = 	Math.floor(_imgWI*(_new_HEI)/_imgHEI);
$(this).css({height:_new_HEI+'px',width:'auto'});	
}
	
else
{
var _new_WI = _totalWI;
_imgHEI = 	Math.floor(_imgHEI*(_new_WI)/_imgWI);
$(this).css({width:_new_WI+'px',height:'auto'});	
}
}
else
{
$(this).load(function(){
_imgWI = $(this).width();
_imgHEI = $(this).height();
if(_ratioSCREEN>_ratioIMG){
var _new_HEI = _totalHEI;
_imgWI = 	Math.floor(_imgWI*(_new_HEI)/_imgHEI);
$(this).css({height:_new_HEI+'px',width:'auto'});	
}
	
else
{
var _new_WI = _totalWI;
_imgHEI = 	Math.floor(_imgHEI*(_new_WI)/_imgWI);
$(this).css({width:_new_WI+'px',height:'auto'});	
}
});
}






});


}


function initImplantations(){
	
	var _maplinks = $('#planisphere').find('a');
	var _totalPays = $('.infoPays').size();
	_maplinks.unbind();
	_maplinks.bind('mouseleave',function(){clearTimeout(_timerMAP);});
	
	_maplinks.bind('mouseenter',function(){
	
	
	
	
	var _newID = $(this).attr('id');

	_newID = _newID.split('link-');
	
	var _thisLiID = $('#li-'+_newID[1]);

	
	
	var countElement = _thisLiID.prevAll('.infoPays').size();
	
	
	if(countElement==_totalPays-1){ countElement--; }
	
	var _newMargin =  (_thisLiID.width()+30)*countElement*(-1);

	var _speed = 600 + (80*countElement);
	
	_timerMAP = setTimeout(function(){
	$('.activPays').removeClass('activPays');										
	_thisLiID.addClass('activPays');							
	$('#liste-pays').stop();
	$('#liste-pays').animate({marginLeft:_newMargin+'px'},_speed,'easeOutCirc');
/*	
	$('#liste-pays').find('li').css({marginTop:'0'})
	_thisLiID.css({marginTop:'-30px'});*/
	},100);
	
	
	
	});
	
	
}




function loadCONTACT(_HREF){
	var _positionID = _HREF.lastIndexOf('id=')+3;
	var _ID = _HREF.substring(_positionID);
	$('#listing-pays').find('.actif').removeClass('actif');
	$('#contact-link-'+_ID).addClass('actif');
	$('#loadCONTACT').stop();
	$('#loadCONTACT').css({opacity:1});
	$('#loadCONTACT').show();
	$('#contentCONTACT').load(_HREF,{contentOnly:1},function(){
		centerCONTENT();
		applySELECTS();
		$('#loadCONTACT').animate({opacity:0},600,function(){$(this).hide();});
	});
	if ($('#contact-link-'+_ID).size() == 1) {
		PAGINATION_LEFT = _ID;
		setHash();
	} else {
		PAGINATION_LEFT = '';
		setHash();
	}
}



function applySELECTS(){
$('div.select').unbind();
$('div.select').each(function(){
var _timerSelect = null;							  
var _curElement = $(this).find('.selectListe');
var _curSelected = $(this).find('.selector');
var _thisHEI = _curElement.height();
_curElement.css({height:0});
$(this).find('*').bind('mouseover',function(){
_curElement.stop();
_curElement.show();
clearTimeout(_timerSelect);
_curElement.animate({opacity:1,height:_thisHEI+'px'},300);
});

$(this).bind('mouseleave',function(){
_curElement.stop();
_timerSelect = setTimeout(function(){
_curElement.animate({opacity:0,height:0},400,function(){$(this).hide();});
},200);
});

$(this).find('a').bind('click',function(){
_curElement.stop();
clearTimeout(_timerSelect);
_curElement.hide();
_curElement.css({height:0,opacity:0});
_curSelected.html($(this).html());
});


});

	
}



function viewFICHE(id,_NOM){
	$('.detail-contact').hide();
	$('#contact-'+id).show();
	$('#thisFilliale').html('- '+_NOM);
}






function initVIDGALERIE(_HREF){
clearTimeout(_bufferSLIDE);



	_GALLINKS = $('#galerie').find('a');
	
	_GALLINKS.bind('mouseover',function(){
		$(this).find('img').stop();
		$(this).find('img').animate({width:'120px',height:'120px',margin:'-12px'},200,'easeOutCirc');
	});
	
	_GALLINKS.bind('mouseout',function(){
		$(this).find('img').stop();
		$(this).find('img').animate({width:'100px',height:'100px',margin:'0'},200,'easeInCirc');
	});
	
	
	_GALLINKS.bind('click',function(){
		clearTimeout(_bufferSLIDE);								
		_GALLINKS.removeClass('actif');
		$('#currentGalerie').html($(this).find('img').attr('alt'));
		$(this).addClass('actif');
		var _hrefCurr = $(this).attr('href');
		var _positionID = _hrefCurr.lastIndexOf('id=')+3;
		PAGINATION_LEFT = _hrefCurr.substring(_positionID);
		setHash();
		loadVIDGALERIE(_hrefCurr);	
	});
	var _CRIGHT = $('#cRIGHT');
	_CRIGHT.load(_HREF,{contentOnly:1},function(){
		if (PAGINATION_LEFT != undefined && PAGINATION_LEFT != '') {
			var _askedGalerie = $('#gal-link-'+PAGINATION_LEFT);
			if (_askedGalerie.size() == 1) {
				clearTimeout(_bufferSLIDE);
				_GALLINKS.removeClass('actif');
				$('#currentGalerie').html($(_askedGalerie).find('img').attr('alt'));
				$(_askedGalerie).addClass('actif');
				loadVIDGALERIE($(_askedGalerie).attr('href'));
			} else {
				loadVIDGALERIE($('#li-gal-0 a').attr('href'));
				PAGINATION_LEFT = '';
				setHash();
			}
		} else {
			loadVIDGALERIE($('#li-gal-0 a').attr('href'));
			PAGINATION_LEFT = '';
			setHash();
		}
		var numberofBG = $('.IMGLOADER').size();
		if(numberofBG>0){
			$('.IMGLOADER').load(function(){
			slidePage(1);
			adjustIMG();
			});
		} else {
			slidePage(1);
			adjustIMG();
		}
	});
}



function loadVIDGALERIE(_HREF){
	$('#loadGalerie').stop();
	$('#loadGalerie').css({opacity:1});
	$('#loadGalerie').show();
	$('#contentGALERIE').load(_HREF,{contentOnly:1},function(){
	_curVID = 0;											 
	centerCONTENT();											 
	$('#loadGalerie').animate({opacity:0},400,function(){$(this).hide();});
	
	
	_maxVID = $('.videoObject').size()-1;
	
	if(_maxVID>0){
	goNavVid();
	}
	else
	{
		
		$('#navGALERIE').hide();	
		$('#galeriePREV').unbind('click');	
		$('#galerieNEXT').unbind('click')
		
	}

	});
}


function goNavVid(){
$('#navGALERIE').show();	
$('#navGALERIE').css({top:'-100px'});
$('#navGALERIE').stop();
$('#navGALERIE').animate({top:'50%'},800);		

$('#galeriePREV').show();
$('#galerieNEXT').show();
$('#galeriePREV').unbind('click');	
$('#galerieNEXT').unbind('click');	

$('#galerieNEXT').bind('click',function(){goNEXTVID();});
$('#galeriePREV').bind('click',function(){goPREVVID();});


}

function goNEXTVID(){


var _newVID = _curVID+1;
if(_newVID>_maxVID){_newVID=0;}


_curVID = _newVID;

$('#countVIDGALERIE').find('strong').html(_curVID+1);




$('#galeriePREV').unbind('click');	
$('#galerieNEXT').unbind('click');
	
$('#current_vid').stop();
$('#current_vid').animate({left:'-300px'},200);	

var _timerSlide = setTimeout(function(){
$('#galerieNEXT').bind('click',function(){goNEXTVID();});
$('#galeriePREV').bind('click',function(){goPREVVID();});									  
$('#current_vid').stop();									  
$('#current_vid').css({left:'130%'});
$('#VIDEO_'+_curVID).show();
$('#current_vid').html($('#VIDEO_'+_curVID).html());
$('#current_vid').animate({left:'50%'},300);	
},600);

}


function goPREVVID(){

var _newVID = _curVID-1;
if(_newVID<0){_newVID=_maxVID;}
_curVID = _newVID;

$('#countVIDGALERIE').find('strong').html(_curVID+1)

$('#galeriePREV').unbind('click');	
$('#galerieNEXT').unbind('click');
	
$('#current_vid').stop();
$('#current_vid').animate({left:'130%'},200);	

var _timerSlide = setTimeout(function(){
$('#galerieNEXT').bind('click',function(){goNEXTVID();});
$('#galeriePREV').bind('click',function(){goPREVVID();});									  
$('#current_vid').stop();									  
$('#current_vid').css({left:'-300px'});
$('#current_vid').html($('#VIDEO_'+_curVID).html());
$('#current_vid').animate({left:'50%'},300);	
},600);

}




function initFOLIOGALERIE(){
	var _totalGal = Math.ceil($('#galerie').find('li').size()/9);
	if(_totalGal>0){
		$('#loadLEFT').prepend('<ul id="navigACTU"></ul>');
		for(i=1;i<=_totalGal;i++) {
			$('#navigACTU').append('<li><a href="javascript:void(0)" class="a_'+i+'" onclick="swichFOLIOGAL('+i+'); $(this).parent(\'li\').addClass(\'actif\');">'+i+'</a></li>');
		}
		$('#navigACTU').find('li:first').addClass('actif');
		if (PAGINATION_LEFT != undefined && PAGINATION_LEFT != '') {
			var _listGal = $('#galerie li');
			var _askedGalerie = $('#gal-link-'+PAGINATION_LEFT);
			if (_askedGalerie.size() == 1) {
				swichFOLIOGAL(Math.ceil((_listGal.index(_askedGalerie.parent('li'))+1)/9));
			}
		}
	}
}


function swichFOLIOGAL(_num){
$('#navigACTU').find('.actif').removeClass('actif');
$('#navigACTU').find('a.a_'+_num).parent('li').addClass('actif');
$('#galerie').find('li').hide();

var _min = (_num-1)*9;
var _max = _min+8;

for(i=_min;i<=_max ;i++){

$('#li-gal-'+i).show();
	
}


}





function checkScroll(){

$('#scroller').show();
var _scrollingHei = Math.round($(window).height()*0.7)-120;
$('.scrolling').css({height:_scrollingHei+'px'});
var _listing = $('.scrolling').find('.content');
var _contentHei = _listing.height();
var _slider = $( "#srcollMe" );
var _minValue = _contentHei - _scrollingHei;

$('#scroller').css({height:(_scrollingHei-10)+'px'});
	
	_listing.css({marginTop:'0px'});
	_slider.unbind();
	_slider.slider( "destroy" );
	_slider.slider({ orientation: 'vertical' , max:0,min:_minValue*-1});
	_slider.bind( "slide", function(event, ui) {
 		_listing.stop();
		_listing.animate({marginTop:ui.value+'px'},800,'easeOutCirc');
	});


centerCONTENT2();


if(_contentHei<_scrollingHei){
$('#scroller').hide();	
}
	
}



function openPlan(_link){

$('body').prepend('<div class="removePlan" style="position:absolute; z-index:300;  background:#000 url(images/load-black.gif) no-repeat center center; top:0; left:0; width:100%; height:100%;" id="overAllPlan"></div><iframe frameborder="0" scrolling="no" allowtransparency="false" width="1" height="1" style="position:absolute; z-index:400; background:#FFF;" id="framePlan" src="'+_link+'" class="removePlan"></iframe>');
$('#overAllPlan').css({opacity:0.8});
var frameWi = $('#overAllPlan').width()-120;
var frameHei = $('#overAllPlan').height()-80;
$('#framePlan').css({width:frameWi+'px',height:frameHei+'px', marginTop:Math.round(frameHei*1.5) ,  marginLeft:'60px'});

$('#framePlan').load(function(){
							  
var _timerPlan = setTimeout(function(){
$('body').prepend('<div id="closeZOOM" class="closePlan removePlan"></div>');
$('#framePlan').css({marginTop:'40px'});
$('.closePlan').bind('click',function(){
$('.removePlan').remove();
});


},100);

});


	
}

function resizePlan(){
var frameWi = $('#overAllPlan').width()-120;
var frameHei = $('#overAllPlan').height()-80;
$('#framePlan').stop();
$('#framePlan').animate({width:frameWi+'px', marginLeft:'60px',height:frameHei+'px', marginTop:'40px'},400);
	
}



