I am going to guess that your FTP password is not the problem.
If it were, a hacker would be able to install much more subtle code into your site than adding Javascript to your index page. Further, if you look at that Javascript code, it was written in a way that's designed to sneak by many filters that applications have to prevent Javascript from sneaking by.
I also don't think that this was SQL injection because if it were, there are other, more powerful and subtle things that the hacker could do than add Javascript to your index page.
My suggestion is that you ask yourself what software you have installed on your site (any sort of blogging software?) that you didn't write. Then google to see if that software has any known exploits.