jQuery(document).ready(function(){
	//toogle FAQ
	jQuery(".toggle_faq").hide();
	jQuery("h2.triggerfaq").click(function(){
		jQuery(this).toggleClass('activefaq');
		jQuery(this).next(".toggle_faq").slideToggle("slow");
		return false;
	});

	//tooltip
  jQuery(".west").tipsy({gravity: 'w', 'fade':true});
  jQuery(".north").tipsy({gravity: 's', 'fade':true});
  jQuery(".south").tipsy({gravity: 'n', 'fade':true});
  jQuery(".east").tipsy({gravity: 'e', 'fade':true});

	//slide_panels
	jQuery('div.tabs ul.tabNavigation a').click(function () {
    jQuery(".toggle_container").slideUp('slow');
		if(jQuery('.active').length == 0) {
		  jQuery(jQuery(this).addClass('active').attr('href')).slideDown('slow');
		  return false;
		}
		if (jQuery(this).hasClass('active')) {
		  jQuery(jQuery(this).removeClass('active').attr('href')).slideUp('slow');
		  return false;
		}
		jQuery(jQuery('.active').removeClass('active').attr('href')).hide();
		jQuery(jQuery(this).addClass('active').attr('href')).show();
		return false;
  });

  jQuery('.toggle_container').hide();
  jQuery('span.trigger').click(function() {
    jQuery(this).toggleClass('active2');
		jQuery(this).next('.toggle_container').slideToggle('fast');
    return false;
	});

	//tabs_panel2
	jQuery(function () {
			var tabContainers = jQuery('#panel2_content_right > div');
			tabContainers.hide().filter(':first').show();
			jQuery('div.tabs_nav2 ul.tabNavigation_hover a').hover(function () {
				tabContainers.hide();
				tabContainers.filter($(this).attr('rel')).show();
				return false;
			});
		});

	//tabs_panel3
	jQuery(function () {
			var tabContainers = jQuery('#panel3_content_right > div');
			tabContainers.hide().filter(':first').show();

			jQuery('div.tabs_nav3 ul.tabNavigation_hover2 a').hover(function () {
				tabContainers.hide();
				tabContainers.filter($(this).attr('rel')).show();
				return false;
			});
		});

  handleSelectionEvents();

  if(typeof(toogloadconsole) == 'undefined')
  {
    $.post('/load-selection', function(data)
    {
      if(!data)
      {
        return;
      }

      var response = eval('(' + data + ')');

      jQuery.cookie('favoritePages', response.pages, {path: '/'});
      jQuery.cookie('favoriteDocuments', response.documents, {path: '/'});

      if(response.pages != '')     favorite_pages_build();
      if(response.documents != '') favorite_docs_build();

      // Popup événementielle
      if(response.popup && jQuery.isFunction(jQuery.fn.prettyPhoto))
      {
        var extension = response.popup.fichier.split('.').pop();

        // Construit le contenu de la popup dynamiquement en fonction des données récupérées
        if(extension == 'swf')
        {
          jQuery('body').append(
            jQuery('<a/>').attr('href', response.popup.fichier + '?width=' + response.popup.largeur + '&height=' + response.popup.hauteur).addClass('popup_evenementielle_trigger')
          );
        }
        else
        {
          jQuery('body').append(
            jQuery('<a/>').hide().attr('href', '#temporary_popup_div').addClass('popup_evenementielle_trigger')
          ).append(
            jQuery('<div/>').hide().attr('id', 'temporary_popup_div').append(
              jQuery('<a/>').attr('href', response.popup.href).append(
                jQuery('<img/>').attr('src', response.popup.fichier).attr('width', response.popup.largeur).attr('height', response.popup.hauteur)
              )
            )
          );
        }

        // Active pretty photo sur le trigger
        jQuery('.popup_evenementielle_trigger').prettyPhoto({
          theme:'facebook',
          default_width: response.popup.largeur,
          default_height: response.popup.hauteur,
          allowresize: false
        });

        // Déclenche l'ouverture de la popup
        jQuery('.popup_evenementielle_trigger').click();
      }
    });
  }
  else
  {
    favorite_pages_build();
    favorite_docs_build();
  }

  $('#panel1 .panel_col1 .selection_select_all').click(function()
  {
    $('#pages_favorites input[type=checkbox]').attr('checked', 'checked');
    return false;
  });

  $('#panel1 .panel_col1 .selection_delete_checked').click(function()
  {
    var indexes = new Array();
    $('#pages_favorites input[type=checkbox]:checked').each(function()
    {
      indexes[indexes.length] = parseInt($(this).attr('id'));
      $(this).parent('li').remove();
    });

    favorite_pages_delete(indexes, false);

    if(typeof(toogloadconsole) == 'undefined')
    {
      $.post('/save-selection', {'pages': jQuery.cookie('favoritePages'), 'documents': jQuery.cookie('favoriteDocs')});
    }

    return false;
  });

  $('#panel1 .panel_col2 .selection_select_all').click(function()
  {
    $('#documents_favorites input[type=checkbox]').attr('checked', 'checked');
    return false;
  });

  $('#panel1 .panel_col2 .selection_delete_checked').click(function()
  {
    var indexes = new Array();
    $('#documents_favorites input[type=checkbox]:checked').each(function()
    {
      indexes[indexes.length] = parseInt($(this).attr('id'));
      $(this).parent('li').remove();
    });

    favorite_docs_delete(indexes, false);

    if(typeof(toogloadconsole) == 'undefined')
    {
      $.post('/save-selection', {'pages': jQuery.cookie('favoritePages'), 'documents': jQuery.cookie('favoriteDocs')});
    }

    return false;
  });

  jQuery('.toggle_container a.delete').click(function() {
    jQuery(this).closest('.panel_col').find('input.checkbox:checked').parent().fadeOut('500', function() {
      jQuery(this).remove();
    });
    jQuery(this).closest('.toggle_container').prev('span.trigger').click();
    return false;
  });

	jQuery('.nos-produits-panel-content').hide();
  //jQuery('#breadcrumb_produit').hide();
  //jQuery('#infos_produit').hide();

  if(jQuery.isFunction(jQuery.fn.prettyPhoto))
  {
    jQuery('a[href$=".flv"]').click(function()
    {
        var sitename = 'atlprochaudiere';
        var flashvars = '&amp;autoplay=1&amp;showvolume=1&amp;showfullscreen=1&amp;showplayer=always';
        var flv_path = jQuery(this).attr('href');

        if(flv_path.indexOf('/easylink/') !== -1)
        {
          //Admin
          flv_path = flv_path.replace(/\/([a-z0-9_]+\.php\/)?easylink\/video/i, '/mediasources/' + sitename + '/videos');
          jQuery(this).attr('href', '/sites/' + sitename + '/images/player_flv_maxi.swf?width=530&height=320&flashvars=flv=' + flv_path + flashvars);
        }
        else if(flv_path.indexOf('player_flv_maxi.swf') === -1) //test pour eviter de refaire le remplacement si on clique plusieurs fois
        {
          //Public
          jQuery(this).attr('href', '/images/player_flv_maxi.swf?width=530&height=320&flashvars=flv=' + flv_path + flashvars);
        }

        jQuery(this).attr('title', '');
      });

    if(jQuery('a[href$=".flv"]').size() > 0)
    {
      jQuery('a[href$=".flv"]').prettyPhoto({
        theme:      'facebook',
        showTitle:  false
      });
    }
  }

	initializeSpecsTable();
  initializeProductTabs();
});

function handleSelectionEvents()
{
  jQuery('.add_page_to_favorites').unbind('click').click(function()
  {
    favorite_pages_add($(this).attr('href'), $(this).attr('tabindex'), $(this).find('strong').html());

    var unique_id = jQuery.gritter.add({
      // (string | mandatory) the heading of the notification
      title: 'Page ajouté à votre sélection !',
      // (string | mandatory) the text inside the notification
      text: 'Consulter et gérer vos pages favorites dans la barre des onglets en haut de cette page',
      // (string | optional) the image to display on the left
      image: jQuery(this).attr('rel'),
      // (bool | optional) if you want it to fade out on its own or just sit there
      sticky: false,
      // (int | optional) the time you want it to be alive for before fading out
      time: '4000'
      // (string | optional) the class name you want to apply to that specific message
      //class_name: 'my-sticky-class'
    });

    return false;
  });

  jQuery('.add_document_to_favorites').unbind('click').click(function()
  {
    var href = $(this).prev('a').attr('href');
    var titre = $(this).closest('div').find('.doc_description_titre').html();
    var format = $(this).closest('div').find('.file_format').html().split('/')[1];
    var taille = $(this).closest('div').find('.file_size').html();
    favorite_docs_add(href, $(this).attr('tabindex'), titre, format, taille);

  	var unique_id = jQuery.gritter.add({
      // (string | mandatory) the heading of the notification
      title: 'Document ajouté à votre sélection !',
      // (string | mandatory) the text inside the notification
      text: 'Consulter, gérer et télécharger vos documents dans la barre des onglets en haut de cette page',
      // (string | optional) the image to display on the left
      image: jQuery(this).attr('rel'),
      // (bool | optional) if you want it to fade out on its own or just sit there
      sticky: false,
      // (int | optional) the time you want it to be alive for before fading out
      time: '4000'
      // (string | optional) the class name you want to apply to that specific message
      //class_name: 'my-sticky-class'
    });

    return false;
  });
}


//customlistscroll
function updateSlider1()
{
  jQuery('#content-slider').slider('destroy');
  jQuery('#content-slider').slider({
    slide: function(event, ui) {
      jQuery('#customlistscroll').scrollTo(jQuery('#customlistscroll ul li')[Math.ceil(-ui.value/2)]);
    },
    change: function(event, ui) {
      jQuery('#customlistscroll').scrollTo(jQuery('#customlistscroll ul li')[Math.ceil(-ui.value/2)]);
    },
    orientation: 'vertical',
    min: -((jQuery('#customlistscroll ul li').length - 5) * 2),
    max: 0
  });
  jQuery('#customlistscroll, #container-slider').unbind('mousewheel').mousewheel(function(event, delta){
    jQuery('#content-slider').slider('value', jQuery('#content-slider').slider('value') + delta)
    return false;
  });
}

//customlistscroll2
function updateSlider2()
{
  jQuery('#content-slider2').slider('destroy');
  jQuery('#content-slider2').slider({
    slide: function(event, ui) {
      jQuery('#customlistscroll2').scrollTo(jQuery('#customlistscroll2 ul li')[Math.ceil(-ui.value/2)]);
    },
    change: function(event, ui) {
      jQuery('#customlistscroll2').scrollTo(jQuery('#customlistscroll2 ul li')[Math.ceil(-ui.value/2)]);
    },
    orientation: 'vertical',
    min: -((jQuery('#customlistscroll2 ul li').length - 5) * 2),
    max: 0
  });
  jQuery('#customlistscroll2, #container-slider2').mousewheel(function(event, delta){
    jQuery('#content-slider2').slider('value', jQuery('#content-slider2').slider('value') + delta)
    return false;
  });
}


function initializeProductTabs()
{
  //Gallery images
  if(jQuery.isFunction(jQuery.fn.prettyPhoto))
	{
    if(jQuery("a[rel^='prettyPhoto']").size() > 0)
    {
      jQuery("a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook'});
    }
  }

  if(jQuery('.gal').length > 0 && jQuery('.ressources_gallery').length > 0)
  {
    jQuery('.gal').masonry({
      singleMode: true,
      itemSelector: '.ressources_gallery'
    });
  }

  handleSelectionEvents();


  var tabContainers = jQuery('div.tabs_prod > div');
  tabContainers.hide().filter(':first').show();

  jQuery('div.tabs_prod ul.tabNavigation_prod a').click(function () {
    tabContainers.hide();
    tabContainers.filter(this.hash).show();
    jQuery('div.tabs_prod ul.tabNavigation_prod a').removeClass('selected2');
    jQuery(this).addClass('selected2');
    return false;
  }).filter(':first').click();
}

function initializeColumnsNavigation()
{
  //columnNavigation
  jQuery("#myTree").columnNavigation({
    containerPosition:"relative",
    containerWidth:"772px",
    containerHeight:"250px",
    columnWidth:257,
    columnFontSize:"11px",
    columnSeperatorStyle:"1px solid rgb(220,220,220)",
    containerBorder:"none",
    columnDeselectFontWeight:"normal",
    columnDeselectColor:"rgb(50,50,50)",
    columnSelectFontWeight:"normal",
    columnSelectBackgroundColor:"rgb(155,156,158)",
    columnSelectBackgroundImage:"url('/images/produit/nav_fleche_grise.png')",
    columnSelectBackgroundPosition:"233px -1px",
    leafDeselectColor:"#FFF",
    leafDeselectBackgroundColor:"#B71234",
    leafDeselectBackgroundPosition:"233px -1px",
    leafSelectBackgroundColor:"#B71234",
    leafSelectBackgroundImage:"url('/images/produit/nav_last_rouge.png')",
    leafSelectBackgroundPosition:"233px -1px",
    columnItemPadding:"0px 3px 0px 3px",
    columnScrollVelocity:200
  });

  jQuery("#myDocsTree").columnNavigation({
    containerPosition:"relative",
    containerWidth:"772px",
    containerHeight:"250px",
    columnWidth:257,
    columnFontSize:"11px",
    columnSeperatorStyle:"1px solid rgb(220,220,220)",
    containerBorder:"none",
    columnDeselectFontWeight:"normal",
    columnDeselectColor:"rgb(50,50,50)",
    columnSelectFontWeight:"normal",
    columnSelectBackgroundColor:"rgb(155,156,158)",
    columnSelectBackgroundImage:"url('/images/produit/nav_fleche_grise.png')",
    columnSelectBackgroundPosition:"233px -1px",
    leafDeselectColor:"#FFF",
    leafDeselectBackgroundColor:"#B71234",
    leafDeselectBackgroundPosition:"233px -1px",
    leafSelectBackgroundColor:"#B71234",
    leafSelectBackgroundImage:"url('/images/produit/nav_last_rouge.png')",
    leafSelectBackgroundPosition:"233px -1px",
    columnItemPadding:"0px 3px 0px 3px",
    columnScrollVelocity:200
  });
}

function initializeSpecsTable()
{
	//Tables des caractéristiques
  $(".tableDiv").each(function() {
      var Id = $(this).get(0).id;
      var maintbheight = 590;
      var maintbwidth = 737;
  $("#" + Id + " .FixedTables").fixedTable({
      width: maintbwidth,
      height: maintbheight,
      fixedColumns: 1,
      // header style
      classHeader: "fixedHead",
      // footer style
      //classFooter: "fixedFoot",
      // fixed column on the left
      classColumn: "fixedColumn",
      // the width of fixed column on the left
      fixedColumnWidth: 240,
      // table's parent div's id
      outerId: Id
      // tds' in content area default background color
      //Contentbackcolor: "#FFFFFF",
      // tds' in content area background color while hover.
      //Contenthovercolor: "#99CCFF",
      // tds' in fixed column default background color
      //fixedColumnbackcolor:"#187BAF",
      // tds' in fixed column background color while hover.
      // fixedColumnhovercolor:"#99CCFF"
    });
  });
  $(".fixedContainer tr").each(function(){
    $(this).children("td:even").css({backgroundColor:"#f2f3f4"})
      .mouseout(function(){
        $(this).css({backgroundColor:"#f2f3f4"});
      });
      $(this).children("td:odd").mouseout(function(){
        $(this).css({backgroundColor:"#fff"});
      })
  });
  $(".fixedContainer tr:first td").css({backgroundColor:"#666666"})
    .mouseout(function(){
      $(this).css({backgroundColor:"#666666"});
    });
  $(".fixedContainer .tab_subtitle").css({backgroundColor:"#bcc1c3"})
    .mouseout(function(){
      $(this).css({backgroundColor:"#bcc1c3"});
    });

  $(".fixedContainer .fixedTable td:not(.tab_subtitle)").mouseover(function(){
    $(this).css({backgroundColor:"#B8193B"});
  });

  $('#espace_pro_toogle input, #espace_pro_toogle2 input, .espace_pro_widget input').keypress(function(e)
  {
    if(e.keyCode == 13)
    {
      $(this).closest('form').submit();
    }
  });

  $('.valid_login').click(function(e)
  {
    $(this).closest('form').submit();
    e.preventDefault();
  });

  $('.valid_login').closest('form').submit(function(e)
  {
    var form = this;
    var auth = false;

    $.ajax({
      url: $(this).attr('action'),
      async: false,
      type: 'POST',
      data: $(form).serialize(),
      success: function(data)
      {
        var response = eval('(' + data + ')');

        if(response.authenticated == 1)
        {
          $(form).attr('action', response.url);
          auth = true;
        }
        else
        {
          $(form).find('.notice').html('Identifiant ou mot de passe erroné');
        }
      }
    });

    return auth;
  });

  $('.fixedColumn').css({height:$('.fixedTable').height() + 'px'});
}



/*
 * Sélection de pages et de documents
 */

function cookie_split(name)
{
	var cookie_ary = Array();

	if (jQuery.cookie(name) != null)
  {
		var sep1 = new RegExp("[|]+", "g");
		var sep2 = new RegExp("[;]+", "g");

		var cookie_ary = jQuery.cookie(name).split(sep1);

		for (var i = 0; i < cookie_ary.length; i++)
    {
			cookie_ary[i] = cookie_ary[i].split(sep2);
		}
	}

	return cookie_ary;
}

function favorite_pages_split ()
{
	return cookie_split('favoritePages');
}

function favorite_docs_split ()
{
	return cookie_split('favoriteDocs');
}

function favorite_pages_build ()
{
	var cookie_ary = favorite_pages_split();
	var favorite_pages_content = '';

  for (var i = 0; i < cookie_ary.length; i++) {
    favorite_pages_content += '<li><a href="' + cookie_ary[i][2] + '" title="' + cookie_ary[i][1] + '"><strong>' + cookie_ary[i][1].replace(/\\'/g, "'") + '</strong></a>\n';
    favorite_pages_content += '<input class="checkbox" type="checkbox" id="' + i + '"/>\n';
    favorite_pages_content += '</li>\n';
  }

	$('#pages_favorites').empty().append(favorite_pages_content);
  updateSlider1();
}

function favorite_docs_build ()
{
	var cookie_ary = favorite_docs_split();
	var favorite_docs_content = '';

  for (var i = 0; i < cookie_ary.length; i++) {
    favorite_docs_content += '<li><img src="/images/content/icon_pdf.png" alt="" width="20" height="20" /><a href="' + cookie_ary[i][2] + '" title="' + cookie_ary[i][1] + '"><strong>' + cookie_ary[i][1].replace(/\\'/g, "'") + '</strong><span>' + cookie_ary[i][3] + ' | ' + cookie_ary[i][4] + '</span></a>\n';
    favorite_docs_content += '<input class="checkbox" type="checkbox" id="' + i + '"/>\n';
    favorite_docs_content += '</li>\n';
  }

	$('#documents_favorites').empty().append(favorite_docs_content);
  updateSlider2();
}

// Array Remove - By John Resig (MIT Licensed)
Array.prototype.remove = function(from, to) {
  var rest = this.slice((to || from) + 1 || this.length);
  this.length = from < 0 ? this.length + from : from;
  return this.push.apply(this, rest);
}

function favorite_pages_add (favorite_pages_url, favorite_pages_type, favorite_pages_text)
{
	var cookie_value = '';
	var cookie_ary = favorite_pages_split();
	var favorite_pages_elt_exist = false;

	if (cookie_ary.length > 0) {
		for (var i = 0; i < cookie_ary.length; i++) {
			if (cookie_ary[i][0] == favorite_pages_type && cookie_ary[i][1] == favorite_pages_text && cookie_ary[i][2] == favorite_pages_url) {
				alert('Déjà enregistré dans ma sélection');
				favorite_pages_elt_exist = true;
				break;
			}
		}

		cookie_value = jQuery.cookie('favoritePages') + '|'
	}

	if (!favorite_pages_elt_exist) {
		cookie_value += favorite_pages_type + ';' + favorite_pages_text + ';' + favorite_pages_url;
		jQuery.cookie('favoritePages', cookie_value, {path: '/'});

    $('#pages_favorites').append($(document.createElement('li')).append('<a href="' + favorite_pages_url + '" title=""><strong>' + favorite_pages_text + '</strong></a><input class="checkbox" type="checkbox" id="' + $('#pages_favorites li').length + '"/>'));
    updateSlider1();
	}

  if(typeof(toogloadconsole) == 'undefined')
  {
    $.post('/save-selection', {'pages': jQuery.cookie('favoritePages'), 'documents': jQuery.cookie('favoriteDocs')});
  }

	return false;
}

function favorite_pages_delete (indexes, save)
{
  indexes.sort();
	var cookie_ary = favorite_pages_split();
	var cookie_value = null;
	var tmp_ary = Array();
  var i;

  for(i = indexes.length - 1; i >= 0; i--)
  {
    cookie_ary.remove(i);
  }

	if (cookie_ary.length) {
		for (var i = 0; i < cookie_ary.length; i++) {
			tmp_ary[i] = cookie_ary[i].join(";");
		}
		cookie_value = tmp_ary.join("|");
	}

	jQuery.cookie('favoritePages', cookie_value, {path: '/'});

  if(save && typeof(toogloadconsole) == 'undefined')
  {
    $.post('/save-selection', {'pages': jQuery.cookie('favoritePages'), 'documents': jQuery.cookie('favoriteDocs')});
  }
}

function favorite_docs_add (favorite_docs_url, favorite_docs_type, favorite_docs_text, format, taille)
{
	var cookie_value = '';
	var cookie_ary = favorite_docs_split();
	var favorite_docs_elt_exist = false;

	if (cookie_ary.length > 0) {
		for (var i = 0; i < cookie_ary.length; i++) {
			if (cookie_ary[i][0] == favorite_docs_type && cookie_ary[i][1] == favorite_docs_text && cookie_ary[i][2] == favorite_docs_url) {
				alert('Déjà enregistré dans ma sélection');
				favorite_docs_elt_exist = true;
				break;
			}
		}

		cookie_value = jQuery.cookie('favoriteDocs') + '|'
	}

	if (!favorite_docs_elt_exist) {
		cookie_value += favorite_docs_type + ';' + favorite_docs_text + ';' + favorite_docs_url + ';' + format + ';' + taille;
		jQuery.cookie('favoriteDocs', cookie_value, {path: '/'});

    $('#documents_favorites').append($(document.createElement('li')).append('<img width="20" height="20" alt="" src="/images/content/icon_pdf.png"/><a href="' + favorite_docs_url + '" title="' + (favorite_docs_text ? favorite_docs_text : 'Document sans titre') + '"><strong>' + (favorite_docs_text ? favorite_docs_text : 'Document sans titre') + '</strong><span>' + format + ' | ' + taille + '</a><input class="checkbox" type="checkbox" id="' + $('#documents_favorites li').length + '"/>'));
    updateSlider2();
	}

  if(typeof(toogloadconsole) == 'undefined')
  {
    $.post('/save-selection', {'pages': jQuery.cookie('favoritePages'), 'documents': jQuery.cookie('favoriteDocs')});
  }

	return false;
}

function favorite_docs_delete (indexes, save) {
	var cookie_ary = favorite_docs_split();
	var cookie_value = null;
	var tmp_ary = Array();

  for(i = indexes.length - 1; i >= 0; i--)
  {
    cookie_ary.remove(i);
  }

	if (cookie_ary.length) {
		for (var i = 0; i < cookie_ary.length; i++) {
			tmp_ary[i] = cookie_ary[i].join(";");
		}
		cookie_value = tmp_ary.join("|");
	}

	jQuery.cookie('favoriteDocs', cookie_value, {path: '/'});

  if(save && typeof(toogloadconsole) == 'undefined')
  {
    $.post('/save-selection', {'pages': jQuery.cookie('favoritePages'), 'documents': jQuery.cookie('favoriteDocs')});
  }
}



/**
 * @name EstSiretValide
 *
 * @param Le code SIRET dont on veut vérifier la validité.
 *
 * @return Un booléen qui vaut 'true' si le code SIRET passé en
 * paramètre est valide, false sinon.
 */
function valideSiret(siret)
{
  var estValide;
  if ( (siret.length != 14) || (isNaN(siret)) )
    estValide = false;
  else {
    // Donc le SIRET est un numérique à 14 chiffres
    // Les 9 premiers chiffres sont ceux du SIREN (ou RCS), les 4 suivants
    // correspondent au numéro d'établissement
    // et enfin le dernier chiffre est une clef de LUHN.
    var somme = 0;
    var tmp;
    for (var cpt = 0; cpt<siret.length; cpt++) {
      if ((cpt % 2) == 0) { // Les positions impaires : 1er, 3è, 5è, etc...
        tmp = siret.charAt(cpt) * 2; // On le multiplie par 2
        if (tmp > 9)
          tmp -= 9; // Si le résultat est supérieur à 9, on lui soustrait 9
      }
      else
        tmp = siret.charAt(cpt);
      somme += parseInt(tmp);
    }
    if ((somme % 10) == 0)
      estValide = true; // Si la somme est un multiple de 10 alors le SIRET est valide
    else
      estValide = false;
  }
  return estValide;
}
