(function() {
  var CONSOLE_DEBUG_ON, Contactlist, Contacts, Controls, Display, Playlist, Router, Video, activatePage, console_dbg, contactPageLoaded, counterTimer, currIndex, flashLoaded, isPlaying, loadPageLoaded, loadTimer, loadedFromRoot, noTransitions, onContactPage, posterImagesLoaded, requireFlash, siteName, spinnerTimer, touchMode, uiSpeed;
  CONSOLE_DEBUG_ON = true;
  console_dbg = function(_message) {
    if (CONSOLE_DEBUG_ON) {
      return console.log(_message);
    }
  };
  siteName = "DDB Group New Zealand";
  uiSpeed = 200;
  counterTimer = null;
  spinnerTimer = null;
  loadTimer = null;
  activatePage = 0;
  currIndex = -1;
  noTransitions = false;
  requireFlash = false;
  touchMode = false;
  isPlaying = false;
  flashLoaded = false;
  onContactPage = false;
  loadedFromRoot = false;
  loadPageLoaded = false;
  contactPageLoaded = false;
  posterImagesLoaded = false;
  Playlist = externalPlaylist;
  Contactlist = externalContactList;
  Controls = {
    panel: $('#bottom'),
    details: $('#bottom #details'),
    next: $('#right'),
    prev: $('#left'),
    close: $('#top-right'),
    play: $('#center'),
    progress: $('#progress'),
    list: $('#nav'),
    logo: $('#top-left'),
    contact: $('#btn-contact'),
    largeLogo: $('#title'),
    loaderCircle: $('#spinner'),
    loaderText: $('#counter'),
    loader: $('#loader'),
    bottomDiv: $('#bottom')
  };
  Video = (function(_$vidElement) {
    var $poster, $video, activate, active, bufferProgress, deactivate, init, load, monitorLoaded, monitorProgress, pause, play, playPause, setProgress, slide, stop, swapProgressBar, vidWrapper, video, _VideoBuffered, _VideoBytesLoaded, _VideoCurrentTime, _VideoDuration, _VideoSetCurrentTime;
    video = $("#video").get(0);
    $video = _$vidElement;
    vidWrapper = $('#vidWrapper');
    $poster = $("#poster");
    isPlaying = false;
    active = true;
    init = function() {
      monitorProgress(false);
      if (requireFlash === true) {
        $('#video').hide();
        return video = $('#flashvideo').get(0);
      } else {
        $('#flashvideo').hide();
        return vidWrapper.hide();
      }
    };
    load = function(_item) {
      var dir, newIndex;
      newIndex = $(Playlist).index(_item);
      if (requireFlash === true) {
        video.flash_src(_item.source.h264);
      } else if (requireFlash === false) {
        video.src = _item.source.h264;
        $poster.hide();
      }
      if (requireFlash === true) {
        video.flash_load();
      } else {
        video.load();
      }
      dir = (currIndex < newIndex ? "next" : (currIndex === newIndex ? "none" : "prev"));
      slide(dir, _item);
      if (!active) {
        activate();
      }
      return stop();
    };
    playPause = function() {
      if (isPlaying !== true) {
        return play();
      } else {
        return pause();
      }
    };
    play = function() {
      if (requireFlash !== true) {
        vidWrapper.show();
      }
      Controls.play.hover(function() {
        return Controls.play.fadeTo(uiSpeed, 1);
      }, function() {
        return Controls.play.fadeTo(uiSpeed, 0);
      }).addClass('paused');
      Controls.close.show();
      Controls.logo.fadeTo(uiSpeed, 0.3);
      Controls.close.fadeTo(uiSpeed, 0.5);
      Controls.prev.fadeOut(uiSpeed);
      Controls.next.fadeOut(uiSpeed);
      swapProgressBar("progress");
      $('#underlay').fadeTo(uiSpeed, 1);
      $(window).trigger('resize');
      $poster.fadeTo(uiSpeed, 0);
      monitorProgress(true);
      monitorLoaded(true);
      if (requireFlash === true) {
        video.flash_play();
      } else {
        video.play();
      }
      return isPlaying = true;
    };
    pause = function() {
      monitorProgress(false);
      Controls.logo.fadeTo(uiSpeed, 1);
      Controls.close.fadeTo(uiSpeed, 1);
      Controls.play.fadeTo(uiSpeed, 1).unbind("mouseenter mouseleave").removeClass("paused");
      if (requireFlash === true) {
        video.flash_pause();
      } else {
        video.pause();
      }
      return isPlaying = false;
    };
    stop = function() {
      monitorLoaded(false);
      $('#underlay').fadeTo(uiSpeed, 0);
      pause();
      $poster.fadeTo(uiSpeed, 1);
      Controls.close.fadeTo(uiSpeed, 0);
      Controls.close.hide();
      Controls.prev.fadeIn(uiSpeed);
      Controls.next.fadeIn(uiSpeed);
      swapProgressBar("playlist");
      if (requireFlash !== true) {
        vidWrapper.hide();
      }
      return isPlaying = false;
    };
    monitorProgress = function(monitor) {
      var playPercent;
      if (monitor === true) {
        playPercent = 100 * (_VideoCurrentTime() / _VideoDuration());
        try {
          Controls.progress.find(".bar").width(playPercent + "%");
        } catch (_e) {}
        setTimeout(function() {
          return monitorProgress(true);
        }, 50);
        Controls.progress.bind("mousedown", function(e) {
          setProgress(e.pageX);
          $('body').mousemove(function(ev) {
            return setProgress(ev.pageX);
          });
          return $('body').mouseup(function() {
            $('body').unbind("mousemove");
            return $('body').unbind("mouseup");
          });
        });
      }
      return playPercent = null;
    };
    bufferProgress = function(_switch) {
      var buffer, initBuff, loadDiff, playPercent;
      buffer = _switch;
      initBuff = _switch;
      pause = _switch;
      playPercent = (function() {
        try {
          return 100 * (_VideoCurrentTime() / _VideoDuration());
        } catch (_e) {}
      })();
      loadDiff = parseInt((((_VideoBuffered() / _VideoDuration()) * 100) / 3) * 2);
      if (initBuff === true && loadDiff <= 30 && (_VideoBuffered() / _VideoDuration()) * 100 < 100) {
        console_dbg("load diff is " + loadDiff);
        initBuff = false;
        buffer = true;
        pause = true;
      } else if (initBuff === false && loadDiff <= 10 && (_VideoBuffered() / _VideoDuration()) * 100 < 100) {
        initBuff = true;
        buffer = true;
        pause = true;
      } else {
        buffer = false;
        pause = false;
      }
      if (buffer === true && _VideoBuffered() < 100) {
        setTimeout(function() {
          return bufferProgress(true);
        }, 50);
      } else {
        Controls.loaderText.fadeOut(1000);
        Controls.loaderCircle.fadeOut(1000);
      }
      if (pause === true) {
        return video.pause();
      } else {
        return video.play();
      }
    };
    setProgress = function(pageX) {
      var clickPercent;
      clickPercent = Math.round((100 / Controls.progress.width()) * pageX);
      _VideoSetCurrentTime((_VideoDuration() / 100) * clickPercent);
      return clickPercent = null;
    };
    monitorLoaded = function(_switch) {
      var soFar;
      if (_switch === true) {
        soFar = (_VideoBuffered() / _VideoBytesLoaded()) * 100;
        if (soFar < 100) {
          try {
            Controls.loader.find(".bar").width(soFar + "%");
          } catch (_e) {}
          loadTimer = setTimeout(function() {
            return monitorLoaded(_switch);
          }, 50);
        } else {
          clearTimeout(loadTimer);
        }
      } else {
        clearTimeout(loadTimer);
      }
      if (soFar >= 100) {
        clearInterval(loadTimer);
        try {
          return Controls.loader.find(".bar").width("100%");
        } catch (_e) {}
      }
    };
    swapProgressBar = function(_option) {
      var dh;
      if (!_option) {
        dh = $progress.height();
        Controls.list.animate({
          height: dh + "px"
        }, uiSpeed);
        Controls.progress.animate({
          height: (dh - 20) + "px"
        }, uiSpeed);
        Controls.loader.animate({
          height: (dh - 20) + "px"
        }, uiSpeed);
        if (dh > 0) {
          Controls.progress.addClass("overflow");
          return Controls.loader.addClass("overflow");
        } else {
          Controls.progress.removeClass("overflow");
          return Controls.loader.removeClass("overflow");
        }
      } else if (_option === "progress") {
        Controls.list.animate({
          height: "0px"
        }, uiSpeed).addClass("overflow");
        Controls.progress.animate({
          height: "20px"
        }, uiSpeed);
        return Controls.loader.animate({
          height: "20px"
        }, uiSpeed);
      } else {
        Controls.list.animate({
          height: "20px"
        }, uiSpeed).removeClass("overflow");
        Controls.progress.animate({
          height: "0px"
        }, uiSpeed);
        return Controls.loader.animate({
          height: "0px"
        }, uiSpeed);
      }
    };
    deactivate = function() {
      Controls.play.hide();
      Controls.close.hide();
      Controls.next.hide();
      Controls.prev.hide();
      return active = false;
    };
    activate = function() {
      Controls.play.show();
      Controls.close.show();
      Controls.next.show();
      Controls.prev.show();
      return active = true;
    };
    slide = function(_dir, _item, _callback) {
      var $current, $next, otherDir;
      if (_dir === "none") {
        return;
          }
      $poster = $("#poster");
      $current = $poster.find("img");
      $next = $("<img class=\"" + _dir + "\" src=\"" + _item.poster + "\"/>");
      otherDir = (_dir === "prev" ? "next" : "prev");
      $poster.append($next);
      return $next.imagesLoaded(function() {
        $next.removeClass(_dir);
        $current.addClass(otherDir);
        return setTimeout(function() {
          return $current.remove();
        }, $next.findTransitionTime());
      });
    };
    _VideoCurrentTime = function() {
      if (requireFlash === true) {
        return video.flash_currentTime();
      } else {
        return video.currentTime;
      }
    };
    _VideoDuration = function() {
      if (requireFlash === true) {
        return video.flash_duration();
      } else {
        return video.duration;
      }
    };
    _VideoBytesLoaded = function() {
      if (requireFlash === true) {
        return video.flash_bytesTotal();
      } else {
        return video.duration;
      }
    };
    _VideoSetCurrentTime = function(time) {
      if (requireFlash === true) {
        return video.flash_currentTime(time);
      } else {
        return video.currentTime = time;
      }
    };
    _VideoBuffered = function() {
      if (requireFlash === true) {
        return video.flash_bytesLoaded();
      } else {
        try {
          return video.buffered.end(0);
        } catch (_e) {}
      }
    };
    return {
      isPlaying: isPlaying,
      active: active,
      deactivate: deactivate,
      activate: activate,
      playPause: playPause,
      stop: stop,
      time: null,
      load: load,
      init: init
    };
  })($('#vidWrapper'));
  Contacts = (function() {
    var init, newContactListItem;
    init = function() {
      var ContactList, contactlistFragment;
      contactPageLoaded = true;
      Display.init();
      $('#pages').append("<div class=\"page\" id=\"contact\"><ul class=\"wrapper\" id=\"contact-list\"></ul></div>");
      ContactList = $('#contact-list');
      contactlistFragment = document.createDocumentFragment();
      $.each(Contactlist, function(_index) {
        return contactlistFragment.appendChild(newContactListItem(this, _index));
      });
      ContactList.append(contactlistFragment);
      contactlistFragment = null;
      return Controls.contact.click(function() {
        if (Router.current() === "contact") {
          return Router.set(Router.previous());
        } else {
          return Router.set("contact");
        }
      });
    };
    newContactListItem = function(_item, _index) {
      var $newDiv, $newItem;
      if (_item.isBuilding === true) {
        $newItem = $("<li class=\"location\"></li>");
      } else {
        $newItem = $("<li></li>");
      }
      $newDiv = $("<div class=\"portrait\"></div>");
      $newDiv.append("<img class=\"real\" src=\"" + _item.portrait.real + "\"/>");
      $newDiv.append("<img class=\"starwars\" src=\"" + _item.portrait.starwars + "\"/>");
      $newItem.append($newDiv);
      $newItem.append("<h2>" + _item.name + "</h2>");
      if (_item.isBuilding === true) {
        $newItem.append("<p class=\"location\">" + _item.address + "</p><p class=\"phone\">" + _item.telephone + " <span>Telephone</span><br>" + _item.fax + " <span>Fax</span></p>");
      } else {
        $newItem.append("<p class=\"title\">" + _item.title + "</p>");
      }
      $newItem.append("<a href=\"mailto:" + _item.email + "\" class=\"email\">" + _item.email + "</a>");
      return $newItem.get(0);
    };
    return {
      init: init
    };
  })($('#contact'));
  Display = (function() {
    var $items, $knt, $totalPlaylistItems, activateListItem, changeVideo, controlSetup, createPlaylist, imageCache, init, loader, newPlaylistItem, offScreen, onScreen, updateNextPrev;
    $items = null;
    $totalPlaylistItems = null;
    $knt = 0;
    Controls.details.get(0).on_ = false;
    init = function() {
      if (loadPageLoaded === true && contactPageLoaded === false && posterImagesLoaded === false) {
        createPlaylist();
        Contacts.init();
        Video.init();
        Router.init();
        if (true) {
          Controls.details.click(function() {
            Controls.details.stop().animate({
              height: (!Controls.details.get(0).on_ ? "150px" : "40px")
            }, uiSpeed).toggleClass("active");
            return this.on_ = !this.on_;
          });
          Controls.next.find("a").click(function() {
            return changeVideo(1);
          });
          Controls.next.find("a").hover(function() {
            return $('#btn-slide-next').stop().animate({
              width: 178 + "px"
            }, 150).addClass("btn-out");
          }, function() {
            return $('#btn-slide-next').css("width", "0px").removeClass("btn-out");
          });
          Controls.prev.find("a").click(function() {
            return changeVideo(-1);
          });
          Controls.prev.find("a").hover(function() {
            return $('#btn-slide-prev').stop().animate({
              width: 178 + "px"
            }, 150).addClass("btn-out");
          }, function() {
            return $('#btn-slide-prev').css("width", "0px").removeClass("btn-out");
          });
          Controls.play.click(function() {
            return Video.playPause();
          });
          Controls.close.click(function() {
            return Video.stop();
          });
        } else {
          Controls.next.hide().addClass("disabled");
          Controls.prev.hide().addClass("disabled");
          Controls.logo.delay(500).fadeIn(1000);
          Controls.panel.delay(500).fadeIn(1000);
          $(document).addEventListener("touchstart", touchStart, false);
          $(document).addEventListener("touchmove", touchMove, false);
          $(document).addEventListener("touchend", touchEnd, false);
          $(document).addEventListener("touchcancel", touchCancel, false);
        }
      }
      if (loadPageLoaded === true && contactPageLoaded === true && posterImagesLoaded === true) {
        Controls.play.fadeTo(uiSpeed, 1).removeClass("paused");
        $("#control").delay(500).fadeIn(100);
        return $('#poster').delay(1000).show(function() {
          if (Router.current() === "") {
            return Router.set(0);
          }
        });
        /*
        if loadedFromRoot is true
        setTimeout( ->
        showAbout()
        , 1500)
        
        Controls.logo.find("div").click -> 
        showAbout()
        
        
        showAbout = ->
        $("#lightbox").fadeIn('slow').click(->
        $(@).fadeOut('slow')
        )
        */
      }
    };
    offScreen = function() {
      return $('#poster').css("margin-top", "-3000px");
    };
    onScreen = function() {
      $('#poster').css("margin-top", "0px");
      return $('#vidWrapper').css("top", "0px");
    };
    updateNextPrev = function(_item) {
      var btn_next, btn_prev, playlistNext, playlistPrev, _next, _prev;
      btn_prev = $('#btn-slide-prev');
      btn_next = $('#btn-slide-next');
      _prev = parseInt(_item) - 1;
      _next = parseInt(_item) + 1;
      if (_next === $totalPlaylistItems) {
        _next = 0;
      }
      if (_prev === -1) {
        _prev = $totalPlaylistItems - 1;
      }
      playlistPrev = Playlist[_prev];
      playlistNext = Playlist[_next];
      btn_prev.find("img").attr("src", playlistPrev.thumbnail).css({
        width: "178px",
        height: "100px"
      });
      btn_next.find("img").attr("src", playlistNext.thumbnail).css({
        width: "178px",
        height: "100px"
      });
      btn_prev.find("h3").text(playlistPrev.name);
      btn_next.find("h3").text(playlistNext.name);
      btn_prev = null;
      btn_next = null;
      playlistPrev = null;
      return playlistNext = null;
    };
    createPlaylist = function() {
      var playlistFragment;
      playlistFragment = document.createDocumentFragment();
      $totalPlaylistItems = Playlist.length;
      $.each(Playlist, function(_index) {
        playlistFragment.appendChild(newPlaylistItem(this, _index));
        return imageCache(this, _index);
      });
      Controls.list.append(playlistFragment);
      playlistFragment = null;
      $items = Controls.list.children();
      $items.click(function() {
        return Router.set($items.index(this));
      });
      return $items.hover(function() {
        return $(this).stop().animate({
          height: ($(this).find("img").height() + 20) + "px"
        }, 200).addClass("up");
      }, function() {
        return $(this).stop().animate({
          height: 20 + "px"
        }, 200).removeClass("up");
      });
    };
    newPlaylistItem = function(_item, _index) {
      var $newItem, $thumbImg, size;
      size = 100 / Playlist.length;
      $thumbImg = $("<img src=\"" + _item.thumbnail + "\" />").css({
        width: "100%",
        height: "auto"
      });
      $newItem = $("<a></a>").append("<div class=\"block\"></div>").css({
        width: size + "%",
        left: (size * _index) + "%"
      });
      $newItem.append("<div class=\"thumb\"></div>");
      $newItem.find(".thumb").append($thumbImg).append("<div class=\"text\"><h3>" + _item.name + "</h3></div>");
      return $newItem.get(0);
    };
    imageCache = function(_item, _index) {
      var imageCacheField;
      loader.init(0);
      imageCacheField = $('#imageCache');
      return imageCacheField = $('<img src="' + _item.poster + '" />').imagesLoaded(function() {
        var percentLoaded;
        $knt++;
        percentLoaded = ($knt / $totalPlaylistItems) * 100;
        return loader.setTo(percentLoaded);
      });
    };
    loader = (function() {
      var counter, i, interval, j, loaderStarted, spinny, to, _spinny_switch;
      i = 0;
      j = 0;
      to = 0;
      interval = 0;
      _spinny_switch = true;
      loaderStarted = false;
      this.init = function(_to) {
        if (loaderStarted !== true) {
          return this.start(_to);
        }
      };
      spinny = function() {
        if (i < 24 * 107) {
          Controls.loaderCircle.css({
            "background-position": -1 * i + "px 0px"
          });
        } else {
          Controls.loaderCircle.css({
            "background-position": "0px 0px"
          });
          i = 0;
        }
        i += 107;
        if (_spinny_switch === true) {
          return setTimeout(function() {
            return spinny();
          }, 40);
        }
      };
      counter = function() {
        var text;
        loaderStarted = true;
        if (j <= to) {
          switch (j.toString().length) {
            case 1:
              text = "00" + j;
              break;
                case 2:
              text = "0" + j;
              break;
                case 3:
              break;
                }
          Controls.loaderText.html(text);
          if (j >= 100) {
            return this.stop();
          } else {
            j++;
            return setTimeout(function() {
              return counter();
            }, 5);
          }
        } else {
          return setTimeout(function() {
            return counter();
          }, 5);
        }
      };
      this.start = function(_to) {
        spinny();
        this.setTo(_to);
        return counter();
      };
      this.stop = function() {
        _spinny_switch = false;
        loaderStarted = false;
        posterImagesLoaded = true;
        Controls.loaderText.hide();
        Controls.largeLogo.show();
        Display.onScreen();
        Display.init();
        i = 0;
        return j = 0;
      };
      this.setTo = function(_to) {
        return to = _to;
      };
      return this;
    })();
    activateListItem = function(_index) {
      var $target, displayTimeout, item;
      $target = $($items[_index]);
      item = Playlist[_index];
      if (requireFlash === true) {
        if (flashLoaded === true) {
          clearTimeout(displayTimeout);
          Video.load(item);
          Video.stop();
          return controlSetup($target, item);
        } else {
          return displayTimeout = setTimeout(function() {
            return activateListItem(_index);
          }, 40);
        }
      } else {
        Video.load(item);
        Video.stop();
        return controlSetup($target, item);
      }
    };
    controlSetup = function($target, item) {
      Controls.play.fadeTo(uiSpeed, 1).removeClass("paused");
      Controls.details.find(".title").fadeTo(uiSpeed, 0, function() {
        return $(this).html(item.name).fadeTo(uiSpeed, 1);
      });
      Controls.details.find(".blurb").fadeTo(uiSpeed, 0, function() {
        return $(this).html(item.blurb).fadeTo(uiSpeed, 1);
      });
      Controls.details.find(".credit").fadeTo(uiSpeed, 0, function() {
        return $(this).html(item.credit).fadeTo(uiSpeed, 1);
      });
      $items.removeClass("active");
      $target.addClass("active");
      return currIndex = Controls.list.find(".active").index();
    };
    changeVideo = function(_d) {
      var current, limit, max;
      current = Controls.list.find(".active").index();
      max = $items.length - 1;
      limit = (current + _d > max ? 0 : (current + _d < 0 ? max : current + _d));
      return $($items.get(limit)).click();
    };
    return {
      init: init,
      activateListItem: activateListItem,
      offScreen: offScreen,
      onScreen: onScreen,
      updateNextPrev: updateNextPrev
    };
  })();
  window.flashReady = function() {
    return flashLoaded = true;
  };
  window.ended = function() {
    return Video.stop();
  };
  Router = (function() {
    var currentPage, currentRoute, findRoute, init, parseRoute, previousPage, previousRoute, routes, setCurrentPage, setLocation;
    currentPage = "";
    previousPage = "";
    routes = {
      __default: {
        title: '',
        fetch: function(_url) {
          if (!posterImagesLoaded) {
            Display.offScreen();
          }
          $("#pages").hide();
          Controls.bottomDiv.show();
          Controls.play.hide();
          Controls.prev.hide();
          Controls.next.hide();
          Display.updateNextPrev(_url);
          Display.activateListItem(_url);
          return Controls.contact.removeClass("backtowork");
        }
      },
      __root: {
        title: '',
        fetch: function(_url) {
          loadedFromRoot = true;
          if (!posterImagesLoaded) {
            Display.offScreen();
          }
          $("#pages").hide();
          $(".page").show();
          $("#" + _url).show();
          Controls.bottomDiv.show();
          Controls.play.show();
          Controls.prev.show();
          Controls.next.show();
          return Controls.contact.removeClass("backtowork");
        }
      },
      contact: {
        title: "Contact",
        fetch: function(_url) {
          Video.stop();
          Controls.bottomDiv.hide();
          Controls.contact.addClass("backtowork");
          Controls.play.hide();
          Controls.prev.hide();
          Controls.next.hide();
          $("#pages").show();
          $(".page").hide();
          $("#" + _url).show();
          if (requireFlash !== true) {
            $('#vidWrapper').hide();
          }
          return $('#poster').hide();
        }
      }
    };
    findRoute = function(_request) {
      var i;
      for (i in routes) {
        if (i === _request) {
          return i;
        }
      }
      if (_request === "") {
        return "__root";
      }
      return "__default";
    };
    parseRoute = function(_input) {
      var hash;
      hash = _input.substr(3, _input.length - 1);
      setCurrentPage(hash);
      return routes[findRoute(hash)].fetch(hash);
    };
    setLocation = function(_url) {
      return window.location.hash = "#!/" + _url;
    };
    setCurrentPage = function(_url) {
      if (currentPage !== "") {
        previousPage = currentPage;
      }
      return currentPage = _url;
    };
    currentRoute = function() {
      return currentPage;
    };
    previousRoute = function() {
      return previousPage;
    };
    init = function() {
      $(window).bind("hashchange", function() {
        return parseRoute(window.location.hash);
      });
      return $(window).trigger("hashchange");
    };
    return {
      init: init,
      current: currentRoute,
      previous: previousRoute,
      setCurrent: setCurrentPage,
      set: setLocation
    };
  })();
  $(document).ready(function() {
    if (Modernizr.touch) {
      touchMode = true;
    } else {
      touchMode = false;
    }
    if (Modernizr.csstransitions) {
      uiSpeed = 0;
    } else {
      noTransitions = true;
      requireFlash = true;
    }
    if (!Modernizr.video.h264) {
      requireFlash = true;
    } else {
      requireFlash = false;
    }
    if ($.browser.msie) {
      requireFlash = true;
    }
    if (loadPageLoaded === false && contactPageLoaded === false && posterImagesLoaded === false) {
      Controls.largeLogo.imagesLoaded(function() {
        loadPageLoaded = true;
        return Display.init();
      });
    }
    return $(window).resize(function() {
      var $poster, $video, windowHeight;
      $video = $('#video');
      $poster = $("#poster");
      windowHeight = $(window).height();
      return $video.css({
        "margin-top": (windowHeight / 2 - $video.height() / 2) + "px"
      });
    });
  });
  $.fn.findTransitionTime = function() {
    var rule;
    rule = (this.css("-webkit-transition-duration") ? this.css("-webkit-transition-duration") : (this.css("-moz-transition-duration") ? this.css("-moz-transition-duration") : (this.css("-o-transition-duration") ? this.css("-o-transition-duration") : (this.css("transition-duration") ? this.css("transition-duration") : "No Duration found"))));
    return Number(rule.replace(/s/, "")) * 1000;
  };
  $.fn.imagesLoaded = function(callback) {
    var blank, elems, len;
    elems = this.filter("img");
    len = elems.length;
    blank = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
    elems.bind("load", function() {
      if (--len <= 0 && this.src !== blank) {
        return callback.call(elems, this);
      }
    }).each(function() {
      var src;
      if (this.complete || this.complete === void 0) {
        src = this.src;
        this.src = blank;
        return this.src = src;
      }
    });
    return this;
  };
}).call(this);

