$(function() {
  $(".stretch-height").each(function() {
    var node = $(this)
    node.height($("~ div", node).offset().top - node.offset().top)
  })
  $("#navigation ul").lavaLamp({
    fx: "backout",
    speed: 700
  })
  $("#layer2").click(function() {
    $("#layer2").empty()
    $("#layer2").hide()
    $("#layer1").hide()
    $("iframe").show()
  })
  if ($.browser.msie) {
    $(".photo-haiku").mouseover(function() {
      $(".category", this).hide()
      $(".content", this).show()
    })
    $(".photo-haiku").mouseout(function() {
      $(".content", this).hide()
      $(".category", this).show()
    })
  }
  $(".video").click(function() {
    var m = this.src.match(/\/([^\/]+)\/default\.jpg$/)
    $("#layer1").show()
    $("#layer2").show()
    $('<div class="object"><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/' + m[1] + '&rel=1&autoplay=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/' + m[1] + '&rel=1&autoplay=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object></div>').appendTo("#layer2")
  })
})
function showImage(url) {
  if ($.browser.msie) {
    $("iframe").hide()
  }
  $("#layer1").show()
  $("#layer2").show()
  var image = document.createElement("img")
  image.id = "image"
  $("#layer2").append(image)
  $("#image").click(
    function() {
      $("#layer2").empty()
      $("#layer2").hide()
      $("#layer1").hide()
      $("iframe").show()
    }
  ).load(
    function() {
      var image = $(this)
      $(this).show()
      this.style.left = (($("#layer2").width() - this.width) / 2) + "px"
      this.style.top = (($("#layer2").height() - this.height) / 2) + "px"
    }
  )
  image.src = url
}
