Thousands attend funeral for fallen deputy