// JavaScript Document
                                        
document.tabEffects = new Array('curtains-v', 'curtains-h', 'square-top', 'square-center');
document.scrollPage = null;
document.adjustHeightBlock = null;
document.menuController = null;
document.cursorMenuScroll = null;
document.studioRotator = null;
document.studioSheets = null;
document.isIE8 = false;
document.isIE6 = false;
document.partfixed = null;  
document.clouds = new Array();
document.bob = null;
document.isFrontPage = true; 
document.ajaxLodader = null;

(function($) {
  $.fn.scrollPage = function( options ) {
    
    this.defaults = {
                      thisName:'scrollPage',
                      mainCtn:'#global',
                      blockName:'.block',
                      countBlocks:0,
                      linksArray: null,
                      linksCount: 0,
                      offsetTop: 0,
                      browserBody:true,
                      browserHtml:false,
                      menuId:'#menu',
                      menuClass:'.text-menu',
                      duration:500
                    };
      
    this.o = $.extend(this.defaults, options);

    this.init = function() {
      var thisObject = this;
      var offsetTop = 0;
       
      document.scrollPage = thisObject;
      
      thisObject.browserLabel();
      
      thisObject.o.linksArray = new Array();
      thisObject.o.linksCount = $(thisObject.o.blockName).length;
      thisObject.o.offsetTop =  parseInt($(thisObject.o.mainCtn).css('margin-top'));
      thisObject.o.offsetTop = isNaN( thisObject.o.offsetTop ) ? 0 : thisObject.o.offsetTop;
      thisObject.setLinkArray();
      
      var pageUrl = document.URL;

      if ( pageUrl.indexOf('#') != -1 ) {
        var ulr = pageUrl.split('#');
        ulr = ulr[1];  
        for ( i = 0 ; i < thisObject.o.linksCount; i ++ ) { 
          if ( $(thisObject.o.menuId+' '+thisObject.o.menuClass+' a').eq(i).attr("href") == "#"+ulr ) { 
            thisObject.scrollBlocs( i );
            return false;
          };
        };
      };
    };
    
    this.setLinkArray = function() {
      var thisObject = this;
      $(thisObject.o.mainCtn+' '+thisObject.o.blockName).each( function(i){  
        var posX = parseInt($(this).offset().left); 
        var posY = parseInt($(this).offset().top - thisObject.o.offsetTop) ;
        var ancre =  $(this).prev().attr("name"); 
        var height =  $(this).outerHeight(true); 
        var width =  $(this).width();
        posY = i * height;
        thisObject.o.linksArray.push({  
                                      left:posX, 
                                      top:posY, 
                                      width:width, 
                                      height:height, 
                                      endTop: (posY + height), 
                                      ancre:ancre
                                   });                             
      });
    };
    this.updateLinkArray = function() {
       var thisObject = this;
       $(thisObject.o.mainCtn+' '+thisObject.o.blockName).each( function(i){  
          var posX = parseInt($(this).offset().left); 
          var posY = parseInt($(this).offset().top - thisObject.o.offsetTop) ;
          var ancre =  $(this).prev().attr("name"); 
          var height =  $(this).outerHeight(true); 
          var width =  $(this).width();
          posY = i * height;  
          thisObject.o.linksArray[i].top = posY;               
      });
    };
    
    this.browserLabel = function() {
      var thisObject = this;
      if ( $.browser.opera ||  $.browser.msie || $.browser.mozilla )  { thisObject.o.browserHtml = true;  thisObject.o.browserBody = false; };
      if ( $.browser.safari ||  $.browser.webkit )  { thisObject.o.browserHtml = false;  thisObject.o.browserBody = true; };
    };
    
    this.getIndexMenu = function( pAncre ) {
      var thisObject = this;                              
      for ( i = 0 ; i < thisObject.o.linksCount ; i++ ) {
        if ( thisObject.o.linksArray[i].ancre == pAncre ) return i;
      };
    };
    
    this.scrollBlocs = function( pIndex ) { 
        
        var thisObject = this;   
        if ( thisObject.o.browserHtml ) {
          $('html').clearQueue().stop().animate(
            {scrollTop: thisObject.o.linksArray[pIndex].top },   
            {duration: thisObject.o.duration,
             step:function() { if ( document.isIE6 ) document.bob.vAlign(); },
             complete:function(){ 
                                  if( !document.menuController.o.mouseOverMenu ) setTimeout( function(){ document.menuController.bindScroll();}, 250 ); 
                                  if ( document.isIE6 ) document.bob.vAlign();
                                }});
        }
        
        if ( thisObject.o.browserBody ) {
          $('body').clearQueue().stop().animate(
          {scrollTop: thisObject.o.linksArray[pIndex].top }, 
          {duration: thisObject.o.duration,
           step:function() { if ( document.isIE6 ) document.bob.vAlign(); },
           complete:function(){ 
                                if( !document.menuController.o.mouseOverMenu ) setTimeout( function(){ document.menuController.bindScroll();}, 250 ); 
                                
                              }});
        }
        
        return;
    };
    
    this.scrollImmediatBlocs = function( pIndex ) { 
       
        var thisObject = this;   
        if ( thisObject.o.browserHtml ) {
          $('html').scrollTop(thisObject.o.linksArray[pIndex].top); 
        }
        
        if ( thisObject.o.browserBody ) {
          $('body').scrollTop(thisObject.o.linksArray[pIndex].top);
        }
        
        return false;
    };

    this.init(); 
  }
})(jQuery);

(function($) {
 
  /* Gestion next / prev / top */
  $.fn.blocNavControls = function( options ) {
     this.defaults = {
                        nameFc:'test',
                        element:null,
                        eltToAppend:null,
                        ctnNav:null,
                        index:0,
                        count:0,
                        duration: 250
                      };
     
     this.o = $.extend(this.defaults, options );
     this.oBtn = new Array();

     this.addButtons = function(){ 
        var thisObject = this;
        thisObject.o.eltToAppend = thisObject.o.element.find('div.ctn-text');
        thisObject.o.eltToAppend.append("<div class=\"nav nav_index_"+thisObject.o.index+"\" />");
        thisObject.o.ctnNav = $('.nav_index_' + thisObject.o.index);

        if ( thisObject.o.index == 0 ) {
           thisObject.o.ctnNav.append('<div class=\"next index_'+(thisObject.o.index+1)+'\" title="Suivant"></div>');
           thisObject.oBtn.push( {action:'next', index:(thisObject.o.index+1) , btn:$(".nav_index_"+thisObject.o.index+" .next")} ); 
           
           thisObject.o.ctnNav.append('<div class=\"bottom index_'+(thisObject.o.count)+'\" title="Bas de page"></div>');
           thisObject.oBtn.push( {action:'bottom', index:thisObject.o.count , btn:$(".nav_index_"+thisObject.o.index+" .bottom")} );
        } else  {
           if ( thisObject.o.index < thisObject.o.count ) {
              
              thisObject.o.ctnNav.append('<div class=\"next index_'+(thisObject.o.index+1)+'\" title="Suivant"></div>');
              thisObject.oBtn.push( {action:'next', index:(thisObject.o.index+1) , btn:$(".nav_index_"+thisObject.o.index+" .next")} );
              
              thisObject.o.ctnNav.append('<div class=\"prev index_'+(thisObject.o.index-1)+'\" title="Précédent"></div>');  
              thisObject.oBtn.push( {action:'prev', index:(thisObject.o.index-1) , btn:$(".nav_index_"+thisObject.o.index+" .prev")} );
              
              thisObject.o.ctnNav.append('<div class=\"top index_0\" title="Haut de page"></div>');
              thisObject.oBtn.push( {action:'top', index:0 , btn:$(".nav_index_"+thisObject.o.index+" .top")} );
              
              thisObject.o.ctnNav.append('<div class=\"bottom index_'+(thisObject.o.count)+'\" title="Bas de page"></div>');
              thisObject.oBtn.push( {action:'bottom', index:thisObject.o.count , btn:$(".nav_index_"+thisObject.o.index+" .bottom")} );
              
           } else {

              thisObject.o.ctnNav.append('<div class=\"prev index_'+(thisObject.o.index-1)+'\" title="Précédent"></div>');  
              thisObject.oBtn.push( {action:'prev', index:(thisObject.o.index-1) , btn:$(".nav_index_"+thisObject.o.index+" .prev")} );
              
              thisObject.o.ctnNav.append('<div class=\"top index_0\" title="Haut de page" title="Bas de page"></div>');
              thisObject.oBtn.push( {action:'top', index:0 , btn:$(".nav_index_"+thisObject.o.index+" .top")} );
              
           };
        };

          thisObject.addEvents();
     };
     
     
     this.addEvents = function(  ) {
       var thisObject = this;
       for ( i = 0, j = thisObject.oBtn.length; i < j ; i++ ) {
          var thisO = thisObject;           
          thisObject.oBtn[i].btn.css({"cursor":"pointer"});
          if ( !document.isIE6 ) {
            thisObject.oBtn[i].btn.mouseover( function() { $(this).addClass("selected"); return;} );
            thisObject.oBtn[i].btn.mouseout(  function() { $(this).removeClass("selected"); return; } );
          } else {
              thisObject.oBtn[i].btn.mouseover( function() { 
                var classe =  thisObject.extractClass( $(this).attr('class'), 0 );
                $(this).addClass(classe+"_selected");
                return;   
              });
              
              thisObject.oBtn[i].btn.mouseout( function() { 
                var classe =  thisObject.extractClass( $(this).attr('class'), 0 );
                $(this).removeClass(classe+"_selected");
                return;   
              });
             
          }
          thisObject.oBtn[i].btn.click( function() { document.menuController.externalClick( thisObject.extractIndex( $(this).attr('class'), 1 ));});
       };
       
       
     };
     
     this.extractClass = function( pClasses, pIndex ) {
       var thisObject = this;
       var classeName = '';
       classes  = pClasses.split(' ');
       if ( classes.length > 0 ) classeName = classes[pIndex];
       return classeName;
     };
     
     this.extractIndex = function( pClasses, pIndex ) {
       var thisObject = this;
       var pos = -1;
       var classes = pClasses.split(' ');
       if ( classes.length > 0 ) classes = classes[pIndex];
       classes = classes.split('_');
       if ( classes.length > 0 ) pos = classes[pIndex];
       if ( pos != -1 ) return pos;
       else return 0;
     };

     this.addButtons();
  };
  
 
})(jQuery);



(function($) {

    $.fn.menuController = function( options ) {
      document.menuController = this;   
      this.defaults = {
                    fName:'MenuController',
                    eltMenuCtn:null,
                    aLinksArray:new Array(),
                    indexSelected:0,
                    mouseOverMenu:false,
                    setTimeoutVar:null
                  };
                   
      this.o = $.extend(this.defaults, options);
      
      this.init = function() {
        var thisObject = this;
        var divOverlayMenu = '<div class="overlay-menu">';
        thisObject.o.eltMenuCtn.find("a").each( function(i){
          var classe = thisObject.getClass( $(this).parent().attr('class'), 1 );
          thisObject.o.aLinksArray.push({ index:i, 
                                          href:$(this).attr('href'),
                                          classe:classe
                                        });                            
          divOverlayMenu += '<div class="overlay-menu-text '+classe+'"> </div>';
        });
             
        divOverlayMenu += '</div>';
        thisObject.o.eltMenuCtn.append( divOverlayMenu );
        /* est-on sur la home page ? */

        if ( !Drupal.settings.is_front ) { document.isFrontPage = false; };
        
        if ( document.isFrontPage ) {  
          thisObject.o.eltMenuCtn.find(".overlay-menu .overlay-menu-text").each( function(i){
            $(this).click( function() {  
              thisObject.o.indexSelected = thisObject.getIndex( thisObject.getClass( $(this).attr('class'), 1) );
              thisObject.shutDownBlocks( document.menuController.o.indexSelected ); 
              thisObject.externScrollPage(); 
              return false; 
            });
          });
        } else  {
          thisObject.o.indexSelected = 1;
          thisObject.o.eltMenuCtn.find(".overlay-menu .overlay-menu-text").each( function(i){
            $(this).click( function() {  
              location.href =  thisObject.o.aLinksArray[ thisObject.getIndex( thisObject.getClass( $(this).attr('class'), 1) ) ].href;
              return false; 
            });
          });
        };
        
        if ( jQuery('#fixed .global-menu #menu .slider').length > 0 ) jQuery().cursorMenuScroll({slider:jQuery('#fixed .global-menu #menu .slider'), parentCtn:jQuery('#fixed .global-menu #menu')});
        
        thisObject.o.eltMenuCtn.mouseenter( function(){
            thisObject.o.mouseOverMenu = true;  
            thisObject.unbindScroll();
        });
        
        thisObject.o.eltMenuCtn.mouseleave( function(){
          document.cursorMenuScroll.moveCursorSelected( thisObject.o.indexSelected );
          thisObject.o.mouseOverMenu = false;   
          thisObject.bindScroll();
        });
        
        thisObject.bindScroll();
        
      };
      
      this.externalClick = function( pIndex ) {     
         var thisObject = this;
         thisObject.o.indexSelected = pIndex;
         thisObject.externScrollPage(); 
         return false; 
      };
      
      this.bindScroll = function() {
        var thisObject = this;
        $(window).scroll( function () { thisObject.fnScroll(); });
      };
      
      this.unbindScroll = function() {
        var thisObject = this;
        $(window).unbind('scroll');
      };
      
      this.findIndexFromOffsetTop = function( pScrollTop ) {
        if ( document.scrollPage != null ) {  
          var h = parseInt( document.scrollPage.o.linksArray[0].height / 2 );
          var pReturn = 0;
        
          for ( i = 0, j = document.scrollPage.o.linksArray.length - 1; i < j ; i ++ ) {
             var vMin = document.scrollPage.o.linksArray[i].top + h;
             var vMax = document.scrollPage.o.linksArray[i + 1 ].top + h;
             if ( ( pScrollTop >= vMin ) && pScrollTop < vMax  ) {
                pReturn = i + 1;
             };
          };
          return pReturn;
        } else return;
      };
      
      

      this.fnScroll = function() {
        var thisObject = this;
        var pageTop = $(window).scrollTop();
        if (thisObject.o.setTimeoutVar != null) clearInterval( thisObject.o.setTimeoutVar );
        thisObject.o.setTimeoutVar = setTimeout( function() { document.menuController.o.indexSelected = thisObject.findIndexFromOffsetTop( pageTop );
                                                              thisObject.shutDownBlocks( document.menuController.o.indexSelected );
                                                              if ( thisObject.findIndexFromOffsetTop( pageTop ) != undefined ) document.cursorMenuScroll.moveX( thisObject.findIndexFromOffsetTop( pageTop )); }, 150 );
                                                              if ( document.isIE6 ) document.bob.vAlign();
       
                                                            };
      
      this.shutDownBlocks = function( pIndex ) {
        var thisObject = this;
        switch ( pIndex ) {
          case 0: 
            document.studioRotator.wakeUp();
            document.studioSheets.shutdown();
            for ( i = 0, j = document.clouds.length ; i < j ; i++ ) document.clouds[i].shutdown();
          break; 
             
          case 1:
            document.studioRotator.shutDown();
            for ( i = 0, j = document.clouds.length ; i < j ; i++ ) document.clouds[i].shutdown(); 
          break;
          
          case 2:
            document.studioRotator.shutDown();
            document.studioSheets.shutdown();
            for ( i = 0, j = document.clouds.length ; i < j ; i++ ) document.clouds[i].shutdown();
          break;
          
          case 3:
            for ( i = 0, j = document.clouds.length ; i < j ; i++ ) document.clouds[i].animate();
            document.studioRotator.shutDown();
            document.studioSheets.shutdown(); 
          break;
        };
        
      };
      
      this.getClass = function( pClasses, pIndex ){
         var classes = pClasses.split(' ');
         classes = classes[pIndex];
         return classes; 
      };
      
      this.externScrollPage = function() {
        var thisObject = this;
        if ( document.scrollPage != null ) document.scrollPage.scrollBlocs(thisObject.o.indexSelected );
        else document.location.href = 'http://' + window.location.host + Drupal.settings.basePath+'#services';   
      };
      
      this.immediatScrollPage = function() {
        var thisObject = this;
        if ( document.scrollPage != null ) document.scrollPage.scrollImmediatBlocs(thisObject.o.indexSelected );
        return false;
      };
      
      this.getIndex = function( pClasse ) {         
        var thisObject = this;
        var pReturn = -1;
        for ( i = 0, j = thisObject.o.aLinksArray.length; i< j; i++ ) {
          if ( thisObject.o.aLinksArray[i].classe == pClasse) {
            return i;
          };
        };
        return  pReturn;
      };
       
      this.init(); 
    };

})(jQuery);


(function($) {
   
   $.fn.cursorMenuScroll = function( options ) {
      
      this.defaults = {
                        fName:'CursorMenuScroll',
                        slider:null,
                        parentCtn:null,
                        wSlider:0,
                        hSlider:0,
                        left:0,
                        top:0,
                        divPosition:new Array(), 
                        setTimoutvar:null,
                        divOver:null
                      };
      this.o = $.extend(this.defaults, options);
      
      document.cursorMenuScroll = this; 
      
      this.init = function() {
        var thisObject = this;
        thisObject.o.wSlider = thisObject.o.slider.width();
        thisObject.o.hSlider = thisObject.o.slider.height();
        thisObject.o.left    = thisObject.o.slider.position().left;
        thisObject.o.top     = thisObject.o.slider.position().top;
        thisObject.getDivPositions();
      };
      
      this.getDivPositions = function() {
        var thisObject = this;
        var ieLeft = 0;
        thisObject.o.parentCtn.find(".overlay-menu-text").each( function(i){
          var thisDiv = $(this);
          if ( document.isIE6 ) ieLeft = 20; 
          thisObject.o.divPosition.push({ index:i,
                                          div:thisDiv,
                                          marginLeft:parseInt( thisDiv.css('margin-left') ), 
                                          left:thisDiv.position().left + parseInt( thisDiv.css('margin-left') ) + parseInt( (thisDiv.width() - thisObject.o.wSlider) /2 ) + ieLeft 
                                        });
                                        
          $(this).mouseenter( function(){ 
            clearTimeout( thisObject.o.setTimoutvar );
            thisObject.o.divOver = thisDiv;
            thisObject.o.setTimoutvar  = setTimeout( function() { thisObject.functionSetTimeOut() } , 150 ); 
          });
          
          $(this).mouseleave( function(){
            if ( thisObject.o.setTimoutvar != null ) window.clearTimeout( thisObject.o.setTimoutvar );
            thisObject.o.setTimoutvar = null;
            window.clearTimeout( thisObject.o.setTimoutvar );
          });
          
        });
        
        if ( !document.isFrontPage ) {
           thisObject.moveCursorSelected(1);
        };
      };
      
      this.functionSetTimeOut = function() {
         var thisObject = this;
         thisObject.moveCursor();    
      };
      
      this.functionClearTimeOut = function() {
         var thisObject = this;    
      };
      
      this.moveCursor = function() {
         var thisObject = this;
         thisObject.moveX(thisObject.getIndex( thisObject.o.divOver ));
      };
      
      this.moveCursorSelected = function( pIndex ) {  
         var thisObject = this;
         thisObject.moveX(pIndex);
      };
      
      this.getIndex = function( pDiv ) {         
        var thisObject = this;
        var pReturn = -1;
        for ( i = 0, j = thisObject.o.divPosition.length; i< j; i++ ) {
          if ( thisObject.o.divPosition[i].div == pDiv ) {
            return i;
          };
        };
        return  pReturn;
      };
      
      this.moveX = function( pIndex ) {
          var thisObject = this;
          if ( pIndex != -1 ) { 
           thisObject.o.slider.clearQueue().stop().animate( {"left":  parseInt( thisObject.o.divPosition[pIndex].left )}, 
                                                            {duration:250,
                                                             complete: function(){} });
          };
      };

      this.init();
      
   };
   
 })(jQuery);       
        


(function($) {
  $.fn.adjustHeightBlock = function( options ) {
    
    this.defaults = {
                      fName:'Adjust',
                      hWindow:0,
                      eltResizable:null,
                      hEltResizable:0,
                      hMintoResize:570,
                      eltCenter:null,
                      hEltCenter:0,
                      hAdjust:0 
                    };
      
    this.o = $.extend(this.defaults, options);
    
    document.adjustHeightBlock = this;
    
    this.getWindow = function() {
      var thisObject = this;
      thisObject.o.hWindow = $(window).height(); 
      thisObject.o.hEltCenter = thisObject.o.eltCenter.height();
      if ( thisObject.o.hWindow > thisObject.o.hMintoResize ) {
        thisObject.o.eltResizable.css({height:thisObject.o.hWindow}); 
      } else {
        thisObject.o.eltResizable.css({height:thisObject.o.hMintoResize}); 
      };
      thisObject.o.hEltResizable = thisObject.o.eltResizable.height(); 
      thisObject.centerElement();
      return false;
    };
    
    this.centerElement = function() {
       var thisObject = this;
       var paddingTop = parseInt( ((thisObject.o.eltResizable.height() - thisObject.o.hEltCenter + thisObject.o.hAdjust) / 2 )  ) ;  
       paddingTop = paddingTop > thisObject.o.hAdjust ? paddingTop : thisObject.o.hAdjust;
       var newHeltToResize = thisObject.o.hEltResizable - paddingTop;
       newHeltToResize = newHeltToResize >= thisObject.o.hMintoResize ? newHeltToResize :  thisObject.o.hMintoResize + 1;  
       thisObject.o.eltResizable.css({'height':newHeltToResize, 'padding-top':paddingTop});
    };
    
    this.getWindow();
  };
    
})(jQuery);


(function($) { 

  $.fn.studioRotator = function( options ) {
  
    this.defaults = {
            element: null,
            eltName:"#studio-rotator",
            heightSlider:0,
            countImages:0,
            wImages:573,
            hImages:354,
            tabImages: null,
            tabOnglets: null,
            tabTextRight: null,
            imgZIndexMax:4,
            lastItemActive:-1,
            itemActive:0,
            ongletMinOpacity:0,
            ongletMaxOpacity:1,
            ongletTimeOff:200,
            ongletTimeOn:250,
            intervalDuration:4000,
            imageDuration:350,
            mouseoverActive:150,
            setInvervalVar:null,
            isLtesie:false
        };
  
    this.o = $.extend(this.defaults, options);
    
    this.init = function() {
         
          var thisObject = this;
          document.studioRotator =  thisObject;

          $( thisObject.o.eltName+ " .images").css({"width":thisObject.o.wImages, "height":thisObject.o.hImages, "overflow":"hidden"});

          var indexImage = 0;
          thisObject.o.countImages = $( thisObject.o.eltName+ " .images .image").length;
          thisObject.o.tabImages = new Array();
          var firstPic = $( thisObject.o.eltName+ " .images .image").eq(indexImage).find("img").attr("src");
          thisObject.addLoadedImage( firstPic, indexImage);
          
        };
        
    this.addLoadedImage = function( pSrc, pIndex ) {
              var thisObject = this;
              var image = new Image();
              var nextLoaded = function( ) {
                  pIndex ++;
                  if ( pIndex < thisObject.o.countImages ) {
                    var nextSrc = $( thisObject.o.eltName+ " .images .image").eq(pIndex).find("img").attr("src");
                    thisObject.addLoadedImage( nextSrc, pIndex);
                  } else {
                    var lastIndex = thisObject.o.countImages - 1;
                    for ( i = lastIndex; i >= 0 ; i-- ) {
                       thisObject.o.tabImages.push( $( thisObject.o.eltName+ " .images .image").eq(i).html() );
                       if ( i > 0 ) $( thisObject.o.eltName+ " .images .image").eq(i).remove();
                    }
                    thisObject.o.tabImages.reverse();
                    thisObject.initRotator();
                  };
              };  
              image.src = pSrc+"";
        	    if ( image.complete ) { 
                  nextLoaded();
        	    } else {
        	      $(image).load( function() { nextLoaded(); });
        	    };   
        };
        
    this.initRotator = function() {
    
              var thisObject = this;
              $( thisObject.o.eltName+ " .images .image").css({"position":"absolute", "left":0, "top":0, "z-index": thisObject.o.imgZIndexMax});
              var index = 0;
              thisObject.o.tabOnglets = new Array();
              $(thisObject.o.eltName+ " .onglets .onglet").each( function() { 
                  $(this).addClass("item_"+index);
                  var aLink =  $(this).find('a');
                  var hasLink = false;
                  var href = '';
                  var texte = ''; 
                  var target = '';
                  if ( aLink.length > 0 ) {
                    href = aLink.attr('href');
                    texte = aLink.html();
                    target = aLink.attr('target') != '' ? aLink.attr('target') : '';
                    hasLink = true;
                  }
                  thisObject.o.tabOnglets.push({element:$(this), index:index, x:$(this).position().left , y:$(this).position().top, hasLink:hasLink, href:href, texte:texte, target:target });
                  index++;
              });
              
              /* refactor thisObject.o.tabImages */
              for ( i = 0, j = thisObject.o.countImages ; i < j ; i++ ) {
                          var img = thisObject.o.tabImages[i];
                          if ( thisObject.o.tabOnglets[i].hasLink ) {
                            img += '<div class="info-overlay">'+thisObject.o.tabOnglets[i].texte+'</div>';
                            thisObject.addCssLinkItem( i );
                            if ( i == 0 ) $( thisObject.o.eltName+ " .images .image").eq(0).html(img);
                          };
                          thisObject.o.tabImages[i] = img;
              };
              
              if ( thisObject.o.tabOnglets[thisObject.o.itemActive].hasLink  ) {
                  thisObject.o.element.parent().parent().find('.images').unbind('click' );
                  thisObject.o.element.parent().parent().find('.images').bind('click', function() { thisObject.itemClick(); });
                  thisObject.o.element.parent().parent().find('.images').css({'cursor':'pointer'});
              } else  {                                             
                  thisObject.o.element.parent().parent().find('.images').unbind('click' );
                  thisObject.o.element.parent().parent().find('.images').css({'cursor':'default'});
              };

              thisObject.addRotatorEvents();
              thisObject.addOngletEvents();
              thisObject.o.setInvervalVar = setInterval( function(){ thisObject.setIntervalFunction(); } , thisObject.o.intervalDuration );    
        
    };
    
    this.addCssLinkItem = function( pIndex ) {
              var thisObject = this;
              thisObject.o.tabOnglets[pIndex].element.css({'cursor':'pointer'});
              thisObject.o.tabOnglets[pIndex].element.attr('title',thisObject.o.tabOnglets[pIndex].texte);
              thisObject.o.tabOnglets[pIndex].element.click(function(){ thisObject.itemClick(); } );
    };

    
    this.itemsController = function( pElt ) {
          var thisObject = this;
          if ( thisObject.getOngletIndex( pElt.attr('class') ) != thisObject.o.itemActive  ) {

              thisObject.itemMouseOut( thisObject.getOnglet( thisObject.o.itemActive ).element );
              thisObject.o.itemActive = thisObject.getOngletIndex( pElt.attr('class') );
              thisObject.itemMouseOver( thisObject.getOnglet( thisObject.o.itemActive ).element );
              thisObject.zIndexImage(0,0);
              var newImage = $( thisObject.createImageCtn( thisObject.o.itemActive ));
              $( thisObject.o.eltName+ " .images").prepend( newImage );
              newImage.css({"opacity":0, "z-index":thisObject.o.imgZIndexMax});            
              $( thisObject.o.eltName+ " .images").prepend( newImage );
              thisObject.zIndexImage(0,thisObject.o.imgZIndexMax);
              
              if ( thisObject.o.tabOnglets[thisObject.o.itemActive].hasLink  ) {
                  thisObject.o.element.parent().parent().find('.images').unbind('click' );
                  thisObject.o.element.parent().parent().find('.images').bind('click', function() { thisObject.itemClick(); });
                  thisObject.o.element.parent().parent().find('.images').css({'cursor':'pointer'});
              } else  {                                             
                  thisObject.o.element.parent().parent().find('.images').unbind('click' );
                  thisObject.o.element.parent().parent().find('.images').css({'cursor':'default'});
              };

              thisObject.animateImage( newImage );
          }; 
     };

    this.shutDown = function() {
      var thisObject = this;
      clearInterval( thisObject.o.setInvervalVar  );
    }; 
    
    this.wakeUp = function() {
      var thisObject = this;
      clearInterval( thisObject.o.setInvervalVar  );
      thisObject.o.setInvervalVar = setInterval( function(){ thisObject.setIntervalFunction();} , thisObject.o.intervalDuration );
    }; 

    this.addRotatorEvents = function() {
          var thisObject = this;
          $(thisObject.o.eltName).mouseenter(function() { clearInterval( thisObject.o.setInvervalVar  ) });
          $(thisObject.o.eltName).mouseleave(function() { clearInterval( thisObject.o.setInvervalVar  );
                                                          thisObject.o.setInvervalVar = setInterval( function(){ thisObject.setIntervalFunction(); } , thisObject.o.intervalDuration ); 
                                                        });
    };
   
    this.addOngletEvents = function() {
          var thisObject = this;
          $(thisObject.o.eltName+ " .onglets .onglet").each( function() { 
            $(this).mouseenter( function() { 
                var $this = $(this);
                clearInterval( thisObject.setTimeoutSlider );
                thisObject.setTimeoutSlider = setTimeout( function(){ thisObject.o.lastItemActive = thisObject.o.itemActive; thisObject.itemsController( $this ); }, thisObject.o.mouseoverActive );
            });
            $(this).mouseleave( function() {  
                clearInterval( thisObject.setTimeoutSlider );  
            });    
          }); 
        };
    
    this.itemMouseOver = function( pElt ) { 
          var thisObject = this;
          pElt.find(".div-overlay").stop().clearQueue().animate({"width":254
                                                                },
                                                                {duration: thisObject.o.ongletTimeOn});
          var localDuration = parseInt( thisObject.o.ongletTimeOff/2);
    };
    
    this.itemClick = function() {
          var thisObject = this;
          if ( thisObject.o.tabOnglets[ thisObject.o.itemActive ].href.indexOf('ajax') != -1 ) {
                    var fCat = thisObject.o.tabOnglets[ thisObject.o.itemActive ].href.split('/');
                    if ( fCat.length > 2 ) fCat = parseInt( fCat[fCat.length-1] );
                      $().ajaxLoader({cat:fCat});
                      return false;
          } else window.location.href = thisObject.o.tabOnglets[ thisObject.o.itemActive ].href;
    };
    
    this.itemMouseOut = function( pElt ) {
         var thisObject = this;
         pElt.find(".div-overlay").stop().clearQueue().animate({"width":0},{duration: thisObject.o.ongletTimeOff});
    };    

    this.setIntervalFunction = function() {
          var thisObject = this;
          thisObject.o.lastItemActive = thisObject.o.itemActive;
          var newACtiveItem =   thisObject.o.itemActive < (thisObject.o.countImages-1) ?  parseInt(thisObject.o.itemActive) + 1 : 0; 
          thisObject.itemsController( thisObject.o.tabOnglets[ newACtiveItem ].element );
    };    
    
    this.createImageCtn = function( pIndex ) {
          var thisObject = this;
          var linkInfo = ''; 
          var newCtn = "<div class=\"image position-absolute\">"+thisObject.o.tabImages[pIndex]+linkInfo+"</div>";
          return newCtn; 
    };
    
    this.zIndexImage = function( pIndex, pZindex ) {
          var thisObject = this;
          $( thisObject.o.eltName+ " .images ").find(".image").eq( pIndex ).css({"z-index":pZindex });
    };
    
    this.animateImage= function( pElt ) {
          var thisObject = this;
          pElt.stop().clearQueue().animate(
                                              {"opacity":1,
                                               "left":0
                                              },
                                              {duration: thisObject.o.imageDuration, 
                                               complete: function(){
                                                                    $(thisObject.o.eltName+" .images").find(".image").eq(1).remove();
                                                                  }
                                              }); 
    };
    
    this.getOngletIndex = function( pClass ) {
          var thisObject = this;
          var classes = pClass.split(' ');
          if ( classes.length > 0 ){
            classe = classes[2];
            classe = classe.split('_');
            return classe[1];
          } else {
            return -1;
          };
    };
    
    this.getOnglet = function( pIndex ) {
          var thisObject = this;
          for ( i = 0 ; i < thisObject.o.countImages ; i++ ) {
            if ( thisObject.o.tabOnglets[i].index == pIndex ) {
                return  thisObject.o.tabOnglets[i];
                break;
            };
          };
    };
    
        
    this.init();
    
  };

})(jQuery);


(function($) { 

  $.fn.studioSheets = function( options ) {
    this.defaults = {
            btnContainer: null,
            laudriesCtn:null,
            wrapperCtn:null,
            defaultValue:'',
            defaultIndex:-1,
            duration:250,
            fadingDuration:125,
            eltSelected:null,
            tabO:null
        };
  
    this.o = $.extend(this.defaults, options);
    
    document.studioSheets = this;
    
    this.init = function() {
        var thisObject = this;
        thisObject.o.tabO = new Array();

          var elt = null;
          var service = '';
          var left = 0;
          var index = 0;
          thisObject.o.defaultIndex = thisObject.o.btnContainer.find('.service').length;
          
          thisObject.o.btnContainer.find('.service').each(function( i ){
              elt = $(this);
              service = thisObject.getClassService( elt.attr('class'), ' ', 1 );
              left = thisObject.o.laudriesCtn.find('.'+service).position().left;
              elt.addClass('pos_'+index);
              elt.css({'cursor':'pointer'});
              elt.find('.bg-service').eq(0).css({"display":"block", "opacity":0});
              thisObject.o.tabO.push({index:index, service:service, left:left, elt:elt}); 
              index ++;
              thisObject.sheetsEvents( $(this) );
             
          });
          
          /* existe-t-il des liens ajax ? */
           thisObject.o.wrapperCtn.find('.laundry').each( function( index){ 
              
              if ( $(this).find('.btn_more a').length > 0 ) {
                var link =  $(this).find('.btn_more a');
                link.bind('click', function(){ 
                  var lHref = $(this).attr('href');
                  if ( lHref.indexOf('ajax') != -1 ) {
                    var fCat = lHref.split('/');
                    if ( fCat.length > 2 ) fCat = parseInt( fCat[2] );
                      $().ajaxLoader({cat:fCat});
                      return false;
                  }    
                });
                 
              }
           
           });   
          
          
          service = thisObject.o.defaultValue;
          elt = thisObject.o.laudriesCtn.find('.'+service);
          left = thisObject.o.laudriesCtn.find('.'+service).position().left;
          thisObject.o.tabO.push({index:index, service:service, left:left, elt:elt}); 

    };
    
    this.addSheetCloseEvents = function( pIndex ) {
        var thisObject = this;
        var service = thisObject.o.tabO[pIndex].service;
        var closeButton = thisObject.o.laudriesCtn.find('.'+service+' .btn_close');
        thisObject.buttonCloseEvents( closeButton );
    };
    
    this.addSheetNavEvents = function( pIndex ) {
        var thisObject = this;
        var service = thisObject.o.tabO[pIndex].service;
        var blueSheet = thisObject.o.laudriesCtn.find('.'+service+' .sheets .blue-sheet');
        var nav = '<div class="add_'+pIndex+' nav" />';
        blueSheet.append( nav );
        var nextBtn = null;
        var prevBtn = null; 

        if ( pIndex == 0 ) {
           $('.add_'+pIndex+'.nav').append('<div class="next" />');
           nextBtn = $('.add_'+pIndex+'.nav .next');
        } else {
          if ( pIndex < thisObject.o.defaultIndex-1 ) {
            $('.add_'+pIndex+'.nav').append('<div class="next" />');
            nextBtn = $('.add_'+pIndex+'.nav .next');
            $('.add_'+pIndex+'.nav').append('<div class="prev" />');
            prevBtn = $('.add_'+pIndex+'.nav .prev');
          } else {
            $('.add_'+pIndex+'.nav').append('<div class="prev" />');
            prevBtn = $('.add_'+pIndex+'.nav .prev');
          };
        };
        pIndex = parseInt( pIndex );
        if ( nextBtn != null ) thisObject.nextSheetEvents( nextBtn, pIndex );
        if ( prevBtn != null ) thisObject.prevSheetEvents( prevBtn, pIndex );
    };
    
    this.blinkNav = function( pIndex ) {
        var thisObject = this;
        var nextTimeout = null;
        var service = thisObject.o.tabO[pIndex].service;
        var nextBtn = thisObject.o.laudriesCtn.find('.'+service+' .sheets .blue-sheet .nav .next');
        var prevBtn = thisObject.o.laudriesCtn.find('.'+service+' .sheets .blue-sheet .nav .prev');
        if ( nextBtn.length > 0 ) {
          setTimeout( function() { nextBtn.addClass('next-selected') } , 250 );
          setTimeout( function() { nextBtn.removeClass('next-selected') } , 350 );
          setTimeout( function() { nextBtn.addClass('next-selected') } , 450 );
          setTimeout( function() { nextBtn.removeClass('next-selected') } , 550 );
        };
        if ( prevBtn.length > 0 ) {
          setTimeout( function() { prevBtn.addClass('prev-selected') } , 200 );
          setTimeout( function() { prevBtn.removeClass('prev-selected') } , 300 );
          setTimeout( function() { prevBtn.addClass('prev-selected') } , 400 );
          setTimeout( function() { prevBtn.removeClass('prev-selected') } , 500 );
        };
    };
    
    this.prevNextLaundriesClicked = function( pIndex ) {
        var thisObject = this;
        for ( i = 0, j = thisObject.o.tabO.length ; i < j ; i++ ) {
          if ( pIndex == i ) thisObject.animateSheet( thisObject.o.tabO[i].elt, 1 );
          else  thisObject.animateSheet( thisObject.o.tabO[i].elt, 0 );
        };
    };
    
    this.nextSheetEvents = function( pElt, pIndex ) {
        var thisObject = this;
        pElt.css({'cursor':'pointer'});
        pElt.mouseover( function() { pElt.addClass('next-selected') });
        pElt.mouseout( function() { pElt.removeClass('next-selected') });
        pElt.click(function(){
          thisObject.eltSelected = thisObject.o.tabO[parseInt(pIndex+1)].elt;
          thisObject.prevNextLaundriesClicked(pIndex+1); 
          thisObject.animateLaudries(-thisObject.o.tabO[parseInt(pIndex+1)].left, -1); 
        });
    };
    
    this.prevSheetEvents = function( pElt, pIndex ) {      
        var thisObject = this;
        pElt.css({'cursor':'pointer'});
        pElt.mouseover( function() { pElt.addClass('prev-selected') });
        pElt.mouseout( function() { pElt.removeClass('prev-selected') });
        pElt.click(function(){
          thisObject.eltSelected = thisObject.o.tabO[parseInt(pIndex-1)].elt;
          thisObject.prevNextLaundriesClicked(pIndex-1); 
          thisObject.animateLaudries(-thisObject.o.tabO[parseInt(pIndex-1)].left, -1); 
        });
    };
    
    this.buttonCloseEvents= function( pElt ){
       var thisObject = this;
       pElt.css({'cursor':'pointer'});  
       pElt.mouseover( function() { pElt.addClass('btn_close_selected') });
       pElt.mouseout( function() { pElt.removeClass('btn_close_selected') });
       pElt.click(function(){
        thisObject.animateSheet( thisObject.eltSelected, 0 );
        thisObject.eltSelected = null; 
        thisObject.animateLaudries(-thisObject.o.tabO[thisObject.o.defaultIndex].left, -1 ); 
       });
    }; 
    
    this.sheetsEvents = function( pElt ) {
        var thisObject = this;
        var index =  thisObject.getClassService( thisObject.getClassService( pElt.attr('class'), ' ', 2 ), '_', 1 );
        thisObject.addSheetCloseEvents( index );
        thisObject.addSheetNavEvents( index );
        pElt.mouseenter(function() { if ( thisObject.eltSelected == null || ( pElt.attr('class') != thisObject.eltSelected.attr('class')) ) thisObject.animateSheet( pElt, 1 ); });
        pElt.mouseleave(function() { if ( thisObject.eltSelected == null || ( pElt.attr('class') != thisObject.eltSelected.attr('class')) ) thisObject.animateSheet( pElt, 0 ); });
        pElt.click(function(){
          if ( thisObject.eltSelected != null ) {
            if ( pElt.attr('class') != thisObject.eltSelected.attr('class') ) {
              thisObject.animateSheet( thisObject.eltSelected, 0 );
              thisObject.eltSelected = pElt; 
              thisObject.animateLaudries(-thisObject.o.tabO[index].left, index );
            }
          } else {
            thisObject.eltSelected = pElt; 
            thisObject.animateLaudries(-thisObject.o.tabO[index].left, index );
          }
          
//           if ( pElt.attr('class') != thisObject.eltSelected.attr('class') ) {
//             if ( thisObject.eltSelected != null ) thisObject.animateSheet( thisObject.eltSelected, 0 );
//             thisObject.eltSelected = pElt; 
//             thisObject.animateLaudries(-thisObject.o.tabO[index].left, index );
//           } 
        });
    };
    
    this.animateSheet = function( pElt, pOpacity ) {
        var thisObject = this;
        var bg = pElt.find('.bg-service');           
        bg.stop().clearQueue().animate({'opacity':pOpacity},
                                       {duration: thisObject.o.fadingDuration});
    };
    
    this.animateLaudries = function( pLeft, pIndex ) {
        var thisObject = this;
        thisObject.o.wrapperCtn.stop().clearQueue().animate({'left':pLeft},
                                                            {duration: thisObject.o.duration,
                                                             complete: function() {
                                                                          if ( pIndex != -1 ) thisObject.blinkNav( pIndex );
                                                             } });
    };
    
    this.shutdown = function() {
        var thisObject = this;
        thisObject.animateLaudries(-thisObject.o.tabO[thisObject.o.defaultIndex].left, -1 );
        thisObject.prevNextLaundriesClicked( -1 );
        thisObject.eltSelected = null;
    };
    
    this.getClassService = function( pClasses, pSplit ,pIndex ) {
        var thisObject = this;
        var classes = pClasses.split( pSplit );
        classes = classes[pIndex];
        return classes; 
    };
    
    this.init();
  
  }   
})(jQuery);  


(function($) {

  $.fn.windowResize = function() {
     document.adjustHeightBlock.getWindow();
     document.scrollPage.updateLinkArray();
     document.menuController.immediatScrollPage();
     document.bob.vAlign();
     for ( i = 0, j = document.clouds.length ; i < j ; i++ ) document.clouds[i].getWWindow();
     if ( document.isIE8 ) {
       jQuery(window).unbind('resize');
       setTimeout( function() { jQuery(window).bind('resize', function() { $().windowResize();  });}, 150 );
      }; 
  };
  
})(jQuery); 

(function($) {
    
    $.fn.studioBooks = function( options ) {
    
    this.defaults = {
                       element:null,
                       btnLink:null,
                       mask:null,
                       xMask:0,
                       yMask:0,
                       wMask:0,
                       hMask:130,
                       rvbImage:null,
                       xImage:0,
                       yImage:0,
                       wImage:125,
                       hImage:130,
                       typeAnimation:'curtains-v',
                       href:'',
                       cat:-1,
                       varInterval:null  
                    };
  
    this.o = $.extend(this.defaults, options);
    
    this.init = function() {
        
        var thisObject = this;
        thisObject.btnLink = thisObject.o.element.find('.ctn-text a');
        thisObject.o.href = thisObject.o.element.find('.ctn-text a').attr('href');
        thisObject.o.cat = thisObject.getCategoryFromUrl( thisObject.o.href, 2 );
        thisObject.o.element.find('.ctn-text a').click( function() { return false; });
        thisObject.o.element.css({'cursor':'pointer'});
         switch( thisObject.o.typeAnimation ) {
            case document.tabEffects[1]:
                thisObject.o.wMask = thisObject.o.wImage;
                thisObject.o.hMask = 0; //thisObject.o.hImage;     
            break;
            case document.tabEffects[2]:
                thisObject.o.wMask = 0; //thisObject.o.wImage;
                thisObject.o.hMask = 0; //thisObject.o.hImage;  
            break;
            case document.tabEffects[3]:
                thisObject.o.wMask = 0; //thisObject.o.wImage;
                thisObject.o.hMask = 0; //thisObject.o.hImage;  
            break;
            case document.tabEffects[0]:
            default:
               thisObject.o.wMask = 0; //thisObject.o.wImage;
               thisObject.o.hMask = thisObject.o.hImage;
            break;
        };
        thisObject.addEvents();
        
    };
    
    this.getCategoryFromUrl = function( pUrl, pIndex ) {
      var cat = -1;
      cats = pUrl.split('/');
      if ( cats.length > 0 ) {
        cat = parseInt( cats[pIndex] );
      }
      
      return cat;
    };
    
    this.openAnimation = function() {
      var thisObject = this;
      thisObject.btnLink.addClass('rollover');
      clearInterval( thisObject.varInterval );
      switch( thisObject.o.typeAnimation ) {
        case document.tabEffects[1]:
          thisObject.varInterval = setInterval( function() { thisObject.curtainHOpen(); } , 10 );      
        break;
        case document.tabEffects[2]:
          thisObject.varInterval = setInterval( function() { thisObject.squareTopOpen(); } , 10 );   
        break;
        case document.tabEffects[3]:
          thisObject.varInterval = setInterval( function() { thisObject.squareCenterOpen(); } , 10 );
        break;
        case document.tabEffects[0]:
        default:
           thisObject.varInterval = setInterval( function() { thisObject.curtainVOpen(); } , 10 ); 
        break;
      };
      
    };
    
    this.closeAnimation = function() {
      var thisObject = this;
       thisObject.btnLink.removeClass('rollover');
      clearInterval( thisObject.varInterval );
      switch( thisObject.o.typeAnimation ) {
        case document.tabEffects[1]:
          thisObject.varInterval = setInterval( function() { thisObject.curtainHClose(); } , 5 );   
        break;
        case document.tabEffects[2]:
          thisObject.varInterval = setInterval( function() { thisObject.squareTopClose(); } , 5 ); 
        break;
        case document.tabEffects[3]:
          thisObject.varInterval = setInterval( function() { thisObject.squareCenterClose(); } , 10 );
        break;
        case document.tabEffects[0]:
        default:
          thisObject.varInterval = setInterval( function() { thisObject.curtainVClose(); } , 5 );    
        break;
      };
      
    };
    
    this.curtainVClose = function( ) {
        var thisObject = this;
        var w = 0;
        var x = 0;
        thisObject.o.wMask += ( 0 - thisObject.o.wMask ) / 10 ;
        w = parseInt( thisObject.o.wMask );
        thisObject.o.xMask = ( thisObject.o.wImage - thisObject.o.wMask ) / 2 ;
        x =  parseInt( thisObject.o.xMask );

        if ( ( thisObject.o.wImage - w ) >= thisObject.o.wImage ) {
          thisObject.o.wMask = 0;
          w = thisObject.o.wMask;
          thisObject.o.xMask = ( thisObject.o.wImage ) / 2 ;
          x =  parseInt( thisObject.o.xMask );
          clearInterval( thisObject.varInterval );
          thisObject.animateCss( x , 0, w, 130 );         
          return
        };
        thisObject.animateCss( x , 0, w, 130 );
    };
    
    this.curtainVOpen = function( ) {
      var thisObject = this;
           var w = 0;
           var x = 0;
           thisObject.o.wMask += ( thisObject.o.wImage - thisObject.o.wMask  ) / 10 ;
           w = parseInt( thisObject.o.wMask );
           thisObject.o.xMask = ( thisObject.o.wImage - thisObject.o.wMask ) / 2 ;
           x =  parseInt( thisObject.o.xMask ); 
           if ( ( thisObject.o.wImage - w ) < 2 ) {
              thisObject.o.wMask = thisObject.o.wImage;
              w = thisObject.o.wImage;
              clearInterval( thisObject.varInterval );
           };
           thisObject.animateCss( x , 0, w, 130 );
    };
    
    this.curtainHClose = function( ) {
        var thisObject = this;
        var h = 0;
        var y = 0;
        thisObject.o.hMask += ( 0 - thisObject.o.hMask ) / 10 ;
        h = parseInt( thisObject.o.hMask );
        thisObject.o.yMask = ( thisObject.o.hImage - thisObject.o.hMask ) / 2 ;
        y =  parseInt( thisObject.o.yMask );
        if ( ( thisObject.o.hImage - h ) >= thisObject.o.hImage ) {
          thisObject.o.hMask = 0;
          w = thisObject.o.hMask;
          thisObject.o.yMask = ( thisObject.o.hImage ) / 2 ;
          y =  parseInt( thisObject.o.yMask );
          clearInterval( thisObject.varInterval );
          thisObject.animateCss( 0 , y, 125, h );
          return
        };
        thisObject.animateCss( 0 , y, 125, h );
    };
    
    this.curtainHOpen = function() {
        var thisObject = this;
        var h = 0;
        var y = 0;
        thisObject.o.hMask += ( thisObject.o.hImage - thisObject.o.hMask  ) / 10 ;
        h = parseInt( thisObject.o.hMask );
        thisObject.o.yMask = ( thisObject.o.hImage - thisObject.o.hMask ) / 2 ;
        y =  parseInt( thisObject.o.yMask );
        if ( ( thisObject.o.hImage - h ) < 2 ) {
          thisObject.o.hMask = thisObject.o.hImage;
          h = thisObject.o.hImage;
          clearInterval( thisObject.varInterval );
        };
        thisObject.animateCss( 0 , y, 125, h );
    };
    
    this.squareTopClose = function() {
        var thisObject = this;
        var h = 0;
        var w = 0;
        var x = 0;
        var y = 0;
        thisObject.o.hMask += ( 0 - thisObject.o.hMask  ) / 10 ;
        thisObject.o.wMask += ( 0 - thisObject.o.wMask  ) / 10 ;
        h = parseInt( thisObject.o.hMask );
        w = parseInt( thisObject.o.wMask );
        thisObject.o.xMask = 0; //thisObject.o.wImage - thisObject.o.wMask ;
        thisObject.o.yMask = 0; //thisObject.o.hImage - thisObject.o.hMask ;
        x =  parseInt( thisObject.o.xMask );
        y =  parseInt( thisObject.o.yMask );
        if ( ( thisObject.o.hImage - h ) >= thisObject.o.hImage ) {
          thisObject.o.hMask = 0;
          thisObject.o.wMask = 0;
          h = thisObject.o.hMask;
          w = thisObject.o.hMask;
          thisObject.animateCss( x , y, w, h ); 
          clearInterval( thisObject.varInterval );
        };
        thisObject.animateCss( x , y, w, h );    
    };
    
    this.squareTopOpen = function() {
        var thisObject = this;
        var h = 0;
        var w = 0;
        var x = 0;
        var y = 0;
        thisObject.o.hMask += ( thisObject.o.hImage - thisObject.o.hMask  ) / 10 ;
        thisObject.o.wMask += ( thisObject.o.wImage - thisObject.o.wMask  ) / 10 ;
        h = parseInt( thisObject.o.hMask );
        w = parseInt( thisObject.o.wMask );
        thisObject.o.xMask = 0 ;
        thisObject.o.yMask = 0; //thisObject.o.hImage - thisObject.o.hMask ;
        x =  parseInt( thisObject.o.xMask );
        y =  parseInt( thisObject.o.yMask );
        if ( ( thisObject.o.hImage - h ) < 2 ) {
          thisObject.o.hMask = thisObject.o.hImage;
          h = thisObject.o.hImage;
          w = thisObject.o.wImage;
          thisObject.animateCss( x , y, w, h ); 
          clearInterval( thisObject.varInterval );
        };
        thisObject.animateCss( x , y, w, h );    
    };
    
    this.squareCenterClose = function() {
        var thisObject = this;
        var h = 0;
        var w = 0;
        var x = 0;
        var y = 0;
        thisObject.o.hMask += ( 0 - thisObject.o.hMask  ) / 10 ;
        thisObject.o.wMask += ( 0 - thisObject.o.wMask  ) / 10 ;
        h = parseInt( thisObject.o.hMask );
        w = parseInt( thisObject.o.wMask );
        thisObject.o.xMask = ( thisObject.o.wImage - thisObject.o.wMask ) / 2;
        thisObject.o.yMask = ( thisObject.o.hImage - thisObject.o.hMask ) / 2;
        x =  parseInt( thisObject.o.xMask );
        y =  parseInt( thisObject.o.yMask );
        if ( ( thisObject.o.hImage - h ) >= thisObject.o.hImage ) {
          thisObject.o.hMask = 0;
          thisObject.o.wMask = 0;
          h = thisObject.o.hMask;
          w = thisObject.o.hMask;
          thisObject.animateCss( x , y, w, h ); 
          clearInterval( thisObject.varInterval );
        };
        thisObject.animateCss( x , y, w, h );    
    };
    
    this.squareCenterOpen = function() {
        var thisObject = this;
        var h = 0;
        var w = 0;
        var x = 0;
        var y = 0;
        thisObject.o.hMask += ( thisObject.o.hImage - thisObject.o.hMask  ) / 10 ;
        thisObject.o.wMask += ( thisObject.o.wImage - thisObject.o.wMask  ) / 10 ;
        h = parseInt( thisObject.o.hMask );
        w = parseInt( thisObject.o.wMask );
        thisObject.o.xMask = ( thisObject.o.wImage - thisObject.o.wMask ) / 2;
        thisObject.o.yMask = ( thisObject.o.hImage - thisObject.o.hMask ) / 2;
        x =  parseInt( thisObject.o.xMask );
        y =  parseInt( thisObject.o.yMask );
        if ( ( thisObject.o.hImage - h ) < 2 ) {
          thisObject.o.hMask = thisObject.o.hImage;
          h = thisObject.o.hImage;
          w = thisObject.o.wImage;
          x = 0;
          y = 0;
          thisObject.animateCss( x , y, w, h ); 
          clearInterval( thisObject.varInterval );
        };
        thisObject.animateCss( x , y, w, h );    
    };
    
    this.addEvents = function() {
        var thisObject = this;
        thisObject.o.element.mouseenter(function(){ thisObject.openAnimation(); });
        thisObject.o.element.mouseleave(function(){ thisObject.closeAnimation(); }); 
        thisObject.o.element.click(function(){ 
          $().ajaxLoader({cat:thisObject.o.cat});  
        });
        
        thisObject.btnLink.click(function(){ 
          $().ajaxLoader({cat:thisObject.o.cat});  
        });   
    };
    
    this.animateCss = function( pX, pY, pW, pH ) {
        var thisObject = this;
        thisObject.o.rvbImage.css({ 'left':-pX, 'top':-pY });
        thisObject.o.mask.css({ 'left':pX, 'top':pY, 'width':pW, 'height':pH });
    };
    
    this.init();
    
  };
})(jQuery); 

(function($) {
    
    $.fn.studioClouds = function( options ) {
    
      this.defaults = {
                         block:null,
                         wBlock:0,
                         wWindow:0,
                         xMin:0,
                         xMax:0,
                         x:0,
                         opacity:1,
                         cloud:null,
                         wCloud:0,
                         speed:1,
                         currentWidth:0,
                         varInterval:null
                      };
    
      this.o = $.extend(this.defaults, options); 
      
      document.clouds.push( this );
      
      this.init = function() {
        var thisObject = this;
        thisObject.o.speed = 1 + parseInt( 2 * Math.random() );
        thisObject.o.wCloud = thisObject.o.cloud.width();
        thisObject.o.block = thisObject.o.cloud.parent().parent();
        thisObject.o.wBlock = thisObject.o.block.width();
        thisObject.o.x = thisObject.o.cloud.position().left;
        thisObject.getWWindow();
        thisObject.animate();
      };

      this.getWWindow = function() {    
        var thisObject = this;
        thisObject.o.wWindow = $(window).width();
        thisObject.o.xMin =  -thisObject.o.block.offset().left - thisObject.o.wCloud;
        thisObject.o.xMax =  thisObject.o.wWindow + thisObject.o.xMin  + thisObject.o.wCloud;
      };
      
      this.calculate = function() {
         var thisObject = this;
         var dx = thisObject.o.x + thisObject.o.speed;
         thisObject.o.x = dx <= thisObject.o.xMax ? dx : thisObject.o.xMin;
         if ( ( thisObject.o.xMax - ( dx + thisObject.o.wCloud )) <=0 ) thisObject.o.currentWidth =  thisObject.o.xMax - dx ;
         else thisObject.o.currentWidth =  thisObject.o.wCloud;
         thisObject.addCss(); 
      };
      
      this.addCss = function() {
        var thisObject = this;
        thisObject.o.cloud.css({"left":thisObject.o.x, "width":thisObject.o.currentWidth  }); 
      };
      
      this.shutdown = function() {
        var thisObject = this;
        clearInterval( thisObject.o.varInterval );
      };
      
      this.animate = function() {
        var thisObject = this;
        clearInterval( thisObject.o.varInterval );
        thisObject.o.varInterval = setInterval( function() { thisObject.calculate(); } , 50 );
      };

      this.init();
    
    }
     
})(jQuery);  

(function($) {
    
    $.fn.studioFtp = function( options ) {
    
      this.defaults = {
                       bob:null,
                       hWindow:0,
                       w:0,
                       h:0,
                       offsetTop:0, 
                       initLeft:0,
                       duration: 250,
                       href:'',
                       hasRollOver:false  
                      };
    
      this.o = $.extend(this.defaults, options); 
      
      document.bob = this; 
      
      this.init = function() {
        var thisObject = this;
 
        thisObject.o.w = thisObject.o.bob.width();
        thisObject.o.h = thisObject.o.bob.height();
        thisObject.o.offsetTop = thisObject.o.bob.find(".btn-bob").position().top;       
        thisObject.o.initLeft = parseInt( thisObject.o.bob.css('left') );
        thisObject.o.href = thisObject.o.bob.find("a").attr('href');
        thisObject.o.bob.css({'cursor':'pointer'});
        thisObject.vAlign();
        thisObject.addEvents();
        thisObject.initAnim();
      };
      
      this.addEvents = function() {
        var thisObject = this;
        thisObject.o.bob.mouseenter( function(){ thisObject.o.hasRollOver = true; thisObject.anime(0); } );
        thisObject.o.bob.mouseleave( function(){ thisObject.anime(thisObject.o.initLeft); });  
        thisObject.o.bob.click( function(){ window.location.href = thisObject.o.href; } );
      };

      this.vAlign = function() {
        var thisObject = this;
        var middle = 0;
        var pageTop = 0; 
        thisObject.o.hWindow = $(window).height();
        if ( document.isIE6 ) { pageTop = $(window).scrollTop(); };
        middle = parseInt( thisObject.o.hWindow / 2 ) - thisObject.o.h + thisObject.o.offsetTop + pageTop;
        thisObject.o.bob.css({'top' : middle}); 
        if ( document.partfixed ) document.partfixed.css({'top':pageTop});
      };
      
      
      this.anime = function( pLeft ) {
        var thisObject = this;
        thisObject.o.bob.stop().clearQueue().animate({'left':pLeft},
                                                     {'duration': thisObject.o.duration });
      };
      
      this.initAnim = function() {
        var thisObject = this;
        if ( !thisObject.o.hasRollOver ) {
          thisObject.o.bob.stop().clearQueue().delay(1500).animate({'left':0},
                                                                   {duration: thisObject.o.duration,
                                                                    complete:function() { thisObject.o.bob.stop().clearQueue().delay(750).animate({'left':thisObject.o.initLeft}, {'duration': thisObject.o.duration}); }
                                                                    });
        };
      };

      this.init();
    
    };
     
})(jQuery);

(function($) {
    
    $.fn.ajaxLoader = function( options ) {
      this.defaults = {
          url:'ajax/book',
          cat: -1,
          init: false
      };
   
      this.o = $.extend(this.defaults, options);
    
      if ( document.isIE6 ) {
        alert("Votre navigateur ne supporte pas la version de cette lightbox.");
        return false;
      };
    
      this.loadPictures = function() {
        var thisObject = this; 
        
        if ( document.diaporama == null ) {
          thisObject.o.init = false;
          document.diaporama = new fnDiaporama( {name:"diaporama"});
        } else {
          thisObject.o.init = true;
        }
        
        $.ajax({
              type: "POST", 
  			      url:  Drupal.settings.basePath+thisObject.o.url,
  			      data: {cat:thisObject.o.cat},
  			      success:function(data){ 
                  			        if ( data != '' ) {
                  			           var obj = $.parseJSON( data );
                        			     if ( thisObject.o.init ) {
                                      document.diaporama.addParams( { header:obj.menu, thumbs:obj.thumbs, menuCatSelected:thisObject.o.cat, titleAnimate:false });
                                      document.diaporama.refreshDiaporama();
                                   } else {
                                     document.diaporama.addParams( { header:obj.menu, thumbs:obj.thumbs, menuCatSelected:thisObject.o.cat});
                       			         document.diaporama.createThumbs();
                                   }   
                  			        }
                  			      },
              error:function(XMLHttpRequest, textStatus, errorThrown) {
                alert(" ERROR: " + XMLHttpRequest + " :: " + textStatus +" :: " + errorThrown) ;
              }
  			});
      };
    
    this.loadPictures( );
    
    }
})(jQuery);    
    
(function($) {

  $.fn.initWindow = function( ) {
  
    this.init = function() {
//       $('body').css({'opacity':0});
//       var bg_image = new Image();
//       bg_image.src = Drupal.settings.basePath+"/sites/all/themes/studioimpresarios/img/sprite.png";
//       this.hideBlock();  
//       if ( bg_image.complete ) { 
//          this.showBlock();
// 	    } else { 
// 	       this.showBlock();
// 	    };   
    }
  
    this.hideBlock = function() {
      
      $('#global').css({'opacity':0});
      $('.region').css({'opacity':0});
    };
    
    this.showBlock = function() {
//       var pDelay = 0;
//       var pGlobal = 125;
//       var pRegion = 50;
//       
//       if ( Drupal.settings.first_time ) {
//         pDelay = 1500;
//         pGlobal = 250;
//         pGlobal = 100;  
//       };
//       $('body').css({'opacity':1});
//       $('#global').delay(pDelay).animate({'opacity':1}, pGlobal);
//       $('.region').animate({'opacity':1}, pRegion);
      var countBlock = jQuery('#global .block').length ;
      if( countBlock > 0 ) {
          $().adjustHeightBlock({eltResizable:$('#global .block'), eltCenter:$('#global .block .ctn-text'), hAdjust: 1.5 * $('#fixed').height() });
          $().scrollPage();
          $('#global .block').each( function(i){ $().blocNavControls( {element:$(this), index:i, count:( countBlock - 1) } ); });
      };
      
      $(window).resize(function() {
        if ( document.adjustHeightBlock != null ) {
              $().windowResize();
        };
      });
         
      /* MENU CONTROLLEUR */
      $().menuController({eltMenuCtn:$('#fixed .global-menu #menu')});
      
      /* STUDIO ROTATOR */  
      if ( $('#studio-rotator').length > 0 )  $().studioRotator( { element:$('#studio-rotator') } );
      
      /* STUDIO SHEETS */
      if ( $('#studio-services').length > 0 ) $().studioSheets({ btnContainer:$('#studio-services .services'), laudriesCtn:$('#studio-services .laudries'), wrapperCtn:$("#studio-services .laudries .wrapper"), defaultValue:'default' });
      
      /* STUDIO BOOKS */
      if ( $('#studio-books .book').length > 0 ) $('#studio-books .book').each( function(i){ $().studioBooks({ element: $(this), mask:$(this).find('.ctn-images .mask-image'), rvbImage:$(this).find('.ctn-images .mask-image img'), typeAnimation:document.tabEffects[i] }); }); 
      
      /* STUDIO CLOUDS */
      if ( $('.ctn-text.contact .clouds').length > 0 ) $('.ctn-text.contact .clouds').each( function(i) { $().studioClouds({cloud:$(this)}) });
      
      /* STUDIO FTP */
      if ( $('#bob').length > 0 ) { $().studioFtp({bob:$('#bob')}) };
      
      /* miscellanous events logos */
      $('#fixed .global-menu h1 a').click( function(){  document.menuController.externalClick(0); return false; }) ;
      $('#footer .ctn-footer .colC a').click( function(){  document.menuController.externalClick(0); return false; }) ;
      
      /* FORM ERRORS */
      
      if ( $('.contact-form .error') .length > 0 ) {
        document.menuController.externalClick(3); return false;
      }
       
    };
  this.showBlock();
  //this.init();
  }

})(jQuery); 
 

jQuery(document).ready( function() {

    if ( jQuery.browser.msie && jQuery.browser.version == '8.0' )  document.isIE8 = true;
    if ( jQuery.browser.msie && jQuery.browser.version == '6.0' )  {  document.isIE6 = true; document.partfixed = jQuery("#fixed"); }   
    
    
    jQuery().initWindow();
    

       
});
;
/**
 * 
 */

function fnDiaporama( pParams ) {
  this.name = '';
  this.layer = 'layer';
  this.divLayer = 'div.layer';
  this.thumbsContainer = null;
  this.thumbsPicsContainer = null;
  this.thumbsPicsContainerWidth = 0;
  this.picContainer = null;
  this.picCtnNext = null;
  this.picCtnPrev = null;
  this.xInit = 0;
  this.yInit = 0;
  this.diaporamaTitle = null;
  this.titleAnimate = true;
  this.menuCatSelected = -1;
  this.durationTransition = 400;
  this.animateCount = 0;
  this.lightbox = null;
  this.picArray = null;
  this.dim = null;
  this.hHeader = 0;
  this.hFooter = 0;
  this.hInfosImg = 70;
  this.picLast = 0;
  this.picCurrent = 0; 
  this.picCount = 0;
  this.hWindow = 0;
  this.wWindow = 0;
  this.initWindowWidth = 0;
  this.initWindowHeight = 0;
  this.thumbs = '';
  this.widthThumb = 134;
  this.header = '';
  
  this.deltaX = 60;
  this.pageXmin;
  this.pageXmax;
  this.posXThumbsPicCtn = 0;
  this.posXMouseEnterThumbsCtn;
  this.minPosXPicContainer;
  this.coefLeft;
  this.coefRight;
  this.isOverThumbsContainer = false;
  this.allowThumbsContainerMoving = false; 
  
  this.addParams(pParams);  
  this.initDiaporama();
};

fnDiaporama.prototype.addParams = function( pObjects ) {
	  for ( prop in pObjects ) if ( pObjects[prop] != undefined ) this[prop] = pObjects[prop];
};

/**
 * Calculate dimensions of window
 * @values :
 * 	thisDiaporama.wWindow
 * 	thisDiaporama.hWindow
 * 	thisDiaporama.initWindowWidth
 * 	thisDiaporama.initWindowHeight
 */
fnDiaporama.prototype.initDiaporama = function( pElt ){
	 var thisDiaporama = this; 
	  thisDiaporama.wWindow = jQuery(document).width();
	  thisDiaporama.hWindow = jQuery(document).height();
	  thisDiaporama.initWindowWidth = jQuery(document).width();
	  thisDiaporama.initWindowHeight = jQuery(document).height();
	  /* creation du layout */
	  if ( thisDiaporama.createLayout() ) thisDiaporama.showPreloder();
};

/**
 * Add a layer background
 */
fnDiaporama.prototype.createLayout = function( pElt ) {
	var thisDiaporama = this;   
	jQuery('body').append('<div class="'+thisDiaporama.layer+'" />');  
	jQuery(thisDiaporama.divLayer).css({'position':'fixed', 
										'z-index':9000, 
										'top':0, 
										'left':0, 
										'width':thisDiaporama.wWindow, 
										'height':thisDiaporama.hWindow, 
										'opacity':0});
  
	jQuery(thisDiaporama.divLayer).animate({"opacity":1},275);  
  
	/**
	 * TODO : Ask if event on layer to close diaporama
	 * 		  jQuery(thisDiaporama.divLayer).click(function(){ thisDiaporama.closeDiaporama(); });
	 */		  
				
  return true;
};


/**
 * Add Thumbs container
 * Add Title Lightbox 
 * 
 * Launch from Ajax request
 */

fnDiaporama.prototype.createThumbs = function() {
  var thisDiaporama = this;
  
// CREER LE MENU DU HAUT 

  jQuery('body').append('<div class="diaporamaTitle" />');    
  jQuery('div.diaporamaTitle').append( thisDiaporama.header );
  thisDiaporama.diaporamaTitle = jQuery('div.diaporamaTitle');
  jQuery('div.diaporamaTitle').append( '<div class="onnOff" />' );

  jQuery('div.onnOff').html('<a href="#">Fermer</a>');  
  jQuery('div.diaporamaTitle').width(thisDiaporama.wWindow);
  thisDiaporama.picLast = 0;
  thisDiaporama.picCurrent = 0;
  
  /*
thisDiaporama.lightbox.remove();
thisDiaporama.showPreloder();
thisDiaporama.thumbsContainer = null;
thisDiaporama.thumbsPicsContainer = null;
thisDiaporama.thumbsPicsContainerWidth = 0;
thisDiaporama.picContainer = null;
thisDiaporama.picCtnNext = null;
thisDiaporama.picCtnPrev = null;
thisDiaporama.xInit = 0;
thisDiaporama.yInit = 0;
thisDiaporama.diaporamaTitle = null;
thisDiaporama.durationTransition = 400;
thisDiaporama.lightbox = null;
thisDiaporama.picArray = null;
thisDiaporama.hHeader = 0;
thisDiaporama.hFooter = 0;
thisDiaporama.hInfosImg = 70;
thisDiaporama.picLast = 0;
thisDiaporama.picCurrent = 0; 
thisDiaporama.picCount = 0;
thisDiaporama.hWindow = 0;
thisDiaporama.wWindow = 0;
thisDiaporama.initWindowWidth = 0;
thisDiaporama.initWindowHeight = 0;
thisDiaporama.thumbs = '';
thisDiaporama.widthThumb = 134;
thisDiaporama.header = '';
												 
   */
  jQuery('div.diaporamaTitle div.onnOff').click(function(){ thisDiaporama.closeDiaporama(); return false; });
  jQuery('div.diaporamaTitle div.diaporamaMenu div.menuItem').each( function(){
	  jQuery(this).click( function(){
		  var url = jQuery(this).find('a').attr('href');
		  url = url.split('/'); 
		  url = url[url.length - 1];
		  if ( url != thisDiaporama.menuCatSelected) {			 
			  jQuery().ajaxLoader({cat:url});
			  thisDiaporama.showPreloder();
		  } 
		  return false;		  
	  });
  });

//	CREATE THUMBS CONTAINER
  jQuery('body').append('<div class="thumbsContainer" />');  
  thisDiaporama.thumbsContainer = jQuery('div.thumbsContainer');
  thisDiaporama.thumbsContainer.css({'width':thisDiaporama.wWindow});
  thisDiaporama.thumbsContainer.append('<div class="thumbsPicsContainer" />');
  thisDiaporama.thumbsPicsContainer = jQuery('div.thumbsPicsContainer');
  thisDiaporama.thumbsPicsContainer.append( thisDiaporama.thumbs );
  
  thisDiaporama.picArray = new Array();
  
  thisDiaporama.picCount = jQuery('.thumbsPicsContainer ul li').length;
  thisDiaporama.thumbsPicsContainerPosition( (thisDiaporama.picCount) * thisDiaporama.widthThumb );
     
//	PARSING UL LI ELEMENTS
  jQuery('.thumbsPicsContainer ul li').each(function(index){
	var tmbSrc = jQuery(this).find('img').eq(0).attr('src');
	var imgSrc = jQuery(this).find('div.div-hidden div.pic-src').text();
	var imgInfos = jQuery(this).find('div.div-hidden div.pic-infos').html();
	var intIndex = parseInt( index + 1 );
	var ifm = jQuery(this).find('div.div-hidden div.pic-infos');
	var txtIndex = intIndex < 10 ? "0" + intIndex : intIndex;
	var txtCount = thisDiaporama.picCount < 10 ? "0"+thisDiaporama.picCount : thisDiaporama.picCount;
	ifm.find('div.line-1').append('<span>'+txtIndex+'/'+txtCount+'</span>');
	imgInfos = ifm.html();
	var spanOverlay = jQuery(this).find('span.span-overlay');
	var classLi = 'img_'+index; 
	jQuery(this).addClass(classLi);   
	jQuery(this).find('div.div-hidden').remove();  
	thisDiaporama.picArray.push({ index:index, 
	                              imgSrc:imgSrc, 
	                              tmbSrc:tmbSrc, 
	                              imgInfos:imgInfos, 
	                              classLi:classLi, 
	                              spanOverlay:spanOverlay,     
	                              spanOverlayHeight:0, 
	                              timeoutOverlay:null });
//	CREATE OVERLAY CONTENT AND EVENT
	thisDiaporama.putSpanOverlay( spanOverlay, index );
	thisDiaporama.putEventsOverlay( jQuery(this), index );   

//	CREATE CLICKEVENT ON THUMBS
	jQuery(this).click(function(){         
		var liSelected = thisDiaporama.getLiSelected( jQuery(this).attr('class') );
		if ( liSelected != thisDiaporama.picCurrent ) {
			thisDiaporama.picLast = thisDiaporama.picCurrent;
			thisDiaporama.picCurrent = thisDiaporama.getLiSelected( jQuery(this).attr('class') );                   
			thisDiaporama.createImage();
		};   
	 });
                                                                                         
  });
      
//	SHOW & ADJUST TITLE LIGHTBOX
   thisDiaporama.diaporamaTitle.css({'width':thisDiaporama.wWindow});
   if ( thisDiaporama.titleAnimate ) {
	   thisDiaporama.diaporamaTitle.animate({'top':0}, {duration:parseInt( thisDiaporama.durationTransition / 2)} );
   } else { 
	   thisDiaporama.diaporamaTitle.css({'top':0});  
   }
//	SHOW THUMBS CONTAINER     
   thisDiaporama.thumbsContainer.animate({'bottom':0}, 
										 {duration: 250,
										  complete:function(){ 
											  thisDiaporama.hidePreloder(); 
											  if ( thisDiaporama.initLightbox() ) {
												  var timeOut =  setTimeout( function() { thisDiaporama.createImage(); }, parseInt( thisDiaporama.durationTransition / 2) );
											  }
											 }}); 
   
//	IF THUMB CONTAINER WIDTH > WINDOW WIDTH 
   /**
    * TODO : Add event to close lightbox
    */
    if ( thisDiaporama.thumbsPicsContainerWidth > thisDiaporama.wWindow ) {
    	/* AJOUT DES EVENEMENT SCROLL SUR LE CONTAINER DE VIGNETTES */ 
    	thisDiaporama.bindRollOverThumbsCtn();
    	thisDiaporama.allowThumbsContainerMoving = true;
    }
   thisDiaporama.appendOverlayThumbs();
  
   thisDiaporama.onresizeEvent();
  
   return true;

};

/**
 * 	ADD EVENT TO SCROLL THUMBS
 */
fnDiaporama.prototype.bindRollOverThumbsCtn = function() {
	 var thisDiaporama = this;

	 thisDiaporama.minPosXPicContainer = thisDiaporama.wWindow - thisDiaporama.thumbsPicsContainerWidth;

	 thisDiaporama.thumbsContainer.bind('mouseenter',function(e){
		 var deltax = 0;
		 var deltay = 0;
		 thisDiaporama.isOverThumbsContainer = true;
		 
		 /* On récupere la position X du cursor */
		 thisDiaporama.posXMouseEnterThumbsCtn = e.pageX;
		 
		 /* on récupère la position de thisDiaporama.thumbsPicsContainer deltaX */
		 thisDiaporama.posXThumbsPicCtn = thisDiaporama.thumbsPicsContainer.position().left;
		 
		 /* Creation de la fenetre pour ne pas appliquer le mouvement */
		 thisDiaporama.pageXmin = thisDiaporama.posXMouseEnterThumbsCtn - thisDiaporama.deltaX;
		 thisDiaporama.pageXmax	= thisDiaporama.posXMouseEnterThumbsCtn + thisDiaporama.deltaX;
		 
		 /* Calculer les coefficient gauche */
		 deltax = thisDiaporama.pageXmin;
		 deltay = Math.abs( thisDiaporama.posXThumbsPicCtn - thisDiaporama.deltaX );
		 thisDiaporama.coefLeft = deltax != 0 ? ( deltay / deltax ) : 0; 
		 
		 /* Calculer les coefficient droite */
		 deltax =  thisDiaporama.wWindow - thisDiaporama.pageXmax - thisDiaporama.deltaX ;
		 deltay = Math.abs( thisDiaporama.posXThumbsPicCtn + thisDiaporama.thumbsPicsContainerWidth - thisDiaporama.wWindow ) ;
		 thisDiaporama.coefRight = deltax != 0 ? ( deltay / deltax ) : 0; 
		 
		 thisDiaporama.thumbsContainer.bind('mousemove', function(e) { 
			 thisDiaporama.binMousemoveCtnThumbs(e); 
		 });
	 });
	 
	 thisDiaporama.thumbsContainer.bind('mouseleave',function(e){
		 thisDiaporama.thumbsContainer.unbind('mousemove');
		 thisDiaporama.isOverThumbsContainer = false;
	 });
};

/**
 * 	REMOVE EVENT TO SCROLL THUMBS
 */
fnDiaporama.prototype.unbindRollOverThumbsCtn = function() {
	 var thisDiaporama = this;
	 thisDiaporama.thumbsContainer.unbind('mouseenter');
};

/**
 * 	ADD MOVE 
 */
fnDiaporama.prototype.binMousemoveCtnThumbs = function( pEvt) {
	  var thisDiaporama = this;
	  var posX = 0;
	  var coef = 0;
	  var dx = 0;
	  if ( ( pEvt.pageX - thisDiaporama.posXMouseEnterThumbsCtn ) >= 0 ) {
		 if ( ( pEvt.pageX - thisDiaporama.posXMouseEnterThumbsCtn ) <= thisDiaporama.deltaX ) dx = 0;
		 else dx = ( pEvt.pageX - thisDiaporama.posXMouseEnterThumbsCtn ) - thisDiaporama.deltaX; 
		 coef = -thisDiaporama.coefRight;
	  } else {
		  if ( ( pEvt.pageX - thisDiaporama.posXMouseEnterThumbsCtn ) >= -thisDiaporama.deltaX ) dx = 0;
		  else dx = ( pEvt.pageX - thisDiaporama.posXMouseEnterThumbsCtn ) + thisDiaporama.deltaX;
		  coef = -thisDiaporama.coefLeft;
	  };
	  posX = thisDiaporama.posXThumbsPicCtn + coef * dx;
	  posX = posX >=0 ? 0 : posX;
	  posX = ( posX >= ( thisDiaporama.wWindow - thisDiaporama.thumbsPicsContainerWidth )) ? posX : ( thisDiaporama.wWindow - thisDiaporama.thumbsPicsContainerWidth );
	  thisDiaporama.thumbsPicsContainer.css({"left":posX});
};

/**
 * 	SHOW PICTURE WITH TRANSITION AND MANAGE ANIMATIONS
 */
fnDiaporama.prototype.showPicture = function( pPicture) { 
	var thisDiaporama = this;	
	thisDiaporama.hidePreloder();	
//	SHOW OVERLAY THUMB SELECTED
	thisDiaporama.overlayAnimate( thisDiaporama.picArray[thisDiaporama.picCurrent].spanOverlay , 0);
//	HIDE OVERLAY THUMB SELECTED
	if ( thisDiaporama.picCurrent != thisDiaporama.picLast ) {
		thisDiaporama.overlayAnimate( thisDiaporama.picArray[thisDiaporama.picLast].spanOverlay , -thisDiaporama.picArray[thisDiaporama.picLast].spanOverlayHeight);
	}

//	DEPLACER LE THUMBS CONTAINER 

	if ( thisDiaporama.allowThumbsContainerMoving && !thisDiaporama.isOverThumbsContainer  ) {
		
		var spanOverlayLeft = thisDiaporama.picArray[thisDiaporama.picCurrent].spanOverlay.offset().left;
		var spanOverlayRight = spanOverlayLeft + thisDiaporama.picArray[thisDiaporama.picCurrent].spanOverlay.width();
		var i;
		var nextx = NaN; 
		if ( spanOverlayLeft <= 0 ) {   
			i = thisDiaporama.picCurrent;
			nextx = ( i * thisDiaporama.widthThumb ) - 1;
		};
		
		if ( spanOverlayRight > thisDiaporama.wWindow ) {
			i = thisDiaporama.picCurrent - parseInt( thisDiaporama.wWindow / thisDiaporama.widthThumb ) + 1;
			nextx = ( i * thisDiaporama.widthThumb );
			if ( - nextx < ( thisDiaporama.wWindow - thisDiaporama.thumbsPicsContainerWidth ) ) {
				nextx = thisDiaporama.thumbsPicsContainerWidth -thisDiaporama.wWindow;				
			};
		};
		//document.title = 'l 359 ' + spanOverlayLeft +  ' :: ' + spanOverlayRight + ' :: ' + thisDiaporama.thumbsPicsContainer.attr('class') + ' :: ' + nextx ;return
		if ( !isNaN(nextx) ) thisDiaporama.thumbsPicsContainer.animate({'left': - nextx }, 250 );
	};

// SEARCH DIMENSION FOR PICTURE TO SHOW UP
	thisDiaporama.dim = thisDiaporama.picDimension(pPicture.width, pPicture.height );

//	APPEND PICTURE IN THE LIGHT BOX
	thisDiaporama.picContainer.append('<img src="'+pPicture.src+'" width="'+thisDiaporama.dim.width+'" height="'+thisDiaporama.dim.height+'" alt="" />');
  
//	SHOW INFORMATIONS

	if ( jQuery('div.info-image').length >= 1 ) {
		var posBottom = parseInt( jQuery( 'div.info-image').css('bottom') ) - 20;
		thisDiaporama.overlayAnimate( thisDiaporama.picArray[thisDiaporama.picLast].spanOverlay, -thisDiaporama.picArray[thisDiaporama.picLast].spanOverlayHeight );

		jQuery( 'div.info-image').animate({'opacity':0, 'bottom':posBottom},
                                      	  {duration: parseInt( thisDiaporama.durationTransition / 2),
                                       	   complete:function(){  
													   jQuery( 'div.info-image').remove(); 
													   thisDiaporama.lightbox.append( thisDiaporama.picArray[thisDiaporama.picCurrent].imgInfos );
													   jQuery( 'div.info-image').css({'opacity':0,
														   							  'width':thisDiaporama.dim.width});
													   if ( thisDiaporama.dim.width < 580 ) {
															jQuery( 'div.info-image div.line-1').css({'font-size': '11px', 'padding-bottom': '4px' });
															jQuery( 'div.info-image div.line-2').css({'font-size': '11px', 'padding-top': '4px' });
														} else {
															jQuery( 'div.info-image div.line-1').css({'font-size': '14px', 'padding-bottom': '9px' });
															jQuery( 'div.info-image div.line-2').css({'font-size': '14px', 'padding-top': '9px' });
														};
													   posBottom = -jQuery('div.info-image').height();
													   jQuery( 'div.info-image').css({'bottom':posBottom});                                                                                               
													   posBottom -= 7;
													   jQuery( 'div.info-image').animate({'opacity':1,
														   								  'bottom':posBottom},
														   								  parseInt( thisDiaporama.durationTransition / 2));}});
	} else {
		thisDiaporama.lightbox.append( thisDiaporama.picArray[thisDiaporama.picCurrent].imgInfos );
		jQuery( 'div.info-image').width( thisDiaporama.dim.width );
		
		if ( thisDiaporama.dim.width < 580 ) {
			jQuery( 'div.info-image div.line-1').css({'font-size': '11px', 'padding-bottom': '4px' });
			jQuery( 'div.info-image div.line-2').css({'font-size': '11px', 'padding-top': '4px' });
		} else {
			jQuery( 'div.info-image div.line-1').css({'font-size': '14px', 'padding-bottom': '9px' });
			jQuery( 'div.info-image div.line-2').css({'font-size': '14px', 'padding-top': '9px' });
		};
		jQuery( 'div.info-image').css({'bottom':-(jQuery('div.info-image').height()+ 7),'z-index': 9999});
		//alert( jQuery('div.info-image').css('position') );
	}

   
//	ANIMATION FOR PICTURES
	if ( thisDiaporama.picContainer.find("img").length > 1 ) {
		thisDiaporama.picContainer.find("img").eq(1).css({"opacity":0});
		thisDiaporama.picContainer.find("img").eq(1).animate({'opacity':1}, 
															  thisDiaporama.durationTransition, 
															  function(){ thisDiaporama.picContainer.find('img').eq(0).remove(); thisDiaporama.widthHeightAnimate();}); 
	} else {   
		thisDiaporama.picContainer.find('img').eq(1).css({'opacity':0});
		thisDiaporama.picContainer.find('img').eq(0).animate({'opacity':1}, 
                                            				 parseInt( thisDiaporama.durationTransition / 2),
                                            				 function(){ thisDiaporama.widthHeightInitAnimate(); } );
	};	
};

/**
 * 	CALCULATE NEW POSITION LIGHTBOX
 * 	!!!!! EVENTS ??? !!!!!!!!!!!!!!
 */
fnDiaporama.prototype.widthHeightAnimate = function() {
	var thisDiaporama = this;
//	thisDiaporama.unbindKeyup();
//	thisDiaporama.unbindClicThumbs();
	var nextX = parseInt( (jQuery(window).width() - thisDiaporama.dim.width) /2);
	var nextY = parseInt(( (jQuery(window).height() - thisDiaporama.dim.height - thisDiaporama.hInfosImg ) / 2 ) - ((thisDiaporama.hFooter - thisDiaporama.hHeader )  /2) + 3 ); 
	var minNext = Math.min( nextX, nextY);
	var currentX = parseInt(thisDiaporama.lightbox.css('left'));
	var currentY = parseInt(thisDiaporama.lightbox.css('top'));
//thisDiaporama.unbindThumbsEvent();
//thisDiaporama.unbindEventsPicture();

	thisDiaporama.lightbox.stop().clearQueue().animate({'left':nextX, 'top':nextY}, { duration: thisDiaporama.nextX } );
	thisDiaporama.picContainer.stop().clearQueue().animate({'height':thisDiaporama.dim.height, 'width':thisDiaporama.dim.width },
									   {duration:parseInt( thisDiaporama.durationTransition / 2),
										complete:function(){thisDiaporama.animatesComplete();}});
};

fnDiaporama.prototype.widthHeightInitAnimate = function() {
	var thisDiaporama = this;
//	thisDiaporama.unbindKeyup();
//	thisDiaporama.unbindClicThumbs();
	var nextX = parseInt( (jQuery(window).width() - thisDiaporama.dim.width) /2);
	var nextY = parseInt(( (jQuery(window).height() - thisDiaporama.dim.height - thisDiaporama.hInfosImg ) / 2 ) - ((thisDiaporama.hFooter - thisDiaporama.hHeader )  /2) + 3); 
	var minNext = Math.min( nextX, nextY);
	var currentX = parseInt(thisDiaporama.lightbox.css('left'));
	var currentY = parseInt(thisDiaporama.lightbox.css('top'));
//thisDiaporama.unbindThumbsEvent();
//thisDiaporama.unbindEventsPicture();

	thisDiaporama.lightbox.css({'left':nextX, 'top':-thisDiaporama.lightbox.width()});
	thisDiaporama.lightbox.animate({'opacity':1, 'top':nextY}, { duration: thisDiaporama.nextX } );
	thisDiaporama.picContainer.animate({'height':thisDiaporama.dim.height, 'width':thisDiaporama.dim.width },
									   {duration:parseInt( thisDiaporama.durationTransition / 2),
										complete:function(){thisDiaporama.animatesComplete();}});
};

/**
 * 	HANDLER BEGIN ANIMATIONS
 */
fnDiaporama.prototype.animatesStart = function() {
	var thisDiaporama = this;
	thisDiaporama.unbindKeyup();
	thisDiaporama.showPreloder();
	thisDiaporama.showOverlayThumbs();
	thisDiaporama.unbindEventsPicture();
	//thisDiaporama.unbindClicThumbs();
};

/**
 * HANDLER END ANIMATIONS
 */
fnDiaporama.prototype.animatesComplete = function() {
	var thisDiaporama = this;
	thisDiaporama.hideOverlayThumbs();
	//var timeOut =  setTimeout( function() { thisDiaporama.bindKeyup(); }, 125 );
	if ( thisDiaporama.picCount > 1 ) {
		thisDiaporama.bindKeyup();
		thisDiaporama.bindEventsPicture();
	};
};

/**
 *  ----------------------
 *  MISCELLANOUS FUNCTIONS
 *  ----------------------
 */

/**
 * 	ADD LEFT RIGHT NAVIGATION OVER PICTURE
 */
fnDiaporama.prototype.bindEventsPicture = function() {
	var thisDiaporama = this;
	
	if ( thisDiaporama.picContainer.find('div.picCtnNext') ) thisDiaporama.picContainer.find('div.picCtnNext').remove();
	if ( thisDiaporama.picContainer.find('div.picCtnPrev') ) thisDiaporama.picContainer.find('div.picCtnPrev').remove();
	
//	EVENT NEXT
	thisDiaporama.picContainer.append('<div class="picCtnNext" />');
	thisDiaporama.picCtnNext = jQuery('.lightbox .picContainer .picCtnNext');
	thisDiaporama.picCtnNext.css({'opacity':0});
	var pWidth = parseInt( thisDiaporama.dim.width / 2.1 );
	var pHeight = parseInt( thisDiaporama.dim.height );
	thisDiaporama.picCtnNext.width( pWidth);
	thisDiaporama.picCtnNext.height( pHeight);
	thisDiaporama.picCtnNext.mouseover( function(){ jQuery(this).animate({'opacity':1}, {duration:175}); });
	thisDiaporama.picCtnNext.mouseout( function(){ jQuery(this).animate({'opacity':0}, {duration:175}); });
	thisDiaporama.picCtnNext.click( function(){  thisDiaporama.nextPicture(); });
	  
	  
//	EVENT PREV this.picCtnNext = null;
	thisDiaporama.picContainer.append('<div class="picCtnPrev" />');
	thisDiaporama.picCtnPrev = jQuery('.lightbox .picContainer .picCtnPrev');
	thisDiaporama.picCtnPrev.css({"opacity":0});
	var pWidth = parseInt( thisDiaporama.dim.width / 2.1 );
	var pHeight = parseInt( thisDiaporama.dim.height );
	thisDiaporama.picCtnPrev.width( pWidth);
	thisDiaporama.picCtnPrev.height( pHeight);
	thisDiaporama.picCtnPrev.mouseover( function(){ jQuery(this).animate({'opacity':1}, {duration:175});});
	thisDiaporama.picCtnPrev.mouseout( function(){ jQuery(this).animate({'opacity':0}, {duration:175});});
	thisDiaporama.picCtnPrev.click( function(){  thisDiaporama.prevPicture(); } );
	  
	/* ie */
	if ( jQuery.browser.msie ) {
		thisDiaporama.picCtnNext.css({"background-image":"url('"+Drupal.settings.basePath+"sites/all/themes/studioimpresarios/img/arrownextie.png')"});
		thisDiaporama.picCtnPrev.css({"background-image":"url('"+Drupal.settings.basePath+"sites/all/themes/studioimpresarios/img/arrowprevie.png')"});
	}
};

fnDiaporama.prototype.unbindEventsPicture = function() {
	var thisDiaporama = this;
	/* remove all events */
	if ( thisDiaporama.picCtnNext != null ) thisDiaporama.picCtnNext.remove();
	if ( thisDiaporama.picCtnPrev != null ) thisDiaporama.picCtnPrev.remove();
};

/**
 * 	BIND / UNBIND KEYS HANDLER
 */
fnDiaporama.prototype.bindKeyup = function() {
	var thisDiaporama = this;  
	jQuery(document).keyup( function(e){
		var keypressed = Math.max( e.which, e.keyCode);
		switch( keypressed  ) {
			case 39: 	/* next */
				thisDiaporama.nextPicture();
				return false;
			break;
			case 37:	/* prev */
				thisDiaporama.prevPicture();
				return false;
			break;
			case 27:
			/*case 32: 	 spacebarre esc */
				thisDiaporama.closeDiaporama();
				return false;
			break;
		}});
};

fnDiaporama.prototype.unbindKeyup = function() {
	  jQuery(document).unbind("keyup");
};

/**
 * 	PREV / NEXT KEY NAVIGATION
 */
fnDiaporama.prototype.nextPicture = function( ) {
	var thisDiaporama = this;
	var nextPicture = thisDiaporama.picCurrent < thisDiaporama.picCount-1 ? (thisDiaporama.picCurrent +1 ) : 0; 
	if ( nextPicture != thisDiaporama.picCurrent ) {
		thisDiaporama.picLast =  thisDiaporama.picCurrent;
		thisDiaporama.picCurrent = nextPicture;
		thisDiaporama.createImage();
	};
};

fnDiaporama.prototype.prevPicture = function( ) {
	var thisDiaporama = this;
	var prevPicture = thisDiaporama.picCurrent > 0  ? (thisDiaporama.picCurrent - 1 ) : thisDiaporama.picCount-1;
	if ( prevPicture != thisDiaporama.picCurrent ) {
		thisDiaporama.picLast =  thisDiaporama.picCurrent;
		thisDiaporama.picCurrent = prevPicture;
		thisDiaporama.createImage();
   };
};

/**
 *  SHOW HIDE PRELOADER PICTURE 
 */
fnDiaporama.prototype.showPreloder = function() {
  jQuery('body').append('<div class="preloader" />');
};

fnDiaporama.prototype.hidePreloder = function() {
  jQuery('div.preloader').remove();
};

/**
 *  CALCULATE WIDTH THUMB CONTAINER 
 */
fnDiaporama.prototype.thumbsPicsContainerPosition = function( pWidth ) { 
	var thisDiaporama = this; 
	jQuery('.thumbsPicsContainer').width( pWidth );
	thisDiaporama.thumbsPicsContainerWidth = pWidth ;
	var posX = parseInt( (thisDiaporama.wWindow - pWidth ) / 2);
	posX = posX < 0 ? 0 : posX;
	jQuery('.thumbsPicsContainer').css({"left":posX});
};

/**
 *  ADD OVERLAY THUMB + EVENT ROLLOVER & ROLLOUT 
 */
fnDiaporama.prototype.putSpanOverlay = function( pElt, pIndex ){
	var thisDiaporama = this;
	var elt = pElt;
	thisDiaporama.picArray[pIndex].spanOverlayHeight =  parseInt( jQuery( elt ).height() ) + 5;
	elt.css({'bottom': -thisDiaporama.picArray[pIndex].spanOverlayHeight, 'opacity':0.85});
};

fnDiaporama.prototype.putEventsOverlay = function( pElt, pIndex ){
	var thisDiaporama = this;
	var elt = pElt;
	var eltClass =  elt.attr('class');
	var spanOverlay = elt.find('span.span-overlay');
	var spanOverlayHeight =  -thisDiaporama.picArray[pIndex].spanOverlayHeight;
	var eltIndex =  thisDiaporama.getLiSelected( elt.attr('class') ); 
	elt.mouseenter(function() { 
		if ( thisDiaporama.picCurrent != thisDiaporama.getLiSelected(eltClass) ) {
			clearTimeout( thisDiaporama.picArray[eltIndex].timeoutOverlay );
			thisDiaporama.picArray[eltIndex].timeoutOverlay = null;
			thisDiaporama.picArray[eltIndex].timeoutOverlay = setTimeout( function(){ thisDiaporama.overlayAnimate( spanOverlay, 0 ); }, 100 );   
		}; 
	});
   
	elt.mouseleave(function() { 
		if ( thisDiaporama.picCurrent != thisDiaporama.getLiSelected(eltClass) ) {
			if ( thisDiaporama.picArray[eltIndex].timeoutOverlay != null ) {
				clearTimeout( thisDiaporama.picArray[eltIndex].timeoutOverlay );
				thisDiaporama.picArray[eltIndex].timeoutOverlay = null;
				thisDiaporama.overlayAnimate( spanOverlay, spanOverlayHeight ) ; 
			}; 
		};
	});
};

/**
 *  RETURN LI THUMB CLASS 
 */
fnDiaporama.prototype.getLiSelected = function( pClass ) {
	var classes = pClass.split('_');
	var classIndex = -1;
	if ( classes.length > 0 ) {
		classIndex = parseInt(classes[1]);
		return classIndex;
	};
	return false; 
};

/**
 *  APPEND OVERLAY CONTAINER THUMBS TO STOP EVENTS
 */
fnDiaporama.prototype.appendOverlayThumbs = function() {
	var thisDiaporama = this;
	jQuery('.thumbsContainer .thumbsPicsContainer').after('<div class="thumbs-overlay" />'); 
	jQuery('.thumbsContainer .thumbs-overlay').css({'background':'#000000', 
													'opacity':0,  
													'position':'absolute', 
													'left':0, 
													'top':0, 
													'width':'100%', 
													'height':'100%'});
};

/**
 *  INITIALIZE LIGHTBOX
 */
fnDiaporama.prototype.initLightbox = function( ) {	  
	var thisDiaporama = this;
	jQuery('body').append('<div class="lightbox" />');
	thisDiaporama.lightbox = jQuery('div.lightbox');
	thisDiaporama.lightbox.append('<div class="picContainer" />');
	thisDiaporama.picContainer = jQuery('.lightbox div.picContainer');
		  
//	RETREIVE HEIGHT HEADER AND FOOTER
	thisDiaporama.hHeader = jQuery('div.diaporamaTitle').height();
	thisDiaporama.hFooter = jQuery('div.thumbsContainer').height(); 
	
//	SET X POSITION
	var x = parseInt( jQuery(window).width() /2 ) ;
	var y = parseInt( jQuery(window).height()  /2 );
	if ( jQuery.browser.opera ) y = ( window.innerHeight - jQuery('.lightbox').height() ) /2 ;
	thisDiaporama.xInit = x;
	thisDiaporama.yInit = y;
	thisDiaporama.lightbox = jQuery('.lightbox');
	jQuery('div.lightbox').css({'opacity':0});
	return true;
};

/**
 *  LOAD AND CREATE IMAGE
 *  !!!!! ADD EVENTS HANDLER !!!!!
 */
fnDiaporama.prototype.createImage = function() {
	var thisDiaporama = this;
	thisDiaporama.animatesStart();
	var image = new Image();
	image.src = thisDiaporama.picArray[thisDiaporama.picCurrent].imgSrc;
	if ( image.complete ) { 
		thisDiaporama.showPicture( image );
		return;
	} else {
		jQuery(image).load( function() { 
			thisDiaporama.showPicture( image );
			return;});
	};   
};

/**
 *  SHOW / HIDE OVERLAY THUMBS
 */
fnDiaporama.prototype.showOverlayThumbs = function() {
	var thisDiaporama = this;
	jQuery('.thumbsContainer .thumbs-overlay').css({'display':'block'});
};

fnDiaporama.prototype.hideOverlayThumbs = function() {
	var thisDiaporama = this;
	jQuery('.thumbsContainer .thumbs-overlay').css({'display':'none'});
};

/**
 *  SHOW / HIDE OVERLAY THUMBS
 */
fnDiaporama.prototype.overlayAnimate = function( pElt, pPosition ) {      
	pElt.stop().clearQueue().animate( {'bottom':pPosition}, {duration: 200});  
};

/**
*	CALCULATE OPTIMAL DIMENSION 
*/
fnDiaporama.prototype.picDimension = function( pWidth, pHeight ) {
	var thisDiaporama = this;
	var minWidth = jQuery(window).width();
	var minHeight = jQuery(window).height() - thisDiaporama.hHeader - thisDiaporama.hFooter - thisDiaporama.hInfosImg;	  
	var w = pWidth;
	var h = pHeight;
	var coef = Math.min( (minWidth/w) , (minHeight/h ));   
	if ( coef < 1 ) {
		w *= coef;
		h *= coef;
	};
	return {width:parseInt(w), height:parseInt(h)};  
};

/**
 *  CLOSE DIAPORAMA
 */
fnDiaporama.prototype.closeDiaporama = function(){

	var thisDiaporama = this;
	
	thisDiaporama.unbindEventsPicture();
	thisDiaporama.unbindKeyup();
	
	thisDiaporama.thumbsContainer.stop().clearQueue().animate({'bottom':-112}, 
			 {duration:parseInt( thisDiaporama.durationTransition / 2),
			  complete:function(){ thisDiaporama.thumbsContainer.remove(); }} );
		
	thisDiaporama.diaporamaTitle.stop().clearQueue().animate({'top':-53}, 
															 {duration:parseInt( thisDiaporama.durationTransition / 2),
															  complete:function(){ thisDiaporama.diaporamaTitle.remove(); }} );
															 	
	jQuery(thisDiaporama.divLayer).stop().clearQueue().animate({'opacity':0}, 
			  							   {duration:parseInt( thisDiaporama.durationTransition / 2),
											step:function( pOpacity ) { thisDiaporama.lightbox.css({'opacity': pOpacity}); },
		   									complete:function(){ jQuery(thisDiaporama.divLayer).remove(); 
		   														 thisDiaporama.lightbox.remove();	
		   														 document.diaporama = null;
		   														}} ); 
	
};

/**
 *  REFRESH DIAPORAMA
 */
fnDiaporama.prototype.refreshDiaporama = function(){

	var thisDiaporama = this;
	
	thisDiaporama.unbindEventsPicture();
	thisDiaporama.unbindKeyup();
		
	thisDiaporama.lightbox.stop().clearQueue().animate({'opacity':0}, 
			  										   {duration:parseInt( thisDiaporama.durationTransition / 2),
			   											complete:function(){ thisDiaporama.lightbox.remove(); }} );
	
	thisDiaporama.thumbsContainer.stop().clearQueue().animate({'bottom':-112}, 
			 							  {duration:parseInt( thisDiaporama.durationTransition / 1.5),
		  								   complete:function(){ 
		  									   	thisDiaporama.thumbsContainer.remove();
		  									    thisDiaporama.diaporamaTitle.remove();
												thisDiaporama.createThumbs();
		  								   }} );   
		
};

/**
 * 	ELEMENTS TO RESIZE
 */
fnDiaporama.prototype.onresizeEvent = function() {
	var thisDiaporama = this;
	thisDiaporama.wWindow = jQuery(window).width();
	thisDiaporama.hWindow = jQuery(window).height();
	if ( jQuery.browser.opera ) thisDiaporama.hWindow = window.innerHeight;
	jQuery(thisDiaporama.divLayer).width(thisDiaporama.wWindow);
	jQuery(thisDiaporama.divLayer).height(thisDiaporama.hWindow);
	thisDiaporama.diaporamaTitle.width( thisDiaporama.wWindow );
	thisDiaporama.thumbsContainer.width( thisDiaporama.wWindow );
	thisDiaporama.widthHeightAnimate();
    if ( thisDiaporama.thumbsPicsContainerWidth < thisDiaporama.wWindow ) {
    	thisDiaporama.thumbsPicsContainerPosition( thisDiaporama.thumbsPicsContainerWidth );
    	thisDiaporama.unbindRollOverThumbsCtn();
    	thisDiaporama.allowThumbsContainerMoving = false;
    	//thisDiaporama.bindRollOverThumbsCtn();
    } else {    	
    	thisDiaporama.thumbsPicsContainer.css({'left':0});
    	//thisDiaporama.unbindRollOverThumbsCtn();
    	thisDiaporama.bindRollOverThumbsCtn();
    	thisDiaporama.allowThumbsContainerMoving = true;
    };
};

/**
*  EVENTS RESIZE
*/
window.onresize = function() {
	if ( document.diaporama != null ) {
		var thisDiaporama = document.diaporama;
		thisDiaporama.onresizeEvent();
	};
};
;

