jQuery(document).ready(function(){
jQuery('div.resumearticle').each(function ()
{
  jQuery(this).click(function ()
  {
    jQuery(this).children('div.popupArticle').modal(
    {
      overlayClose: true
    });
  });
})
;
  var popupStatus = 0;
  var popupDiv = "";
  var textDiv = "";

  function loadPopup()
  {
    if(popupStatus==0)
    {
      jQuery("#backgroundPopup").css({
        "opacity": "0.7"
      });
      jQuery("#backgroundPopup").fadeIn("slow");
      jQuery(popupDiv).fadeIn("slow");
      popupStatus = 1;
    }
  }

  function disablePopup()
  {
    if(popupStatus==1)
    {
      popupStatus = 0;
      jQuery(popupDiv).fadeOut("slow");
      jQuery("#backgroundPopup").fadeOut("slow");
      popupDiv = "";
    }
  }

  function centerPopup()
  {
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = jQuery(popupDiv).height();
    var popupWidth = jQuery(popupDiv).width();
    jQuery(popupDiv).css({
      "position": "absolute",
      "top": windowHeight/2-popupHeight,
      "left": windowWidth/2-popupWidth
    });
    jQuery("#backgroundPopup").css({
      "height": windowHeight
    });
  }

  jQuery(".buttonDossier").click(function()
  {
    var thisLi = jQuery(this).attr('id');
    popupDiv = "#popup"+thisLi;
    textDiv = "#texte"+thisLi;
    if (jQuery(textDiv).text() != "")
    {
      centerPopup();
      loadPopup();
    }
  });

  jQuery(".buttonDossier").mouseover(function()
  {
    var thisLi = jQuery(this).attr('id');
    textDiv = "#texte"+thisLi;
    if (jQuery(textDiv).text() == "")
    {
      jQuery("li#"+thisLi).css({"cursor":"default"});
    }
  });

  jQuery(".popupDossierClose").click(function()
  {
    disablePopup();
  });

  jQuery("#backgroundPopup").click(function()
  {
    disablePopup();
  });

  jQuery(document).keypress(function(e)
  {
    if(e.keyCode==27 && popupStatus==1)
    {
      disablePopup();
    }
  });

;
jQuery(function ()
{
  jQuery('a').each(function ()
  {
    if (jQuery(this).hasClass('nochange') == false)
    {
      jQuery(this).addClass('simplemodal');
      jQuery('a.simplemodal').attr('href', '#');
    }
  });
})
jQuery('a.simplemodal').click(function ()
{
  jQuery("#specialInscription").modal({opacity : 90, minHeight: 280});
})
;

  jQuery.noConflict();

  jQuery(document).ready(function()
  {
    // Pub dossier
    jQuery('.pics').cycle(
    {
      fx:    'zoom, fade, curtainX',
      sync:  false,
      timeout: 6000
    });

    var max = 600;

    // Bloc articles à venir
    var height = jQuery('div#lspfuturarticle').batch('height');
    if(height >= max)
    {
      jQuery('div#lspfuturarticle').css('height', max-20);
      jQuery('div#lspfuturarticle').css('overflow-y', 'auto');
    }

    // Bloc Dossier à venir
//    height = jQuery('div#lspnews').batch('height');
//    if(height >= max)
//    {
//      jQuery('div#lspnews').css('height', max-20);
//      jQuery('div#lspnews').css('overflow-y', 'auto');
//    }
  });

  jQuery('ul.sf-menu').superfish({
      delay:       800,                            // delay on mouseout
      animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation
      speed:       'slow',                          // faster animation speed
      autoArrows:  false,                           // disable generation of arrow mark-up
      dropShadows: false                            // disable drop shadows
  });

  jQuery('span#bt_maj').click(function ()
  {
    jQuery('form#cart_form').submit();
  });

  jQuery('#go').click(function ()
  {
    jQuery('form#identification').submit();
    return false;
  });

  jQuery('#password').keypress(function(e)
  {
    if(e.which == 13)
    {
      jQuery(this).blur();
      jQuery('#go').focus().click();
    }
  });

  jQuery(function()
  {
    jQuery.superbox();
  });

  jQuery(function ()
  {
    jQuery('.bubbleInfo').each(function ()
    {
      // options
      var distance = 35;
      var time = 250;
      var hideDelay = 100;

      var hideDelayTimer = null;

      // tracker
      var beingShown = false;
      var shown = false;
      var trigger = jQuery('.trigger', this);
      var popup = jQuery('.popup', this).css('opacity', 0);

      jQuery([trigger.get(0), popup.get(0)]).click(function ()
      {
        // stops the hide event if we move from the trigger to the popup element
        if (hideDelayTimer) clearTimeout(hideDelayTimer);

        // don't trigger the animation again if we're being shown, or already visible
        if (beingShown || shown)
        {
          return;
        }
        else
        {
          beingShown = true;

          // reset position of popup box
          popup.css({
            top: 0,
            left: 0,
            display: 'block' // brings the popup back in to view
          })

          // (we're using chaining on the popup) now animate it's opacity and position
          .animate({
            top: '+=' + distance + 'px',
            opacity: 1
          }, time, 'swing', function()
          {
            // once the animation is complete, set the tracker variables
            beingShown = false;
            shown = true;
          });
        }
      });

      jQuery([popup.get(0)]).click(function ()
      {
        // reset the timer if we get fired again - avoids double animations
        if (hideDelayTimer) clearTimeout(hideDelayTimer);

        // store the timer so that it can be cleared in the mouseover if required
        hideDelayTimer = setTimeout(function ()
        {
          hideDelayTimer = null;
          popup.animate({
            top: '-=' + distance + 'px',
            opacity: 0
          }, time, 'swing', function ()
          {
            // once the animate is complete, set the tracker variables
            shown = false;
            // hide the popup entirely after the effect (opacity alone doesn't do the job)
            popup.css('display', 'none');
          });
        }, hideDelay);
      });
    });
  })
;
 })