Ivan,
That's likely not working there because the Facebook Javascript library (FB) hasn't been initialized yet, so if you look at the Javascript console, it's probably saying something like "FB does not exist".
To directly add that code, you'll need to either put it within a Javascript timeout, so that it only executes after 500ms or so, or put it into the JFBCSystem plugin code. That section in the System plugin only gets executed after the FB.init call, since it's a part of it.
Hope that helps,
Alex