function writeCaptcha() {
  if (!Application) var Application = {};
  if (!Application.Page) Application.Page = {};
  if (!Application.Page.ClientCAPTCHA) {
    Application.Page.ClientCAPTCHA = {
      sessionIDString: '',
      captchaURL: [],
      getRandomLetter: function () { 
        return String.fromCharCode(
          Application.Page.ClientCAPTCHA.getRandom(65,90)
        );
      },
      getRandom: function(lowerBound, upperBound) { 
        return Math.floor((upperBound - lowerBound + 1) * 
          Math.random() + lowerBound);
      },
      getSID: function() {
        if (Application.Page.ClientCAPTCHA.sessionIDString.length <= 0) {
          var tempSessionIDString = '';
          for (var i = 0; i < 32; ++i) {
            tempSessionIDString += Application.Page.ClientCAPTCHA.getRandomLetter();
          }
          Application.Page.ClientCAPTCHA.sessionIDString.length = tempSessionIDString;
        }
        return Application.Page.ClientCAPTCHA.sessionIDString;
      },
      getURL: function() {
        if (Application.Page.ClientCAPTCHA.captchaURL.length <= 0) {
          var tempURL = 'http://www.emailcontrol.com.au/admin/resources/form_designs/captcha/index.php?c=';
          tempURL += Application.Page.ClientCAPTCHA.getRandom(1,1000);
          tempURL += '&ss=' + Application.Page.ClientCAPTCHA.getSID();
          Application.Page.ClientCAPTCHA.captchaURL.push(tempURL);
        }
        return Application.Page.ClientCAPTCHA.captchaURL;
      }
    }
  }

  var temp = Application.Page.ClientCAPTCHA.getURL();
  for (var i = 0, j = temp.length; i < j; i++) {
    document.write('<img src="' + temp[i] + '" alt="img' + i + '" />');
  }
}


function CheckMultiple348(frm, name) {
  for (var i=0; i < frm.length; i++) {
    fldObj = frm.elements[i];
    fldId = fldObj.id;
    if (fldId) {
      var fieldnamecheck = fldObj.id.indexOf(name);
      if (fieldnamecheck != -1 && fldObj.checked) {
        return true;
      }
    }
  }
  return false;
}


function CheckForm348(f) {
  var email_re = /[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/i;
  if (!email_re.test(f.email.value)) {
    alert("Please enter your email address.");
    f.email.focus();
    return false;
  }

  if (f.format.selectedIndex == -1) {
    alert("Please choose a format to receive your email campaigns in");
    f.format.focus();
    return false;
  }

  if (f.captcha.value == "") {
    alert("Please enter the security code shown");
    f.captcha.focus();
    return false;
  }

  var fname = "CustomFields_897_348";
  var fld = document.getElementById(fname);
  if (fld.value == "") {
    alert("Please enter a value for field Firstname");
    fld.focus();
    return false;
  }

  var fname = "CustomFields_898_348";
  var fld = document.getElementById(fname);
  if (fld.value == "") {
    alert("Please enter a value for field Surname");
    fld.focus();
    return false;
  }

  return true;
}
