    /* facebook parameters */
    /*
    var keysObject = {
                        parents:{api_key:"apikey"},
                        bhg:{api_key:"apikey2"}
                    };
    var streamObject = {
                        comment:'This is a comment',
                        attachment: {'name':'Title',
                                     'href':'http://www.linkurl.com',
                                     'description':'Body Text',
                                     'media':[{'type':'image',
                                               'src':'http://www.imageurl.com',
                                               'href':'http://www.linkurl.com'
                                              }]
                                  },
                        actionLink: [{'text':'Action Text','href':'http://www.actionurl.com'}]
                        useXD: 'false'
                    };
    var buttonObject = {id: 'buttonID',hideButton:false};

    **/

mdp.app.simpleFacebookConnect = function( keysObject, streamObject, buttonObject, debug ){

    var _useFaceBook, _apiKeys, _useXD, _debug, _buttonId, _hideButton;
    var _comment, _attachment, _actionLink, _targetId, _userMessagePrompt, _callback, _autoPublish, _actorId;

    function simpleFacebookConnect(){

        keysObject = keysObject || {};
        streamObject = streamObject || {};
        buttonObject = buttonObject || {};

        _debug = debug;
        _useFaceBook = false;
        _apiKeys = keysObject || null;
        _comment = streamObject['comment'] || null;
        _attachment = streamObject['attachment'] || null;
        _actionLink = streamObject['actionLink'] || null;
        _targetId = streamObject['targetId'] || null;
        _userMessagePrompt = streamObject['userMessagePrompt'] || null;
        _callback = streamObject['callback'] || null;
        _autoPublish = streamObject['autoPublish'] || null;
        _actorId = streamObject['actorId'] || null;
        _useXD = streamObject['useXD'] == 'false' ? false : true;
        _buttonId = buttonObject['hideButton'] || null;
        _hideButton = buttonObject['hideButton'] || false;
        $('html:first').attr('xmlns:fb', 'http://www.facebook.com/2008/fbml');

        if( _buttonId ) _checkButton( _buttonId );
        if( streamObject ) _buildStreamPublish( null );
        _initializeFacebook();

    }

    function _initializeFacebook(){
        if( !_apiKeys[ _getDomainName() ] ){
            _useFaceBook = false;
            if( _hideButton )
            if( _debug ) alert( '_useFaceBook:' + _useFaceBook );
        } else {
            _useFaceBook = true;
            if( window.FB ) {
                if( _useXD ){
                    FB.init( _apiKeys[ _getDomainName() ].api_key, "/common/common/facebook/xd_receiver.jsp" );
                } else {
                    FB.init( _apiKeys[ _getDomainName() ].api_key );
                }
                if( _debug ) alert('found FB');
            }
            if( _debug ) alert( '_useFaceBook:' + _useFaceBook );
        }
    }

    function _checkButton( s ){
        var e;
        if( _hideButton ){
            if(e = $(s)){
                e.css('display','none');
            }
        }
    }

    function _sendToFaceBook(){
        if( _debug ) alert('_sendToFaceBook');
        if( window.FB ) {
            if( _debug ) alert('found FB');
            FB.ensureInit(function () {
                if( _debug ) alert('ensureInit');
                FB.Connect.streamPublish( _comment, _attachment, _actionLink, _targetId, _userMessagePrompt, _callback, _autoPublish, _actorId );
            });
        }
    }

    function _getDomainName(){
        var h = self.location.host, n;
        for( n in _apiKeys )if( h.indexOf( n ) > -1 ) return n;
        return null;
    }

    function _buildStreamPublish( obj ){
        var att = false, sObj = obj || {};
        if( _debug ) alert('buildSimpleObject');

        _comment = sObj['comment'] || _comment;
        _attachment = sObj['attachment'] || _attachment;
        _actionLink = sObj['actionLink'] || _actionLink;
        _useXD = sObj['useXD'] || _useXD;
    }

    this.sendToFaceBook = function(){
        if( _useFaceBook ) {
            _sendToFaceBook();
            if( _debug ) alert('sendToFaceBook - true');
            return true;
        } else {
            if( _debug ) alert('sendToFaceBook - false');
            return false;
        }
    };

    this.buildStreamPublish = function( o ){
        _buildStreamPublish( o );
    };

    this.requireSession = function(callback){
        FB.Connect.requireSession(callback);
    };

    this.injectMultiFriendInviteForm = function(el,obj){
        var o = obj || {};
        var html = "";
        html += "<fb:serverfbml style=\"width:"+ (o.width || "") + "px\">";
        html += "     <script type=\"text/fbml\">";
        html += "         <fb:fbml>";
        html += "             <fb:request-form";
        html += "                     action=\"" + (o.action || "") + "\"";
        html += "                     method=\"POST\"";
        html += "                     invite=\"true\"";
        html += "                     type=\""+ (o.type || "") +"\"";
        html += "                     content=\""+ (o.content || "") + "\"";
        html += "             <fb:multi-friend-selector showborder=\"false\" actiontext=\""+ (o.actionText || "") +"\" condensed=\""+ (o.condensed || false) +"\" />";
        html += "             </fb:request-form>";
        html += "         </fb:fbml>";
        html += "     </script>";
        html += " </fb:serverfbml>";
        $(el).html(html);
        this.parseDomElement(el);
    };

    this.parseDomElement = function(el){
        FB.XFBML.Host.parseDomElement(el);
    };


    simpleFacebookConnect();
};
