/**
/* form_functions.js
/*
 * @copyright: 2009 by Thomas M. Stambaugh & Zeetix, LLC (http://www.zeetix.com)
 * All rights reserved.
 *
 * The contents of this file may not be copied, duplicated, or used without the
 * written consent of Zeetix, LLC.
 *
 * Contains the functions (as opposed methods) used by forms.
 *
 * Loaded after the class definitions (so that they are available to here) and
 * before class methods (so that these functions are available to those methods)
 *
**/

/**
 * Remembers that the body has been loaded.
 */
var _hasBodyOnLoadBeenCalled = false;

function isLoaded() {
  //Answer true if the onload handler has been called, else false.
  return _hasBodyOnLoadBeenCalled;
};

function _handleOnloadEventBasic(){
  // Record the firing of onload from the body
  _hasBodyOnLoadBeenCalled = true;
};

function onloadHandler() {
  // An onload event has been received from the body.
  _handleOnloadEventBasic();
  externalLinks();
  if (this.initializeToolbarButtons) {
      //Sets up the portfolio toolbars
      initializeToolbarButtons();
      }
  this._formApplication = FormApplication.create();
};

/**
 * Avoid using target attribute to conform to standards
 */
function externalLinks() {
  if (!document.getElementsByTagName) return;
  var anchors = document.getElementsByTagName("a");
  for (var i=0; i<anchors .length; i++) {
    var anchor = anchors[i];
    if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
      anchor.target = "_blank";
      anchor.title = (anchor.title != "") ? anchor.title+" (opens in a new window)" : "opens in a new window";
      anchor.className = (anchor.className != '') ? anchor.className+' external' : 'external';
      }
    }
  }
