﻿    
    function UpdateFromGlobalSettings()
    {  var strInputType;
       strInputType = document.PageForm.cboInputType[document.PageForm.cboInputType.selectedIndex].value;
       if (strInputType == 'CHECKBOX')
       {
            if (document.getElementById('txtOptInText'))
            {
                if (document.getElementById('txtSubLabel'))
                {
                 document.getElementById('txtSubLabel').value = document.getElementById('txtOptInText').value;
                }
                if (document.getElementById('chkRequired'))
                {
                 document.getElementById('chkRequired').checked = document.getElementById('chkOptInRequired').checked;
                }
                if (document.getElementById('chkDefaultValue'))
                {
                 document.getElementById('chkDefaultValue').checked = document.getElementById('chkOptInDefaultChecked').checked;
                }
            }
        }
    }
    

function LoadElementViaAJAX(astrURL,astrFieldName, astrFieldType) {
    var xmlHttp, strResponseHTML;
 try
  {  // Firefox, Opera 8.0+, Safari  
    xmlHttp=new XMLHttpRequest();  
  }
catch (e)
  {  // Internet Explorer  
    try
    {    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    
        try
            {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
        catch (e)
            {      alert("Your browser does not support AJAX!");      
                   return false;     }    
    }  
  }
  xmlHttp.onreadystatechange = function () {
      if (xmlHttp.readyState == 4) {
          if (astrFieldType == 'TEXTBOX') {

              document.getElementById(astrFieldName).value = '';
              strResponseHTML = xmlHttp.responseText
              if (astrFieldName == 'txtSplashVendorAddress') {
                  strResponseHTML = strResponseHTML.replace(/<br>/g, '<br>\n');
              }
              if (astrFieldName == 'HiddenHasPaymentInformation') {
                  if (strResponseHTML == '1') {
                      if (document.PageForm.cboPayMerchantOn) { document.PageForm.cboPayMerchantOn.selectedIndex = 1; }
                  }
                  else {
                      strResponseHTML = '0';
                  }
                  document.getElementById(astrFieldName).value = strResponseHTML;
                  HandlePayMerchantDirectly(false, true);
              }
              document.getElementById(astrFieldName).value = strResponseHTML;

          }
          if (astrFieldType == 'CHECKBOX') {
              document.getElementById(astrFieldName).checked = false;
              strResponseHTML = xmlHttp.responseText
              if (strResponseHTML == '1') {
                  document.getElementById(astrFieldName).checked = true;
              }
              else {
                  document.getElementById(astrFieldName).checked = false;
              }
          }
          if (astrFieldType == 'SELECT') {

              strResponseHTML = xmlHttp.responseText
              if (astrFieldName == 'cboPayMerchantHowToSend') {
                  var objPayMerchantHowToSend1, objPayMerchantHowToSend2, objPayMerchantHowToSend3;
                  var objItemsText, objItemsValue, objTextArray, objValueArray, intCount;
                  objPayMerchantHowToSend1 = document.getElementById('cboPayMerchantHowToSend1');
                  objPayMerchantHowToSend2 = document.getElementById('cboPayMerchantHowToSend2');
                  objPayMerchantHowToSend3 = document.getElementById('cboPayMerchantHowToSend3');
                  if (objPayMerchantHowToSend1) {
                      objItemsText = new Array();
                      objItemsValue = new Array();
                      objItemsText['BOTH'] = ['ACH/Direct Deposit - Free', 'Regular Mail Check - $1.50', 'Overnight Check - $30.00'];
                      objItemsValue['BOTH'] = ['1', '2', '3'];
                      objItemsText['CHECK'] = ['Regular Mail Check - $1.50', 'Overnight Check - $30.00'];
                      objItemsValue['CHECK'] = ['2', '3'];
                      objItemsText['ACHDIRECT'] = ['ACH/Direct Deposit - Free'];
                      objItemsValue['ACHDIRECT'] = ['1'];
                      for (var count = objPayMerchantHowToSend1.options.length - 1; count >= 0; count--) { objPayMerchantHowToSend1.options[count] = null; }
                      for (var count = objPayMerchantHowToSend2.options.length - 1; count >= 0; count--) { objPayMerchantHowToSend2.options[count] = null; }
                      for (var count = objPayMerchantHowToSend3.options.length - 1; count >= 0; count--) { objPayMerchantHowToSend3.options[count] = null; }
                      objTextArray = null
                      objValueArray = null
                      objTextArray = objItemsText[strResponseHTML];
                      objValueArray = objItemsValue[strResponseHTML];
                      if (objTextArray) {
                          objPayMerchantHowToSend1.options.length = objTextArray.length;
                          objPayMerchantHowToSend2.options.length = objTextArray.length;
                          objPayMerchantHowToSend3.options.length = objTextArray.length;
                          for (var intCount = 0; intCount < objTextArray.length; intCount++) {
                              objPayMerchantHowToSend1.options[intCount].text = objTextArray[intCount];
                              objPayMerchantHowToSend1.options[intCount].value = objValueArray[intCount];
                              objPayMerchantHowToSend2.options[intCount].text = objTextArray[intCount];
                              objPayMerchantHowToSend2.options[intCount].value = objValueArray[intCount];
                              objPayMerchantHowToSend3.options[intCount].text = objTextArray[intCount];
                              objPayMerchantHowToSend3.options[intCount].value = objValueArray[intCount];
                          }
                      }
                  }
              }

          }
          if (astrFieldType == 'HTML') {
              strResponseHTML = xmlHttp.responseText;
              document.getElementById(astrFieldName).innerHTML = strResponseHTML;
          }
          else {
              UpdateFromGlobalSettings();
          }
      }
  }
  xmlHttp.open('GET', astrURL + '&random=' + Math.floor(Math.random() * 2000000), true);
  xmlHttp.send("");  
}

