// JavaScript utéf8

/*** globales pour $ et js ***********************************/

readyPush=new Array();	/* chaque élément sera évalué au $(document).ready  */
needMouse=false;		/* si vrai, le onmousemouse sera activé sur le body */
x_mouse=y_mouse=0;		/* retournées par body.onmousemouse */
moveTarget=false;		/* activée par body.onmousemouse, stopée par body.mouseup */
globalZindex=100;		/* incrémenter 'manuellement' :) */

/*** globales pour $ et js ***********************************/


/* *** fonctions js classiques *** */
// trace('kekchose')
function trace(str){if( typeof document.traceBox == 'undefined' ){var traceBox=document.createElement('TEXTAREA');traceBox.cols='40';traceBox.rows='10';with(traceBox.style){position='absolute';right='20px';bottom='20px';}traceBox.ondblclick=function(){this.style.display='none';};document.body.appendChild(traceBox);document.traceBox=traceBox;}document.traceBox.value=str+"\n"+document.traceBox.value;document.traceBox.style.display='block';}

String.prototype.trim = function() {return this.replace(/(^\s*)|(\s*$)/g,'');}
function findObj(n,c)			{var x,d=c?c.document:document; if(!(x=d.getElementById(n))){x=d[n]};return x;}
function findTags(obj,tag,arr)	{if(tag=='*'){obj.ALLS = obj.all||obj.getElementsByTagName(tag);}else{obj[tag+"S"] = obj.all?obj.all.tags(tag):obj.getElementsByTagName(tag);};if(arr)return obj.ALLS || obj[tag+"S"] || [];}
function getBounds(obj)			{obj.X=obj.offsetLeft;obj.Y=obj.offsetTop;obj.W=obj.offsetWidth;obj.H=obj.offsetHeight;var tempObj=obj;while(tempObj=tempObj.offsetParent){if (isNaN(tempObj.offsetTop)) break;obj.X+=tempObj.offsetLeft;obj.Y+=tempObj.offsetTop; }return obj;}

/* ajouter arrondi monétaire */
function arrondi(nbre){if(nbre=="") return "";nbre=nbre.replace(/,/g,".");if(isNaN(parseFloat(nbre,10)))return "0.00";nbre=String(Math.round(parseFloat(nbre,10)*100)/100);nbre=nbre.replace(/(^[0-9]+$)/,"$1.00");nbre=nbre.replace(/(^[0-9]+\.[0-9]$)/,"$1"+"0");return nbre;}
/* ajouter arrondi monétaire */
function ismail(mail){return (/^([a-z_0-9\.-]+)@([a-z_0-9\.-]+)\.([a-z]{2,5})$/).test(mail);}
function Fwrite(str){document.write(str);}
function change_url(str){location=str;}
function clearSelection(){var sel;if(document.selection && document.selection.empty){try{document.selection.empty();}catch(e){};}else if(window.getSelection){sel=window.getSelection();if(sel && sel.removeAllRanges)sel.removeAllRanges();}}
function set_opacity(el,opacity){opacity =Math.max(0.001,Math.min((/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 99.999 : 100,opacity));el.style["filter"] = "alpha(opacity="+opacity+")";el.style["-moz-opacity"] = opacity/100;el.style["-khtml-opacity"] = opacity/100;el.style["opacity"] = opacity/100;}

// obsolètes :
// utiliser obj.parentNode
function findRealParent(obj)	{if(!obj.parentNode)obj.parentNode=obj.parentElement ; return obj.parentNode;}


/* *** fin fonctions js classiques *** */
/* *** fonctions combo js classiques *** */

function Combo_Supprimer(liste){
	while(liste.selectedIndex != -1) liste.options[liste.options.selectedIndex]=null;
}
function Combo_Bouger(liste,up){
var n = liste.selectedIndex;
	if(n<0) return;
var opt=liste.options[n];
var tempText=opt.text, tempValue=opt.value;
	if(up){
		if(n > 0){
		opt.text = liste.options[n-1].text;
		opt.value = liste.options[n-1].value;
		liste.options[n-1].text = tempText;
		liste.options[n-1].value = tempValue;
		liste.options[n].selected=false;
		liste.options[n-1].selected=true;
		}
	}else{
		if(n < liste.options.length-1){
		opt.text = liste.options[n+1].text;
		opt.value = liste.options[n+1].value;
		liste.options[n+1].text = tempText;
		liste.options[n+1].value = tempValue;
		liste.options[n].selected=false;
		liste.options[n+1].selected=true;
		}
	}
}
function Combo_Add(liste,value,text){
var n = liste.length;
liste.options[n]=new Option(text,value);
}

function Combo_Select_All(liste){
	for(var i=0; i < liste.length; i++) liste[i].selected = true;
}
/* *** fin fonctions combo classiques *** */


/* *** fonctions du site *** */
//Fonction pour cacher la liste		
function wait (liste) {return setTimeout(	function() { liste.hide(); }, 1000 );}//active ou désactive les boutons left / right
// btns : objet Jquery des boutons droite/gauche
// api : api du plugIn slider
function updateButtons (btns, api) {
	
	var i = api.getCurrentIndex();
	var l = api.getChildrenLength();
	
	btns.css({
		'opacity'	: '1',
		'cursor'	: 'pointer'
	});
	
	if( i === 0 ) {
		btns.eq(0).css({
			'opacity'	: '0.2',
			'cursor'	: 'default'
		});
	}else if( i === l-1 ) {
		btns.eq(1).css({
			'opacity'	: '0.2',
			'cursor'	: 'default'
		});
	}
	
};

//comme on affiche 4 logos dans la zone et non pas un on désactive le scroll avant que le pointeur soit à la fin de la liste
function updateNavigationLogo (btns, step) {
	
	function uNL (api) {
		
		var i = api.getCurrentIndex();
		var l = api.getChildrenLength();
			
		if( i === l-step ) {
			i = api.setCurrentIndex(l-1);
		};
		
		updateButtons(btns, api);
		
		if( i === l-1 ) {
			api.setCurrentIndex(l-step);
			//désactive juste le scroll l'action par défaut du lien est toujours annulé
			btns.eq(1).unbind('click.scroll');
		};
	};
	return uNL;
};


/* *** fin fonctions du site *** */


$(document).ready(function() {

	for(var i=0;i<readyPush.length;i++){
	eval(readyPush[i]);
	}

	if(needMouse){
		$("body").mousemove( function(e) {
		x_mouse=e.pageX; y_mouse=e.pageY;
			if(moveTarget && moveTarget.activeIt){
				clearSelection();
				moveTarget.activeIt();
			return false;
			}
		} );
		
		$("body").mouseup( function(e) {
			if(moveTarget && moveTarget.stopIt) moveTarget.stopIt();
		moveTarget=false;
		} );
		
	}

/* *** VOTRE CODE ICI *** */

/*** menu langSelector */
var selecteur = $('#langSelector');
	
	if ( selecteur.length ) {
	var liste 	= selecteur.find('ul');
	var langSelector = new miniMenu(selecteur,liste);
	}

function miniMenu(selecteur,liste){
var tx=0, that=this, liste=liste, actif=false;

	$(selecteur).find('*').each(
		function(a,b){
			b.onmouseover=function(){ actif=true; clearTimeout(tx); liste.show(); }
			b.onmouseout=function(){ actif=false; tx=setTimeout(function(){if(!actif) liste.hide();},500); }
		}
	);
	
}



	/***FIN  menu langSelector */
	/*** scroll des news de la home corporate */

var scrollContainer = $('#sliderNews');
	
	if( scrollContainer.length ) {
		
	var minTop 	= 0;
	var maxTop 	= (scrollContainer.height() - 170)*-1; //240
	var pas		= 60;
		
		function changeColor () {
			var currentPos 	= parseInt(scrollContainer.css('top'));
			var color = currentPos === 0 ? '#ccc' : '#009147';
			$('#scrollTop').css('background', color);
			};
		
		$('#scrollTop').click( function(e) {
			scrollContainer.stop(true, true);
			var currentPos 	= parseInt(scrollContainer.css('top'));
				if( currentPos === 0 ) {
					$(this).css('background', '#CCC');
					return false;
				}
			var nextPos = currentPos+pas;
			nextPos = nextPos > 0 ? 0 : nextPos;
			scrollContainer.animate( { top : nextPos }, 'fast', changeColor );
			return false;
			});
		
		$('#scrollBottom').click( function(e) {
			scrollContainer.stop(true, true);
			var currentPos = parseInt(scrollContainer.css('top'));
			if( currentPos === maxTop ) {
				return false;
			};
			var nextPos = currentPos-pas;
			nextPos = nextPos < maxTop ? maxTop : nextPos;
			scrollContainer.animate( { top : nextPos }, 'fast', changeColor );
			return false;
		});
				
	};

	/*** FIN scroll des news des homes corporate et locaux */
	
	/*** animation terre de la home corporate*/
	
function initLocaux(){
var old=false;
var that = this;
$('#flashHome > map > area:first-child').each(
		function(a,b){
		$('.mapLocal').eq(a).css({opacity:0,visibility:'visible',display:'none'});
			b.onclick=function(){
			$('.mapLocal').eq(a).hide(); return false;
			}
		}
	);

$('#locaux a').each(
		function(a,b){
			b.onclick=function(){
			cacheOld(a);
			old=a;
			$('.mapLocal').css({opacity:0});$('.mapLocal').eq(a).show().animate({opacity:1},700);
			return false;
			}
		}
	);

	function cacheOld(a){
		
		if(old){
			$('.mapLocal').eq(old).stop().css({opacity:0}).hide();
		}
	}

}
	/*** FIN animation terre de la home corporate*/
	
	/*** carte pays des licensed-applicators */

function initLicensed(){
var old=false;
var that = this;

	if($('#carte a').length && $('.contentType8 > ul > li').length){
		//trace($('.contentType8 > ul > li').length);
		var adress 	= $('.contentType8 > ul > li');
		var a 		= $('#carte a');
		//old=adress.eq(0);
		
			a.click(
			function(e) {
				e.preventDefault();
				
				var v = adress.filter(':visible');
				var n = $(this).attr('href');

				if( v.length && n != '#'+v.attr('id') ) {
					v.fadeOut('fast', 
							function(e) {
								adress
								.filter(n)
								.fadeIn();
							 }
						 );
				}else{
					adress
					.filter($(this).attr('href'))
					.fadeIn();
				}
					
			}
		);

	}
	
}
	/*** FIN pays des licensed-applicators */
	
	/*** diaporama entete news */
var d = $('#diaporama');
	
var paramsDiapo = {
	delay : 2000, //durée de la transition
	timeout : 3000 //temps d'attente entre 2 transitions
}
	
	if( d.length ) {
		if( $('#diaporama img').length>1 ){
		$('#diaporama').fade( paramsDiapo );
		}
		/*else{
		trace($('#diaporama img').eq(0));
		}*/
	};
	/*** FIN diaporama entete news */
	
	/*** activation carte contact */
var cng = $('#carteNotreGroupe')
	
	if( cng.length ) {
		
		var adress 	= $('.contentType6 > div');
		var a 		= cng.find('area');
		
		a.click(
			function(e) {
				e.preventDefault();
				
				var v = adress.filter(':visible');
				var n = $(this).attr('href');

				if( v.length && n != '#'+v.attr('id') ) {
					v.fadeOut('fast', 
							function(e) {
								adress
								.filter(n)
								.fadeIn();
							 }
						 );
				}else{
					adress
					.filter($(this).attr('href'))
					.fadeIn();
				}
					
			}
		);
	};
	/*** FIN activation carte contact */

	/*** Home locaux */

	/*Slider gauche/droite de la home*/
	if( $('#scrollMarket').length ) {
	
		$.slide.defaultClasses = {
			scrollContainer : '.listType1' // zone à faire défiler
		};
		
		var boutons			= $('.scrollButton.left,.scrollButton.right', '#scrollMarket');
		var setNavElement 	= updateNavigationLogo(boutons, 5);
		
		params1 = {
			delay 			: 500, // durée de la transition
			timeout 		: 5000, // temps d'attente entre 2 transitions
			scrollRight		: '.scrollButton.right', 
			scrollLeft		: '.scrollButton.left',
			endCallback 	: setNavElement
		};
		
		$('#scrollMarket').slide(params1);
		
		var sliderApi 	= $('#scrollMarket').data('slidePluginDatas');
		
		if ( sliderApi.getChildrenLength() <= 5 ) {
			
			boutons.unbind('click.scroll').css({
				'opacity'	: '0.2',
				'cursor'	: 'default'
			});
			
		}else{
			//mise à jour des flèche de scroll
			setNavElement(sliderApi);
			
			boutons.eq(0).click( function() {
				if ( sliderApi.getCurrentIndex() === sliderApi.getChildrenLength()-6 ) {
					sliderApi.rebindRight();
				};
			});
			
		};
	
	};
	
	/*** FIN Home locaux */





	/*** markets-specifications*/
	
	b = $('.scrollMarket');
	
	/*Slider gauche/droite de la home*/
	if( b.length ) {
		
		
		//  #scrollContainer en double 
		/*** tabScrollMarket */
		
		$('#tabScrollMarket a').each(
			function(a,b){
				$(b).click(
					function(e){
					e.preventDefault();
						$('.scrollMarket').each(
							function(i,s){
								if(i==a){
								$(s).show();
								$(b).addClass('active');
									$('.rubTexte').eq(i).show();
								}else{
								$(s).hide();
									$('.rubTexte').eq(i).hide();
								$('#tabScrollMarket a').eq(i).removeClass('active');
								}
							}
						);
					}
				);
			}
		);
		
		/*** Fin tabScrollMarket */
	
		$.slide.defaultClasses = {
			scrollContainer : '.listType1' // zone à faire défiler
		};
		
		
		var sa = [];
		
		for (var i = 0; i<2; i++) {
			var sm = $('#sm'+i+'');
			var boutons = $('.scrollButton.left,.scrollButton.right', sm);
			
			var sne = updateNavigationLogo(boutons, 7);
			
			var params = {
				delay 			: 500, // durée de la transition
				timeout 		: 5000, // temps d'attente entre 2 transitions
				scrollRight		: '.scrollButton.right',
				scrollLeft		: '.scrollButton.left',
				endCallback 	: sne
			};
			
			sm.slide(params);
			
			sa[i] = sm.data('slidePluginDatas');
			
			boutons.data('index', i);
			
			if ( sa[i].getChildrenLength() <= 7 ) {	
				boutons.unbind('click.scroll').css({
					'opacity'	: '0.2',
					'cursor'	: 'default'
				});
			
			}else{
				sne(sa[i]);
				//mise à jour des flèche de scroll
				boutons.eq(0).click( function() {
					
					if ( sa[$(this).data('index')].getCurrentIndex() === sa[$(this).data('index')].getChildrenLength()-8 ) {
						
						sa[$(this).data('index')].rebindRight();
					};
				});
				
			};
			
		}
		
		/*
		var boutons			= $('.scrollButton.left,.scrollButton.right', '.scrollMarket');
		var setNavElement 	= updateNavigationLogo(boutons, 7);
		
		params = {
			delay 			: 500, // durée de la transition
			timeout 		: 5000, // temps d'attente entre 2 transitions
			scrollRight		: '.scrollButton.right', 
			scrollLeft		: '.scrollButton.left',
			endCallback 	: setNavElement
		};
		
		$(b[0]).slide(params1);
		$(b[1]).slide(params1);
		
		var sliderApi = $(b[0]).data('slidePluginDatas');
		var sliderApi1 = $(b[1]).data('slidePluginDatas');
		
		if ( sliderApi.getChildrenLength() <= 7 ) {			
			boutons.unbind('click.scroll').css({
				'opacity'	: '0.2',
				'cursor'	: 'default'
			});
			
		}else{
			//mise à jour des flèche de scroll
			setNavElement(sliderApi);
			boutons.eq(0).click( function() {
				if ( sliderApi.getCurrentIndex() === sliderApi.getChildrenLength()-6 ) {
					sliderApi.rebindRight();
				};
			});
			
		};
		*/
	};
	
	/*** FIN markets-specifications */


	/***  infobulle résultats de recherche */
	
	if($('.com').length){
	var infobulle=document.createElement('DIV'), bulle=document.createElement('DIV');
	document.body.appendChild(infobulle);
	infobulle.appendChild(bulle);
	infobulle.className='infobulle';
	bulle.innerHTML = 'zooooooo';
		$('.com a:first-child').each(
			function(a,b){
			b.titre=b.title;
			b.title='';
				b.onclick=function(){return false;}
				b.onmouseover=function(){
				var x=$(this).offset().left, y=$(this).offset().top, L=$(infobulle).width();
				$(infobulle).show();
				$(bulle).html(b.titre);
				$(infobulle).css( {left:(x-L-20)+'px',top:y+'px'} );
				}
				b.onmouseout=function(){
				$(infobulle).hide();
				}
			}
		);
	}


	/*** FIN infobulle résultats de recherche */


	/* popup GGmap contact locaux */
GGmap=$('#pop');
/*GGmap.fancybox({
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
			});
 
GGmap.fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'

			});*/
	if( $('#pop').length ) {
		$(GGmap).click(
			function(){
			window.open($(this).attr('href'),"fen","top=100, left=100, menubar=no, status=no, scrollbars=no, menubar=no, width=640, height=480");
			return false;
			}
		);
	
	}
	/* FIN popup GGmap contact locaux */





	/*** autre chose */

/* *** FIN DE VOTRE CODE *** */


/* *** detection version FlashPlayer déclaration de la version demandée *** */
navigator.NeedFlashVersion=7;
navigator.NeedFlash=false;navigator.FlashVersion=0;navigator.CanPlayFlashPlayer=false;
	if( document.getElementsByTagName ){
	var of=document.getElementsByTagName('OBJECT'); var nf=of.length;for (var i=0;i<nf;i++){var source=of[i].innerHTML;if(!(/\.swf["?]/gi.test(source))) continue;of[i].AllowScriptAccess = "always";if( !navigator.NeedFlash ){navigator.NeedFlash=0;try{navigator.FlashVersion=parseInt(navigator.plugins["Shockwave Flash"].description.match(/[0-9]+[.,]/));}catch(e){try{var ie_vers=of[i].GetVariable("$version");navigator.FlashVersion=(parseInt(ie_vers.match(/[0-9]+[.,]/)));}catch(e){}}}navigator.NeedFlash++;}if(navigator.NeedFlash && navigator.FlashVersion<navigator.NeedFlashVersion){navigator.CanPlayFlashPlayer=false;var div=document.createElement('DIV');div.className='NeedFlashVersion';div.innerHTML='You need to upgrade your Flash Player';document.body.appendChild(div);}else{navigator.CanPlayFlashPlayer=true;}
	}
/* *** FIN detection version FlashPlayer *** */
});
