Modernizr.addTest("positionfixed", function()
{
   if(navigator.userAgent.match(/AppleWebKit\/(.*)Mobile\//))
   {
      return false
   }
   if(navigator.userAgent.match(/Android(.*)Mobile/))
   {
      return false
   }
   var f = document.createElement("div"), e = f.cloneNode(false), b = false, a = document.body || (function()
   {
      b = true;
      return document.documentElement.appendChild(document.createElement("body"))
   }
   ());
   var d = a.style.cssText;
   a.style.cssText = "padding:0;margin:0";
   f.style.cssText = "position:fixed;top:42px";
   a.appendChild(f);
   a.appendChild(e);
   var c = f.offsetTop !== e.offsetTop;
   a.removeChild(f);
   a.removeChild(e);
   a.style.cssText = d;
   if(b)
   {
      document.documentElement.removeChild(a)
   }
   return c
}
);
jQuery(document).ready(function(a)
{
   a.startingOpacity = 0.2;
   a.lastItemClicked = null;
   a.fn.startWebkitAnimation = function(b)
   {
      var c = a(this);
      if( ! c.hasClass(b))
      {
         c.addClass(b)
      }
      else
      {
         c.css("-webkit-animation-name", "none");
         setTimeout(function()
         {
            c.css("-webkit-animation-name", b)
         }
         , 0)
      }
      return a(this)
   }
   ;
   a.fn.vAlign = function(b)
   {
      if(b == undefined)
      {
         b = 0
      }
      return this.each(function(c)
      {
         var d = Math.abs(a(this).height() + b - a(this).parent().height()) / 2;
         if(d > 0)
         {
            a(this).css("margin-top", d).css("top", 0)
         }
      }
      )
   }
   ;
   a(".page-template-page-selected-work-php #postwrapper .post").click(function(b)
   {
      b.preventDefault();
      var c = a(this).find("a").attr("href");
      a.openShadowBox(
      {
         content : c, player : "img", gallery : "selected_work"
      }
      )
   }
   );
   a(".post").hover(function()
   {
      var b = a(this).find(".post-content");
      var c = a(this).find(".post-background");
      b.vAlign();
      b.stop().css("opacity", 0).show().animate(
      {
         opacity : 1
      }
      , 250);
      c.stop().css("opacity", 0).show().animate(
      {
         opacity : 0.8
      }
      , 250);
      a(this).css("z-index", 1)
   }
   , function()
   {
      var b = a(this).find(".post-content");
      var c = a(this).find(".post-background");
      b.stop().animate(
      {
         opacity : 0
      }
      , 250, function()
      {
         b.hide()
      }
      );
      c.stop().animate(
      {
         opacity : 0
      }
      , 250, function()
      {
         c.hide()
      }
      );
      a(this).css("z-index", 0)
   }
   );
   a(".page-id-5087 #postwrapper .post").click(function(c)
   {
      c.preventDefault();
      var d = a(this).find("a").attr("href");
      var b = '<iframe frameborder="0" width="100%" height="100%" src="'+d+'"></iframe>';
      a.openShadowBox(
      {
         content : d, player : "iframe", width : 640, height : 360, gallery : "videos"
      }
      )
   }
   );
   a.closeShadowbox = function()
   {
      Shadowbox.close();
      a.lastItemClicked = null
   }
   ;
   a.handleResize = function(b)
   {
      if(b == undefined)
      {
         b = false
      }
      var e = Shadowbox.dimensions.width, c = a(window).width(), d = (c - e) / 2;
      d -= 20;
      a("#mi-prev,#mi-next").width(d);
      if( ! Modernizr.positionfixed)
      {
         a("#sb-container,#mi-next,#mi-prev").css("top", a(window).scrollTop());
         a("#mi-download").css("position", "absolute").css("top", a(window).scrollTop() + a("#sb-container").height() - 100);
         a("#mi-data").css("position", "absolute").css("top", a(window).scrollTop() + a("#sb-container").height() - 100)
      }
   }
   ;
   a.intervalHandler = function()
   {
      a.handleResize()
   }
   ;
   a.isResizing = function(b)
   {
      if(b)
      {
         a(window).bind("resize.keatley scroll.keatley", a.handleResize)
      }
      else
      {
         a(window).unbind(".keatley")
      }
   }
   ;
   a.onShadowboxChanged = function(e)
   {
      a("#mi-dl-url,#mi-blog-url,#mi-download").hide();
      a("#mi-prev,#mi-next").hide();
//      a("#mi-title").text(e.title.toUpperCase());
      if(e.link)
      {
         a("#mi-subtitle").text(e.link.children[0].title.toUpperCase());
         var d = a(e.link.children[0]), b = (d.attr("rel")), g = a(e.link.children[1]), c = (g.text()), f = "/download-image/?image=" + b;
         if(b != undefined && b.length)
         {
            a("#mi-dl-url a").attr("href", f);
            a("#mi-dl-url,#mi-download").show()
         }
         if(c != undefined && c.length)
         {
            a("#mi-blog-url a").attr("href", "/blog/" + c);
            a("#mi-blog-url,#mi-download").show()
         }
      }
      a.handleResize(true)
   }
   ;
   a.onShadowboxClosed = function(b)
   {
      a.lastItemClicked = null;
      a("#mi-data,#mi-download,#mi-dl-url,#mi-blog-url").hide();
      a("#mi-next,#mi-prev").hide();
      a.isResizing(false)
   }
   ;
   a.onShadowboxFinished = function(f)
   {
      if(a("body").hasClass("page-id-14"))
      {
         return
      }
      a("#mi-data").show();
      a.handleResize(true);
      if(a.lastItemClicked && ! navigator.userAgent.match(/AppleWebKit\/(.*)Mobile\//))
      {
         var e = (a.lastItemClicked.attr("id") == "mi-prev") ? 1 : a.startingOpacity;
         a("#mi-prev").show().css("opacity", e);
         e = (a.lastItemClicked.attr("id") == "mi-next") ? 1 : a.startingOpacity;
         a("#mi-next").show().css("opacity", e)
      }
      else
      {
         a("#mi-next,#mi-prev").show().css("opacity", a.startingOpacity)
      }
      a("#mi-title").text(f.title.toUpperCase());
      if(f.link)
      {
         a("#mi-subtitle").show();
         a("#mi-subtitle").text(f.link.children[0].title.toUpperCase());
         var d = a(f.link.children[0]), b = (d.attr("rel")), h = a(f.link.children[1]), c = (h.text()), g = "/download-image/?image=" + b;
         if(b != undefined && b.length)
         {
            a("#mi-dl-url a").attr("href", g);
            a("#mi-dl-url,#mi-download").show()
         }
         if(c != undefined && c.length)
         {
            a("#mi-blog-url a").attr("href", "/blog/" + c);
            a("#mi-blog-url,#mi-download").show()
         }
      }
      else
      {
         a("#mi-subtitle").hide()
      }
   }
   ;
   a.onShadowboxOpened = function(b)
   {
      a.isResizing(true)
   }
   ;
   a.openShadowBox = function(b)
   {
      Shadowbox.open(b)
   }
   ;
   a("#mi-next").click(function(b)
   {
      b.preventDefault();
      if( ! Shadowbox.isOpen)
      {
         return
      }
      a.lastItemClicked = a(this);
      Shadowbox.next()
   }
   );
   a("#mi-prev").click(function(b)
   {
      b.preventDefault();
      if( ! Shadowbox.isOpen)
      {
         return
      }
      a.lastItemClicked = a(this);
      Shadowbox.previous()
   }
   );
   a("#mi-prev,#mi-next").css("opacity", a.startingOpacity);
   a("#mi-prev,#mi-next").hover(function()
   {
      a(this).css("opacity", 1)
   }
   , function()
   {
      a(this).css("opacity", a.startingOpacity)
   }
   );
   Shadowbox.init(
   {
      animate : true, animateFade : true, animSequence : "sync", continuous : true, displayCounter : false, displayNav : true, enableKeys : true, fadeDuration : 0.35, initialHeight : 200, initialWidth : 200, modal : false, onChange : a.onShadowboxChanged, onClose : a.onShadowboxClosed, onOpen : a.onShadowboxOpened, onFinish : a.onShadowboxFinished, overlayColor : "#fff", overlayOpacity : 0.97, players : ["html", "img", "iframe"], resizeDuration : 0.35, viewportPadding : 75
   }
   )
}
);

