At the time when any petition has been filed seeking to commit any person to the custody of the Alabama Department of Public Health, the probate judge shall appoint a guardian ad litem to represent and protect the rights of such person and shall determine if the person has the funds and capacity to secure the services of an attorney to represent him. If the person does not have the funds or capacity to secure the services of an attorney, the probate judge shall appoint an attorney, who may be the same person as the guardian ad litem, to represent him.