	$(document).ready(function()
	{
		$(document).pngFix();
		
	});
	
	
	function toggleTag( id )
	{
		$(id).toggleClass( 'on' );
		
		updateThumbs();
	}
	
	function selectTag( id )
	{
		// turn other tags off
		$('a.tag').removeClass( 'on' );
		$(id).addClass( 'on' );
		
		updateThumbs();
	}
	
	function updateThumbs()
	{
		// make a list of all the tags that are 'on'
		var tags = getCurrentTags();
		
		// go through the images and switch them on or off
		$('#project_picker img').each( function()
									   {
											if( testImage( this, tags ) )
											{
												$(this).removeClass( 'off' );
											}
											else
											{
												
												$(this).addClass( 'off' );
											}
									   
									   } );
	}
	
	function getCurrentTags()
	{
		var tags = new Array();
		
		$('#tag_list a.on').each( function()
								  {
								  	 tags.push( jQuery.trim( $(this).get(0).id ) );
								  } );
		return tags;
	}
	
	function testImage( image, tags )
	{
		for(var i in tags)
		{
			if( $(image).hasClass( tags[i] ))
			{
				return true;
			}
		}
		
		return false;
	}