//this "includes" the facebook connect javascript.
document.write('<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>');
/*
set up some reasonable defaults to that can be overridden later.
*/
   var story_body = ''; //this shows up just below the comment box on the form set this to be the content you want to include in the message.
   var api_key = '500d8f073b05ae4291627a36989bc3a9'; //default to the astrology.com app  get this number from the facebook developer app.
   var channel_path = "xd_receiver.htm";
   var user_message_prompt = '';  //this shows up at the top o fthe form just after the  
   var template_id = 124004557136;  //default to the horoscope template  this is the id of the "feed template" set this up for each application in fbdeveloper app.
   var button_text = 'Publish on Facebook';// this is the HTML for the "button" could be an <img> too.
   var show_photo = true; //whether or not to show the profile photo ahead of the "publish" link.
   
   //this is a handler for the "pbulish" link.
   var load_feed = function() {
     var completed=false
     var user_message = {value: "user message"};
	 FB.Connect.requireSession(function(){
        FB.Connect.showFeedDialog(template_id,null,[],story_body,null,FB.RequireConnect.promptConnect,doFeedComplete,user_message_prompt)
	  });
   };
   
   var onConnected=function(){
  // alert('Connected');
     if (show_photo) {
       $('#fbconnect').html(
         '<fb:profile-pic uid="loggedinuser" size="square" facebook-logo="true"></fb:profile-pic> <a href="javascript:load_feed();">' + button_text + '</a>');
     }else{
        $('#fbconnect').html(
           '<a href="javascript:load_feed();">' + button_text + '</a>');
     }
     FB.XFBML.Host.parseDomTree();      
   };
   
   var onNotConnected = function(){
        $('#fbconnect').html('<a href="javascript:load_feed();">Share on Facebook</a>')
   };
   var doReady = function(){
    
     FB.init(api_key, channel_path,
       {"ifUserConnected":onConnected, "ifUserNotConnected":onNotConnected});  
   };
   
   var doFeedComplete = function(){
      iv_doTracking('as:horoscopes:facebookconnect:horoscopes2fb','','','','nbcuivsites,nbcuivastrology');
       };
   