Type 1: If I HAVE time, I WILL visit you. (Maybe I will have time. I do not know at this moment.)
Type 2: If I HAD time (I do not have time, for I am always working), I WOULD visit you. (So I am not going to visit you. Sorry.)
Type 3. If I HAD HAD time last week (I did not, for I had to work), I WOULD HAVE VISITED you. (So I did not visit you last week. Please forgive me.)
*****
If I have $100, I will lend it to you. Let me check my wallet right now.
If I had $100, I would lend it to you. But I cannot lend it, for I do not have $100.
If I had had $100 last week, I would have lent it to you. But last week, I did not have $100, so that is the reason that I did not lend you the money. Please don't be angry with me.