var titles = {
  "images/work/cartoons-poker.jpg": "<strong>Cartoons Playing Poker</strong> - 2010 - acrylic on canvas - 40in x 30in",
  "images/work/nick-think2.jpg": "<strong>What Does Nick Think?</strong> - 2009 - website design",
  "images/work/astrigh1.jpg": "<strong>Astrigh Truck Risk</strong> - 2008 - website design",
  "images/work/senior-intermedia.jpg": "<strong>Senior Exhibition Intermedia</strong> - 2007 - digital print",
  "images/work/senior-sculpture.jpg": "<strong>Senior Exhibition Sculpture</strong> - 2007 - digital print",
  "images/work/asian-viking.jpg": "<strong>Asian Viking</strong> - 2006 - acrylic on canvas - 40in x 30in",
  "images/work/color-red.jpg": "<strong>The Color Red</strong> - 2005 - acrylic on canvas - 12in x 16in",
  "images/work/subway.jpg": "<strong>Subway</strong> - 2005 - corrugated cardboard - 20in x 20in x 15in",
  "images/work/takeout.jpg": "<strong>Takeout</strong> - 2005 - sheet steel, metal wiring",
  "images/work/good-in-blue.jpg": "<strong>You Look So Good in Blue</strong> - 2005 - acrylic on canvas - 12in x 16in",
  "images/work/breakfast.jpg": "<strong>Breakfast of Champions</strong> - 2006 - mixed media",
  "images/work/girlsbestfriend.jpg": "<strong>A Girl's Best Friend</strong> - 2005 - mixed media",
  "images/work/vincent-vs-dali.jpg": "<strong>Vincent vs. Dali</strong> - 2004 - acrylic, graphite on board - 20in x 16in",
  "images/work/trompe.jpg": "<strong>Trompe L'Oeil</strong> - 2004 - graphite - 24in x 16in",
  "images/work/stalefish.jpg": "<strong>Stalefish</strong> - 2004 - paint chips - 16in x 20in",
  "images/work/horse-project.jpg": "<strong>Horse Project</strong> - 2006 - website illustration"
};

var groups = {

  japanesegothic: [
    {
      "href": "images/work/japanese-gothic.jpg",
      "title": "<strong>Japanese American Gothic</strong> - 2010 - acrylic on canvas - 16in x 20in"
    }, {
      "href": "images/work/japanese-gothic2.jpg",
      "title": "Naomi and Ben with <strong>Japanes American Gothic</strong>"
    }
  ],
  
  characters: [
    {
      "href": "images/work/character-max.jpg",
      "title": "<strong>Max at the Gym</strong> - 2010 - illustration"
    }, {
      "href": "images/work/character-margot.jpg",
      "title": "<strong>Margot at the Fair</strong> - 2010 - illustration"
    }, {
      "href": "images/work/character-donnie.jpg",
      "title": "<strong>Donnie at the DMV</strong> - 2010 - illustration"
    }, {
      "href": "images/work/character-gandalf.jpg",
      "title": "<strong>Gandalf at the Arcade</strong> - 2010 - illustration"
    }, {
      "href": "images/work/character-gogo.jpg",
      "title": "<strong>Gogo at the Playboy Mansion</strong> - 2010 - illustration"
    }, {
      "href": "images/work/character-joker.jpg",
      "title": "<strong>The Joker at Disneyland</strong> - 2010 - illustration"
    }, {
      "href": "images/work/character-paulie.jpg",
      "title": "<strong>Paulie at the Beach</strong> - 2010 - illustration"
    }, {
      "href": "images/work/character-rufio.jpg",
      "title": "<strong>Rufio at the Renaissance Faire</strong> - 2010 - illustration"
    }, {
      "href": "images/work/character-veruca.jpg",
      "title": "<strong>Veruca at the Rodeo</strong> - 2010 - illustration"
    }
  ],
  
  steve: [
    {
      "href": "images/work/steve-v1.jpg",
      "title": "<strong>Steve and Vanessa's Wedding</strong> - Save the Dates"
    }, {
      "href": "images/work/steve-v2.jpg",
      "title": "<strong>Steve and Vanessa's Wedding</strong> - Invitations"
    }, {
      "href": "images/work/steve-v3.jpg",
      "title": "<strong>Steve and Vanessa's Wedding</strong> - Wedding Website"
    }
  ],
  
  yellow: [
    {
      "href": "images/work/yellow1.jpg",
      "title": "<strong>It's Ok, I Met a Chinese Person Once</strong> - 2007 - oil on canvas - 4ft x 4ft"
    }, {
      "href": "images/work/yellow2.jpg",
      "title": "<strong>Don't Drink and Derive (I Know My Calculus)</strong> - 2007 - oil on canvas - 4ft x 4ft"
    }, {
      "href": "images/work/yellow3.jpg",
      "title": "<strong>Geisha</strong> - 2007 - oil on canvas - 4ft x 4ft"
    }, {
      "href": "images/work/yellow4.jpg",
      "title": "<strong>Still Trying to Back Out of the Driveway</strong> - 2007 - oil on canvas - 4ft x 4ft"
    }, {
      "href": "images/work/yellow5.jpg",
      "title": "<strong>Herro, Kitty</strong> - 2007 - oil on canvas - 4ft x 4ft"
    }, {
      "href": "images/work/yellow6.jpg",
      "title": "<strong>They All Look the Same Anyway</strong> - 2007 - oil on canvas - 4ft x 4ft"
    }
  ],
  
  smartone: [
    {
      "href": "images/work/smart-one1.jpg",
      "title": "<strong>The Smart One (Which One's the Ho?)</strong> - 2004 - acrylic on canvas - 20in x 16in"
    }, {
      "href": "images/work/smart-one2.jpg",
      "title": "<strong>The Smart One (Which One's the Ho?)</strong> - 2004 - acrylic on canvas - 20in x 16in"
    }, {
      "href": "images/work/smart-one3.jpg",
      "title": "<strong>The Smart One (Which One's the Ho?)</strong> - 2004 - acrylic on canvas - 20in x 16in"
    }
  ],
  
  weeks68: [
    {
      "href": "images/work/68weeks-1.jpg",
      "title": "<strong>Allow 6 to 8 Weeks</strong> - 2006 - mixed media"
    }, {
      "href": "images/work/68weeks-2.jpg",
      "title": "<strong>Allow 6 to 8 Weeks</strong> - 2006 - mixed media"
    }
  ],
  
  alterego: [
    {
      "href": "images/work/alterego1.jpg",
      "title": "<strong>Alter Ego</strong> - 2005 - mixed media"
    }, {
      "href": "images/work/alterego2.jpg",
      "title": "<strong>Alter Ego</strong> - 2005 - mixed media"
    }
  ],
  
  inventory: [
    {
      "href": "images/work/inventory1.jpg",
      "title": "<strong>Inventory</strong> - 2006 - installation"
    }, {
      "href": "images/work/inventory2.jpg",
      "title": "<strong>Inventory</strong> - 2006 - installation"
    }, {
      "href": "images/work/inventory3.jpg",
      "title": "<strong>Inventory</strong> - 2006 - installation"
    }
  ],
  
  instababies: [
    {
      "href": "images/work/instababies1.jpg",
      "title": "<strong>Instababies Technology Inc.</strong> - 2006 - installation"
    }, {
      "href": "images/work/instababies2.jpg",
      "title": "<strong>Instababies Technology Inc.</strong> - 2006 - installation"
    }
  ],
  
  shipping: [
    {
      "href": "images/work/shipping1.jpg",
      "title": "<strong>Shipping and Handling</strong> - 2006 - installation"
    }, {
      "href": "images/work/shipping2.jpg",
      "title": "<strong>Shipping and Handling</strong> - 2006 - installation"
    }, {
      "href": "images/work/shipping3.jpg",
      "title": "<strong>Shipping and Handling</strong> - 2006 - installation"
    }
  ],
  
  lynnandtonicv5: [
    {
      "href": "images/work/lynnandtonic-v5-1.jpg",
      "title": "<strong>Lynnandtonic.com version 5</strong> - 2010 - website design"
    }, {
      "href": "images/work/lynnandtonic-v5-2.jpg",
      "title": "<strong>Lynnandtonic.com version 5</strong> - 2010 - website design"
    }
  ],
  
  lynnandtonicv4: [
    {
      "href": "images/work/lynnandtonic-v4-1.jpg",
      "title": "<strong>Lynnandtonic.com version 4</strong> - 2008 - website design"
    }, {
      "href": "images/work/lynnandtonic-v4-2.jpg",
      "title": "<strong>Lynnandtonic.com version 4</strong> - 2008 - website design"
    }
  ]

};


jQuery("document").ready(
  function(event) {

  setupFilter();

});

var setupFilter = function() {

  var filters = $(".filter");
  filters.each(function(idx, item, enumerable) {
                 $(item).click(handleFilter);
               });

  $("#portfolio li a").click(handleFancyBox);
};

var handleFancyBox = function(event) {
  event.preventDefault();
  var group = ($(this).parent().hasClass("group")) ? ($(this).parent().attr("className").split(" ").pop()) : null;
  if(group === null) {
    var obj = {
      "href": $(this).attr("href")
    };

    if(titles.hasOwnProperty(obj.href)) {
      obj["title"] = titles[obj.href];
    }

    $.fancybox([obj]);
  } else {
    $.fancybox(groups[group]);
  }
};

var handleFilter = function(event) {
  event.preventDefault();
  var filters = $(".filter");
  filters.each(
    function(idx, item, enumerable) {
      $(this).removeClass("active");
    });


  var key = $(this).attr("className").replace("filter", "").replace(" ", "");

  var portfolioItems = $("#portfolio li");

  portfolioItems.each(
    function(idx, item, enumerable) {
      if($(item).hasClass(key)) {
        $(item).show();
      } else {
        $(item).hide();
      }
    });

  $(this).addClass("active");
};
