if (typeof dynamo == "undefined") { 
  var dynamo = new Object();
}
  
if (typeof dynamo.linksInterface == "undefined") {
  dynamo.linksInterface = function() {
    this.ajax = new luckymarble.ajaxUtil();
    this.debugMode = true;
    var oldonload = window.onload;

    if (typeof window.onload != 'function') {
      window.onload = function() {
        memberLinks.initialize();
      }
    } else {
      window.onload = function() {
        if (oldonload) {
          oldonload();
        }
        memberLinks.initialize();
      }
    }
  }

  dynamo.linksInterface.prototype = {
    // render the "registration" form based on information retrieved via AJAX
    processRender: function() {
      var myAjax     = dynamo.linksInterfaceObj.ajax.ajaxObj;
      var myFileType = dynamo.linksInterfaceObj.ajax.fileType;
  
      if (myAjax.readyState == "4") {
        if (myAjax.status == 500 && dynamo.linksInterfaceObj.debugMode == true) {
          alert(myAjax.responseText);
        } else if (myAjax.status == 200 || window.location.href.indexOf("http") == -1) {
          if (myFileType == "txt") {
            if (myAjax.responseText != "") {
              var myTargetDiv = document.getElementById("dynamo_member_links");
              var myNewDiv    = document.createElement("div");
              var childNodes = myTargetDiv.childNodes;
              
              // assign response text to a separate "document" not attached to the main DOM.
              // This must be done otherwise there will be a confilict with png-image handler script
              myNewDiv.innerHTML = myAjax.responseText;

              // clear any previous html from where the form would be
              if (childNodes.length > 0) {
                myTargetDiv.removeChild(childNodes[0])
              }
             
              // attach the new response
              myTargetDiv.appendChild(myNewDiv);
            }
          } 
        } else  {
          alert(myAjax.status + languageParam["dynamo_error-retrieving_response"]);
        }
      } 
    },
    
    // handle initialization
    initialize: function() {    
      this.ajax.getAjaxRequest(rootPath + "dynamo/", "module=members&component=member_links&bypass=1", this.processRender, "txt");
    } 
  }

  dynamo.linksInterfaceObj = new dynamo.linksInterface();
  memberLinks = dynamo.linksInterfaceObj;
}