jQuery(document).ready(function($) {
  $('div#content_narrow a').facebox({
    loadingImage: '/includes/facebox/loading.gif',
    closeImage: '/includes/facebox/closelabel.gif',
    opacity: 0.3
  });

  function displayFeed(ele, feed) {
    var limit = 5;
    content = '';
    if (feed.items.length < limit) { limit = feed.items.length; }

    for(i =0; i < limit; i++) {
      content += '<li><a href="' + feed.items[i].link + '">' + feed.items[i].title + '</a></li>';
    }

    $(ele).html(content);

  }

  jQuery.getFeed({
    url: '/blog.littlestreamsoftware.xml',
    success: function(feed) {
      displayFeed('ul#littlestreamsoftwareblog', feed);
    }
  });


  jQuery.getFeed({
    url: '/theadmin.xml',
    success: function(feed) {
      displayFeed('ul#theadminblog', feed);
    }
  });

});

var serviceData = {
  'cd1':'Custom Development - The Creek (Level 1)',
  'cd2':'Custom Development - The Stream (Level 2)',
  'cd3':'Custom Development - The River (Level 3)',
  'cr1':'Code Review - The Ford (Level 1)',
  'cr2':'Code Review - The Causeway (Level 2)',
  'cr3':'Code Review - The Bridge (Level 3)',
  'ad1':'System Architecture Blueprints - The Raft ( Level 1)',
  'ad2':'System Architecture Blueprints - The Boat (Level 2)',
  'ad3':'System Architecture Blueprints - The Ship (Level 3)',
  'setup-preferred':'Redmine Setup - Preferred Host',
  'setup-standard':'Redmine Setup - Standard Host',
  'setup-custom':'Redmine Setup - Custom Host',
  'support1':'Redmine Support - Bronze',
  'support2':'Redmine Support - Silver',
  'support3':'Redmine Support - Gold',
  'support-single':'Redmine Support - Single',
  'custom':'Custom Request'
};

function selectWufooForm() {
    var serviceCode = $(document).getUrlParam("service");
    var selectedService = serviceData[serviceCode];
    if (selectedService != null) {
        return 'field6=' + escape(selectedService);
    } else {
        return '';
    }
}
