$( document ).ready(
	function()
	{
		var last_command_selected = null,
			jq_last_cmd_activo = null;
		var prefix_content_command = 'cnt-';
		var jq_cmd_activo = $( '#navigation a.activo' );

		if( jq_cmd_activo.length == 1 )
		{
			jq_last_cmd_activo = $( '#' + prefix_content_command + jq_cmd_activo.attr( 'id' ) );
			last_command_selected = jq_last_cmd_activo;
			
			jq_last_cmd_activo.show();
		}
		
		$( '#navigation a' ).each(
			function( i, obj )
			{
				var jq_link = $( obj );
				
				if( jq_link.hasClass( 'has_submenu' ) )
				{
					jq_link.click(
						function()
						{
							return false;
						}
					);
				}

				jq_link
					.mouseover(
						function()
						{
							if( last_command_selected )
							{
								last_command_selected.hide();
							}
							
							last_command_selected = $( '#' + prefix_content_command + this.id );
								
							last_command_selected.show();
						}
					);
			}
		);
		
		$( '#main-menu' ).mouseleave(
			function()
			{
				if( last_command_selected )
				{
					if( ! jq_last_cmd_activo || last_command_selected.attr( 'id' ) != jq_last_cmd_activo.attr( 'id' ) )
					{
						last_command_selected.hide();
					}
				}
				
				if( jq_last_cmd_activo )
				{
					if( ! last_command_selected || last_command_selected.attr( 'id' ) != jq_last_cmd_activo.attr( 'id' ) )
					{
						jq_last_cmd_activo.show();
					
						last_command_selected = jq_last_cmd_activo;
					}
				}
			}
		);
	}
);
