function toggle_posts(project_id)
{
  if($('div#blog_posts_' + project_id + ' div.other_blogposts').is(':hidden'))
  {
    $('div#blog_posts_' + project_id + ' div.other_blogposts:hidden').slideDown('slow');
    $('div#blog_posts_' + project_id + ' div.bigfatplus').html('<a href="#" onclick="toggle_posts(' + project_id + '); return false;" onfocus="this.blur();">-</a>');
  }
  else
  {  
    $('div#blog_posts_' + project_id + ' div.other_blogposts').slideUp('slow');
    $('div#blog_posts_' + project_id + ' div.bigfatplus').html('<a href="#" onclick="toggle_posts(' + project_id + '); return false;" onfocus="this.blur();">+</a>');
  }
  
  return false;
}


// Create the tooltips only on document load
$(document).ready(function() 
{
  $('abbr.score').tipsy({gravity: 'e', delayIn: 100, delayOut: 500}); 
  $('abbr.watchers').tipsy({gravity: 'se', delayIn: 100, delayOut: 500}); 
  $('abbr.forks').tipsy({gravity: 'ne', delayIn: 100, delayOut: 500}); 
  
  $('abbr.gem_downloads').tipsy({gravity: 'e', delayIn: 100, delayOut: 500}); 
  $('abbr.gem_version').tipsy({gravity: 'se', delayIn: 100, delayOut: 500}); 
  $('abbr.gem_version_downloads').tipsy({gravity: 'n', delayIn: 100, delayOut: 500}); 
  
  $('.github_repo').tipsy({gravity: 'sw', delayIn: 100, delayOut: 500}); 
  
  $('.project_resource').tipsy({gravity: 'n', delayIn: 100, delayOut: 50, title: function() { return this.getAttribute('href').replace(/http\:\/\//g,''); }});
  
   // Dropdown for penalties
   $('#content .project .score p span.penalty a[tooltip]').each(function()
   {
      $(this).qtip({
         content: $('#' + $(this).attr('tooltip')).html(),
         position: {
            corner: {
               tooltip: 'topMiddle', // Use the corner...
               target: 'bottomMiddle' // ...and opposite corner
            }
         },
         show: { delay: 10 },
         style: {
            border: {
               width: 2,
               radius: 5,
               color: '#666'
            },
            padding: 5,
            width: 300,
            backgroundColor: '#EFEFEF',
            tip: true,
            name: 'light'
         }

      });
   });

   // Dropdown for project information
   $('#content a[tooltip].category_details').each(function()
   {
      $(this).qtip({
         content: $('#' + $(this).attr('tooltip')).html(),
         position: {
            corner: {
               tooltip: 'topLeft', // Use the corner...
               target: 'bottomMiddle' // ...and opposite corner
            }
         },
         show: { delay: 50 },
         hide: {
            fixed: true // Make it fixed so it can be hovered over
         },
         style: {
            border: {
               width: 5,
               radius: 10,
               color: '#000000'
            },
            padding: 10,
            width: 350,
            backgroundColor: '#222222',
            tip: true,
            name: 'dark'
         }

      });
   });
   
   
   // Dropdown for Categories
   $('#grey_block a[tooltip]').each(function()
   {
      $(this).qtip({
         content: $('#category-dropdown').html(),
         position: {
            corner: {
               tooltip: 'topRight', // Use the corner...
               target: 'bottomMiddle' // ...and opposite corner
            }
         },
         show: { delay: 50 },
//         position: { adjust: { x: -25, y: 0 } },
         hide: {
            fixed: true, // Make it fixed so it can be hovered over
            delay: 450
         },
         style: {
            border: {
               width: 5,
               radius: 10,
               color: '#333'
            },
            padding: 10,
            width: 800,
            backgroundColor: '#222',
            tip: true,
            name: 'dark'
         }

      });
   });
});

jQuery(document).ready(function() {
  jQuery("abbr.timeago").timeago();
});
