// Common functions used throughout the admin interface.

$(document).ready(function()
  {
    // Give all of the text input fields the "textbox" class.
    $('input[type="text"]').addClass('textbox');
    
    // Highlight our makeshift table rows.
    $('div.odd, div.even').hover(
      function()
      {
        $(this).addClass("hover");
      },
      function()
      {
        $(this).removeClass("hover");
      }
    );
    
    // Hide any filter boxes by default.
    $('div.filter').each(function()
      {
        if ($.cookie($(this).attr('id')) != true)
        {
          $(this).children('form').hide();
          $(this).children('div.link').children('a').text('Show filter');
        }  
      });
      
    // Showing and hiding filter boxes.
    $('div.filter div.link a').click(function()
      {
        var filter_form = $(this).parent().siblings('form');
        var filter_id = $(this).parent().parent().parent().attr('id');
        
        filter_form.toggle();
        if (filter_form.is(':visible'))
        {
          $(this).text('Hide filter');
          $.cookie(filter_id, true);
        }
        else
        {
          $(this).text('Show filter');
          $.cookie(filter_id, false);
        }
      });
    
  });
  
function checkboxSelect(container_id, state)
{
  if (state == 'undefined')
  {
    state = true;
  }
	$('#' + container_id + ' input[type=checkbox]').each(function()
	{
		this.checked = state;
	});

}
