// ########## CRYPT MAIL ##########
function crypt(User){
  window.location.href='mailto:' + User + '@meabilis.fr';
}

if (typeof jQuery != 'undefined') {
  jQuery('html').addClass('js');
  jQuery(function($) {

    // ########## CARROUSEL ##########
    if($().jCarouselLite){
      $('#headerSlide .jCarouselLite').jCarouselLite({
      visible: 1,
      start: 0,
      mouseWheel: true,
      btnGo: ['#headerSlide .0','#headerSlide .1', '#headerSlide .2', '#headerSlide .3']
      });
      
      $('.jCarouselLite','#sitesExamples').jCarouselLite({
        btnNext: '#sitesExamples .next',
        btnPrev: '#sitesExamples .prev',
        mouseWheel: true,
        speed: 300,
        visible:1,
        afterEnd: function(selected){
          $('#labelExamplesIndex').text($('img',selected).attr('alt'));
        }
      });
      
      $('.jCarouselLite','#themes').jCarouselLite({
        btnNext: '#themes .next',
        btnPrev: '#themes .prev',
        mouseWheel: true,
        speed: 300,
        visible:1,
        afterEnd: function(selected){
          $('#labelThemesIndex').text($('img',selected).attr('alt'));
        }
      });
      
      $('.jCarouselLite','#themesCarrousel').jCarouselLite({
        btnNext: '#themeNext',
        btnPrev: '#themePrev',
        mouseWheel: true,
        speed: 300,
        visible:4,
        start:0
      });
    }

    var $steps = $('#headerSlide button');
    $steps.click(function(){
      $steps.removeClass('active');
      $(this).addClass('active');
      return false;
    });
    
    // ########## FAQ ##########
    $('.faq dt strong').click(function(e){
      $(this).closest('dl').find('dd').toggle();
      e.preventDefault();
    });
    
    // ########## INSCRIPTION TOOLTIPS ##########
    $('#inscription input','#formLogin input')
      .focus(function(e){
       $(this).closest('fieldset').find('.helpText').show();
      })
      .blur(function(e){
       $(this).closest('fieldset').find('.helpText').hide();
    });
    $('.helpImg').hover(
      function(){
        $(this).closest('fieldset').find('.helpText').show();
      },
      function(){
        $(this).closest('fieldset').find('.helpText').hide();
      }
    );
    
    // ########## INSCRIPTION FOCUSFIELD ##########
    $('.largeInput input[type="text"], .smallInput input[type="text"],.smallInput input[type="password"]')
      .focus(function(){
        $(this).parent('span').addClass('focusField');
        if(this.value == this.defaultValue){
          this.value = '';
        }
      })
      .blur(function() {
        $(this).parent('span').removeClass('focusField');
        if(this.value == ''){
          this.value = this.defaultValue;
        }
      });
      
    if($().tabs){
      // ########## SITES EXAMPLES ##########
      $('#tabs,#tabsGlossary').tabs();
      $('#alt').addClass('ui-tabs-hide');
    }
    
    $('#themesCarrousel a').click(function(e) {
      e.preventDefault();
      $('#themeLargePreview img').attr('src', $(this).attr('href'));
      var themeLabel = $('img', this).attr('alt');
      $('#themeLabel').text(themeLabel);
    })

  });
}
