$(document).ready( function()
{
	var sp_text_links = $( '#na-descr .na-species-img' );

	sp_text_links.bind( 'mouseover', function() 
	{
		var species = $( this ).attr( 'class' ).split( " " )[ 1 ];
		// console.log( "Class: " + species );

		$( '#na-photos .na-species-img.' + species ).hide().css( 'backgroundColor', '#555' ).fadeIn( 'slow' );
	});

	$( '#na-photos .na-species-img' ).bind( 'mouseover', function() 
	{
		var species = $( this ).attr( 'class' ).split( " " )[ 2 ];
		// console.log( "Class: " + species );

		$( '#na-descr .na-species-img.' + species ).hide().css( 'backgroundColor', '#EE9' ).fadeIn( 'slow' );
	});

	$( '#na-descr .na-species-img' ).bind( 'mouseout', function() 
	{
		$( '#na-photos .na-species-img' ).css( 'backgroundColor', '#FFF' );
	});

	$( '#na-photos .na-species-img' ).bind( 'mouseout', function() 
	{
		$( '#na-descr .na-species-img' ).css( 'backgroundColor', '#FFF' );
	});


	var add_table_stripes = function() 
	{
    		$( 'table.species-list tr:odd' ).css( 'backgroundColor', '#CEFFBE' );
	};

	add_table_stripes();


	var toggle_species = function() 
	{
		var rows = $( 'table.species-list tr' )

		rows.find( 'td:first' ).prepend( '<span class="arrow">&raquo; </span>' );
    		rows.find( 'p.rand_img' ).hide();
    		rows.find( 'td:eq(1) div' ).hide();

		var arrows = $( 'table.species-list span.arrow' )

		arrows.css( 'cursor', 's-resize' );
		arrows.css( 'color', '#393' );

		arrows.toggle( function()
		{
			$( this ).parent().parent().find( 'td p.rand_img' ).slideDown();
			$( this ).parent().parent().find( 'td:eq(1) div' ).slideDown();
			$( this ).css( 'cursor', 'n-resize' );
		}, function()
		{
			$( this ).parent().parent().find( 'td p.rand_img' ).slideUp();
			$( this ).parent().parent().find( 'td:eq(1) div' ).slideUp();
			$( this ).css( 'cursor', 's-resize' );
		});
	};

	toggle_species();
});

