var projects = {
  Homesite: {
    title: 'Homesite Insurance',
    url: 'http://homesite.com/',
    img: 'img/homesite.png',
    info: {
      Time: 'June 2010 - Present',
      Position: 'Web Developer',
      Skills: 'JS/JQuery, .NET, SQL Server, etc'
    },
    desc: 'Improved home insurance quoting web app, as part of a great team with many talents.  Ratcheted up ' +
      'the user experience by several notches of awesomeness.  Built test automation framework using Selenium.'
  },
  InQuest: {
    title: 'InQuest Technologies',
    url: 'http://www.inquesttechnologies.com/',
    img: 'http://cdn.orbza.com/portfolio/inquest.png',
    info: {
      Time: 'October 2008 - May 2010',
      Position: 'Software Engineer',
      Skills: 'C#, ASP.NET, Javascript / jQuery, Ajax, SQL Server'
    },
    desc: 'Delivered enterprise-class web application using C#, ASP.NET, SQL Server, jQuery/JS, and HTML/CSS. ' +
      'Assisted in modernizing software engineering practices during the buildout of a small team.  Led the ' +
      'charge to bring the application to life and improve performance as an in-house expert on Javascript.'
  },
  NetflixPrize: {
    title: 'Netflix Prize',
    url: 'http://tillberg.us/netflixprize',
    img: 'http://cdn.orbza.com/portfolio/netflixprize.png',
    info: {
      Time: 'October 2007 - February 2008',
      Position: 'Solo Contestant',
      Skills: 'C++, Adv. Math & Analysis, Multithreading, AI'
    },
    desc: 'Developed a comprehensive collaborative filtering system to predict user ratings of movies ' +
      'based on a provided rating history.  Predicted ratings 8.3% better than Netflix\'s baseline system. ' +
      'Ranked fifth place overall by February 2008 in the million-dollar contest to reach 10%.'
  },
  AmieStreet: {
    title: 'Amie Street',
    url: 'http://en.wikipedia.org/wiki/Amie_Street',
    img: 'http://cdn.orbza.com/portfolio/amiestreet.png',
    info: {
      Time: 'February - May 2008',
      Position: 'Software Engineer, Recommendations Expert',
      Skills: 'Analysis, C++, Python, MySQL, Git'
    },
    desc: 'Worked with Internet startup music vendor Amie Street (amiestreet.com) to develop a prototype ' +
      'content recommendation system for their large and diverse collection of music.'
  },
  RapidRec: {
    title: 'Rapid Recommendations',
    url: 'http://www.rapidrec.com/',
    img: 'http://cdn.orbza.com/portfolio/rapidrec.png',
    info: {
      Time: 'September 2008 - March 2009',
      Position: 'Founder, Independent Developer',
      Skills: 'Analysis, Python, C++, XML, MySQL, Ajax'
    },
    desc: 'Web start-up that was to serve quality content recommendations as a REST XML web service. ' +
      'Built a P2P-replicated key-key-value store using Python to manage ratings data efficiently.'
  },
  MBTA: {
    title: 'MBTA Transit Times',
    url: 'http://tillberg.us/mbta',
    img: 'img/mbta.png',
    info: {
      Time: 'May 2010',
      Skills: 'Python, AI'
    },
    desc: 'Used service data provided publicly by the MBTA to produce a heat map showing typical travel ' +
      'times from a selected starting location to anywhere else in the Boston area.'
  },
  BookText: {
    title: 'CSS3 3D Text',
    url: 'blog.html',
    img: 'img/blog.png',
    info: {
      Time: 'April 2011'
    },
    desc: 'Proof-of-concept demonstration of using CSS3 2D transformation matrices to mimic 3D text ' +
      'display.  Someday I will make my blog render in this format.'
  },
  Player: {
    title: 'HTML5 Audio Player',
    url: 'player.html',
    img: 'img/player.png',
    info: {
      Time: 'March 2010'
    },
    desc: 'Demonstration of HTML5 audio and canvas in an integrated music player.  The spectrum analysis ' +
      'displayed was a side-product of the research done for the Audella project below.'
  },
  FreeCell2: {
    title: 'Web FreeCell',
    url: 'freecell.html',
    img: 'http://cdn.orbza.com/portfolio/freecell2.png',
    info: {
      Time: 'August 2009',
      Skills: 'Javascript, jQuery, HTML, CSS, AI'
    },
    desc: 'Built a web-based version of my earlier C# Better FreeCell application.  14 kB of Javascript ' +
      'provides a full-featured FreeCell game plus a depth-first-search solver that seamlessly works in ' +
      'the background to detect deadlock/loss conditions.'
  },
  RiverDefense: {
    title: 'River Defense',
    url: 'http://www.kongregate.com/games/Tillberg/river-defense',
    img: 'http://cdn.orbza.com/portfolio/riverdef.png',
    info: {
      Time: 'October 2008',
      Skills: 'Flash/ActionScript, Python, MySQL, Ajax, UI Design'
    },
    desc: 'River Defense is a Flash-based strategy game fashioned after Desktop Tower Defense.  It expands ' +
      'upon that theme by using a dynamic physics model and by automatically recording and playing back ' +
      'other players\' games.  Over 650,000 games have been played and more than seven years\' worth of ' +
      'gameplay have been recorded as of September 2009.'
  },
  CellBE: {
    title: 'PS3/CellBE Image Processing',
    url: '',
    img: 'http://cdn.orbza.com/portfolio/ps3video.png',
    info: {
      Time: 'May - July 2008',
      Skills: 'CellBE Assembly, Image Processing, C#, .NET, Sockets'
    },
    desc: 'Created a Windows C# application and a server running on a Playstation 3 (running Linux) that ' +
      'interface to analyze video images in real-time.  Other CellBE work includes some later work processing ' +
      'Netflix Prize data on a pair of PS3s (with an x86 master node) using a proprietary high-performance ' +
      'clustering and task distribution framework.'
  },
  Audella: {
    title: 'Audella',
    url: '',
    img: 'http://cdn.orbza.com/portfolio/audella.png',
    info: {
      Time: 'June - October 2007',
      Skills: 'C#, C++, Analysis, MySQL, Client/Server Networking'
    },
    desc: 'Windows application that fingerprints music files for the purpose of correcting meta information ' +
      'and automatically organizing music on the client computer. Works with the a server to track submitted ' +
      'fingerprints and meta information and to determine (more or less by a "voting" system) which labels ' +
      'are correct and which are erroneous.'
  },
  FreeCell: {
    title: 'FreeCell',
    url: 'http://tillberg.us/betterfreecell',
    img: 'http://cdn.orbza.com/portfolio/betterfreecell.png',
    info: {
      Time: 'November 2006',
      Skills: 'C#, .NET, AI, UI Design'
    },
    desc: 'Built an enhanced clone of the popular FreeCell title in C#.  Aside from a number of subtle ' +
      'changes to the flow of the game (without changing the rules), the major addition was a system that ' +
      'continuously checks the game for deadlocking.  This fixed a major flaw in the Microsoft version ' +
      'where players often reached a point where the game could not progress toward either a win or loss ' +
      'condition.'
  },
  DLAExplorer: {
    title: 'DLA Explorer',
    url: 'http://tillberg.us/dla',
    img: 'http://cdn.orbza.com/portfolio/dlaexplorer.png',
    info: {
      Time: 'October 2006',
      Skills: 'C#, .NET, DirectX, Physics'
    },
    desc: 'Built a Windows application to visualize Diffusion-Limited Aggregates (DLAs) in both two ' +
      'and three dimensions.  DLAs were the subject of previous work as an undergraduate in which I ' +
      'co-authored a paper on the computational complexity of building them on massively parallel computers.'
  }
};
$(function() {
    var animTime = 300;
    var projectTemplateHtml = '' +
      '<li class="project">' +
      '<a class="imgWrap" href="<%= url %>"><img src="<%= img %>"></a>' +
      '<div class="info"><a href="<%= url %>"><h2><%= title %></h2></a>' +
      '<dl><% _.each(info, function(v, k) { %><dt><%= k %></dt><dd><%= v %></dd><% }); %></dl>' +
      '<p><%= desc %></p></div>';
    var projectTemplate = _.template(projectTemplateHtml);
    
    $('ul.projects').append(_.map(projects, function(project) {
      return project.title ? projectTemplate(project) : '';
    }).join(''));
    
    $('ul.projects li').hoverClass();
    $('ul.projects li').eq(0).addClass('current');
    $('#prev').addClass('hidden').click(function() {
      var $prev = $('li.current').removeClass('current').prev();
      $prev.addClass('current');
      $('#next').removeClass('hidden');
      if ($prev.prev().length === 0) { $('#prev').addClass('hidden'); }
      return false;
    });
    $('#next').click(function() {
      var $next = $('li.current').removeClass('current').next();
      $next.addClass('current');
      $('#prev').removeClass('hidden');
      if ($next.next().length === 0) { $('#next').addClass('hidden'); }
      return false;
    });
    
    
    $('ul.projects-list').addClass('projects-grid').removeClass('projects-list');
    $('ul.projects-grid li').each(function() {
	    var $t = $(this);
    	var $p = $t.find('p'); var $div = $t.find('div'); var $txt = $t.find('h2, p, dd, dt'); var $img = $t.find('img');
    	var href = $t.find('a').attr('href');
    	if (href && href !== '') {
      	$txt.css('cursor', 'pointer').click(function() {
    	    window.location = href;
      	});
    	}
    	$t.hoverClass('hover');
    	$t.hover(function() {
    	    $div.stop(true).animate({marginLeft: -72, marginTop: -72, width: 384, height: 320}, animTime);
    	    $img.stop(true).animate({opacity: 0.12}, animTime);
    	    $txt.stop(true).animate({opacity: 1}, animTime);
    	}, function() {
    	    $div.stop(true).animate({marginLeft: 0, marginTop: 0, width: 240, height: 200}, animTime);
    	    $img.stop(true).animate({opacity: 1}, animTime);
    	    $txt.stop(true).animate({opacity: 0}, animTime);
    	});
    });
});

