Javascript problem with facebook connect code

I have this script added to a facebook icon (#id) on my front page:

(function() {
  var e = document.createElement('script');
  e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
  e.async = true;
  document.getElementById('fb-root').appendChild(e);
})();
window.fbAsyncInit = function() {
    var fbClicked = false;
    FB.init({appId: 'Myappid', status: true, cookie: true, xfbml: true});

    FB.Event.subscribe('auth.login', function(response) {
        if(response.session && fbClicked){
            window.location = 'http://www.mysite.com/facebookauth/?ref=/';
        }
    });
}
function thFBShortCut() {
    FB.login(function(response) {
        fbClicked = true;
        if (response.session && response.perms && fbClicked) {
            window.location = 'http://www.mysite.com/facebookauth/?ref=/';
        }
    }, {perms:'email,publish_stream'});
}
function thFBLogin() {
    fbClicked = true;
    $('.popbox').fadeOut(); 
    FB.getLoginStatus(function(response) {
        if(response.session && response.status == 'connected' && fbClicked) {
            window.location = 'http://www.mysite.com/facebookauth/?ref=/';
        }
    });
}

I want when whenever user press on facebook icon, the script should trigger facebook connect app. I added <div id="fb-root"></div> right after <body <?php body_class(); ?>>, but when I load my site I keep getting these error messages: document.getElementById(“fb-root”) is null and FB is not defined [Break On This Error] FB.login(function(response) {

My html:

&lt;a id="facebookicon" onclick="thFBShortCut()"&gt;Login&lt;/a&gt;