/**
  * HTML XMLNS tag (required)
  *
  * @param array of options
  * @example $this->Facebook->init();
  * @return string of scriptBlock for FB.init() or error
  */
 public function init($options = array())
 {
     $locale = FB::getLocale();
     if (!Configure::read('Facebook.appId')) {
         $application = Configure::read('Application');
         if ($application) {
             $details = sprintf('Application %s (id %s) does not have an app_id - use the settings tab in nodescamp to link this site to a facebook application', $application['name'], $application['id']);
         } else {
             $details = 'This request is not associated with an application, the facebook application id cannot be determined automatically';
         }
         throw new CakeException('No Facebook configuration detected.' . $details);
     }
     $defaults = array('status' => true, 'cookie' => true, 'xfbml' => true, 'autoResize' => true, 'jQuery' => true);
     extract(array_merge($defaults, (array) Configure::read('Application.Facebook'), $options));
     $appId = Configure::read('Facebook.appId');
     $session = $this->Session->read('FB.Session');
     $init = '<div id="fb-root"></div>';
     $init .= $this->Html->scriptBlock("\n\t\t\twindow.fbAsyncInit = function() {\n\t\t\t\tFB.init({\n\t\t\t\t\tappId\t\t: " . json_encode($appId) . ",\n\t\t\t\t\tchannelUrl\t: \"" . Router::url('/channel.html', true) . "\",\n\t\t\t\t\tsession\t\t: " . json_encode($session) . ",\n\t\t\t\t\tstatus\t\t: " . json_encode($status) . ",\n\t\t\t\t\tcookie\t\t: " . json_encode($cookie) . ",\n\t\t\t\t\txfbml\t\t: " . json_encode($xfbml) . ",\n\t\t\t\t\toauth\t\t: true // Enable OAuth 2.0\n\t\t\t\t});\n\n\t\t\t\t// Resize the canvas to get rid of scroll bars\n\t\t\t\tif (" . json_encode($autoResize) . ") {\n\t\t\t\t\tFB.Canvas.setAutoGrow();\n\t\t\t\t}\n\n\t\t\t\t// Register jQuery event\n\t\t\t\tif (" . json_encode($jQuery) . " && jQuery) {\n\t\t\t\t\tjQuery(document).trigger('fbAsyncInit');\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t(function() {\n\t\t\t\tvar e = document.createElement('script');\n\t\t\t\te.src = document.location.protocol + '//connect.facebook.net/" . $locale . "/all.js';\n\t\t\t\te.async = true;\n\t\t\t\tdocument.getElementById('fb-root').appendChild(e);\n\t\t\t}());\n\t\t\t", $options);
     return $init;
 }