(function() {
  var $, studioworksjs;
  $ = jQuery;
  studioworksjs = {};
  studioworksjs.portrait_tooltips = function($block) {
    return $block.once(function() {
      var on_hover, on_out;
      $(".field-items2", this).each(function() {
        if ($(".field-item2", this).length > 3) {
          return $(".field-item2:last-child", this).addClass("last-field");
        }
      });
      $(".thumb figcaption", $block).stop().css({
        display: "none",
        visibility: "hidden",
        opacity: 0
      }).fadeOut(0);
      on_hover = function(e) {
        $(this).addClass("hover");
        return $("figcaption", $(this)).stop().css({
          display: "block",
          visibility: "visible"
        }).animate({
          opacity: 1.0
        }, 300);
      };
      on_out = function(e) {
        $(this).removeClass("hover");
        return $("figcaption", $(this)).stop().css({
          display: "none",
          visibility: "hidden",
          opacity: 0
        }).fadeOut(0);
      };
      return $(".thumb", $block).hover(on_hover, on_out);
    });
  };
  studioworksjs.news = function($block, has_highlight) {
    var current_news, first_news, hide_description_item, show_description_item;
    if (has_highlight == null) {
      has_highlight = true;
    }
    current_news = false;
    first_news = $(".views-row:first");
    hide_description_item = function($target) {
      if (has_highlight) {
        if (first_news[0] !== $target[0]) {
          return $(".description", $target).slideUp(300);
        }
      } else {
        return $(".description", $target).slideUp(300);
      }
    };
    show_description_item = function($target) {
      return $(".description", $target).delay(100).slideDown(200);
    };
    return $block.each(function() {
      var $this;
      $this = $(this);
      $this.addClass("js-processed");
      current_news = $(".views-row:first");
      $(".views-row:not(:first) .description", $this).hide();
      return $(".views-row").click(function(e) {
        var $t;
        e.preventDefault();
        $t = $(this);
        hide_description_item(current_news);
        current_news = $t;
        return show_description_item(current_news);
      });
    });
  };
  studioworksjs.sticky_footer = function($block) {
    return $block.once(function() {
      $("body").append($('#main-footer'));
      return $('#main-footer').stickyfooter();
    });
  };
  studioworksjs.portfolio_siblings = function($block) {
    var group_portfolio_thumbs, init_thumbs_scroll;
    group_portfolio_thumbs = function($target) {
      var $pThumbs, i, pArrLen, pPerDiv;
      $pThumbs = $('.article-type-project', $target);
      pArrLen = $pThumbs.length;
      pPerDiv = 5;
      for (i = 0; 0 <= pArrLen ? i <= pArrLen : i >= pArrLen; i += pPerDiv) {
        $pThumbs.filter(':eq(' + i + '),:lt(' + (i + pPerDiv) + '):gt(' + i + ')').wrapAll('<div class="projects-group" />');
      }
      return true;
    };
    init_thumbs_scroll = function($target) {
      group_portfolio_thumbs($target);
      $("nav.portfolio").css({
        overflow: "hidden",
        position: "relative",
        width: 722,
        height: 180
      });
      $("nav.portfolio .inner").css({
        position: "absolute",
        width: "20000em"
      });
      $(".projects-group").css({
        position: "width",
        width: 722,
        float: "left"
      });
      $(".thumbs-nav a").css({
        cursor: "pointer"
      });
      $target.scrollable({
        items: ".inner"
      });
      return true;
    };
    return $block.each(function() {
      var $this;
      $this = $(this);
      $this.addClass("js-processed");
      return init_thumbs_scroll($(this));
    });
  };
  Drupal.behaviors.studioworks2_base = {
    attach: function(context, settings) {
      studioworksjs.news($("#block-views-news-block:not(.js-processed)"));
      studioworksjs.news($("#block-views-jobs-block:not(.js-processed)"), false);
      studioworksjs.portfolio_siblings($("#project_siblings:not(.js-processed)"));
      studioworksjs.portrait_tooltips($(".ds-1col.article-portraits-liste"));
      return $("#article-22").once(function() {
        return $(".field-name-field-groupes .scrollable").scrollable({
          items: ".field-items"
        });
      });
    }
  };
}).call(this);
;
/*!
 * jQuery Tools v1.2.6 - The missing UI library for the Web
 * 
 * scrollable/scrollable.js
 * tooltip/tooltip.js
 * 
 * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
 * 
 * http://flowplayer.org/tools/
 * 
 */
(function(a){a.tools=a.tools||{version:"v1.2.6"},a.tools.scrollable={conf:{activeClass:"active",circular:!1,clonedClass:"cloned",disabledClass:"disabled",easing:"swing",initialIndex:0,item:"> *",items:".items",keyboard:!0,mousewheel:!1,next:".next",prev:".prev",size:1,speed:400,vertical:!1,touch:!0,wheelSpeed:0}};function b(a,b){var c=parseInt(a.css(b),10);if(c)return c;var d=a[0].currentStyle;return d&&d.width&&parseInt(d.width,10)}function c(b,c){var d=a(c);return d.length<2?d:b.parent().find(c)}var d;function e(b,e){var f=this,g=b.add(f),h=b.children(),i=0,j=e.vertical;d||(d=f),h.length>1&&(h=a(e.items,b)),e.size>1&&(e.circular=!1),a.extend(f,{getConf:function(){return e},getIndex:function(){return i},getSize:function(){return f.getItems().size()},getNaviButtons:function(){return n.add(o)},getRoot:function(){return b},getItemWrap:function(){return h},getItems:function(){return h.find(e.item).not("."+e.clonedClass)},move:function(a,b){return f.seekTo(i+a,b)},next:function(a){return f.move(e.size,a)},prev:function(a){return f.move(-e.size,a)},begin:function(a){return f.seekTo(0,a)},end:function(a){return f.seekTo(f.getSize()-1,a)},focus:function(){d=f;return f},addItem:function(b){b=a(b),e.circular?(h.children().last().before(b),h.children().first().replaceWith(b.clone().addClass(e.clonedClass))):(h.append(b),o.removeClass("disabled")),g.trigger("onAddItem",[b]);return f},seekTo:function(b,c,k){b.jquery||(b*=1);if(e.circular&&b===0&&i==-1&&c!==0)return f;if(!e.circular&&b<0||b>f.getSize()||b<-1)return f;var l=b;b.jquery?b=f.getItems().index(b):l=f.getItems().eq(b);var m=a.Event("onBeforeSeek");if(!k){g.trigger(m,[b,c]);if(m.isDefaultPrevented()||!l.length)return f}var n=j?{top:-l.position().top}:{left:-l.position().left};i=b,d=f,c===undefined&&(c=e.speed),h.animate(n,c,e.easing,k||function(){g.trigger("onSeek",[b])});return f}}),a.each(["onBeforeSeek","onSeek","onAddItem"],function(b,c){a.isFunction(e[c])&&a(f).bind(c,e[c]),f[c]=function(b){b&&a(f).bind(c,b);return f}});if(e.circular){var k=f.getItems().slice(-1).clone().prependTo(h),l=f.getItems().eq(1).clone().appendTo(h);k.add(l).addClass(e.clonedClass),f.onBeforeSeek(function(a,b,c){if(!a.isDefaultPrevented()){if(b==-1){f.seekTo(k,c,function(){f.end(0)});return a.preventDefault()}b==f.getSize()&&f.seekTo(l,c,function(){f.begin(0)})}});var m=b.parents().add(b).filter(function(){if(a(this).css("display")==="none")return!0});m.length?(m.show(),f.seekTo(0,0,function(){}),m.hide()):f.seekTo(0,0,function(){})}var n=c(b,e.prev).click(function(a){a.stopPropagation(),f.prev()}),o=c(b,e.next).click(function(a){a.stopPropagation(),f.next()});e.circular||(f.onBeforeSeek(function(a,b){setTimeout(function(){a.isDefaultPrevented()||(n.toggleClass(e.disabledClass,b<=0),o.toggleClass(e.disabledClass,b>=f.getSize()-1))},1)}),e.initialIndex||n.addClass(e.disabledClass)),f.getSize()<2&&n.add(o).addClass(e.disabledClass),e.mousewheel&&a.fn.mousewheel&&b.mousewheel(function(a,b){if(e.mousewheel){f.move(b<0?1:-1,e.wheelSpeed||50);return!1}});if(e.touch){var p={};h[0].ontouchstart=function(a){var b=a.touches[0];p.x=b.clientX,p.y=b.clientY},h[0].ontouchmove=function(a){if(a.touches.length==1&&!h.is(":animated")){var b=a.touches[0],c=p.x-b.clientX,d=p.y-b.clientY;f[j&&d>0||!j&&c>0?"next":"prev"](),a.preventDefault()}}}e.keyboard&&a(document).bind("keydown.scrollable",function(b){if(!(!e.keyboard||b.altKey||b.ctrlKey||b.metaKey||a(b.target).is(":input"))){if(e.keyboard!="static"&&d!=f)return;var c=b.keyCode;if(j&&(c==38||c==40)){f.move(c==38?-1:1);return b.preventDefault()}if(!j&&(c==37||c==39)){f.move(c==37?-1:1);return b.preventDefault()}}}),e.initialIndex&&f.seekTo(e.initialIndex,0,function(){})}a.fn.scrollable=function(b){var c=this.data("scrollable");if(c)return c;b=a.extend({},a.tools.scrollable.conf,b),this.each(function(){c=new e(a(this),b),a(this).data("scrollable",c)});return b.api?c:this}})(jQuery);
(function(a){a.tools=a.tools||{version:"v1.2.6"},a.tools.tooltip={conf:{effect:"toggle",fadeOutSpeed:"fast",predelay:0,delay:30,opacity:1,tip:0,fadeIE:!1,position:["top","center"],offset:[0,0],relative:!1,cancelDefault:!0,events:{def:"mouseenter,mouseleave",input:"focus,blur",widget:"focus mouseenter,blur mouseleave",tooltip:"mouseenter,mouseleave"},layout:"<div/>",tipClass:"tooltip"},addEffect:function(a,c,d){b[a]=[c,d]}};var b={toggle:[function(a){var b=this.getConf(),c=this.getTip(),d=b.opacity;d<1&&c.css({opacity:d}),c.show(),a.call()},function(a){this.getTip().hide(),a.call()}],fade:[function(b){var c=this.getConf();!a.browser.msie||c.fadeIE?this.getTip().fadeTo(c.fadeInSpeed,c.opacity,b):(this.getTip().show(),b())},function(b){var c=this.getConf();!a.browser.msie||c.fadeIE?this.getTip().fadeOut(c.fadeOutSpeed,b):(this.getTip().hide(),b())}]};function c(b,c,d){var e=d.relative?b.position().top:b.offset().top,f=d.relative?b.position().left:b.offset().left,g=d.position[0];e-=c.outerHeight()-d.offset[0],f+=b.outerWidth()+d.offset[1],/iPad/i.test(navigator.userAgent)&&(e-=a(window).scrollTop());var h=c.outerHeight()+b.outerHeight();g=="center"&&(e+=h/2),g=="bottom"&&(e+=h),g=d.position[1];var i=c.outerWidth()+b.outerWidth();g=="center"&&(f-=i/2),g=="left"&&(f-=i);return{top:e,left:f}}function d(d,e){var f=this,g=d.add(f),h,i=0,j=0,k=d.attr("title"),l=d.attr("data-tooltip"),m=b[e.effect],n,o=d.is(":input"),p=o&&d.is(":checkbox, :radio, select, :button, :submit"),q=d.attr("type"),r=e.events[q]||e.events[o?p?"widget":"input":"def"];if(!m)throw"Nonexistent effect \""+e.effect+"\"";r=r.split(/,\s*/);if(r.length!=2)throw"Tooltip: bad events configuration for "+q;d.bind(r[0],function(a){clearTimeout(i),e.predelay?j=setTimeout(function(){f.show(a)},e.predelay):f.show(a)}).bind(r[1],function(a){clearTimeout(j),e.delay?i=setTimeout(function(){f.hide(a)},e.delay):f.hide(a)}),k&&e.cancelDefault&&(d.removeAttr("title"),d.data("title",k)),a.extend(f,{show:function(b){if(!h){l?h=a(l):e.tip?h=a(e.tip).eq(0):k?h=a(e.layout).addClass(e.tipClass).appendTo(document.body).hide().append(k):(h=d.next(),h.length||(h=d.parent().next()));if(!h.length)throw"Cannot find tooltip for "+d}if(f.isShown())return f;h.stop(!0,!0);var o=c(d,h,e);e.tip&&h.html(d.data("title")),b=a.Event(),b.type="onBeforeShow",g.trigger(b,[o]);if(b.isDefaultPrevented())return f;o=c(d,h,e),h.css({position:"absolute",top:o.top,left:o.left}),n=!0,m[0].call(f,function(){b.type="onShow",n="full",g.trigger(b)});var p=e.events.tooltip.split(/,\s*/);h.data("__set")||(h.unbind(p[0]).bind(p[0],function(){clearTimeout(i),clearTimeout(j)}),p[1]&&!d.is("input:not(:checkbox, :radio), textarea")&&h.unbind(p[1]).bind(p[1],function(a){a.relatedTarget!=d[0]&&d.trigger(r[1].split(" ")[0])}),e.tip||h.data("__set",!0));return f},hide:function(c){if(!h||!f.isShown())return f;c=a.Event(),c.type="onBeforeHide",g.trigger(c);if(!c.isDefaultPrevented()){n=!1,b[e.effect][1].call(f,function(){c.type="onHide",g.trigger(c)});return f}},isShown:function(a){return a?n=="full":n},getConf:function(){return e},getTip:function(){return h},getTrigger:function(){return d}}),a.each("onHide,onBeforeShow,onShow,onBeforeHide".split(","),function(b,c){a.isFunction(e[c])&&a(f).bind(c,e[c]),f[c]=function(b){b&&a(f).bind(c,b);return f}})}a.fn.tooltip=function(b){var c=this.data("tooltip");if(c)return c;b=a.extend(!0,{},a.tools.tooltip.conf,b),typeof b.position=="string"&&(b.position=b.position.split(/,?\s/)),this.each(function(){c=new d(a(this),b),a(this).data("tooltip",c)});return b.api?c:this}})(jQuery);
;
/*
 *
 * Copyright (c) 2009 Heyday (dev [at] heyday [dot] co [dot] nz)
 * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license
 *
 */

/**
 *
 * @name     jquery.heyday.stickyfooter
 * @version  1.0
 * @author   Shane Garelja (shane [at] heyday [dot] co [dot] nz)
 * @requires jQuery
 *
 */

/*
 * Sticky footer plugin for jQuery

Minimum CSS:
.liner {
  margin:0 auto;
  width:960px;
}
#Footer {
    width: 100%;
  z-index:100;
  position:relative;
    overflow: hidden;
}

Ideal markup example:
<body>
    <div id="Container" class="liner">
        <p>Main content</p>
    </div>
    <div id="Footer">
        <div class="liner">
            <p>Centred footer content</p>
        </div>
    </div>
</body>

Example usage:
$('#Footer').stickyfooter();

 */

;(function ($) {

  $.fn.stickyfooter = function (options) {

            // Settings
    var settings = $.extend(
            {
                // Height in pixels of drawer in "closed" state
                visible: 60,
                // ID of toggle element that opens/closes drawer
                toggleCSSSelector: '#Toggle',
                // Class added to toggle to indicate it it open/closed
                drawerOpenCSSClass: 'open',
                // Callback to set toggle state to inactive
                inactiveToggle_Callback: function() {
                    $(settings.toggleCSSSelector).animate({'opacity':'0.2'});
                },
                // Callback to set toggle state to active
                activeToggle_Callback: function() {
                    $(settings.toggleCSSSelector).animate({'opacity':'1.0'});
                },
                // Callback to add class to toggle to indicate open state
                drawerOpen_Callback: function() {
                    $(settings.toggleCSSSelector).addClass(settings.drawerOpenCSSClass);
                },
                // Callback to add class to toggle to indicate closed state
                drawerClosed_Callback: function() {
                    $(settings.toggleCSSSelector).removeClass(settings.drawerOpenCSSClass);
                }
            }, options ),

            // Global vars
            $window = $(window),
            $footer = $(this),
            _drawerOpen = false,

            // Functions
            setFooterPos = function(firstRun) {

                var footerTopPos = ($footer.height()) * -1,
                    availableHeight = $(document).height() - $window.height(),
                    kickInPos = $window.scrollTop() + $footer.height() - settings.visible;

                // Set to pos fixed bottom if content less than window height
                if ((availableHeight <= 0)) {
                    $footer.stop().css({position: 'fixed', left: '0px', bottom: 0});
                    settings.inactiveToggle_Callback();
                } else {
                    // Set to pos relative if footer visible
                    if ((availableHeight <= kickInPos) && ($footer.css('position') != 'relative' || firstRun)) {
                        $footer.stop().css({position: 'relative', bottom: 'auto'});
                        settings.inactiveToggle_Callback();
                    // Set to pos fixed if footer NOT visible
                    } else if ((availableHeight > kickInPos) && ($footer.css('position') != 'fixed' || firstRun)) {
                        if (firstRun) {
                            $footer.stop().css({position: 'fixed', left: '0px', bottom: footerTopPos}).animate({'bottom': footerTopPos + settings.visible})
                        } else {
                            $footer.stop().css({position: 'fixed', left: '0px', bottom: footerTopPos + settings.visible});
                        }
                        settings.activeToggle_Callback();
                    }
                }
                
            };

    return this.each(function() {

            if (($.browser.msie && $.browser.version <= 6) || navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod') {

                // Not supported

            } else {

                $footer.wrap('<div></div>').parent().css({'width': '100%', 'height':$footer.height()});
                $window.bind('scroll.stickyfooter resize.stickyfooter', function () {
                    if (!_drawerOpen) setFooterPos(false);
                });
                $(settings.toggleCSSSelector).bind('click', function(e) {
                    e.preventDefault();
                    if ($footer.css('position') != 'relative') {
                        if (_drawerOpen) {
                            $footer.stop().animate({ bottom:
                                    Math.min(
                                        $footer.height() - settings.visible,
                                        $(document).height() - $window.height() - $window.scrollTop()
                                    ) * -1 });

                            settings.drawerClosed_Callback();
                            _drawerOpen = false;
                        } else {
                            $footer.stop().animate({bottom: $footer.height() - $footer.height()});
                            settings.drawerOpen_Callback();
                            _drawerOpen = true;
                        }
                    }
                });
                setFooterPos(true);
                
                $footer.wrap('<div class="stickywrap"></div>').parent().css({'width': '956px', 'margin': 'auto'});
            }

        });


  };

})(jQuery);;

