You should check the second error first. in this case I think it is also the cause of at least the first error.
ad in the process you start with an elseif, you should start with an if statement. I suggest reading chapters (or search the web) about the if statement.
Also you should take a look at how to open and close entities and architectures.
Finally I give you a tip: Use tabs to line your code. As you start a block (if, begin, port, etc.) you use a tab on the next line, this improves reading and thereby you can easily find problems related to errors like 10500.