/*<![CDATA[*/
$(document).ready(function(){
  
//  $("#header h1").click(function() {
//      location.href = "/";
//  });
  
  if($("#blog").length > 0) {
    activeNav = $("a[href*='/posts']").parent();
    activeNav.addClass("active");
  };
  
  

  // Big Targer for clickable items
  // clashes with booking button on item-teasers
  /*
  $(".item-teaser a").bigTarget({
      clickZone : 'li:eq(0)'
  });
  
  $(".item-teaser-big a").bigTarget({
      clickZone : 'li:not(.nobigclick):eq(0)'
  });
  
  $(".people-teaser a").bigTarget({
      clickZone : 'li:eq(0)'
  });
  
  $(".panel-item-alternatives a").bigTarget({
      clickZone : 'div:eq(0)'
  });
  */
  
  $("#site-navigation ul li a").each(function(e, v) {
    p = $(v).parent();
    $("span img", p).width($(v).width() + 32)
  });
  
  
  $("ul.subnav").hide();
  
  $("#site-navigation ul li").hover(function(){
      p = $(this);
      
      if($("ul.subnav", p).length > 0) {
        $("ul.subnav.active").hide();
        $("ul.subnav", p).show();
      };
      
      $("span img", p).animate({
          top: "0px"
      }, {
          queue: false,
          duration: 400
      });
  }, function(){
      p = $(this);
      
      if($("ul.subnav", p).length > 0) {
        $("ul.subnav:not(.active)", p).hide();
        $("ul.subnav.active").show();
      };
      
      if (!p.hasClass("active")) {
          $("span img", p).animate({
              top: "-25px"
          }, {
              queue: false,
              duration: 400
          });
      }
  });
  
});

function jsonFlickrApi(rsp) {
   if (rsp.stat != "ok"){
    // If this executes, something broke!
    return;
   }
   
   //variable "s" is going to contain 
   //all the markup that is generated by the loop below
   var s = "";
   
   //this loop runs through every item and creates HTML 
   for (var i=0; i < rsp.photos.photo.length; i++) {
    photo = rsp.photos.photo[ i ];
    
    //notice that "t.jpg" is where you change the
    //size of the image
    t_url = "http://farm" + photo.farm + 
    ".static.flickr.com/" + photo.server + "/" + 
    photo.id + "_" + photo.secret + "_" + "s.jpg";
      
    p_url = "http://farm" + photo.farm + 
    ".static.flickr.com/" + photo.server + "/" + 
    photo.id + "_" + photo.secret + ".jpg";
    
    s +=  '<li><a rel="gallery" href="' + p_url + '">' + '<img alt="'+ 
    photo.title + '"src="' + t_url + '"/>' + '</a></li>';
  }


 var thumbList = "<ul>" + s + "</ul>";
 document.writeln(thumbList);

}

/*]]>*/