function updateSize()
{
   var size = 0;
   $('ul.type li input:checked').each(function()
   {
      size += parseInt( $(this).attr('value') );
   });
   
   $('#contentheader .download .size').text(size + 'KB');
}

$(document).ready(updateSize);
$('#contentheader ul.type input:checkbox').click(updateSize);

$('#contentheader ul.type li').bind('click', function(event)
{
   if($(event.target).is('input') || $(this).children('input').attr('disabled')) return;

   var elem = $(this).children('input');
   
   if(elem.attr('checked')) 
   {
      if($('#contentheader input:checked').length == 1)
         return;
      else
         elem.removeAttr('checked');
   }
   else 
      elem.attr('checked', 'checked');
   
   updateSize();
}
).mousedown(function(){ return false });

$('a.download').click(function()
{
   var options = $('#contentheader input:checked');
   
   if(options.length > 0)
   {
      var get = '';
      options.each(function()
      {
         get += $(this).attr('name') + '/';
      });
      
      document.location.href = '/projects/qtip/download/package/' + get;
   }
   else alert('Please choose atleast one download package.');
});

