﻿/*(function (){
	$('body').addClass('js');

})*/


$(document).ready(function(){ init(); });
function init(){
	if($('.listHome').length>0)
	{ homeLinks(); }
	if($('.PcorporateDiv').length>0)
	{ linkcorpo(); }
	if($('.ongletsStandards').length>0)
	{ initTabs(); }
	if($('.ongletsInvisibles').length>0)
	{ initHiddenTabs(); }
	if($('ul.ongletsLigne').length>0)
	{ initTabsInline(); }
	if($('.ongletsFrise').length>0)
	{ initTabsfrise(); }
	if($('.sitemapWrapper').length>0)
	{ sitemap(); }
	if($('.formstep').length>0)
	{ formStep(); }
	if($('.globalresults').length>0)
	{ animateResults(); }
	if($('.listMainPress').length>0)
	{ ListPress(); }
	if($('.PlistLink').length>0)
	{ listLinksSelect(); }
	if($('.galleryContainer').length>0)
	{ organizeGallery(); }
	if($('.horizontalGallery').length>0)
	{ organizeHorizontalGallery(); }
	if($('.sect-bas-text').length>0)
	{ textDownLinks(); }
	if($('.sect-haut-text').length>0)
	{ textUpLinks(); }
	if($('.paragraphe').length>0)
	{ paragrapheLinks(); }
	if($('#sect-haut p').length>0)
	{ borderSectHaut(); }
	if($('.paveStandard').length>0)
	{ paveStandard(); }
	if($('.listItemNews').length>0)
	{ listItemNews(); }
	scrollFooter();
	ajustFooter();
	LeftNav('#leftCol .navlev3');
	//LeftNav('#context .navigation');
	validateform();
	siteInit();
	initOptions();
}

function siteInit() {
	// Fonction  rcrire/remplacer pour les besoins locaux d'initialisations de site
}

function LeftNav(Selectors) {
	$(Selectors+' ul li:not(.on) ul').hide();
	$(Selectors+' ul li.on[id]').addClass('activeOn');
	//$('body').removeClass('js');
	$('#leftCol .navlev3 ul li:not(.on) ul').hide();
    var openSideMenu = function(obj){
		if(!$(obj).parent('li').hasClass('active')){
			$(obj).parent().parent().children('li[id]').each(function(i){
				var current = $(this);
				$(this).children('ul:p0').slideUp('fast',function()
					{
						current.removeClass('activeOn');
					}
				);
			});
			$(obj).parent().parent().children('li[id].active:not(.on)').each(function(i){
				var current = $(this);
				$(this).children('ul:p0').slideUp('fast',function()
					{
						current.removeClass('active');
						current.find('li.active').removeClass('active');
						current.find('ul').hide();
					}
				);
			});
		}
        $(obj).parent('li:not(.on)').toggleClass('active');
		$(obj).parent('li.on').toggleClass('activeOn');
       if($(obj).next().is(':hidden')){
            $(obj).next().slideDown('fast')
        } else {
            $(obj).next().slideUp('fast',function()
			{
				$(obj).parent('li:not(.on)').find('ul').hide();
			});

        }
    };



    $(Selectors+' ul li a').click(function(e){
		if($(this).attr('href')=='#')
		{
			openSideMenu($(this));
			e.preventDefault();
			return false;
		} else {
			if($(this).attr('target')!='_blank')
			{
				window.location = $(this).attr('href');
			}
		}
    });
	$(Selectors+' li[id]:last').addClass('last');
	$(Selectors+' li.on:last').addClass('current');
    
}


/***
Function : initOptions()
Description : Masquage des pictos superflux dans les couleurs non adaptées à la charte de la page en cours
***/
function initOptions(){
	/*var icones = ["AddFav", "Print", "Send"];
	var colors = ["Green", "Pink", "Purple", "Blue", "Orange", "White", "Red"];*/
	var isTitle = $("#pageTitle").html() != null && String($("#pageTitle").html()).length > 0;
	/*var isOptions = $("#icones_tmp").html() != null && String($("#icones_tmp").html()).length > 0;
	var currentExpertColorClass = "expertred";
	
	
		$('#toolBox img').hide();
	
	if (isTitle && isOptions){
		currentExpertColorClass = $("#expert").attr("class");
		if(!currentExpertColorClass || currentExpertColorClass.length <= 0) currentExpertColorClass = "expertwhite";
	}
	
	if (isOptions){
		$('#toolBox').show();*/
		if(!isTitle){
			$("#pageTitleContainer").removeClass("page-title");
			$("#pageTitleContainer").addClass("page-title-icones");
			$('#toolButtonPrintRed, #toolButtonSendRed, #toolButtonSendRed, #toolButtonAddFavRed').show();
		}/* else {
			$('#toolButtonPrintWhite, #toolButtonSendWhite, #toolButtonSendWhite, #toolButtonAddFavWhite').show();
 		}
		$('#contentMain').prepend($('#icones'));
		$('#icones').css({'right':'196px','top':'1px'});
	}
	if ($("#icones") && $("#icones_tmp")) $("#icones").append( $("#icones_tmp").html() );*/
	
}

function stripHtml(elem)
{ 
        var regexp = /<("[^"]*"|'[^']*'|[^'">])*>/gi;   
         elem.replace(regexp,'')  
        return elem;  
    }  

function linkcorpo()
	{  

		if ($.trim($('.PcorporateDiv div p').text())!='') {
			$('.PcorporateDiv div p').append('<span class="quoteEnd">&nbsp;</span>');
			$('.PcorporateDiv div p').prepend('<span class="quoteBegin">&nbsp;</span>');
		} else {
			$('.PcorporateDiv div p').hide();
		}
		$('.linkCorpo').each(
			function(i)
			{
				var newId=i;
				$(this).attr('id','linkCorpo'+newId);
				var nombreLiens = $('#linkCorpo'+newId+'.linkCorpo li').length;
				var longueur = $(this).width();
				$('#linkCorpo'+newId+'.linkCorpo li').each(
					function()
					{
						$(this).css('width',parseInt(((longueur-(10*(nombreLiens-1)))-(2*nombreLiens))/nombreLiens)+'px')

					}
				);
				$('#linkCorpo'+newId+'.linkCorpo li:last').addClass('last');
			}
		);
	}
	

function scrollFooter()
{
	// Toujours afficher le footer groupe en bas de page
	if(!$('#backgroundMain').hasClass('poping'))
	{
		$('body, html').css('overflow','hidden');
		//$('#backgroundMain').css({'height':($(window).height())-28+'px','width':($(window).width())+'px'});
		function resize_id(div_id){
			$(div_id).css({'height':($(window).height())-24+'px','width':($(window).width())+'px'});
			ajustFooter();
		}
		window.onresize = function() { resize_id('#backgroundMain') }
		resize_id('#backgroundMain');
	}
}

//Idem pour le bas de page
function ajustFooter()
{
	if ($('#twoThirdsRight').height()<($(window).height()-116) && $('.contentTabHomeRight').length==0)
	{
		$('#backgroundMain #mainContent').css('height',($(window).height()-116)+'px');
		//$('#mainContent').css('height',$('#leftCol').height()+'px');
	}
}
	
function validateform()
{
errMessage = $('#formErrorRequiredText').text();
if (errMessage == '')
	errMessage = "This field is required / Ce champ est obligatoire.";
	
jQuery.validator.messages.required = errMessage;
var rep=$('#reponse');
//$($('.input-submit')).append(rep);
$("#Formevol :input, #Formevol :textarea").each
		(
			function ()
			{
				inputClass=$(this).attr('class');
				if(inputClass =='required')
				{
					$("#Formevol").validate
						({
							rules: 
							{
								field: "required"
							},
							errorPlacement: function(error, element) {
								 if (element.attr("type") == "checkbox" || element.attr("type") == "radio" )
								   element.closest('div').append(error);
								 else
								   error.insertAfter(element);
						   }
						});
				}
			}
			
		)
$(".form-simple #formulaire :input, .form-simple #formulaire :textarea").each
		(
			function ()
			{
				inputClass=$(this).attr('class');
				if(inputClass =='required')
				{
					$("#formulaire").validate
						({
							rules: 
							{
							field: "required"
							},
						  errorPlacement: function(error, element) {
							 if (element.attr("type") == "checkbox" 
										 || element.attr("type") == "radio" )
							   element.closest('div').append(error);
							 else
							   error.insertAfter(element);
						   }
						});
				}
			}
			
		)	
		$("#formPAsAPAs :input, #formPAsAPAs :textarea").each
		(
			function ()
			{
				inputClass=$(this).attr('class');
				if(inputClass =='required')
				{
					//alert('ee');
					$("#formPAsAPAs").validate
						({
							rules: 
							{
							field: "required"
							},
						  errorPlacement: function(error, element) {
							 if (element.attr("type") == "checkbox" 
										 || element.attr("type") == "radio" )
							 {
							   element.closest('div').append(error);
							   $('.formBlock').hide();
							   $('label.error:first').closest('.formBlock').show();
							   if($('#expert').height()>$('#mainContent').height())
								{
									$('#backgroundMain').css({'overflow':'auto'});
									$('#mainContent').css({'height':'auto'});
								} else {
									ajustFooter();
									scrollFooter();
								}
							 } else {
							   error.insertAfter(element);
							   $('.formBlock').hide();
							   $('label.error:first').closest('.formBlock').show();
							   if($('#expert').height()>$('#mainContent').height())
								{
									$('#backgroundMain').css({'overflow':'auto'});
									$('#mainContent').css({'height':'auto'});
								} else {
									ajustFooter();
									scrollFooter();
								}
							 }
						   }
						});
				}
			}
			
		)
}
function addFav(){
	window.external.AddFavorite(location.href,"Intranet AREVA");
}

function setLanguage(lg){
	document.languageForm.L.value = lg;
	document.languageForm.submit();
}

/*function ssxiti(){}*/


// Alignement vertical en fonction du contenu des paragraphes :
function borderSectHaut()
{
	// CCX - Haut de page : Suppression des paragraphes vides.
	$('.sect-haut-text p').each(
		function()
		{	
			if($.trim($(this).text())=='')
				$(this).hide();
		}
	);

	if($('#sect-haut p').length>0&&$('#sect-haut h3').length==0)
	$('#sect-haut p').addClass('paddingZero');
}

// CCX : Pavé Standard : Cache le titre si il n'existe pas et ajoute des espaces insecable devant les
// liens afin de résoudre un bug sous IE avec les puces (le texte chevauche la puce).
function paveStandard()
{
	$('.paveStandard h3:has(span:empty)').hide();
	$('.paveStandard a:not(.autonomy_links, .mailto)').prepend('<span>&nbsp;&nbsp;&nbsp;</span>');
}

// PAragraphes avec image gauche :  adapter la largeur des liens en fonction de l'image
function paragrapheLinks()
{
	$('.paragraphe').each(
		function()
		{
			if($(this).find('ul').length>0 && $(this).find('p').length>0 && $.trim($(this).find('p').text())!='')
				$(this).find('ul').addClass('paddingTop');
		}
	);

}

var compteur = 1;
var totalItems;

function countNews(compteur)
{
	$('.listHome .listHomeControls .numberCont span:first').text(compteur)
}


function slideNews()
{
	if(compteur!=totalItems)
	{
		$('.listHome .homeListWrapper ul').animate({'left':(parseInt($('.listHome .homeListWrapper ul').css('left'))-544)+'px'},500);
		compteur++;
		//countNews(compteur)
	} else {
		$('.listHome .homeListWrapper ul').animate({'left':parseInt($('.listHome .homeListWrapper ul').css('left'))+(544*(totalItems-1))+'px'},500,(function()
		{
			transformNewsButton($('.listHome .listHomeControls #newsnext img'),'on');
			transformNewsButton($('.listHome .listHomeControls #newsprevious img'),'off');
		}));
			compteur = 1;
			//countNews(compteur)
	}
	if(compteur!=totalItems)
	{
		transformNewsButton($('.listHome .listHomeControls #newsprevious img'),'on');
		transformNewsButton($('.listHome .listHomeControls #newsnext img'),'on');
	} else {
		transformNewsButton($('.listHome .listHomeControls #newsnext img'),'off');
	}
}


function transformNewsButton(elem,state)
{
	if(state=='off'&&!elem.attr('src').match('_off'))
	{
		elem.attr('src',elem.attr('src').replace('.gif','_off.gif'));
	} else if(state=='on') {
		elem.attr('src',elem.attr('src').replace('_off.gif','.gif'));
	}
}

// Liste des news dfilantes sur la home :
function homeLinks()
{
	// Le dfilement est fix ici  6 secondes (6000 millisecondes) :
	var speed = 6000;
	totalItems = $('.listHome .homeListWrapper ul li').length;
	var monIntervalHome;
	$('.listHome .homeListWrapper ul').css('width',544*totalItems+'px');
		monIntervalHome=setInterval(
			function()
			{
				slideNews();
			},speed
		);
	$('.listHome .listHomeControls #newspause').click(function()
	{
		if($('.listHome .listHomeControls #newspause img').attr('src').match('_off'))
		{
			transformNewsButton($('.listHome .listHomeControls #newspause img'),'on');
			monIntervalHome=setInterval(
			function()
			{
				slideNews()
			},speed);
		} else {
			clearInterval(monIntervalHome);
			transformNewsButton($('.listHome .listHomeControls #newspause img'),'off');
		}
	});
	$('.listHome .listHomeControls #newsprevious').click(function()
	{
		if(!$('.listHome .homeListWrapper ul').is(':animated')&&compteur>1)
		{
			clearInterval(monIntervalHome);
			$('.listHome .homeListWrapper ul').animate({'left':(parseInt($('.listHome .homeListWrapper ul').css('left'))+544)+'px'},500);
			compteur--;
			//countNews(compteur)
			if(!$('.listHome .listHomeControls #newspause img').attr('src').match('_off'))
			{
				monIntervalHome=setInterval(
				function()
				{
					slideNews()
				},speed );
			}
			transformNewsButton($(this).find('img'),'on');
			if(compteur<totalItems)
			{transformNewsButton($('.listHome .listHomeControls #newsnext img'),'on');}
		}
		if(compteur==1)
		{
			transformNewsButton($(this).find('img'),'off');
		}
	});
	$('.listHome .listHomeControls #newsnext').click(function()
	{
		if(!$('.listHome .homeListWrapper ul').is(':animated')&&compteur<totalItems)
		{
			clearInterval(monIntervalHome);
			$('.listHome .homeListWrapper ul').animate({'left':(parseInt($('.listHome .homeListWrapper ul').css('left'))-544)+'px'},500);
			compteur++;
			//countNews(compteur)
			if(!$('.listHome .listHomeControls #newspause img').attr('src').match('_off'))
			{
				monIntervalHome=setInterval(
				function()
				{
					slideNews()
				},speed );
			}
			transformNewsButton($(this).find('img'),'on');
			if(compteur>1)
			{ transformNewsButton($('.listHome .listHomeControls #newsprevious img'),'on'); }
		}
		if(compteur==totalItems)
		{
			transformNewsButton($(this).find('img'),'off');
		}
	});
	//countNews(compteur);
	$('.listHome .listHomeControls .numberCont span:last').text(totalItems)
	
	// Ajustement des deux blocs de la home
	if($('.contentTabHomeLeft').height()<$('.contentTabHomeRight').height()-27)
	{
		$('.contentTabHomeLeft').css('height',($('.contentTabHomeRight').height()-27)+'px');
	} else if($('.contentTabHomeRight').height()-27<$('.contentTabHomeLeft').height())
	{
		$('.contentTabHomeRight').css('height',($('.contentTabHomeLeft').height()+27)+'px');
	}
}


function changeContent(idElem,elem)
{
	$('#'+idElem+'.ongletsStandards .contentTabStandard').hide();
	$('#'+idElem+'.ongletsStandards .contentTabStandard').each(
		function(i,e)
		{
			if(i==elem)
			{
				$(this).show();
				if($(this).height()+$('#'+idElem+'.ongletsStandards .tabContainer').height()>($('#twoThirdsRight').height()-($('#sect-haut').height()+$('#sect-bas').height()) ))
				{
					$('#backgroundMain').css({'overflow':'auto'});
					$('#mainContent').css({'height':'auto'});
				} else {
					ajustFooter();
					scrollFooter();
				}
			}
			else
			{
				$(this).hide();
				/*resize_id('#backgroundMain')
				ajustFooter();*/
			}
		}
	)
}

function changeHiddenContent(idElem,elem)
{
	$('#'+idElem+'.ongletsInvisibles .contentTabInvisible').each(
		function(i,e)
		{
			if(i==elem)
			{
				$(this).show();
			}
			else
			{
				$(this).hide();
			}
		}
	)
	/* FIX CCX Ticket  10215 - 922  */				
	if($('#expert').height()>$('#mainContent').height())
	{
		$('#backgroundMain').css({'overflow':'auto'});
		$('#backgroundMain').css({'overflow-x':'hidden'});
		$('#mainContent').css({'height':'auto'});
	} else {
		ajustFooter();
		scrollFooter();
	}
}

function changeContentFrise(idElem,elem)
{
	$('#'+idElem+'.ongletsFrise .contentTabStandardFrise').each(
		function(i,e)
		{
			if(i==elem)
			{
				$(this).show();
			}
			else
			{
				$(this).hide();
			}
		}
	)
}

function testOnglet(idbrique, identifiant){
	idbrique = 'StandardTabsNewId' + (idbrique -1)
	//$('#'+idbrique).hide();
	$('#'+idbrique+' .contentTabStandard').each(
		function(i,e)
		{
			if(i==identifiant)
			{
				$(this).show();
			}
			else
			{
				$(this).hide();
			}
		}
	)
}

function ChangeOnglet(idbrique, identifiant){
	identifiant = identifiant -1
	var newId = $('ul[class*=brick_' + idbrique + ']').attr('id');
	if (newId.indexOf("StandardTabs") != -1) {
		$('#'+newId+' li .labelInline').removeClass('active');
		$('#'+newId+' .contentTabStandard').hide();
		$('#'+newId+'.ongletsInvisibles .contentTabInvisible').hide();
		$('#'+newId+' li .labelInline:eq('+identifiant+')').addClass('active');
		$('#'+newId+' .contentTabStandard:eq('+identifiant+')').show();
		$('#'+newId+'.ongletsInvisibles .contentTabInvisible:eq('+identifiant+')').show();
	} else if (newId.indexOf("inlineTabsNew") != -1) {
		$('#'+newId+'.ongletsLigne .contentTabInline').hide();
		$('#'+newId+'.ongletsLigne .contentTabInline:eq('+identifiant+')').show();
		$('#'+newId+'.ongletsLigne li h2:eq('+identifiant+')').addClass('active');
	} else if (newId.indexOf("FriseTabsNew") != -1) {
		$('#'+newId+'.ongletsFrise .contentTabStandardFrise').hide();
		$('#'+newId+'.ongletsFrise .contentTabStandardFrise:eq('+identifiant+')').show();
		$('#'+newId+'.ongletsFrise li .labelInline').removeClass('active');
		$('#'+newId+'.ongletsFrise li .labelInline:eq('+identifiant+')').addClass('active');
		var largeurTotale = $('#'+newId+'.ongletsFrise .tabContainerFrise').width();
		var largeurCache = $('#'+newId+'.ongletsFrise .carrousel-conteneur').width();
		var tab = $('.labelInline:eq('+identifiant+')');
		var position = tab.position();
		if (position.left > parseInt(largeurTotale-largeurCache)) {
			$('#'+newId+'.ongletsFrise .tabContainerFrise').css({'margin-left':'-'+parseInt(largeurTotale-largeurCache)+'px'});
		} else if (position.left < largeurCache) {
		} else {
			$('#'+newId+'.ongletsFrise .tabContainerFrise').css({'margin-left':'-'+position.left+'px'});
		}
	}
	/* FIX CCX Ticket  10215 - 922  */				
	if($('#expert').height()>$('#mainContent').height())
	{
		$('#backgroundMain').css({'overflow':'auto'});
		$('#backgroundMain').css({'overflow-x':'hidden'});
		$('#mainContent').css({'height':'auto'});
	} else {
		ajustFooter();
		scrollFooter();
	}
}

function voirBlabla(identifiant, idbrique){
	idbrique = 'StandardTabsNewId' + (idbrique -1)
	// alert(idbrique)
	identifiant = identifiant - 1 ;
	changeHiddenContent(idbrique,identifiant);
}

function ChangeTab(idbrique, identifiant){
	idbrique = 'StandardTabsNewId' + (idbrique -1)
	identifiant = identifiant - 1 ;
	changeHiddenContent(idbrique,identifiant);
}

function initTabs()
{
	var bOpenPreciseTab;
	var openTabNumber;
	var id_cat = $('.ongletsStandards:first').attr("id");
	var id_catTab = id_cat.split(".")[0];
	var id_catNum = id_cat.split(".")[1];

	$('.ongletsStandards').each
	(
		function(i,e)
		{
			bOpenPreciseTab = false;
			openTabNumber = '';
			
			// On attribue une id diffrente pour chaque groupe d'onglets
			var newId = 'StandardTabsNewId'+i;
			$(this).attr({id:newId});
				
			// La classe 'active' sert pour l'onglet en cours
			
			if (id_catTab != "" && id_catNum != "" && $(this).hasClass('brick_'+id_catTab)) {
				bOpenPreciseTab = true;
				openTabNumber = id_catNum-1;
			}
			// Si pas de choix d'ouverture d'onglet on activ seulement le premier onglet et on l'affiche
			if (!bOpenPreciseTab) {
				$('#'+newId+'.ongletsStandards li .labelInline:first').addClass('active');
				$('#'+newId+'.ongletsStandards .contentTabStandard').hide();
				$('#'+newId+'.ongletsStandards .contentTabStandard:first').show();
			}

			$(this).prepend('<li class="tabContainer"></li>');
			var largeurTotale=0;
			$('#'+newId+'.ongletsStandards li .labelInline').each
			(
				function(i,e)
				{
					//on verifie quel onglet doit être affiché et on cache les autres
					if (bOpenPreciseTab && i == openTabNumber) {	// si param ID_CAT passé et qui i = param 
						$('#'+newId+'.ongletsStandards .contentTabStandard').hide();
						$(this).addClass('active');
						$('#'+newId+'.ongletsStandards .contentTabStandard:eq('+i+')').show();
					}
					
					// On change de place les onglets dans le flux HTML
					var changeFlux = $(e).after($('#'+newId+'.ongletsStandards li .labelInline')[i+1]);
					$('#'+newId+'.ongletsStandards .tabContainer').append(changeFlux);
					$(this).click(
						function()
						{
							// On change le classe active au clic
							$('#'+newId+'.ongletsStandards li .labelInline').removeClass('active');
							$(this).addClass('active');
							// appel pour afficher/masquer le contenu
							changeContent(newId,i);
						}
					);
					largeurTotale+=($(this).width()+21);
				}
			);
			if(largeurTotale>(($(this).width()/100)*95))
			{
				var newLargeur = ($(this).width()/100)*95;
				var countItems = $('#'+newId+'.ongletsStandards li .labelInline').length;
				$('#'+newId+'.ongletsStandards li .labelInline').each(
					function()
					{
						$(this).css('width',parseInt((newLargeur-(16*countItems+(5*(countItems-1))))/countItems)+'px')
					}
				);
			}
		}
	)
}

function initHiddenTabs()
{
	var bOpenPreciseTab;
	var openTabNumber;
	var id_cat = $('.ongletsInvisibles:first').attr("id");
	var id_catTab = id_cat.split(".")[0];
	var id_catNum = id_cat.split(".")[1];

	$('.ongletsInvisibles').each
	(
		function(i,e)
		{
			bOpenPreciseTab = false;
			openTabNumber = '';
			
			// On attribue une id diffrente pour chaque groupe d'onglets
			var newId = 'StandardTabsNewId'+i;
			$(this).attr({id:newId});
			
			if (id_catTab != "" && id_catNum != "" && $(this).hasClass('brick_'+id_catTab)) {
				bOpenPreciseTab = true;
				openTabNumber = id_catNum-1;
			}
			// Si pas de choix d'ouverture d'onglet on activ seulement le premier onglet et on l'affiche
			$('#'+newId+'.ongletsInvisibles .contentTabInvisible').hide();
			if (!bOpenPreciseTab) {
				$('#'+newId+'.ongletsInvisibles .contentTabInvisible:first').show();
			} else {
				$('#'+newId+'.ongletsInvisibles .contentTabInvisible:eq('+openTabNumber+')').show();
			}

			$(this).prepend('<li class="tabContainer"></li>');
			var largeurTotale=0;

			//$('#'+newId+'.ongletsInvisibles li .labelInline').each
			/*$('#'+newId+'.ongletsInvisibles li').each
			(
				
				function(i,e)
				{
					alert("!!!!");
					//on verifie quel onglet doit être affiché et on cache les autres
					if (bOpenPreciseTab && i == openTabNumber) {	// si param ID_CAT passé et qui i = param 
						alert ("....");
						$('#'+newId+'.ongletsInvisibles .contentTabInvisible').hide();
						//$(this).addClass('active');
						$('#'+newId+'.ongletsInvisibles .contentTabInvisible:eq('+i+')').show();
					}				
				
					// On change de place les onglets dans le flux HTML
					var changeFlux = $(e).after($('#'+newId+'.ongletsInvisibles li')[i+1]);
					$('#'+newId+'.ongletsInvisibles .tabContainer').append(changeFlux);
					$(this).click(
						function()
						{
							// On change le classe active au clic
							$('#'+newId+'.ongletsInvisibles li').removeClass('active');
							$(this).addClass('active');
							// appel pour afficher/masquer le contenu
							changeHiddenContent(newId,i);
						}
					);
					largeurTotale+=($(this).width()+21);
				}
			);
			*/
			/*if(largeurTotale>(($(this).width()/100)*95))
			{
				var newLargeur = ($(this).width()/100)*95;
				var countItems = $('#'+newId+'.ongletsInvisibles li').length;
				$('#'+newId+'.ongletsInvisibles li').each(
					function()
					{
						$(this).css('width',parseInt((newLargeur-(16*countItems+(5*(countItems-1))))/countItems)+'px')
					}
				);
			}*/
		}
	)
}

// Accordion jquery javascript
function initTabsInline()
{
	var bOpenPreciseTab;
	var openTabNumber;
	var id_cat = $('.ongletsLigne:first').attr("id");
	var id_catTab = id_cat.split(".")[0];
	var id_catNum = id_cat.split(".")[1];
	
	$('ul.ongletsLigne').each
	(
		function(i,e)
		{
			bOpenPreciseTab = false;
			openTabNumber = '';		
		
			// On attribue une id diffrente pour chaque groupe d'onglets
			var newId = 'inlineTabsNewId'+i;
			$(this).attr({id:newId});
			
			if (id_catTab != "" && id_catNum != "" && $(this).hasClass('brick_'+id_catTab)) {
				bOpenPreciseTab = true;
				openTabNumber = id_catNum-1;
			}
			
			$('#'+newId+'.ongletsLigne .contentTabInline').hide();
			
			if (bOpenPreciseTab) {
				$('#'+newId+'.ongletsLigne .contentTabInline:eq('+openTabNumber+')').show();
				$('#'+newId+'.ongletsLigne li h2:eq('+openTabNumber+')').addClass('active');
			} else {
				// realise un test pour fermer ou non le premier onglet
				if ($(this).hasClass("close"))
				{
					$('#'+newId+'.ongletsLigne .contentTabInline:first').hide();
				} else {
					$('#'+newId+'.ongletsLigne .contentTabInline:first').show();
					$('#'+newId+'.ongletsLigne li h2:first').addClass('active');
				}
			}

			$('#'+newId+'.ongletsLigne li h2').click(
				function()
				{
					$('#'+newId+'.ongletsLigne li h2').removeClass('active');
					$(this).addClass('active');
					var checkElement = $(this).next();
					if((checkElement.is('#'+newId+'.ongletsLigne .contentTabInline')) && (checkElement.is(':visible')))
					{
						$(this).removeClass('active');
						$('.subFooter, .subFooterLogo').hide();
						$('#'+newId+'.ongletsLigne .contentTabInline:visible').slideUp('normal',
							function()
							{
								$('.subFooter, .subFooterLogo').show();
								ajustFooter();
								scrollFooter();
							}
						);
					}
					if((checkElement.is('#'+newId+'.ongletsLigne .contentTabInline')) && (!checkElement.is(':visible')))
					{
						$('#'+newId+'.ongletsLigne .contentTabInline:visible').slideUp('normal');
						checkElement.slideDown('normal',
							function()
							{
								if($('#expert').height()>$('#mainContent').height())
								{
									//$('body, html').css('overflow','auto');
									$('body').css({'overflow':'auto'});
									$('#mainContent').css({'height':'auto'});
								} else {
									ajustFooter();
									scrollFooter();
								}
							}
						);
						return false;
					}
				}
			);
		}
	);
}

function sitemap()
{
	$('#sitemap .sitemapWrapper .mapItem').bind('click',
		function scrollSiteMap()
		{
			var content = $(this).next();
			if(!content.is(':visible'))
			{
				content.show();
				$(this).find('h2').addClass('active');
			}else if(content.is(':visible'))
			{
				content.hide();
				$(this).find('h2').removeClass('active');
			}
		}
	);
	$('#sitemap .sitemapWrapper .sitemapWrapper .mapItem').unbind();
}


//frise 

	var CptFrise = 0; 
	function initTabsfrise()
	{
		var bOpenPreciseTab;
		var openTabNumber;
		var id_cat = $('.ongletsFrise:first').attr("id");
		var id_catTab = id_cat.split(".")[0];
		var id_catNum = id_cat.split(".")[1];
	
		$('.ongletsFrise').each
		(
			function(i,e)
			{
				// On attribue une id diffrente pour chaque groupe d'onglets
				var newId = 'FriseTabsNewId'+i;
				$(this).attr({id:newId});
				
				if (id_catTab != "" && id_catNum != "" && $(this).hasClass('brick_'+id_catTab)) {
					bOpenPreciseTab = true;
					openTabNumber = id_catNum-1;
				}
				
				$('#'+newId+'.ongletsFrise .contentTabStandardFrise').hide();
				if (bOpenPreciseTab) {
					$('#'+newId+'.ongletsFrise .contentTabStandardFrise:eq('+openTabNumber+')').show();
					currentel=$('#'+newId+'.ongletsFrise li .labelInline:eq('+openTabNumber+')').addClass('active');
				} else {
					//alert("???");
					$('#'+newId+'.ongletsFrise .contentTabStandardFrise:first').show();
					currentel=$('#'+newId+'.ongletsFrise li .labelInline:first').addClass('active');
				}
				
				$(this).prepend('<li class="tabContainerFrise"></li>');
				//$('.ongletsFrise li .labelInline').css('position','absolute');
				//$('#'+newId+'.ongletsFrise li .labelInline').css('position','absolute');
				var listeSize =  $('.ongletsFrise li .labelInline').length;
				if (listeSize>1)
				{
					$('<li class="navprev"><span class="cell"><a href="#"></a></span></li>').insertBefore('.tabContainerFrise');
					$('<li class="navnext"><span class="cell"><a href="#"></a></span></li>').insertAfter('.tabContainerFrise');
					$(".navprev,.tabContainerFrise,.navnext").wrapAll('<div class="friseList"></div>') 
				}
				else
				{
					$('.ongletsFrise li .labelInline').addClass('single');
				}
				var newLongueur = 0;
				$('#'+newId+'.ongletsFrise li .labelInline').each
				(
					function(i,e)
					{
						// On change de place les onglets dans le flux HTML
						var changeFlux = $(e).after($('#'+newId+'.ongletsFrise li .labelInline')[i+1]);
						$('#'+newId+'.ongletsFrise .tabContainerFrise').append(changeFlux);
						//$(this).css('left',(newLongueur)+'px')
						$(this).click(
							function()
							{
								// On change le classe active au clic
								$('#'+newId+'.ongletsFrise li .labelInline').removeClass('active');
								 currentel=$(this).addClass('active');
								 var index = $(".tabContainerFrise h2").index(this);
								// appel pour afficher/masquer le contenu
								CptFrise=index;
								changeContentFrise(newId,i);
								return currentel;
								
							}
						);
						newLongueur+=($(this).width());
					}
				);
				$('#'+newId+'.ongletsFrise .tabContainerFrise').css('width',(newLongueur+(60*listeSize))+'px')
				
				// Ciblage de la bande de diapositives 
				$('#'+newId+'.ongletsFrise .tabContainerFrise').wrap('<div class="carrousel-conteneur"></div>')
				var largeurTotale = $('#'+newId+'.ongletsFrise .tabContainerFrise').width();
				var largeurCache = $('#'+newId+'.ongletsFrise .carrousel-conteneur').width();
			
				//Carousel
				$('#'+newId+'.ongletsFrise .navprev .cell a').mouseover
				(
					function()
					{
						var containerMarginLeft = parseInt($('#'+newId+'.ongletsFrise .tabContainerFrise').css('margin-left'));	
						alwaysMoveRight = setInterval
						(
							function()
							{
								if(parseInt($('#'+newId+'.ongletsFrise .tabContainerFrise').css('margin-left'))<0)
								{
									$('#'+newId+'.ongletsFrise .tabContainerFrise').css({'margin-left':parseInt($('#'+newId+'.ongletsFrise .tabContainerFrise').css('margin-left'))+10+'px'})
								}
							}
							,1
						);
					$('#'+newId+'.ongletsFrise .navprev .cell a').mouseout
						(
							function()
							{
								clearInterval(alwaysMoveRight);
							}
						);
					});	
					$('#'+newId+'.ongletsFrise .navnext .cell a').mouseover(function()
					{
						var containerMarginLeft = parseInt($('#'+newId+'.ongletsFrise .tabContainerFrise').css('margin-left'));	

							alwaysMoveLeft = setInterval
							(
								function()
								{
									if(parseInt($('#'+newId+'.ongletsFrise .tabContainerFrise').css('margin-left'))>-parseInt(largeurTotale-largeurCache))
									{
										$('#'+newId+'.ongletsFrise .tabContainerFrise').css({'margin-left':parseInt($('#'+newId+'.ongletsFrise .tabContainerFrise').css('margin-left'))-10+'px'}) 
									}
										
								}
								,1
							);
						$('#'+newId+'.ongletsFrise .navnext .cell a').mouseout
						(
							function()
							{
								clearInterval(alwaysMoveLeft);
							}
						);
					}
				);
				if (bOpenPreciseTab) {
					var tab = $('.labelInline:eq('+openTabNumber+')');
					var position = tab.position();
					if (position.left > parseInt(largeurTotale-largeurCache)) {
						$('#'+newId+'.ongletsFrise .tabContainerFrise').css({'margin-left':'-'+parseInt(largeurTotale-largeurCache)+'px'});
					} else if (position.left < largeurCache) {
					} else {
						$('#'+newId+'.ongletsFrise .tabContainerFrise').css({'margin-left':'-'+position.left+'px'});
					}
				}
			}
		)
	}



function listeOrder()
{	
		$('.listContent dl').css("display","none");
		$('.listContent .listItemAlpha').each
		(
			function (i)
			{
				
				var listId=$(".indexLetter:eq("+i+")").text();
				if (/[^a-z]/gi.test(listId))  {
				var newId='listAll';				
				$(this).attr({id:newId});
				$('.listMainAlpha .indexList ul li #list').addClass("active");
				} 
				else
				{
				var newId='list'+listId;
					$(this).attr({id:newId});
				}				
				$('.listContent dl:first').css("display","block");
				var Id=$('.listContent dl:first').attr("id");
				$('.listMainAlpha .indexList #'+Id).addClass("active");
			}
		)
		
		$('.listMainAlpha .indexList ul li a').click
			(
			function()
				{
					$('.listContent dl').css("display","none");
					$('.listMainAlpha .indexList .active').removeClass("active");
					var Id2=$(this).attr("id");	
						if (Id2 == 'list')  {
						$(this).addClass("active");
						$('#listAll').css("display","block");
						}
						else
						{
						$(this).addClass("active");
						$('.listContent #list'+Id2).css("display","block");
						/*alert($('.listContent dl#'+Id2).text());*/	
						}
				}
			
			)

}

function animateResults(){  

$('.globalresults').append('<div class="testpos"></div>');


	$(".resultPercent div").each
		   (
			   function(i)
				{ 
				   var percentage = $(this).text(); 
				   var newId = 'color'+i%3;//modulo 3
				   var newIdT = 'result'+i;
				   $('.testpos:eq('+i+')').attr({id:newIdT});
				   $(this).attr({id:newId});
				   $(".resultPercent").each(function(e){
				   var newId2 = 'backcolor'+e%3;
				   $(this).attr({id:newId2});
				   });
				   $(this).css({width: "0%"}).animate({  
							 width: percentage}, 'slow'); 


				}
			);


	$('.percent span').each
	(		
		function (e)
		{
			var newId = 'colorspan'+e; 
			$(this).attr({id:newId});
			var Id1=$('#result'+e);
			var Id2=$('#colorspan'+e);
			$(Id1).append(Id2);
			var newIdSpan = 'colorspan'+e%3; 
			$('.testpos:eq('+e+') span').attr({id:newIdSpan});
		}

	);



}

//Variables pour formulaires
var NbElement;
var Cpt;

function formStep ()
{
	// plugin
	(function($){
		$.fn.nextUntill = function(expr){
			var helpFunction = function($obj, expr){
				var $siblings = $obj.nextAll();
				var end = $siblings.index( $siblings.filter(expr) );
				if(end===-1) return $([]);
				return $siblings.slice(0, end);
			}
			var retObject = new Array();
			this.each(function(){
				$.merge(retObject, helpFunction($(this), expr));
			});
			return $(retObject);
		}
	})(jQuery);
			// alert("DEBUG SCWA en cours ...");
$('.formstep').each
	(
		function (i,a)
		{
			newId="formStep"+i;
			$(this).attr({id:newId});
		
			$(this).find('h3').each
			(			
				function (j,a)
				{
					newId="formTitle"+i+"-"+j;
					$(this).attr({id:newId});
					current=$(this).nextUntill('h3');
					title=current.prev();
					current.wrapAll('<div class="formBlock"></div>') ;			
				}
			)
			
			$(this).find('.formBlock').each
			(
				function(j)
				{
					Title=$('#formStep'+i+'.formstep h3:eq('+j+')');
					$(this).prepend(Title);
				}
			)
			
			currentH3=$('#formStep'+i+'.formstep h3:last');
			divcurrent=$(currentH3).nextUntill('#formStep'+i+' .input-submit');
			currentH3.wrapAll('<div class="formBlock"></div>') ;
			
			lastBlock=$('#formStep'+i+' .formBlock:last');
			$(lastBlock).append(divcurrent);

			answerNav=$('<div class="answerNav"><a class="prevQuest" href="#">< '+$(this).find('#navPrevious').html()+'</a><a class="nextQuest" href="#">'+$(this).find('#navNext').html()+' ></a><div class="clear"></div></div>');
			$('#formStep'+i+' .formBlock').append(answerNav);
			$('#formStep'+i+' .formBlock:first .answerNav .prevQuest').remove();
			$('#formStep'+i+' .formBlock:last .answerNav .nextQuest').remove();
			$('#formStep'+i+' .formBlock:last .answerNav').addClass('lastNav').prepend($(this).find('#button'));
			blockSubmit=$('#formStep'+i+' .input-submit');			
			blockSubmit.hide();
			
			$('#formStep'+i+' .formBlock').hide();
			$('#formStep'+i+' .formBlock:first').show();
			var NbElement = $('#formStep'+i+' h3').length;
			var Cpt=0;
			$('#formStep'+i+' .nextQuest').click(function()
				{
					/*var current = $(".formBlock:eq("+Cpt+")");	
					 if(Cpt < (NbElement-1) ) 
						{ 
							current.hide();
							Cpt++; 
							var nexth = current.next();
							current = $(nexth);
							current.show();											
						}*/
						$(this).closest(".formBlock").hide().next(".formBlock").show();
						/* FIX CCX Ticket  10215 - 922  */				
						if($('#expert').height()>$('#mainContent').height())
						{
							$('#backgroundMain').css({'overflow':'auto'});
							$('#mainContent').css({'height':'auto'});
						} else {
							ajustFooter();
							scrollFooter();
						}
						return false;
				});
		
			$('#formStep'+i+' .prevQuest').click(function()
				{
					/*var current = $(".formBlock:eq("+Cpt+")");				
					if(Cpt > 0) 
					{ 
						current.hide();
						Cpt--; 
						 var nexth = current.prev();
						current = $(nexth);
						current.show();								
					}*/
					$(this).closest(".formBlock").hide().prev(".formBlock").show();
					/* FIX CCX Ticket  10215 - 922  */				
					if($('#expert').height()>$('#mainContent').height())
					{
						$('#backgroundMain').css({'overflow':'auto'});
						$('#mainContent').css({'height':'auto'});
					} else {
						ajustFooter();
						scrollFooter();
					}						
						return false;
				});			
		}
	)	
}
function ListPress()
{
	var newId = 0;
	$('.listMainPress').each(
		function(i)
		{
		newId=i;
		$(this).attr('id','listMainPress'+newId);
		$('#listMainPress'+newId+' .listItemPress').hide();
		$('#listMainPress'+newId+'.listMainPress').append('<select name="synthese'+newId+'" class="synthList"></select>')
//$('<p class="synthDate"><a href=#>Retrouvez ici la dernire synthse de presse du</a></p>').insertBefore('.listPressTitle');
update=$('<span class="updateDate"></span>');
$('#listMainPress'+newId+' .listLink li a').append(update);
	function updateDate(str,valeur)
	{
		$("#listMainPress"+newId+" .updateDate").text(' '+str);
		$("#listMainPress"+newId+" .listLink li a").attr('href',valeur)
	}

	$('#listMainPress'+newId+' .listItemPress a').each
	(
		function ()
		{
			list_text   = $(this).text();		
			list_value  =  $(this).attr('href');
			$("#listMainPress"+newId+" select[name='synthese"+newId+"']").append('<option value="'+list_value+'">'+list_text+'</option>');
		}
	)
	updateDate($("#listMainPress"+newId+" select option:first").text(),$("#listMainPress"+newId+" select option:first").attr('value'))
		
	 $("#listMainPress"+newId+" select").change(function () {
         document.location=this.value;
        })
        //.trigger('change');
	
	});
}





function listLinksSelect()
{
	var newId = 0;
	$('.PlistLink').each(

		function(i)
		{
		newId=i;
		$(this).attr('id','PlistLink'+newId);
		$('.PlistLinkList').hide();
		$('<select name="synthese'+newId+'" class="synthList"></select>').insertBefore('#PlistLink'+newId+' .PlistLinkList')


	$('#PlistLink'+newId+' .PlistLinkList li a').each
	(
		function (i)
		{
			var list_text   = $(this).text();		
			var list_value  = $(this).attr('href');
			$('select[name="synthese'+newId+'"]').append('<option value="'+list_value+'">'+list_text+'</option>');
						//alert('');
		}
	);
		
	 $(".listLink select, .PlistLink select").change(function() {
         window.location.href=this.value;
		});
	});
}

// Galerie par dfaut
function organizeGallery()
{
	if($('.galleryContainer').length!=0)
	{
		var nombreDefilements = $('.galleryInner').length;
		$('.galleryWrapper').css({'width':(570*nombreDefilements)+'px'})
		var colLength = $('.gallerySuiteContainer:first .galleryItem').length;
		$('.galleryInner').each(
			function(i,e)
			{
				$(this).addClass('float').addClass('numberCols'+colLength);
				
			}
		);

		var count = 0;
		function enableDisableButtons()
		{
			if(count>0)
			{
				$('.galleryContainer .btnGalLeft').removeClass('disabled');
			}
			else
			{
				$('.galleryContainer .btnGalLeft').addClass('disabled');
			}
			if(count<(nombreDefilements-1))
			{
				$('.galleryContainer .btnGalRight').removeClass('disabled');
			}
			else
			{
				$('.galleryContainer .btnGalRight').addClass('disabled');
			}
		}
		$('.galleryContainer .btnGalLeft').click(
			function()
			{
				if(parseInt($('.galleryWrapper').css('margin-left'))<0&&!$('.galleryWrapper').is(':animated'))
				{
					count=count-1;
					$('.galleryWrapper').animate
					(
						{
							marginLeft: (parseInt($('.galleryWrapper').css('margin-left'))+500)+'px'
						},
						1500
					);
					enableDisableButtons();
				}
			}
		);
		$('.galleryContainer .btnGalRight').click(
			function()
			{
				if(parseInt($('.galleryWrapper').css('margin-left'))>-(500*(nombreDefilements-1))&&!$('.galleryWrapper').is(':animated'))
				{
					count=count+1;
					$('.galleryWrapper').animate
					(
						{
							marginLeft: (parseInt($('.galleryWrapper').css('margin-left'))-500)+'px'
						},
						1500
					);
					enableDisableButtons();
				}
			}
		);
		enableDisableButtons()
		$('.btnGalleryContainer').css('padding',($('.galleryContainer').height()/2-26) + 'px 0 0');
	}
}

//Adapter le conteneur au format de l'image
function adapteConteneur(e)
	{
		if(e.width()>=e.height())
		{
			$('.mainImageContainer').addClass('paysage').removeClass('portrait');
		}else{
			$('.mainImageContainer').addClass('portrait').removeClass('paysage');
		}
	}


// Changer l'image centrale
function changeImage(i,e)
{

		newSrc = (e.attr('src')).replace('/miniature/','/');
		newAlt = e.attr('alt');
		newLegend= e.attr('title');
		if(i==0)
		{
			$('.galHorSupBtnLeft').addClass('disabled');
			$('.galHorSupBtnRight').removeClass('disabled');
		} else {
			$('.galHorSupBtnLeft').removeClass('disabled');
		}
		if(i==($('.listingContainer img').length-1))
		{
			$('.galHorSupBtnRight').addClass('disabled');
			$('.galHorSupBtnLeft').removeClass('disabled');
		} else {
			$('.galHorSupBtnRight').removeClass('disabled');
		}
		$('.mainImageContainer .mainImage').fadeOut(
		1000,
		function()
		{
			$(this).remove();
			var loadingImage = setTimeout(function(){
				$('.mainImageContainer').css({'background-image': 'url(/lib_central/images/ACTIV/common/lightbox-ico-loading.gif)','background-repeat':'no-repeat','background-position:':'50% 50%'});
			},200);
			$('<img src="'+newSrc+'" alt="'+newAlt+'" class="mainImage" />').prependTo('.mainImageContainer');
			$('.mainImageContainer .mainImage').hide();
			$('.mainImageContainer .mainImage').load(
				function()
				{
					if($(this).width()>400)
					{
						$(this).attr('width','400');
					} else {
						$(this).attr('width',$(this).width());
					}
					$('.mainImageContainer').animate({'height':$(this).height()},500);
					clearTimeout(loadingImage);
					$('.mainImageContainer').css({'background-image':'none'});
					$(this).fadeIn(1000);
					adapteConteneur(e);
				}
			);
			$('.imgLegend dt').text(newAlt);
			$('.imgLegend dd').text(newLegend);
			$('.downloadImage a').attr({'href':newSrc})
			
		});
}

function slideSwitch() {
    var $active = $('.viewAreaImage div.active');
    if ( $active.length == 0 ) $active = $('.viewAreaImage div:last');

    var $next =  $active.next().length ? $active.next()
        : $('.viewAreaImage div:first');
	
	$active.fadeOut(1000, function() {
		$active.removeClass('active').addClass('hidden');
		$next.removeClass('hidden').addClass('active');
	});
}


//Galerie horizontale
function organizeHorizontalGallery()
{
	if($('.horizontalGallery').length!=0)
	{
		if($('.horizontalGallery.popin').length!=0) {
			// http://jonraasch.com/blog/a-simple-jquery-slideshow
			$('.viewAreaImage img').each(
				function(i,e) {
					var URL = ($('.viewAreaImage img')[i].src).replace('/miniature/','/');
					$('.viewAreaImage img').eq(i).attr({'src':URL});
				}
			)
			$('.horizontalGallery.popin .viewArea .viewAreaImage').css({'width':'100%'});
			$('.viewAreaImage div:first').removeClass('hidden').addClass('active');
			setInterval( "slideSwitch()", 5000 );
		} else {
			// Dfinir l'image par dfaut
			var firstURL = ($('.listingContainer img')[0].src).replace('/miniature/','/');
			var firstDescr = $('.listingContainer img')[0].alt;
			var firstLegend = $('.listingContainer img')[0].title; 
			$('.mainImageContainer .mainImage').attr({'src':firstURL,'alt':firstDescr});
			$('.downloadImage a').attr({'href':firstURL})
			$('.imgLegend dt').text(firstDescr);
			$('.imgLegend dd').text(firstLegend);
			$('.listingContainer').css({'width':(parseInt($('.listingContainer img').length)*150)+4+'px'})
			$('.horizontalGallery .imgContainerTop').css({'float':'left'});
			$('.horizontalGallery .imgContainerTop a').attr('href','javascript:;');
			$('.listingContainer img:first').addClass('active');
			$('.galHorSupBtnLeft').addClass('disabled');
			$('.mainImageContainer .mainImage').load(
				function()
				{
					$('.mainImageContainer').css({
						'height':$('.mainImageContainer .mainImage:first').height()
					})
				}
			);
			adapteConteneur($('.listingContainer img:first'));
		}
		
		
		// Dfilement horizontal
		$('.galHorBtnLeft').mouseover(
			function()
			{
				monInterval=setInterval(
					function()
					{
						if (parseInt($('.listingContainer').css('left'))<0)
						{
								$('.listingContainer').css({'left':parseInt($('.listingContainer').css('left'))+5+"px"});
						}else{
							clearInterval(monInterval);
						}
					},
					15
				);
			}
		);
		$('.galHorBtnLeft').mouseout(
			function()
			{
				clearInterval(monInterval);
			}
		);
		
		$('.galHorBtnRight').mouseover(
			function()
			{
				monInterval=setInterval(
					function()
					{
						taille = parseInt($('.listingContainer').css('width'));
						if (parseInt($('.listingContainer').css('left'))>(-taille+500))
						{
								$('.listingContainer').css({'left':parseInt($('.listingContainer').css('left'))-5+"px"});
						}else{
							clearInterval(monInterval);
						}
					},
					15
				);
			}
		);
		$('.galHorBtnRight').mouseout(
			function()
			{
				clearInterval(monInterval);
			}
		);
		
		// Changer l'image centrale au clic sur les miniatures
		$('.listingContainer img').each(
			function(i,e)
			{
				$(this).click(
					function()
					{
						if(!$('.mainImageContainer .mainImage').is(':animated'))
						{
							$('.listingContainer img').removeClass('active');
							changeImage(i,$(this));
							$(this).addClass('active');
						}
					}
				);
			}
		);
		
		//Changer l'image centrale au clic sur les boutons gauche/droite
		$('.galHorSupBtnLeft').click(
			function()
			{
				var imageIndex = 0;
				$('.listingContainer img').each(
					function(i,e)
					{
						if(i!=0&&!$('.mainImageContainer .mainImage').is(':animated'))
						{
							if($(e).hasClass('active'))
							{
								imageIndex = i-1;
								$('.listingContainer img').each(
									function(i,e)
									{
										if(i==imageIndex)
										{
											$('.listingContainer img').removeClass('active');
											$(e).addClass('active');
											changeImage(i,$(e));
										}
									}
								);
							}
						}
					}
				);
			}
		);
		$('.galHorSupBtnRight').click(
			function()
			{
				var imageIndex = 0;
				$('.listingContainer img').each(
					function(i,e)
					{
						if(i!=$('.listingContainer img').length&&!$('.mainImageContainer .mainImage').is(':animated'))
						{
							if($(e).hasClass('active'))
							{
								imageIndex = i + 1
							}
							if(i!=0&&i==imageIndex)
							{
								$('.listingContainer img').removeClass('active');
								$(e).addClass('active');
								changeImage(i,$(e));
							}
						}
					}
				);
			}
		);
	}	
}



function check(){
	if (document.searchField.KEY.value.length<2){
		alert('Please enter 2 characters at least.');
		return false;
	}
		return true;
}

function wait(millis){
    var date = new Date();
    var curDate = null;    
    do { curDate = new Date(); }
    while(curDate-date < millis);
}

function acd(user_sn, strLanguage) {    

	if (strLanguage=="EN") {
	    fille=window.open('http://acdus.areva.corp:8080/Areva/portals/std/index-portal.jsp');
	    wait(1000)        
	    fille.location.href='http://acdus.areva.corp:8080/Areva/forms/AllPersonnes/resource/search.jsp?type=&sn='+user_sn+'&givenName=&arevaCompanyLink=&arevaSiteLink=&arevaOuLink=&telephoneNumber=&modifyShoppingCart=false&addalltoShoppingCart=false&CurrentElementsearchResultForm=&SearchStatus=newRequest&view=8-WhitePages&resource=AllPersonnes';    
	    fille.focus();
	}
	else{ 
	    fille=window.open('http://acdeurope.areva.corp:8080/Areva/portals/std/index-portal.jsp');
	    wait(1000)        
	    fille.location.replace('http://acdeurope.areva.corp:8080/Areva/forms/AllPersonnes/resource/search.jsp?type=&sn='+user_sn+'&givenName=&arevaCompanyLink=&arevaSiteLink=&arevaOuLink=&telephoneNumber=&modifyShoppingCart=false&addalltoShoppingCart=false&CurrentElementsearchResultForm=&SearchStatus=newRequest&view=8-WhitePages&resource=AllPersonnes')    
	    fille.focus(); 	    
	}
}

function acd(user_sn) {    
	fille=window.open('http://acdeurope.areva.corp:8080/Areva/portals/std/index-portal.jsp');
	wait(1000)        
	fille.location.replace('http://acdeurope.areva.corp:8080/Areva/forms/AllPersonnes/resource/search.jsp?type=&sn='+user_sn+'&givenName=&arevaCompanyLink=&arevaSiteLink=&arevaOuLink=&telephoneNumber=&modifyShoppingCart=false&addalltoShoppingCart=false&CurrentElementsearchResultForm=&SearchStatus=newRequest&view=8-WhitePages&resource=AllPersonnes')    
	fille.focus(); 	    
}

function redir(temp){
	window.open(temp,'Impression','width=700,height=600,menubar=no,toolbar=yes,scrollbars=yes')
}

function textDownLinks()
{
	
	if($('.sect-bas-text li .link_back2list').length>0||$('.sect-bas-text li .link_archive').length>0)
	{
		// alert("Debug SCWA en cours ...");
		countItems = $('.sect-bas-text li, .sect-bas-text p').length;
		// alert("countItems="+countItems);
		countDifferentItems = $('.sect-bas-text li .link_back2list, .sect-bas-text li .link_archive').length;
		// alert("countDifferentItems="+countDifferentItems);
		if(countItems==countDifferentItems) {
			$('#sect-bas .sect-bas-text').hide();
			
			// $('#sect-bas h3').hide();
		}
		if(countDifferentItems>0)
		{
			$('#sect-bas').append('<div class="textBasItems"></div>');
			$('.sect-bas-text li .link_back2list, .sect-bas-text li .link_archive').each(
			function(i)
			{
				$(this).parent().remove();
				$('#sect-bas .textBasItems').append($(this));
			});
			// Si il y a des liens de type archive et/ou retour à la liste et que le titre est vide alors on supprimer la bordure
			// alert($.trim($('#sect-bas h3').text()));
			if ($('#sect-bas .sect-bas-text p').length>0&&$.trim($('#sect-bas .sect-bas-text p').text())=='') {
				countItems = countItems -1;
			}
			if ($.trim($('#sect-bas h3').text())==''||countItems>countDifferentItems) 
			{
				// alert("suppr border");
				$('.textBasItems').css("border","none");
			}
			if (countItems==countDifferentItems) {
				$('#sect-bas ul.linkTable_left').remove();
			}
		}
		// } else {
			// $('.sect-bas-text li .link_archive').each(
			// function(i)
			// {
				// $(this).parent('li').addClass('linkArchive');
			// });
		// }
		
	}
	if($.trim($('#sect-bas .sect-bas-text p').text())=='')
	{
		// $('#sect-bas .sect-bas-text p').hide();
		$('#sect-bas .sect-bas-text p').remove();
	}
	if($('#sect-bas .sect-bas-text').is(':empty'))
	{
		$('#sect-bas .sect-bas-text').hide();
	}
	if($('#sect-bas .sect-bas-text').is(':empty')&&$('#sect-haut .img-right').is(':empty'))
	{
		// $('.moreInfo').hide();
	}
	if ($('#sect-bas .sect-bas-text p').css('display') == 'none' && $('#sect-bas .sect-bas-text li').css('display') == 'none')
	{
		$('#sect-bas .sect-bas-text').hide();
	}
}
function textUpLinks()
{
	if($('#sect-haut .img-right').is(':empty'))
	{
		$('#sect-haut .img-right').hide();
	}
	if($('#sect-haut .sect-haut-text').text()=='')
	{
		$('#sect-haut .sect-haut-text').hide();
	}
}

function listItemNews()
{
	if ($(".listItemNews").closest(".sect-expert").next(".sect-expert").find(".paragraphe").length > 0) {
		$(".listItemNews").closest(".sect-expert").next(".sect-expert").find(".paragraphe").css("margin-top","15px");
	}
}

function popinAjax(url,largeur,hauteur,media)
{		
		if(!media)
			{ var media = '' }
		if(!largeur||largeur=='')
			{ largeur = 650; }
		if(!hauteur||hauteur=='')
		{ 
			hauteur = parseInt(parseInt($(window).height())/100)*70; 
		}
		if($.browser.msie && jQuery.browser.version.substr(0,1)=='6')//if IE
		{
			$("body").append('<iframe id="TB_HideSelect"></iframe><div id="TB_overlay"></div><div id="TB_window"></div>');
			$('body, html').css('overflow','auto');
		}	else {//all others
				$("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
				$('body, html').css('overflow','auto');
		}
		if(tb_detectMacXFF()){
			$("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
		}else{
			$("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
		}
		positionTop = parseInt(($(window).height()-hauteur)/2);
		positionLeft = parseInt(($(window).width()-largeur)/2);
		$('body').append('<div id="popin_container" style="width:'+largeur+'px; height:'+hauteur+'px; top:'+positionTop+'px; left:'+positionLeft+'px;" class="'+media+'"><div id="popin_titlebar"><div id="closePopin"></div><h2></h2></div><div id="popin_content" style="width:'+largeur+'px"></div></div>');
		$('body').append($('#popin_container'));
		$('#popin_container').css({'width':largeur+'px','top':positionTop+'px','left':+positionLeft+'px'})
		$('#popin_content').css({'width':largeur+'px','height':hauteur+'px'});
		
		$('#popin_content').append('<img src="/lib_central/images/ACTIV/common/lightbox-ico-loading.gif" style="position:absolute; top:'+parseInt((hauteur-40)/2)+'px; left:'+parseInt((largeur-32)/2)+'px;" id="lightbox-ico-loading" />')
		$('#popin_container').fadeIn('fast',
			function()
			{
				$('#popin_content').append('<iframe src="'+url+'" style="width:'+largeur+'px;height:1px" id="TB_iframeContent" name="TB_iframeContent'+Math.round(Math.random()*1000)+'" frameborder="0"></iframe>');
				$('#popin_content iframe').load(function(){
					$('#lightbox-ico-loading').remove();
					$('#TB_iframeContent').css('height',hauteur+'px');
				});

			}
		);
		$('#TB_overlay').click(remove_popin);
		$('#closePopin').click(remove_popin);
}

function popinMediatheque(url,largeur,hauteur,media)
{		
		if(!media)
		{ var media = '' }
  			if($.browser.msie && jQuery.browser.version.substr(0,1)=='6')//if IE
			{
			$("body").append('<iframe id="TB_HideSelect"></iframe><div id="TB_overlay"></div><div id="TB_window"></div>');
			$('body, html').css('overflow','auto');
			}else
			{//all others
					$("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
					$('body, html').css('overflow','auto');
			}
		if(tb_detectMacXFF()){
			$("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
		}else{
			$("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
		}
		positionTop = parseInt(($(window).height()-hauteur)/2);
		positionLeft = parseInt(($(window).width()-largeur)/2);
		$('body').append('<div id="popin_container" style="width:'+largeur+'px; height:'+hauteur+'px; top:'+positionTop+'px; left:'+positionLeft+'px;" class="'+media+'"><div id="popin_titlebar"><div id="closePopin"></div><h2></h2></div><div id="popin_content" style="width:'+largeur+'px"></div></div>');
		$('body').append($('#popin_container'));
		$('#popin_container').css({'width':largeur+'px','top':positionTop+'px','left':+positionLeft+'px'})
		$('#popin_content').css({'width':largeur+'px','height':hauteur+'px'});
		
		$('#popin_content').append('<img src="/lib_central/images/ACTIV/common/lightbox-ico-loading.gif" style="position:absolute; top:'+parseInt((hauteur-40)/2)+'px; left:'+parseInt((largeur-32)/2)+'px;" id="lightbox-ico-loading" />')
		$('#popin_container').fadeIn('fast',
			function()
			{

				$.ajax({
					   type: "GET",
					   url: url,
					   success: function(e){
						   // Le marquage Xiti est supprimé dans le DOM
						   newValue = e.replace(/<script(.*)\/script>/g,'');
						 $('#popin_content').html(newValue);
						$('#popin_content #pageTitleContainer *').hide();
						$('#popin_titlebar h2').text($('#popin_content #pageTitleContainer h2').html());
						$('#popin_content .poping').css({'width':largeur+'px','height':(hauteur-4)+'px','overflow':'visible'})
						if(media=='video')
						{
								$('#popin_container').addClass('heightAuto');
								$('#popin_container').addClass(media);
						}
					   }
					 });
						
						
						//Rcupration du title
						//if (window.DOMParser)
						 // {
						//	  parser=new DOMParser();
						//	  xmlDoc=parser.parseFromString(e,"text/xml");
						 // }
						//else // Internet Explorer
						 // {
						//	  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
						//	  xmlDoc.async="false";
						//	  xmlDoc.loadXML(e);
						 // } 						  
						//nomdelafenetre=xmlDoc.getElementsByTagName("title")[0].childNodes[0].nodeValue;
						
						
						
						

				//}*/
			}
		);
		$('#TB_overlay').click(remove_popin);
		$('#closePopin').click(remove_popin);
}
function tb_detectMacXFF() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
    return true;
  }
}
function remove_popin()
{
	$('#popin_container').fadeOut('fast',
		function()
		{
			$('#popin_container').remove();
			$('#TB_window').remove();
			$('#TB_HideSelect').remove();
			$('#TB_overlay').remove();
			$('body, html').css('overflow','hidden');
		}
	);
}

	function openWin(name,src,lngWidth,lngHeight,bScroll) {
		var xCoord;
		var yCoord;
		var strAgent=navigator.userAgent;
		if (typeof(window['tmp']) != 'undefined'){
			if (tmp) tmp.close();
			}
		if (strAgent.indexOf('Mozilla/3')==-1 && strAgent.indexOf('MSIE 3')==-1) {
			xCoord=(screen.width/2 - (lngWidth/2));
			yCoord=(screen.height/2 - (lngHeight/2));
		}
		tmp=open(src,name,'top='+ yCoord +',left='+ xCoord +',directories=no,menubar=no,scrollbars='+bScroll+',resizable=no,location=no,toolbar=no,width='+lngWidth+',height='+lngHeight);
		if (strAgent.indexOf('MSIE 3')==-1) tmp.focus();
	}

function chmtLangue(param){
   document.LANGUAGE.L.value=param;
    document.LANGUAGE.submit();
  }
  
function openLyteFrame(url,largeur,hauteur,media)
{
	popinAjax(url,largeur,hauteur,media);
}

jQuery.fn.liScroll = function(settings) {
		settings = jQuery.extend({
		travelocity: 0.07
		}, settings);		
		return this.each(function(){
				var $strip = jQuery(this);
				$strip.addClass("BlockScroll")
				var stripWidth = 0;
				var $mask = $strip.wrap("<div class='mask'></div>");
				var $tickercontainer = $strip.parent().wrap("<div class='tickercontainer'></div>");								
				var containerWidth = $strip.parent().parent().width();	//a.k.a. 'mask' width 	
				$strip.find("li").each(function(i){
					stripWidth += jQuery(this, i).width();
				});
				$strip.width(stripWidth);		
				var defTiming = stripWidth/settings.travelocity;
				var totalTravel = stripWidth+containerWidth;				
				function scrollnews(spazio, tempo){
					$strip.animate({left: '-='+ spazio}, tempo, "linear", function(){$strip.css("left", containerWidth); scrollnews(totalTravel, defTiming);});
				}
				scrollnews(totalTravel, defTiming);				
				$strip.hover(
					function(){
						jQuery(this).stop();
					},
					function(){
						var offset = jQuery(this).offset();
						var residualSpace = offset.left + stripWidth;
						var residualTime = residualSpace/settings.travelocity;
						scrollnews(residualSpace, residualTime);
					}
				);			
		});	
};


/*Cette fonction permet de comptabiliser les statistiques
params :
	url
	strType -> T pour Tlchargement, N pour navigation
*/
function addStatistics(url, strType){
	// Si le lien contient le terme "liblocal", alors c'est un lien de tlchargement.
	if (url.toLowerCase().indexOf("liblocal")>0) {
		nomfichier=url.substring(url.lastIndexOf("/")+1,url.lastIndexOf(".")+4);
		xt_med('C', ssxiti(location.href), nomfichier, strType);			
	}
}
