﻿// <script language="JavaScript">

var lastCalled = new Date();
var INCORPORATOR_TELEPHONE_TEXT = "1300 653 373";

// detect browser
  var Netscape = Boolean(navigator.appName == "Netscape");
// detect platform
  var Mac = Boolean(navigator.userAgent.indexOf("Mac") > -1);
  // now extract version number
  if(Netscape) {
    var NetscapeVer = parseFloat(navigator.appVersion);
  }

// Function used to combine 2 or more event handlers and still preserve the 'this' keyword.
function CombineEventHandlersAND()
{
    var argumentsTop = CombineEventHandlersAND.arguments;

    return function()
    {
        var arguments = argumentsTop; // We need to do this so that the anonymous function copies the VALUE of argumentsTop as it's being created (instead of just adding a reference to the globally available CombineEventHandlersAND.arguments)

        var result = true;
        for (var i = 0; i < arguments.length; i++)
        {

            // Call the function with the correct 'this' keyword
            this.Func4b93e166a0784b4aafb07ac4867eeb1a = arguments[i];
            result = result & this.Func4b93e166a0784b4aafb07ac4867eeb1a();
        }

        this.Func4b93e166a0784b4aafb07ac4867eeb1a = undefined;
        return result;
    }
}

// Add the String.trim(..) function to IE
if (typeof String.prototype.trim !== 'function')
{
    String.prototype.trim = function ()
    {
        return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
    }
}

/* Function to catch enter from causing form submission */
function catchEnter(e) {
  var nav4 = window.Event ? true : false;

  if (nav4) // Navigator 4.0x
    var whichCode = e.which
  else // Internet Explorer 4.0x
    if (e.type == "keypress") // the user entered a character
      var whichCode = e.keyCode
    else
      var whichCode = e.button;

  if (whichCode == 13)
	return false;
}

function validateAlert(message, field) {
  var fieldText = ((field.text) ? "the \"" + field.text + "\"" : "this") + " field";
  message = message.replace(/%f/, fieldText);
  alert(message);
}

function validateSelection() {
  if (!this.mandatory && (this.selectedIndex <= 0 || this.options[this.selectedIndex].value == null))
    return true;

	if (this.selectedIndex <= 0 || this.options[this.selectedIndex].value == null){
		this.focus();
	  validateAlert("Please select an option in %f", this);
		return false;
	}
	return true;
}

function removeZeroPrefix(s) 
{
  s = "" + s;
  if (s.charAt(0) == '0')
    s = s.substring(1, s.length);
  return s;
}

function addZeroPrefix(s) 
{
    if (s.length < 4)
        s = '0' + s;
    return s;
}

function trim(s)
{
	var l=0; var r=s.length -1;
	while(l < s.length && s.charAt(l) == ' ')
	{	l++; }
	while(r > l && s.charAt(r) == ' ')
	{	r-=1;	}
	return s.substring(l, r+1);
}

function stripSpaces(s)
{
    var result = "";
    for (i=0;i<=s.length;i++)
    {
        if (s.charAt(i) != ' ')
            result += s.charAt(i);
    }
    return result;
}

var oldSuburb = "";
function validateDataEnteredSuburb() {
  var value = this.value.replace(/^\s*(.*)\s*$/, '$1');
  var doselect = this.select ? true : false;

  var lowerCase = trim(value.toLowerCase());
  if (oldSuburb != lowerCase)
  {
    var pattern = /((sydney)|(melbourne)|(adelaide)|(perth)|(hobart)|(darwin)|(canberra)|(brisbane))/;
    var patternAllowed = /((north)|(south)|(east)|(west))/;
    var patternPostCodeAllowed = /^\d+(000)$/;
    var postcode = document.page.postcode.value;
    var country_name = document.page.country_name.value.toLowerCase();

    if (lowerCase.search(pattern) >= 0 && (lowerCase.search(patternAllowed) < 0 && postcode.search(patternPostCodeAllowed) < 0) && country_name == 'australia' )
  	{
  	  validateAlert("Incorporator detects that you may have entered an Australian capital city into the \"Suburb (or if no suburb, the town or locality)\" field. If the address has a suburb, the suburb (and only the suburb) should be entered (otherwise the application to incorporate the company will be likely to be rejected by ASIC). (Of course, the address actually may be in a capital city CBD in which case the capital city name itself is acceptable.) Please note that you will not be given this warning a second time on your current visit to this page.", this);
  	  oldSuburb = lowerCase;
  	  this.focus();
  	  return false;
  	}
  }

  if (!value || value == "") {
    this.focus();
    // 20080318 - ES - Firefox doesn't do select so added test for this.select (see 7 lines up)
    if (doselect) this.select();
     if (this.comment) {
   validateAlert("Please enter some information"+ comment + " %f.", this);
    }
    else {
    
     validateAlert("Please enter some information into %f.", this);
    }
    return false;
    
  }
  return true;
}

var prevAsicValue = "";
function validateDataEnteredAsicReservationNumber() {
  var value = this.value.replace(/^\s*(.*)\s*$/, '$1');
  var doselect = this.select ? true : false;

  if (!this.mandatory && value == "")
    return true;

	if (!value || value == "") 
	{
		this.focus();
		// 20080318 - ES - Firefox doesn't do select so added test for this.select (see 7 lines up)
		if (doselect) this.select();
		if (this.comment) 
		{
			validateAlert("Please enter some information"+ comment + " %f.", this);
		}
		else 
		{
			validateAlert("Please enter some information into %f.", this);
		}
		return false;
	}
	if (prevAsicValue != value)
	{
		var lowerCase = value.toLowerCase();
		var asicPattern = /(b|f|bn)/;
		if (lowerCase.search(asicPattern) >= 0)
		{  
			alert("It appears that you may have entered a mere state registered business name into the ASIC reservation number field. If the proposed company name has not been reserved at ASIC, but merely has been registered as a state registered business name, you should go back, via the 'Back' button on the underlying page, and change your answer from 'Yes' to 'No' to the question asking whether the proposed company name has already been reserved at ASIC. Please note that you will not be given this warning message a second time on your current visit to this page.");
			prevAsicValue = value;
			return false;
		}
		var asicPattern2 = /^((\d{9})|(\d{1}e\d{7}))$/;
		if (lowerCase.search(asicPattern2) < 0)
		{  
			alert("It appears that you may have entered something other than an acceptably formatted ASIC reservation number into the ASIC reservation number field (here are two examples of correctly formatted ASIC reservation numbers: Example One: 024201853 , Example Two: 1E2420185 ). Please recheck the number you have entered, and please also make sure that there are no spaces either before, within, or after the number. Please also note that you will not be given this warning message a second time on your current visit to this page.");
			prevAsicValue = value;
			return false;
		}
	}
  return true;
}

function validateDataEntered() {
  var value = this.value.replace(/^\s*(.*)\s*$/, '$1');
  var doselect = this.select ? true : false;

  if (!this.mandatory && value == "")
    return true;

  if (!value || value == "") {
    this.focus();
    // 20080318 - ES - Firefox doesn't do select so added test for this.select (see 7 lines up)
    if (doselect) this.select();
     if (this.comment) {
   validateAlert("Please enter some information"+ comment + " %f.", this);
    }
    else {
    
     validateAlert("Please enter some information into %f.", this);
    }
    return false;
  }
  return true;
}

function isAustralia() {
  // Mantis 3834: Supporting outside australia from state list
  var bAustralia = false;
  if( typeof( document.page.country_name ) != "undefined" )
  {
	  //JC 25/03/03 changed function to suit Mac IE 5.1.4
	  var lowercase_country = document.page.country_name.value.toLowerCase();
	  bAustralia = (lowercase_country.search(/^australia$/) == 0)

    // Check states
	  if( typeof( document.page.state_id ) != "undefined" && bAustralia)
    {
      var lowercase_state = document.page.state_id.value.toLowerCase().substring(0, 7);
      bAustralia = (lowercase_state.search(/^outside$/) != 0)
    }
  }
  
  return bAustralia;
}

function checkDigitsOnly( strDigitsOnly )
{
    var i=0;
    for(i=0; i<strDigitsOnly.length; i++ )
    {
        if (strDigitsOnly.charAt(i) < '0' || strDigitsOnly.charAt(i) > '9')
            return false;
    }

    return true;
}

// Mantis 3828: Validate Australian postcodes
// Note: I was going to make this a separate function called by validatePostcode(), but the called function does then not have access to this and postcode.
// TODO: Add in the lastCalled time checks to ajax to set prev values in callback but allowing bypass after 5s.
var pendingAUPostcodeAjax = false;
var prevAUPostcodeValue = "";
var prevAUPostcodeState = "";
var prevAUPostcodeLocality = "";
var validateAustralianPostcode_Include_POBox = false;
function validateAustralianPostcode() { 
  this.value = trim(this.value);
  if (isAustralia()) {
  	var postcode = parseFloat(this.value);
  	var pcode_size = this.value.length;

  	if (isNaN(postcode) || !checkDigitsOnly(this.value))
  	{
    		if (!((Netscape)&&(Mac))) {
      			this.select();
      			this.focus();
      		}
    		alert("Please enter a valid Australian postcode (i.e. 4 digits) into the \"Postcode\" field.");
    		return false;
  	}

	  if (postcode < 0001 || postcode > 9999 || pcode_size != 4) {
    		if (!((Netscape)&&(Mac))) {
      			this.select();
      			this.focus();
      		}
    		alert("Please enter a valid Australian postcode (i.e. 4 digits) into the \"Postcode\" field.");
    		return false;
  	}
    
    if (prevAUPostcodeValue != this.value || prevAUPostcodeState != document.page.state_id.value)
    {
      var state_id = this.form.elements['state_id'].value;
      var stateFilter = null;
      var stateAbbr = null;
      var stateStartDigit = null
      switch (parseInt(state_id))
      {
        case 1: // QLD - 4###
          stateFilter = /^4\d{3}$/;
          stateAbbr = "QLD";
          stateStartDigit = "4";
          break;
        case 2: // NSW - 2###
          stateFilter = /^2\d{3}$/;
          stateAbbr = "NSW";
          stateStartDigit = "2";
          break;
        case 3: // VIC - 3###
          stateFilter = /^3\d{3}$/;
          stateAbbr = "VIC";
          stateStartDigit = "3";
          break;
        case 4: // SA - 5###
          stateFilter = /^5\d{3}$/;
          stateAbbr = "SA";
          stateStartDigit = "5";
          break;
        case 5: // WA - 6###
          stateFilter = /^6\d{3}$/;
          stateAbbr = "WA";
          stateStartDigit = "6";
          break;
        case 6: // TAS - 7###
          stateFilter = /^7\d{3}$/;
          stateAbbr = "TAS";
          stateStartDigit = "7";
          break;
        case 7: // NT - 0###
          stateFilter = /^0\d{3}$/;
          stateAbbr = "NT";
          stateStartDigit = "0";
          break;
        case 8: // ACT - 2###
          stateFilter = /^2\d{3}$/;
          stateAbbr = "ACT";
          stateStartDigit = "2";
          break;
        default:
          break;
      }
      if (stateFilter != null && !this.value.match(stateFilter))
      {
        alert("The postcode you have entered (" + this.value + ") does not look to be a correct postcode for " + stateAbbr + " (because " + stateAbbr + "  'delivery area' postcodes start with the digit " + stateStartDigit + "). Accordingly, please review and adjust your entry/s in the postcode and/or the State/territory field. And please note that you will not be given this warning message a second time in respect of the exact same entries on this/your current visit to this page.");
        prevAUPostcodeState = document.page.state_id.value;
        prevAUPostcodeValue = this.value;
    	return false;
      }
    }
    
    if (prevAUPostcodeValue != this.value || prevAUPostcodeState != document.page.state_id.value || prevAUPostcodeLocality != document.page.city_name.value)
    {
      // We want to set this prior to making the AJAX call. If the Ajax call crashes then at least the user can continue
      prevAUPostcodeValue = document.page.postcode.value;
      prevAUPostcodeState = document.page.state_id.value;
      prevAUPostcodeLocality = document.page.city_name.value;
        
      if (!pendingAUPostcodeAjax)
      {
        pendingAUPostcodeAjax = true;
        $.get("../_INC/ValidatePostcodeLocality.asp", { postcode: removeZeroPrefix(this.value), locality: document.page.city_name.value, pobox: validateAustralianPostcode_Include_POBox }, function(data) {
            //prevAUPostcodeValue = document.page.postcode.value;
            //prevAUPostcodeState = document.page.state_id.value;
            //prevAUPostcodeLocality = document.page.city_name.value;
            pendingAUPostcodeAjax = false;

            var results = data.split(':');
            switch (parseInt(results[0]))
            {
                case 1:
                    alert('The postcode you have entered (' + prevAUPostcodeValue + ') does not look to be a correct postcode for the suburb/locality you have entered (' + prevAUPostcodeLocality + ').\n\nAccordingly, please review and adjust the postcode and/or the suburb/locality you have entered. (If you want to check postcodes and matching suburbs/localities, you can do so at http://www1.auspost.com.au/postcodes/.)\n\nPlease note that you will not be given this warning message a second time in respect of the exact same entries on this/your current visit to this page.');
                    return;
                case 2:
                    alert('The suburb/locality you have entered (' + prevAUPostcodeLocality + ') does not look to be an officially spelt, official Australian suburb/locality.\n\nAccordingly, please review and adjust the suburb/locality you have entered. (If you want to check the official spelling of official Australian suburbs/localities which match the postcode you have entered, you can do so at http://www1.auspost.com.au/postcodes/.)\n\nPlease note that you will not be given this warning message a second time in respect of the exact same entries on this/your current visit to this page.');
                    return;
                case 3:
                    if (validateAustralianPostcode_Include_POBox)
                        alert('The postcode you have entered (' + prevAUPostcodeValue + ') does not look to be an official Australian postcode.\n\n[By the way, the official postcode for the suburb/locality you have entered (' + prevAUPostcodeLocality + ') appears to be ' + addZeroPrefix(results[1]) + '. And if you want to check official Australian postcodes and matching official Australian suburbs/localities, you can do so at http://www1.auspost.com.au/postcodes/].\n\nAccordingly, please review and adjust the postcode you have entered. Please note that you will not be given this warning message a second time in respect of the exact same entries on this/your current visit to this page.');
                    else
                        alert('The postcode you have entered (' + prevAUPostcodeValue + ') does not look to be an official Australian (\'Delivery Area\') postcode.\n\n[By the way, the official postcode for the suburb/locality you have entered (' + prevAUPostcodeLocality + ') appears to be ' + addZeroPrefix(results[1]) + '. And if you want to check official Australian postcodes and matching official Australian suburbs/localities, you can do so at http://www1.auspost.com.au/postcodes/].\n\nAccordingly, please review and adjust the postcode you have entered. Please note that you will not be given this warning message a second time in respect of the exact same entries on this/your current visit to this page.');
                    return;
                case 4:
                     if (validateAustralianPostcode_Include_POBox)
                        alert('Your entry for the postcode (' + prevAUPostcodeValue + ') does not appear to be an official Australian postcode.\n\nAlso, your entry for the suburb/locality (' + prevAUPostcodeLocality + ') does not appear to be an officially spelt official Australian suburb/locality.\n\n(If you want to check official Australian postcodes and their officially spelt officially matching suburbs/localities, you can do so at http://www1.auspost.com.au/postcodes/.).\n\nAccordingly, please review and adjust the postcode and/or the suburb/locality you have entered. Please note that you will not be given this warning message a second time in respect of the exact same entries on this/your current visit to this page.');
                    else
                        alert('Your entry for the postcode (' + prevAUPostcodeValue + ') does not appear to be an official Australian (\'Delivery Area\') postcode.\n\nAlso, your entry for the suburb/locality (' + prevAUPostcodeLocality + ') does not appear to be an officially spelt official Australian suburb/locality.\n\n(If you want to check official Australian postcodes and their officially spelt officially matching suburbs/localities, you can do so at http://www1.auspost.com.au/postcodes/.).\n\nAccordingly, please review and adjust the postcode and/or the suburb/locality you have entered. Please note that you will not be given this warning message a second time in respect of the exact same entries on this/your current visit to this page.');
                    return;
            }

            _loib_onClick(document.page, 'page_continue', '_page_continue(document.page)', true);
        });
        
        return false;
      }
      else
      {
        return false;
      }
    }    
  }
  return true;
}

// TODO: Add in the lastCalled time checks to ajax to set prev values in callback but allowing bypass after 5s.
var pendingPostcodeAjax = false;
var prevPostcodeValue = "";
var prevPostcodeState = "";
var prevPostcodeLocality = "";
var validatePostcode_Include_POBox = false;
function validatePostcode() {
  this.value = trim(this.value);
  if (isAustralia()) {
  
    //var postcode = parseInt(this.value); // Java bug with parseInt and leading 0's (assumes octal)
    var postcode = parseFloat(this.value);
  	var pcode_size = this.value.length;

  	if (isNaN(postcode) || !checkDigitsOnly(this.value))
  	{
  		if (!((Netscape)&&(Mac))) {
  			this.select();
  			this.focus();
  		}
  		alert("Please enter a valid Australian postcode (i.e. 4 digits) into the \"Postcode\" field.");
  		return false;
  	}

  	if (postcode < 0001 || postcode > 9999 || pcode_size != 4) {
  		if (!((Netscape)&&(Mac))) {
  			this.select();
  			this.focus();
  		}
  		alert("Please enter a valid Australian postcode (i.e. 4 digits) into the \"Postcode\" field.");
  		return false;
  	}
    
    if (prevPostcodeValue != this.value || prevPostcodeState != document.page.state_id.value)
    {
      var state_id = document.page.state_id.value;
      var stateFilter = null;
      var stateAbbr = null;
      var stateStartDigit = null
      switch (parseInt(state_id))
      {
        case 1: // QLD - 4###
          stateFilter = /^4\d{3}$/;
          stateAbbr = "QLD";
          stateStartDigit = "4";
          break;
        case 2: // NSW - 2###
          stateFilter = /^2\d{3}$/;
          stateAbbr = "NSW";
          stateStartDigit = "2";
          break;
        case 3: // VIC - 3###
          stateFilter = /^3\d{3}$/;
          stateAbbr = "VIC";
          stateStartDigit = "3";
          break;
        case 4: // SA - 5###
          stateFilter = /^5\d{3}$/;
          stateAbbr = "SA";
          stateStartDigit = "5";
          break;
        case 5: // WA - 6###
          stateFilter = /^6\d{3}$/;
          stateAbbr = "WA";
          stateStartDigit = "6";
          break;
        case 6: // TAS - 7###
          stateFilter = /^7\d{3}$/;
          stateAbbr = "TAS";
          stateStartDigit = "7";
          break;
        case 7: // NT - 0###
          stateFilter = /^0\d{3}$/;
          stateAbbr = "NT";
          stateStartDigit = "0";
          break;
        case 8: // ACT - 2###
          stateFilter = /^2\d{3}$/;
          stateAbbr = "ACT";
          stateStartDigit = "2";
          break;
        default:
          break;
      }
      if (stateFilter != null && !this.value.match(stateFilter))
      {
        alert("The postcode you have entered (" + this.value + ") does not look to be a correct postcode for " + stateAbbr + " (because " + stateAbbr + "  'delivery area' postcodes start with the digit " + stateStartDigit + "). Accordingly, please review and adjust your entry/s in the postcode and/or the State/territory field. And please note that you will not be given this warning message a second time in respect of the exact same entries on this/your current visit to this page.");
        prevPostcodeValue = this.value;
        prevPostcodeState = document.page.state_id.value;
        return false;
      }
    }
    
    if (prevPostcodeValue != this.value || prevPostcodeState != document.page.state_id.value || prevPostcodeLocality != document.page.city_name.value)
    {

      // We want to set this prior to making the AJAX call. If the Ajax call crashes then at least the user can continue
      prevPostcodeValue = document.page.postcode.value;
      prevPostcodeState = document.page.state_id.value;
      prevPostcodeLocality = document.page.city_name.value;
        
      if (!pendingPostcodeAjax)
      {
        pendingPostcodeAjax = true;
        $.get("../_INC/ValidatePostcodeLocality.asp", { postcode: removeZeroPrefix(this.value), locality: document.page.city_name.value, pobox: validatePostcode_Include_POBox }, function(data) {
            //prevPostcodeValue = document.page.postcode.value;
            //prevPostcodeState = document.page.state_id.value;
            //prevPostcodeLocality = document.page.city_name.value;
            pendingPostcodeAjax = false;

            var results = data.split(':');
            switch (parseInt(results[0]))
            {
                case 1:
                    alert('The postcode you have entered (' + prevPostcodeValue + ') does not look to be a correct postcode for the suburb/locality you have entered (' + prevPostcodeLocality + ').\n\nAccordingly, please review and adjust the postcode and/or the suburb/locality you have entered. (If you want to check postcodes and matching suburbs/localities, you can do so at http://www1.auspost.com.au/postcodes/.)\n\nPlease note that you will not be given this warning message a second time in respect of the exact same entries on this/your current visit to this page.');
                    return;
                case 2:
                    alert('The suburb/locality you have entered (' + prevPostcodeLocality + ') does not look to be an officially spelt, official Australian suburb/locality.\n\nAccordingly, please review and adjust the suburb/locality you have entered. (If you want to check the official spelling of official Australian suburbs/localities which match the postcode you have entered, you can do so at http://www1.auspost.com.au/postcodes/.)\n\nPlease note that you will not be given this warning message a second time in respect of the exact same entries on this/your current visit to this page.');
                    return;
                case 3:
                    if (validatePostcode_Include_POBox)
                        alert('The postcode you have entered (' + prevPostcodeValue + ') does not look to be an official Australian postcode.\n\n[By the way, the official postcode for the suburb/locality you have entered (' + prevPostcodeLocality + ') appears to be ' + addZeroPrefix(results[1]) + '. And if you want to check official Australian postcodes and matching official Australian suburbs/localities, you can do so at http://www1.auspost.com.au/postcodes/].\n\nAccordingly, please review and adjust the postcode you have entered. Please note that you will not be given this warning message a second time in respect of the exact same entries on this/your current visit to this page.');
                    else
                        alert('The postcode you have entered (' + prevPostcodeValue + ') does not look to be an official Australian (\'Delivery Area\') postcode.\n\n[By the way, the official postcode for the suburb/locality you have entered (' + prevPostcodeLocality + ') appears to be ' + addZeroPrefix(results[1]) + '. And if you want to check official Australian postcodes and matching official Australian suburbs/localities, you can do so at http://www1.auspost.com.au/postcodes/].\n\nAccordingly, please review and adjust the postcode you have entered. Please note that you will not be given this warning message a second time in respect of the exact same entries on this/your current visit to this page.');
                    return;
                case 4:
                    if (validatePostcode_Include_POBox)
                        alert('Your entry for the postcode (' + prevPostcodeValue + ') does not appear to be an official Australian postcode.\n\nAlso, your entry for the suburb/locality (' + prevPostcodeLocality + ') does not appear to be an officially spelt official Australian suburb/locality.\n\n(If you want to check official Australian postcodes and their officially spelt officially matching suburbs/localities, you can do so at http://www1.auspost.com.au/postcodes/.).\n\nAccordingly, please review and adjust the postcode and/or the suburb/locality you have entered. Please note that you will not be given this warning message a second time in respect of the exact same entries on this/your current visit to this page.');
                    else
                        alert('Your entry for the postcode (' + prevPostcodeValue + ') does not appear to be an official Australian (\'Delivery Area\') postcode.\n\nAlso, your entry for the suburb/locality (' + prevPostcodeLocality + ') does not appear to be an officially spelt official Australian suburb/locality.\n\n(If you want to check official Australian postcodes and their officially spelt officially matching suburbs/localities, you can do so at http://www1.auspost.com.au/postcodes/.).\n\nAccordingly, please review and adjust the postcode and/or the suburb/locality you have entered. Please note that you will not be given this warning message a second time in respect of the exact same entries on this/your current visit to this page.');
                    return;
            }

            _loib_onClick(document.page, 'page_continue', '_page_continue(document.page)', true);
        });
        
        return false;
      }
      else
      {
        return false;
      }
    }    
  } else {
  
   	if (this.value == "") {
  		if (!((Netscape)&&(Mac))) {
  			this.select();
  			this.focus();
  		}
  		alert("Please enter a value into the \"Postcode\" field.");
  		return false;
  	}    
    
  }
  return true;
}

// JC 31/10/03 Ref 997 For validating town and country of birth, ensuring they are not the same (unless new york etc).
var oldTownValue = "";
function validateStateAndBirthTown ()
{	
	var townValue = document.page.birth_town.value.replace(/^\s*(.*)\s*$/, '$1');
	var value = this.value.replace(/^\s*(.*)\s*$/, '$1');
	if (this.mandatory && value == "")
	{
   		alert ("Please enter some information into the \"State or country of birth\" field", this);
   		this.focus();
    	        this.select();
   		return false;
   	}

  	if (!value || value == "") 
  	{
    		this.focus();
    		this.select();
     		if (this.comment) 
     		{
   			validateAlert("Please enter some information"+ comment + " %f.", this);
    		}
    		return false;
    	}
	
	var lowerCase = value.toLowerCase();
	var townLowerCase = townValue.toLowerCase();
	var pattern = /^((n|h)(\.*)(y|k)(\.*)|new york|singapore|hong kong)/;
	var message;
	if (lowerCase.search(pattern) < 0 && oldTownValue!= lowerCase && townLowerCase.search(pattern) < 0 && lowerCase == townLowerCase)
	{
		message = "Incorporator detects that you may have incorrectly entered an identical 'Town or city of birth' and 'State or country of birth' for this person. Although this can sometimes be correct (e.g. Singapore, Singapore), it generally will not be correct. Would you therefore please reconsider your entries for these fields and adjust them if necessary and as appropriate. Please also note that you will not be given this warning message a second time on your current visit to this page and in respect of the exact same identical entries."; 
		validateAlert(message, this);
		this.select();
		this.focus();
		titleIsValid = true;
		oldTownValue = lowerCase;
		return false;
	}
	return true;
}

//JC 17/10/03 Ref 973 This one is for page 10/55 
var oldNameAbbValue = ""
function validateNameForAbbrevIfNotCompanyNumber ()
{
	var value = this.value.replace(/^\s*(.*)\s*$/, '$1');
	if (!value || value == "") 
	{
    		this.focus();
    		this.select();
     		validateAlert("Please do enter some information into %f.", this);
    		return false;
    	}
	var upperCase = value;
	if (oldNameAbbValue != upperCase)
	{
		var lowerCase = upperCase.toLowerCase();
		var message;
		var businessPattern = /((\s+)(pty(\.*)|proprietary|ltd(\.*)|limited|n(\.*)l(\.*)|no liability)|(p(\.*)(\/*)l(\.*))|(a(\.*)c(\.*)n)|(a(\.*)b(\.*)n)|(a(\.*)r(\.*)b(\.*)n)|(australian (business|company|registered body) number)|(solicitor(s*))|(solcr(\.*))|(slcr(s*|s*\.*))|(lawyer(s*))|(accountant(s*))|accnts(\.*))/;  // This comment is here to fix the Visual Studio colouring problem because it recognises a start comment block in this line*/
		if (lowerCase.search(businessPattern) < 0)
		{
			var pattern = /(((\s+)[a-z]{1}(\.*)(\s+))|(^[a-z]{1}(\.*)$)|(^[a-z]{1}\.*\s+)|(\s+[a-z]{1}(\.*)$))/
			if (lowerCase.search(pattern) >= 0)
			{
				message = "Incorporator detects that you may have used one or more initials/abbreviations in a persons name. Please note that initials/abbreviations should not be used; persons full names should always be specified. If so, please enter the full name(s). Otherwise please proceed as normal (and please note that you will not be given this warning message a second time on your current visit to this page and in respect of the exact same entry). (Also, Incorporator acknowledges that sometimes, some persons names comprise no more than a single letter. If that is the case here, then please proceed as normal ... but please be aware that you may independently have to confirm that fact specifically with ASIC in order to get the company registered.)";
			}
			else
			{
				return true;
			}
			validateAlert(message, this);
			this.select();
			this.focus();
			oldNameAbbValue = upperCase;
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		return true;
	}
}

// JC 17/10/03 Ref 972 Checks for abbreviations in the surname field
var oldSurnameValue = "";
var oldFirstnameValue = "";
var fraudHitCount = 0;
var pendingFraudCheckAjax = false;
var trustNameCheckOldSurname = "";
function checkSurnameForAbbreviation() 
{
	var mandatory = this.mandatory;
	var value = this.value.replace(/^\s*(.*)\s*$/, '$1');
	if (mandatory) 
  {
	  if (!value || value == "") 
	  {
      this.focus();
    	this.select();
	    validateAlert("Please enter some information into %f.", this);
    	return false;
    }
	} 
  else if (value == "")
  {
    return true;
  }
  
  var firstname = "";  
  if( (""+document.page.first_given_name) != "undefined" )
      firstname = document.page.first_given_name.value.toLowerCase();
  else if (("" + document.page.b_first_given_name) != "undefined")
      firstname = document.page.b_first_given_name.value.toLowerCase();
  var surname = value.toLowerCase();
  var pattern = /(((\s+)[a-z]{1}(\.*)(\s+))|(^[a-z]{1}(\.*)$)|(^[a-z]{1}\.*\s+)|(\s+[a-z]{1}(\.*)$))/
  //var pattern = /(((\s+)\w{1}(\.*)(\s+))|(\w{1}(\.*)(\s+))|((\s+)\w{1}(\.*))|(^(\w{1})(\.*)$))/;
  if (surname.search(pattern) >= 0)
  {
    validateAlert("Please enter a word/name in this field, not just an initial.", this);  	
    this.select();
    this.focus();
    return false;
  }

  // 20080708 - Mantis 2192 - Remove check for (for) as it was blocking usage
  if (this.validateTrustee && trustNameCheckOldSurname != surname)
  {
    trustNameCheckOldSurname = surname;
    var nextPattern = /(\s+|^)((trust)|(trusts)|(trustee)|(trustees)|(t'ee)|(t'ees)|(atf)|(a.t.f.)|(as trustee for)|(behalf)|(executor)|(executors))(\s+|$)/;
    if (surname.search(nextPattern) >= 0)
    {
        alert("Incorporator detects that you have entered something indicating (or along the lines of) a trust in the 'Surname or family name field'. Even if this shareholder/member will be holding the share(s) as a trustee/on trust, any indication of that should be removed from this field. Also, please note that even if this shareholder/member will be holding the share(s) on trust, you must still enter here, and only enter here, the name of the trustee/individual/human being i.e. do not mention the name of the trust, do not mention the beneficiary(s), and do not mention the fact that the share(s) are going to be held on trust as you will be asked separately about this later. Please note that you will not be given this warning message a second time in respect of the exact same entry on this/your current visit to this page.");
    	this.select();
    	this.focus();
    	return false;
    }
  }

  // Has data changed from last click?
  if (oldSurnameValue == surname && oldFirstnameValue == firstname)
  {
    // Check for fraud hits
    if (fraudHitCount > 0)
    {
      validateAlert("There is a problem with your application. Please phone Incorporator on " + INCORPORATOR_TELEPHONE_TEXT + " to discuss.", this);  	
      this.select();
      this.focus();
      return false;
    }

    // Pass check
    return true;
  }
  
  return true;
}


// JC 17/10/03 Ref 972 Checks for abbreviations in the given name field
function checkSecondNameForAbbreviationECR () 
{
	var mandatory = this.mandatory;
	var value = this.value.replace(/^\s*(.*)\s*$/, '$1');
	if (mandatory)
	{
		var lowerCase = value.toLowerCase();
		var message;
		var pattern = /(((\s+)[a-z]{1}(\.*)(\s+))|(^[a-z]{1}(\.*)$)|(^[a-z]{1}\.*\s+)|(\s+[a-z]{1}(\.*)$))/
		if (lowerCase.search(pattern) >= 0)
		{
			message = "Please enter a word/name in this field, not just an initial."
			validateAlert(message, this);
			this.select();
			this.focus();
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		return true;
	}
}

// JC 17/10/03 Ref 972 Checks for abbreviations in the given name field
var oldFirstNameAbbreviationValue = "";
function checkFirstNameForAbbreviation () 
{
	var mandatory = this.mandatory;
	var value = this.value.replace(/^\s*(.*)\s*$/, '$1');
	if (mandatory) {
	if (!value || value == "") 
	{
    		this.focus();
    		this.select();
	     		validateAlert("Please enter some information into %f.", this);
    		return false;
    	}
	}
	var upperCase = value;
	if (true)//(oldFirstNameAbbreviationValue != upperCase)
	{
		var lowerCase = upperCase.toLowerCase();
		var message;
		var pattern = /(((\s+)[a-z]{1}(\.*)(\s+))|(^[a-z]{1}(\.*)$)|(^[a-z]{1}\.*\s+)|(\s+[a-z]{1}(\.*)$))/
		if (lowerCase.search(pattern) >= 0)
		{
			message = "Please enter a word/name in this field, not just an initial."
			//message = "Incorporator detects that you may have used one or more initials/abbreviations in this persons name. Please note that initials/abbreviations are not allowed; persons' full names must always be specified. If so, please enter the full name(s). Otherwise please proceed as normal (and please note that you will not be given this warning message a second time on your current visit to this page and in respect of the exact same entry). (Also, Incorporator acknowledges that sometimes, some persons' names comprise no more than a single letter. If that is the case here, then please proceed as normal ... but please be aware that you may independently have to confirm that fact specifically with ASIC in order to get the company registered.)";
		}
		else
		{
			return true;
		}
		validateAlert(message, this);
		this.select();
		this.focus();
		oldFirstNameAbbreviationValue = upperCase;
		return false;
	}
	else
	{
		return true;
	}
}

// JC 10/01/2006 Ref 2192 Checks for abbreviations in the given name field
function checkFirstNameForAbbreviationECR () 
{
	var mandatory = this.mandatory;
	var value = this.value.replace(/^\s*(.*)\s*$/, '$1');
	if (mandatory) {
		if (!value || value == "") 
		{
	    		this.focus();
	    		this.select();
	     		validateAlert("Please enter some information into %f.", this);
	    		return false;
	    	}
		var lowerCase = value.toLowerCase();
		var message;
		var pattern = /(((\s+)[a-z]{1}(\.*)(\s+))|(^[a-z]{1}(\.*)$)|(^[a-z]{1}\.*\s+)|(\s+[a-z]{1}(\.*)$))/
		if (lowerCase.search(pattern) >= 0)
		{
			message = "Please enter a word/name in this field, not just an initial."
			validateAlert(message, this);
			this.select();
			this.focus();
			return false;
		}
	}
	return true;
}

// JC 17/10/03 Ref 971 For validating Ultimate Holding Company name, ensuring ends in pty ltd etc.
oldUHCValue = "";
function validateUHCfield () {
	var value = this.value.replace(/^\s*(.*)\s*$/, '$1');
	if (!value || value == "") 
	{
    		this.focus();
    		this.select();
     		validateAlert("Please enter some information into %f.", this);
    		return false;
  }
	var upperCase = value;
  if (document.page.registered_in_australia.value == 'AUSTRALIA' && oldUHCValue != upperCase)
	{
		var lowerCase = upperCase.toLowerCase();
		var message;
		var pattern = /((\s+)(pty(\.*)|proprietary|ltd(\.*)|limited|n(\.*)l(\.*)|no liability))/;
		if (lowerCase.search(pattern) <= 0)
		{
			message = "Incorporator detects that you may have accidentally and incorrectly omitted the 'name ending' of the ultimate holding company (e.g. 'Pty Ltd', 'Limited' etc.) in the 'Company Name' field box. If so, please insert the 'name ending' in the 'Company Name' field box. Otherwise please proceed as normal (and please note that you will not be given this warning message a second time on your current visit to this page and in respect of the exact same entry).";
		}
		else
		{
			return true;
		}
		validateAlert(message, this);
		this.select();
		this.focus();
		oldUHCValue = upperCase;
		return false;
	}
	else
	{
		return true;
	}
}

// 28/03/03 Function moved from page 10/44 to here.
// 19/11/02 Task#279 Created
var titleIsValid = false;
var oldValue = "";
function validateApplicantName() {
	var value = this.value.replace(/^\s*(.*)\s*$/, '$1');
	var upperCase = value;
	var lowerCase = upperCase.toLowerCase();
	var pattern = /(solicitor|lawyer|accountant)s?\s*$/;
	var message;
	if (lowerCase == "") {
      		if (!((Netscape)&&(Mac))) {
      			this.select();
      			this.focus();
      		}
      		alert("Please enter a value into the \"" + this.text + "\" field.");
      		return false;
    	} else if (lowerCase.search(pattern) >= 0) {
		validateAlert("Your entry in the '" + this.text + "' field suggests that the applicant may be a legal or accounting firm. " +  
			"In such a case the name of the actual person who will sign on behalf of the firm must be stated, and it must be clear on " +  
			"the face of the entry that the name of the actual person signing is indeed stated e.g. 'Smiths Lawyers per John William Smith' " +  
			"or 'Osbornes Accountants per Harry Andrew Taylor'. \nIn any event (but nevertheless in compliance with the above requirement), " +  
			"would you please change (or re-arrange) your entry so that it does not end with any of the following words:\n Solicitor, Solicitors, " +  
			"Lawyer, Lawyers, Accountant or Accountants."
			, this);
		return false;
	} 
	else 
	{	
		// JC 14/08/2003 ref 892 New validation for missing ACN (etc) after Ltd (etc) 
		if (oldValue!= upperCase || !titleIsValid) 
		{
			// JC 28/08/2003 ref 925 Added "p./l." check to pattern and checkPattern variables.
			var pattern = /((p(\.*)(\/*)l(\.*))|pty(\.*)|proprietary|ltd(\.*)|limited|nl|n.l.|no liability)(\s*)(a(\.*)c(\.*)n(\.*)|australian company number|a(\.*)b(\.*)n(\.*)|australian business number|arbn|a.r.b.n.|australian registered body number)/; // */
			var secondPattern = /(pty(\.*)|proprietary)(\s*)(ltd(\.*)|limited)(\s*)(a(\.*)c(\.*)n(\.*)|australian company number|a(\.*)b(\.*)n(\.*)|australian business number|a(\.*)r(\.*)b(\.*)n(\.*)|australian registered body number)/;
			var checkPattern = /(\s+)+(pty|ltd|limited|no liability|proprietary|n(\.*)l(\.*)|p(\.*)l(\.*))$|^(pty|ltd|limited|no liability|proprietary|n(\.*)l(\.*)|p(\.*)l(\.*))+(\s+)|(\s+)(pty|ltd|limited|no liability|proprietary|n(\.*)l(\.*)|p(\.*)l(\.*))+(\s+)/;
			if (lowerCase.search(checkPattern) >= 0)
			{
				if ((lowerCase.search(pattern) >= 0) || (lowerCase.search(secondPattern) >= 0))
				{
					//return true;
				}
				else
				{
					message = "Incorporator detects that you may have specified a company name in this field without also specifying its ACN (Australian Company Number) or ABN (Australian Business Number) etc. (as is required). If so, and if the company is an Australian company, please specify its ACN or ABN etc. (e.g. 'Smiths Pty Ltd ACN 332 684 776' or 'Jones Limited ABN 92 558 945 675'). If so, and the company is a foreign company registered as such in Australia, please specify its ARBN (Australian Registered Body Number) (e.g. 'Smiths Pty Ltd ARBN 332 684 776'). If so, and the company is a foreign company not registered as such in Australia, Incorporator suggests that you specify its country of incorporation [e.g. 'Westminster Finance Limited (inc. in England)']. Otherwise please proceed as normal (and please note that you will not be given this warning message a second time on your current visit to this page and in respect of the exact same error)."; 
					validateAlert(message, this);
					this.select();
					this.focus();
					titleIsValid = true;
					oldValue = upperCase;
					return false;
				}
			}
		}
	}
	//
	
	//JC 17/10/03 Ref 973 This one is for 10/40
	if (oldValue!=upperCase)
	{
		var businessPattern = /((\s*)(pty(\.*)|proprietary|ltd(\.*)|limited|n(\.*)l(\.*)|no liability)|(p(\.*)(\/*)l(\.*))|(a(\.*)c(\.*)n)|(a(\.*)b(\.*)n)|(a(\.*)r(\.*)b(\.*)n)|(australian (business|company|registered body) number))/; // */
		if (lowerCase.search(businessPattern) < 0)
		{
			var pattern = /(((\s+)[a-z]{1}(\.*)(\s+))|(^[a-z]{1}(\.*)$)|(^[a-z]{1}\.*\s+)|(\s+[a-z]{1}(\.*)$))/
			if (lowerCase.search(pattern) >= 0)
			{
				message = "Incorporator detects that you may have used one or more initials/abbreviations in a persons name. Please note that initials/abbreviations should not be used; persons full names should always be specified. If so, please enter the full name(s). Otherwise please proceed as normal (and please note that you will not be given this warning message a second time on your current visit to this page and in respect of the exact same entry). (Also, Incorporator acknowledges that sometimes, some persons names comprise no more than a single letter. If that is the case here, then please proceed as normal ... but please be aware that you may independently have to confirm that fact specifically with ASIC in order to get the company registered.)";
			}
			else
			{
				return true;
			}
			validateAlert(message, this);
			this.select();
			this.focus();
			oldValue = upperCase;
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		return true;
	}
}

// Task 300 
function validatePOBox() {
  var value = this.value.replace(/^\s*(.*)\s*$/, '$1');
  var upperCase = value;
  // JC 21/03/03 task 268 changed pattern = /P(\.)?O(\.)?(\s)*Box/i; as MSIE 4.5 on Mac has issues with /i
  //var pattern = new RegExp( "P(\\.)?(\\s)?O(\\.)?(\\s)*Box", "i" );

  // JC 25/03/79 changed "if (this.value.search(pattern) >= 0)" 
  // and pattern now only checks for lowercase, and the string itself is converted to lowercase. 
  // Macintosh IE 4.5 had problames with "i" and 5.1.4 had problems with the RegExp fix (above).
  var lowerCase = upperCase.toLowerCase();
  var pattern = /p(\s*)(\.*)(\s*)o(\s*)(\.*)(\s*)*box/;

  if (lowerCase.search(pattern) >= 0) {
    this.focus();
    alert("Incorporator detects that you have entered a PO or GPO Box address in the 'Street "
       + "address (i.e. number and name):' field. The Corporations Act/ASIC requires that an "
       + "actual address be specified. Please adjust your entry accordingly.");
    return false;
  } else {
    return this.validateDataEntered();
  }
}
// Task 300 - end

function removeUnitNumberLetterSpace()
{
    // Find instances of <Number><Space><Letter> and remove the space
    var pattern = /\d+\s+[A-Za-z](\s+|$)/
    var index = this.value.search(pattern);
    
    if (index >= 0)
    {
        // Add the precursor (if any)
        var replacement = this.value.substr(0, index);
        var remainder = this.value.substring(index);
        
        // Add the <Number>
        index = remainder.search(/\s/);
        replacement += remainder.substr(0, index);
        remainder = remainder.substring(index);

        // Remove the <Space>
        index = remainder.search(/[A-Za-z]/);
        replacement += remainder.substring(index);
        
        // Trim leading and trailing spaces
        replacement = trim(replacement);

        // Replace the value
        this.value = replacement;
    }

    return true;
}

// Mantis 4450
function trimUnitNumberToMaxLength() {
    var ADDRESS_UNIT_NO_SIZE = 7;

    if (this.value.length > ADDRESS_UNIT_NO_SIZE)
        this.value = this.value.substr(0, ADDRESS_UNIT_NO_SIZE);

    return true;
}

function trimASICNoToMaxLength()
{
    var BOARDMEMBER_ASIC_NO_SIZE = 20;

    if (this.value.length > BOARDMEMBER_ASIC_NO_SIZE)
        this.value = this.value.substr(0, BOARDMEMBER_ASIC_NO_SIZE);

    return true;
}

var validateCareOf_messageShown = false;
function validateCareOf()
{
    if(validateCareOf_messageShown)
        return true;
        
    pattern = new RegExp("care of|c/o|c / o|c/-|c / -|c/|c /");
    var lowerCase = this.value.toLowerCase();
    
    if(lowerCase.search(pattern) >= 0)
    {
        alert("Incorporator detects that you have may have entered a 'Care of' address, as the residential address of this person. ASIC always rejects such 'Care of' residential addresses (because it, understandably, makes ASIC think that the true residential address of the person has not been listed). Accordingly, please adjust your entry so that it includes the actual residential address of this person, and so that it does not include the words 'Care of' (or equivalent). And please note that you will not be given this warning message a second time on your current visit to this page in respect of the same entry (or equivalent) in the same field.");
        validateCareOf_messageShown = true;
        return false;
    }
    return true;
}

var validateNoStreetName_messageShown = null;
function validateNoStreetName()
{
    if (this.value.length == 0) // Ignore this check if the field value is empty (since there should be another validation check for this)
        return true;

    try
    {
        var country_name = document.page.country_name.value.toLowerCase();
        if (country_name != "australia")
            return true; // Ignore this check if this is NOT an Australian address
    }
    catch (exception)
    {
        // Skip this check
        return true;
    }
        
    if (validateNoStreetName_messageShown == this.value)
        return true;

    pattern = new RegExp("[a-zA-Z]{2,}");
    var lowerCase = this.value.toLowerCase();

    if (lowerCase.search(pattern) < 0)
    {
        alert("There does not appear to be any Street name in the 'Street address (i.e. number and name):' field. Please check this and include a Street name, as may be appropriate. And please note that you will NOT be given this warning message a second time in respect of the exact same entry on this/your current visit to this page.");
        validateNoStreetName_messageShown = this.value;
        return false;
    }
    return true;
}

var validateFloorLevelAbbreviation_messageShown = null;
function validateFloorLevelAbbreviation()
{
    if (this.value.length == 0) // Ignore this check if the field value is empty (since there should be another validation check for this)
        return true;

    if (validateFloorLevelAbbreviation_messageShown == this.value)
        return true;

    pattern = /(level)|(lvl)|(lvl\.)|(floor)|(flr)|(flr\.)/g
    var lowerCase = this.value.toLowerCase();

    if (lowerCase.search(pattern) >= 0)
    {
        alert("You appear to have entered in the 'Unit number (if applicable)' field, some word/s or abbreviation/s indicating a floor or level number. In Incorporator's experience, ASIC almost always REJECTS an application to incorporate a company where the words 'Floor' or 'Level' (or any abbreviation of those words) is included in the 'Unit number ...' field for addresses which are supposed to be residential addresses. Accordingly, and if applicable, would you please remove the words 'Floor' or 'Level' (or any abbreviation of those words) from the 'Unit number ...' field. And please note that you will NOT be given this warning message a second time in respect of the exact same entry on this/your current visit to this page.");
        validateFloorLevelAbbreviation_messageShown = this.value;
        return false;
    }
    return true;
}

//var hasPOBox = true; 
var validStreetAddress = false; // so that the following functon will not complain more than once per page load.
var oldCorner = "  "; // JC Ref 1221 For Corner addresses
var oldNumber = "  "; // JC Ref 1221 For Corner addresses
var oldMultiNumber = "  "; // KD Ref 4042 For Multinumber street addresses
function validateStreetAddress() {
	var value = this.value.replace(/^\s*(.*)\s*$/, '$1');
	var pattern = /((^|(\s))\d+)/;

	//if (!validStreetAddress) {
	if (oldNumber != value) {
		var mandatory = this.mandatory;
		if (mandatory) {
			if (value == "") {
				this.focus();
				this.select();
				if (this.comment) {
					validateAlert("Please enter some information"+ comment + " %f.", this);
				}
				else {
					validateAlert("Please enter some information into %f.", this);
				}
				return false;
			}
			else if (!(pattern.test(value))) {
				this.focus();
				this.select();
				validStreetAddress = true;
				oldNumber = value;
				validateAlert("There is no street number in the %f. This may be because you have accidentally inserted the street number in one of the earlier fields (e.g. the 'Unit or office number' field or the 'Floor or level number' field) (or it may, of course, be because your 'street address' indeed does not include a street number). Please check this and make any adjustments as may be necessary (if any). (Please note that you will not be given this warning message a second time in respect of this exact same entry on this occassion and in respect of your current visit to this page.)", this);
				return false;
			}
		}
		else {
			if (!(value == "")) {
				if (!(pattern.test(value))) {
					this.focus();
					this.select();
					validStreetAddress = true;
					oldNumber = value;
					validateAlert("There is an entry in the %f, but there is no street number included. This may be because you have accidentally inserted the street number in one of the earlier fields (e.g. the 'Unit or office number' field or the 'Floor or level number' field), or it may, of course, be because your 'street address' indeed does not include a street number, or it may even be because you have (accidentally) included something in the field even though you don't in fact want to specify a Street Address at all. Please check this and make any adjustments (or deletions) as may be necessary (if any). (Please note that you will not be given this warning message a second time in respect of this exact same entry on this occassion and in respect of your current visit to this page.)", this);
					return false;
				}
			}
		}
	}
	
	// JC Ref 1221 For Corner addresses
	if (oldCorner != value) {
		var lowerCase = value.toLowerCase();
		cornerPattern = /(\s+|^|\()((corner)|(corners)|(cnrs)|(cnrs(\.))|(cnr)|(cnr(\.)))($|\s+)/;
		if (lowerCase.search(cornerPattern) >= 0)
		{
			validateAlert("Incorporator detects that the 'Street address (i.e. number and name):' field may include a 'corner address'. Please note that ASIC does not accept 'corner addresses' (even if the overall address you specify also includes a Building/location name, and even if such a Building/location is very prominent, for example, a giant shopping mall such as 'Westfield EastGardens', 'Chadstone Shopping Centre' or 'Indooroopilly Shopping Centre') ... If the address has a street number or a street number range (e.g. '200 - 250') you must specify it (instead of a corner address). Accordingly, would you please amend the address if (and as) necessary. And please note that you will not be given this warning message a second time on your current visit to this page and in respect of the exact same entry.", this);
			oldCorner = value;
			return false;
		}
	}
	
	// KD Ref 4042 For multinumber street addresses
	if (oldMultiNumber != value)
	{
    var country_name = document.page.country_name.value.toLowerCase();
		var lowerCase = value.toLowerCase();
		multiNumberPattern = /(\s+|^|\()(\d+\s*-\s*\d+)($|\s+)/;

		if (lowerCase.search(multiNumberPattern) >= 0 && country_name == 'australia')
		{
			validateAlert("Incorporator detects that you have may have entered a 'Multi-numbered' Australian street address (i.e. " + lowerCase.match(multiNumberPattern)[0] + "). Incorporator has found that ASIC almost always rejects Multi-numbered street addresses, and almost always accepts a single numbered version of such street addresses. Incorporator therefore suggests that you adjust your entry so that it includes only a single number/digit (e.g. " + lowerCase.match(multiNumberPattern)[0].match(/^\d+/) + "). Please note that you will not be given this warning a second time on your current visit to this page and in respect of the same entry.", this);
			oldMultiNumber = value;
			return false;
		}
	}
	return true;
}
// JC 03/10/2003 ref 958 Validate Company Name Ending
var nameIsValid = false;
var oldNameEndingValue = "";
function validateCompanyNameEnding () {
	var value = this.value.replace(/^\s*(.*)\s*$/, '$1');
	if (!value || value == "") 
	{
    		this.focus();
    		this.select();
     		validateAlert("Please enter some information into %f.", this);
    		return false;
    	}
	var upperCase = value;
	if (oldNameEndingValue != upperCase)
	{
		var lowerCase = upperCase.toLowerCase();
		var message;
		var pattern = /((\s+)(pty(\.*)|proprietary|ltd(\.*)|limited|n(\.*)l(\.*)|no liability))/;
		
		// JC 06/10/03 Ref 961 pattern2
		var pattern2 = /((aboriginal corporation)|(aboriginal corpn(\.*))|(aboriginal council)|(council of aborigines)|(chamber of commerce)|(chamber of comm.)|(chamber of manufacturers)|(chartered)|(chartd(\.*))|(consumer)|(co((\s*)|-)operative)|(co(\.*)((\s+)|-)op(\.+|\s+|$))|(executor)|(exec'or)|(ex'or(\.*))|(exec'or.)|(g(\.*)s(\.*)t(\.*))|(goods (and|&) services tax)|(guarantee)|(warranty)|(g'ee(\.*))|(incorporated)|(incorp)|((^|\s)inc\.?($|\s))|(incorp'd(\.*))|((\s+|^)inc(\.*)(\s+|$))|(made in australia)|(made in aust(\.*))|(made in aussie(\.*))|(made in oz(\.*))|(australian made)|(aussie made)|(r(\.*)s(\.*)l(\.*))|(returned( & | and |(\s*))(services|services'|servicemen's|servicemens|servicemens') league)|(starr bowkett)|(stock exchange)|(stock ex(\.*))|(stock exge(\.*))|((torres|torr.) straight islander (corpn(\.*)|corporation))|(trust(e*))|(t'ee(\.*)))/;
		// JC 05/02/2008 ref 3559 fixed prob with co open incorrectly detecting co op
		// OLD CO OP (REPLACED ABOVE) --> (co(\.*)((\s+)|-)op(\.*))
		//var pattern2 = /(\s+|^)((aboriginal corporation)|(aboriginal corpn(\.*))|(aboriginal council)|(council of aborigines)|(chamber of commerce)|(chamber of comm.)|(chamber of manufacturers)|(chartered)|(chartd(\.*))|(consumer)|(co((\s*)|-)operative)|(co(\.*)((\s*)|-)op(\.*))|(executor)|(exec'or)|(ex'or(\.*))|(exec'or.)|(g(\.*)s(\.*)t(\.*))|(goods (and|&) services tax)|(guarantee)|(g'ee(\.*))|(incorporated)|(incorp'd(\.*))|(inc(\.*))|(made in australia)|(made in aust(\.*))|(made in aussie(\.*))|(made in oz(\.*))|(australian made)|(aussie made)|(r(\.*)s(\.*)l(\.*))|(returned( & | and |(\s*))(services|services'|servicemen's|servicemens|servicemens') league)|(starr bowkett)|(stock exchange)|(stock ex(\.*))|(stock exge(\.*))|((torres|torr.) straight islander (corpn(\.*)|corporation))|(trust(e*))|(t'ee(\.*)))($|\s+)/;

		// JC 06/10/03 Ref 962 pattern3
		var pattern3 = /((anzac)|(geneva cross)|(geneva x)|(gen. cross)|(red (crescent|cres.|cross|x))|(red lion (and|&) (sun|son))|(united nations)|((^u|(\s+)u)(\.*)(n(\.*)$|n(\s+)(\.*)))|(university)|(((^u)|((\s+)u))ni(\.+)))/;
		
		// JC 07/10/03 Ref 964 pattern4
		var pattern4 = /((friendly society)|(friendly (soc|soc'y)(\.*)))/;
		
		// JC 07/10/03 Ref 965 pattern5
		var pattern5 = /(((^a|((\s+)a))(\.*)d(\.*)(i$|(i(\.*)$)|(i(\.*)(\s+))))|(authorised deposit(-|(\s*))taking institution)|(bank)|(banker)|(banking)|(bank'g(\.*))|(building society)|(bld('*)g(\.*) soc('*)y(\.*))|(credit society)|(cr(\.*) society)|(credit socy(\.*))|(cr(\.*) soc'y(\.*))|((credit|(cr(\.*))) union))/;

		// JC 22/06/04 Ref 1203 pattern6
		var pattern6 = /(\s+|^)((hrh)|(h(\.*)r(\.*)h(\.*))|(his majesty)|(her majesty)|(qe2)|(q(\.*)e(\.*)2)|(qeii)|(q(\.*)e(\.*)ii)|(king)|(queen)|(prince)|(princess)|(royal)|(regal)|(by appointment)|(palace)|(q(\.*)e(\.*) 2)|(q(\.*)e(\.*) ii))($|\s+)/;
		
		// JC 22/06/04 Ref 1204 pattern7
		var pattern7 = /(\s+|^)((ex-servicemen)|(ex servicemen)|(ex-servicemen's)|(ex servicemen's)|(ex-service)|(ex service)|(ex-services)|(ex services)|(ex army)|(ex navy)|(ex airforce)|(ex-army)|(ex-navy)|(ex-airforce)|(returned servicemen)|(veteran)|(digger)|(diggers)|(digger's)|(diggers'))($|\s+)/;

		// JC 22/06/04 Ref 1205 pattern8
		var pattern8 = /(\s+|^)((bradman)|(sir donald)|(the don)|('the don')|("the don")|(the don's))($|\s+)/;

		// JC 24/06/04 Ref 1209 pattern9
		var pattern9 = /(\s+|-|^)((abo)|(abos)|(arsehole)|(arse-hole)|(arseholes)|(arse-holes)|(arsejockey)|(arse-jockey)|(arsejockeys)|(arse-jockeys)|(arsejockies)|(arse-jockies)|(arssholes)|(asshole)|(ass-hole)|(ass-holes)|(assjockey)|(ass-jockey)|(assjockeys)|(ass-jockeys)|(assjockies)|(ass-jockies)|(black bastard)|(black bastards)|(black-bastard)|(black-bastards)|(blackcunt)|(black-cunts)|(bum bandit)|(bum bandits)|(bum-bandit)|(bum-bandits)|(bumjump)|(bum-jump)|(bumjumper)|(bum-jumper)|(bumjumpers)|(bum-jumpers)|(bumjumps)|(bum-jumps)|(chogi)|(chogie)|(cock)|(cockhead)|(cock-head)|(cockheads)|(cock-heads)|(cocklicker)|(cock-licker)|(cocklickers)|(cock-lickers)|(cocks)|(cocksucker)|(cock-sucker)|(cocksuckers)|(cock-suckers)|(cum)|(cumdrinker)|(cum-drinker)|(cumdrinkers)|(cum-drinkers)|(cums)|(cunt)|(cunthead)|(cunt-head)|(cuntheads)|(cunt-heads)|(cuntman)|(cunt-man)|(cuntmen)|(cunt-men)|(cuntox)|(cunt-ox)|(cuntoxes)|(cunt-oxes)|(cuntoxs)|(cunt-oxs)|(cunts)|(cuntstruck)|(cunt-struck)|(dago)|(dagos)|(datepacker)|(date-packer)|(datepackers)|(date-packers)|(fagdaddies)|(fag-daddies)|(fagdaddy)|(fag-daddy)|(fagdaddys)|(fag-daddys)|(faggot)|(faggots)|(fuck)|(fuckyou)|(fuckyous)|(fuckyouse)|(fuckyouses)|(fucku)|(fuckus)|(fuckus)|(fucked)|(fucked)|(fucked-off)|(fucker)|(fuckers)|(fuckhole)|(fuck-hole)|(fuckholes)|(fuck-holes)|(fucking)|(fuckme)|(fuck-me)|(fuckmedead)|(fuck-me-dead)|(fuckoff)|(fuck-off)|(fucks)|(fuckwit)|(fudge packer)|(fudge-packer)|(fudgepackers)|(fudge-packers)|(gism)|(gizm)|(gook)|(gooks)|(hymie)|(jack off)|(jack offs)|(jack-off)|(jack-offs)|(jerkoff)|(jerk-off)|(jerkoffs)|(jerk-offs)|(jew boy)|(jew boys)|(jew-boy)|(jew-boys)|(jism)|(jizm)|(kike)|(motherfucker)|(mother-fucker)|(motherfuckers)|(mother-fuckers)|(muff diver)|(muff divers)|(muff-diver)|(muff-divers)|(nigger)|(niggers)|(piss)|(pisser)|(pissers)|(pisses)|(pissflap)|(piss-flap)|(pissflaps)|(piss-flaps)|(poofta)|(poofter)|(poofters)|(pussie plunger)|(pussie plungers)|(pussie poker)|(pussie pokers)|(pussie-plunger)|(pussie-plungers)|(pussie-poker)|(pussie-pokers)|(pussy plunger)|(pussy plungers)|(pussy poker)|(pussy pokers)|(pussy-plunger)|(pussy-plungers)|(pussy-poker)|(pussy-pokers)|(ringrenderer)|(ring-renderer)|(ringrenderers)|(ring-renderers)|(ringsticker)|(ring-sticker)|(ringstickers)|(ring-stickers)|(rodgering)|(shit)|(shits)|(shitter)|(shitters)|(slit eye)|(slit eyes)|(slit-eye)|(slit-eyes)|(spic)|(spics)|(tits)|(twat)|(twats)|(wank)|(wanker)|(wankers)|(wanks)|(wop)|(wops))($|-|\s+)/;

		// JC 24/06/04 Ref 1212 pattern10
		var pattern10a = /((commonwealth government)|(federal government))/;
		var pattern10 = /(\s+|^)((commonwealth)|(federal))($|\s+)/;

		// JC 24/06/04 Ref 1213 pattern11
		var pattern11 = /(\s+|^)((crown)|(government)|(police)|(municipal)|(authority)|(city council)|(town council)|(local council)|(council of)|(department)|(instrumentality)|(state)|(territory)|(territories)|(auth)|(auth\.)|(auth'y)|(dept)|(dept(\.))|(govt(\.))|(govt)|(gov)|(gov(\.))|(terr'y)|(terr'y(\.)))($|\s+)/;

		// JC 24/06/04 Ref 1214 pattern12
		var pattern12 = /(\s+|^)((incapacitated)|(incapacities)|(incapacity)|(amputee)|(amputees)|(amputee's)|(amputees')|(alzheimer)|(alzheimer's)|(alzheimers)|(alzheimers')|(autistic)|(autistic's)|(autistics)|(autistics')|(autism)|(blind)|(deaf)|(demented)|(dementia)|(diabetic)|(diabetics)|(diabetic's)|(diabetics')|(disabled)|(down syndrome)|(down's syndrome)|(downs syndrome)|(downs' syndrome)|(dumb)|(moron)|(morons)|(moron's)|(morons')|(spastic)|(spastics)|(spastic's)|(spastics')|(subnormal)|(sub-normal)|(subnormals)|(sub-normals)|(subnormal's)|(sub-normals')|(wheelie)|(wheelies)|(wheelie's)|(wheelies'))($|\s+)/;

    // JC 05/02/2008 Ref 3545 New detection for invalid characters.
    var pattern13 = /[^\w\*\@\$\=\#\%\.\,\-\(\)\{\}\!\?\:\;\'\"\_\/\|\\\&\s]/;
		if (lowerCase.search(pattern13) >= 0) // && !nameIsValid)
		{
			message = "The proposed company name contains at least one (unusual) character or symbol not allowed to be used in company names. Please change or adjust the proposed company name accordingly. (You can read more about ASIC's policy on this via the optional pop-up guidance entitled \"Use of symbols in company names\" available via the underlying page.)";
    	validateAlert(message, this);
      this.select();
      this.focus();
      nameIsValid = false;
      return false;
    }

    // JC 05/03/2008 Ref 3582 ECR integration ensure at least one valid character.
    var pattern14 = /(\w)/;
		if (lowerCase.search(pattern14) < 0) // && !nameIsValid)
		{
			message = "The proposed company name does not contain at least one alphabetic (a/A to z/Z) or numeric (0 to 9) character. ASIC requires that unless the company is to be an ACN named company, the proposed company name must contain at least one alphabetic or numeric character. Please change or adjust the proposed company name accordingly (or use the 'Back' button and specify that the company will simply be identified by its ACN).";
   	validateAlert(message, this);
      this.select();
      this.focus();
      nameIsValid = false;
      return false;
    }
    
		if (lowerCase.search(pattern) >= 0) // && !nameIsValid)
		{
			message = "Incorporator detects that you may have accidentally and incorrectly inserted the 'name ending' of the company (e.g. 'Pty Ltd', 'Limited' etc.) in this field box, even though the 'name ending' already appears on the right hand side of the field box (and with the result that the company's 'name ending' is, incorrectly, appearing twice). If so, please delete the 'name ending' from your entry in the field box. Otherwise please proceed as normal (and please note that you will NOT be given this warning message a second time on your current visit to this page and in respect of the exact same error).";
		}
		// JC 06/10/03 Ref 961
		else if (lowerCase.search(pattern2) >= 0)
		{
		    message = "Incorporator detects that the proposed company name includes at least one of the following 'unacceptable' words or phrases (or a word or phrase or an abbreviation having the same or similar meaning): Aboriginal Corporation, Aboriginal Council, Chamber of Commerce, Chamber of Manufacturers, Chartered, Consumer, Co-operative, Executor, GST, G.S.T., Guarantee (similar word: Warranty), Incorporated, Inc, Inc., Incorp, Made in Australia, R.S.L., RSL, Starr Bowkett, Stock Exchange, Torres Straight Islander Corporation, Trust, Trustee. (All of these words and phrases - and words or phrases or abbreviations having the same or similar meaning - are specified to be unacceptable for use in the names of companies incorporated under the Corporations Act 2001 - per section 147(1)(c) of the Corporations Act 2001, read in conjunction with regulation 2B6.01(2), and Part 2 rule 6203(b) and Part 3 of Schedule 6, of the Corporations Regulations 2001.). However, they may be used if specific ministerial consent to their use in a particular instance has been given - per section 147(2)(b) of the Corporations Act 2001. So unless you have, or intend to get, ministerial consent to the use of this proposed company name, please choose another name for the proposed company. And please note that you will NOT be given this warning message a second time on your current visit to this page and in respect of the exact same proposed company name.";
		}
		// JC 06/10/03 Ref 962
		else if (lowerCase.search(pattern3) >= 0)
		{
			message = "Incorporator detects that the proposed company name includes (or is similar to) at least one of the following words or phrases (either on their own or as part of other words or phrases): Anzac, Geneva Cross, Red Crescent, Red Cross, Red Lion and Sun, United Nations, University. These words or phrases may only be so used with appropriate ministerial consent - per section 147 of the Corporations Act 2001, read in conjunction with regulation 2B6.02, and Part 4 of Schedule 6, of the Corporations Regulations 2001. So unless you have, or intend to get, the appropriate ministerial consent, please choose another company name. And please note that you will NOT be given this warning message a second time on your current visit to this page and in respect of the exact same proposed company name.";
		}
		// JC 07/10/03 Ref 964
		else if (lowerCase.search(pattern4) >= 0)
		{
			message = "Incorporator detects that the proposed company name includes the words 'Friendly Society' (or something similar). If it is proposed to use these words in relation to the conduct of a financial business, the consent of APRA (the Australian Prudential Regulation Authority) is required (per section 147 of the Corporations Act 2001, read in conjunction with regulation 2B.6.02, and Part 5 of Schedule 6, of the Corporations Regulations 2001). If, however, it is proposed to use these words other than in relation to the conduct of a financial business, then ministerial consent is required (per section 147 of the Corporations Act 2001, read in conjunction with regulation 2B.6.01(2), and Part 2 and Part 3 of Schedule 6, of the Corporations Regulations 2001). So unless you have, or intend to get, the appropriate consent, please choose another company name. And please note that you will NOT be given this warning message a second time on your current visit to this page and in respect of the exact same proposed company name.";
		}
		// JC 07/10/03 Ref 965 pattern5
		else if (lowerCase.search(pattern5) >= 0)
		{
			message = "Incorporator detects that the proposed company name includes (or is similar to) at least one of the following words or phrases (either on their own or as part of other words or phrases): ADI, authorised deposit-taking institution, bank, banker, banking, building society, credit society, credit union. Such words or phrases (either on their own or - excepting 'ADI' - as part of other words or phrases) may only be used with the consent of APRA (the Australian Prudential Regulation Authority) - per section 147 of the Corporations Act 2001, read in conjunction with regulation 2B.6.02, and Part 5 of Schedule 6, of the Corporations Regulations 2001. So unless you have, or intend to get, APRA's consent, please choose another company name. And please note that you will NOT be given this warning message a second time on your current visit to this page and in respect of the exact same proposed company name.";
		}
		// 1203
		else if (lowerCase.search(pattern6) >= 0)
		{
			message = "Incorporator detects that the proposed company name may suggest a connection with the Royal Family or the receipt of Royal patronage. If the proposed company name does in fact suggest a connection with the Royal Family or the receipt of Royal patronage, and if such a connection or receipt of patronage does not exist, then the proposed company name will be unacceptable for registration - per section 147(1)(c) of the Corporations Act 2001, read in conjunction with regulation 2B6.01(2), and Part 2 rule 6203(e)(i) & (ii) of Schedule 6, of the Corporations Regulations 2001. So unless you are confident that the proposed company name does not in fact suggest such a connection or does not in fact suggest such a receipt of patronage, or that if it does, such a connection or receipt of patronage does in fact exist, please choose another name for the proposed company. And please note that you will NOT be given this warning message a second time on your current visit to this page and in respect of the exact same proposed company name.";
		}
		// 1204
		else if (lowerCase.search(pattern7) >= 0)
		{
			message = "Incorporator detects that the proposed company name may suggest a connection with an ex-servicemen's organisation. If the proposed company name does in fact suggest a connection with an ex-servicemen's organisation, and if such a connection does not exist, then the proposed company name will be unacceptable for registration - per section 147(1)(c) of the Corporations Act 2001, read in conjunction with regulation 2B6.01(2), and Part 2 rule 6203(e)(iii) of Schedule 6, of the Corporations Regulations 2001. So unless you are confident that the proposed company name does not in fact suggest such a connection, or that if it does, such a connection does in fact exist, please choose another name for the proposed company. And please note that you will NOT be given this warning message a second time on your current visit to this page and in respect of the exact same proposed company name.";
		}
		// 1205
		else if (lowerCase.search(pattern8) >= 0)
		{
			message = "Incorporator detects that the proposed company name may suggest a connection with Sir Donald Bradman. If the proposed company name does in fact suggest a connection with Sir Donald Bradman, and if such a connection does not exist, then the proposed company name will be unacceptable for registration - per section 147(1)(c) of the Corporations Act 2001, read in conjunction with regulation 2B6.01(2), and Part 2 rule 6203(e)(iv) of Schedule 6, of the Corporations Regulations 2001. So unless you are confident that the proposed company name does not in fact suggest such a connection, or that if it does, such a connection does in fact exist, please choose another name for the proposed company. And please note that you will NOT be given this warning message a second time on your current visit to this page and in respect of the exact same proposed company name.";
		}
		// 1209
		else if (lowerCase.search(pattern9) >= 0)
		{
		    message = "Incorporator detects that the proposed company name contains a word which, in its opinion, is undesirable or is likely to be offensive to the public or to any section of the public. Incorporator has accordingly formed the opinion that ASIC is likewise likely to be of the opinion that the proposed company name will be undesirable or likely to be offensive to the public or to any section of the public and hence that the proposed company name will be unacceptable for registration - per section 147(1)(c) of the Corporations Act 2001, read in conjunction with regulation 2B6.01(2), and Part 2 rule 6203(a) of Schedule 6, of the Corporations Regulations 2001. Incorporator will, therefore, not let you proceed with this proposed company name. However, if you think that Incorporator is mistaken about any of this, please phone Incorporator on " + INCORPORATOR_TELEPHONE_TEXT + ".";
			validateAlert(message, this);
			return false;
		}
		// 1212
		else if ( (lowerCase.search(pattern10) >= 0) && (lowerCase.search(pattern10a) < 0 ) )
		{
			message = "Incorporator detects that the proposed company name includes either the word 'Commonwealth' or 'Federal' (or both). Accordingly, unless ASIC is satisfied that the word is used in a geographical context, the proposed company name will be unacceptable for registration - per section 147(1)(c) of the Corporations Act 2001, read in conjunction with regulation 2B6.01(2), and Part 2 rules 6203(c) and 6205 of Schedule 6, of the Corporations Regulations 2001. So unless you are confident that the word is used in a geographical context, please choose another name for the proposed company. And please note that you will NOT be given this warning message a second time on your current visit to this page and in respect of the exact same proposed company name.";
		}
		// 1213
		else if (lowerCase.search(pattern11) >= 0)
		{
			message = "Incorporator detects that the proposed company name includes at least one of the following words or phrases (or an abbreviation of them) - Crown, Government, Municipal, Authority, City Council, Town Council, Local Council, Council of, Department, Instrumentality, Police, State, Territory, Territories. Accordingly, Incorporator has concluded that the proposed company name may (but, admittedly, may not) suggest a connection with the Crown, the Commonwealth Government, the Government of a State or Territory, a municipal or other local authority, the Government of any other part of the Queen's dominions, possessions or territories, a department, authority or instrumentality of the Commonwealth Government or of a State or Territory, or the Government of a foreign country. If the proposed company name does in fact, in the context in which it is proposed to be used, suggest such a connection, and if such a connection does not in fact exist, the proposed company name will be unacceptable for registration - per section 147(1)(c) of the Corporations Act 2001, read in conjunction with regulation 2B6.01(2), and Part 2 rule 6203(d) of Schedule 6, of the Corporations Regulations 2001. So unless you are confident that, in the context in which it is proposed to be used, the proposed company name does not suggest such a connection, or that if it does, such a connection exists, please choose another name for the proposed company. And please note that you will NOT be given this warning message a second time on your current visit to this page and in respect of the exact same proposed company name.";
		}
		// 1214
		else if (lowerCase.search(pattern12) >= 0)
		{
			message = "Incorporator detects that the proposed company name may (but, admittedly, may not) suggest some kind of total or partial personal incapacitation. If the proposed company name does in fact suggest such an incapacitation, and if, in the context in which it is proposed to be used, the proposed company name suggests that such an incapacitation affects the members of an organisation, and if those members are not so affected, the proposed company name will be unacceptable for registration - per section 147(1)(c) of the Corporations Act 2001, read in conjunction with regulation 2B6.01(2), and Part 2 rule 6203(f) of Schedule 6, of the Corporations Regulations 2001. So unless you are confident that, in the context in which it is proposed to be used, the proposed company name does not suggest such an incapacitation, or that if it does, it does not suggest that such an incapacitation affects the members of an organisation, or that if it does such members are in fact so affected, please choose another name for the proposed company. And please note that you will NOT be given this warning message a second time on your current visit to this page and in respect of the exact same proposed company name.";
		}
		else
		{
			return true;
		}
		validateAlert(message, this);
		this.select();
		this.focus();
		nameIsValid = true;
		oldNameEndingValue = upperCase;
		return false;
	}
	else
	{
		return true;
	}
}

// JC 14/08/2003 ref 892 New validation for missing ACN (etc) after Ltd (etc)
var titleIsValid = false;
var oldValue892_2 = "";
function validateTitlePage08_38_0 () {
	var value = this.value.replace(/^\s*(.*)\s*$/, '$1');
	var upperCase = value;
	var lowerCase = upperCase.toLowerCase();
	var message;
	if (oldValue892_2!= upperCase || !titleIsValid) 
	{
		// JC 28/08/2003 ref 925 Added "p./l." check to pattern and checkPatter variables.
		var pattern = /((p(\.*)(\/*)l(\.*))|pty(\.*)|proprietary|ltd(\.*)|limited|nl|n.l.|no liability)(\s*)(a(\.*)c(\.*)n(\.*)|australian company number|a(\.*)b(\.*)n(\.*)|australian business number|arbn|a.r.b.n.|australian registered body number)/;
		var secondPattern = /(pty(\.*)|proprietary)(\s*)(ltd(\.*)|limited)(\s*)(a(\.*)c(\.*)n(\.*)|australian company number|a(\.*)b(\.*)n(\.*)|australian business number|a(\.*)r(\.*)b(\.*)n(\.*)|australian registered body number)/;
		var checkPattern = /(\s+)+(pty|ltd|limited|no liability|proprietary|n(\.*)l(\.*)|p(\.*)l(\.*))$|^(pty|ltd|limited|no liability|proprietary|n(\.*)l(\.*)|p(\.*)l(\.*))+(\s+)|(\s+)(pty|ltd|limited|no liability|proprietary|n(\.*)l(\.*)|p(\.*)l(\.*))+(\s+)/;
		if (lowerCase.search(checkPattern) >= 0)
		{
			if ((lowerCase.search(pattern) >= 0) || (lowerCase.search(secondPattern) >= 0)) 
			{
				//return true;
			}
			else
			{
				message = "Incorporator detects that you may have specified a company name in this field without also specifying its ACN (Australian Company Number) or ABN (Australian Business Number) etc. (as is required). If so, and if the company is an Australian company, please specify its ACN or ABN etc. (e.g. 'Smiths Pty Ltd ACN 332 684 776' or 'Jones Limited ABN 92 558 945 675'). If so, and the company is a foreign company registered as such in Australia, please specify its ARBN (Australian Registered Body Number) (e.g. 'Smiths Pty Ltd ARBN 332 684 776'). If so, and the company is a foreign company not registered as such in Australia, Incorporator suggests that you specify its country of incorporation [e.g. 'Westminster Finance Limited (inc. in England)']. Otherwise please proceed as normal (and please note that you will not be given this warning message a second time on your current visit to this page and in respect of the exact same error).";
				validateAlert(message, this);
				this.select();
				this.focus();
				titleIsValid = true;
				oldValue892_2 = upperCase;
				return false;
			}
		}
	}
	if (!this.mandatory && value == "") {
    		return true;
    	}
  	if (!value || value == "") {
    		this.focus();
    		this.select();
     		if (this.comment) {
   			validateAlert("Please enter some information"+ comment + " %f.", this);
    		}
    		else 
    		{
     			validateAlert("Please enter some information into %f.", this);
	    	}
    		return false;
  	}
	
	//JC 17/10/03 Ref 973 This one is for 08/38_0
	if (oldValue892_2 != upperCase)
	{
		var businessPattern = /((\s*)(pty(\.*)|proprietary|ltd(\.*)|limited|n(\.*)l(\.*)|no liability)|(p(\.*)(\/*)l(\.*))|(a(\.*)c(\.*)n)|(a(\.*)b(\.*)n)|(a(\.*)r(\.*)b(\.*)n)|(australian (business|company|registered body) number))/;
		// 08/07/04 Ref 1215 Trustee pattern
		var trustPattern = /(\s+|^)((trust)|(trusts))($|\s+)/;
		var trustCheckPattern = /(\s+|^)((trust company)|(trust co(\.?))|(trust coy(\.?)))($|\s+)/;
		if (lowerCase.search(trustPattern) >= 0 && lowerCase.search(trustCheckPattern) < 0)
		{
			var trusteePattern = /(\s+|^)((trustee)|(trustees)|(t'ee)|(t'ees)|(atf)|(a(\.)t(\.)f(\.))|(behalf)|(for)|(executor)|(executors))($|\s+)/;
			if (lowerCase.search(trusteePattern) < 0)
			{
			message = "Incorporator detects that you may have specified a trust as a member/shareholder without also specifying the trustee (or trustees) of the trust. Where a trust will be a member/shareholder of the proposed company, ASIC requires that the name of the trustee(s) be specified (either with or without mention of the trust). So for example, either of these two entries would be acceptable - 'John Peter Smith as trustee for The Smith Family Trust' or simply 'John Peter Smith'. But this entry would not be acceptable - 'The Smith Family Trust' (because it does not specify the trustee of the trust). Also, instead of using the term 'as trustee for' you may instead use an abbreviation such as 'A.T.F.' or 'ATF' - for example 'John Peter Smith ATF The Smith Family Trust' . So, if necessary, would you please adjust your entry. And please note that you will not be given this warning message a second time on your current visit to this page and in respect of the exact same entry.";
			validateAlert(message, this);
			this.select();
			this.focus();
			oldValue892_2 = upperCase;
			return false;
		}
		}
		
		else if (lowerCase.search(businessPattern) < 0)
		{
			var pattern = /(((\s+)[a-z]{1}(\.*)(\s+))|(^[a-z]{1}(\.*)$)|(^[a-z]{1}\.*\s+)|(\s+[a-z]{1}(\.*)$))/
			if (lowerCase.search(pattern) >= 0)
			{
				message = "Incorporator detects that you may have used one or more initials/abbreviations in a persons name. Please note that initials/abbreviations should not be used; persons full names should always be specified. If so, please enter the full name(s). Otherwise please proceed as normal (and please note that you will not be given this warning message a second time on your current visit to this page and in respect of the exact same entry). (Also, Incorporator acknowledges that sometimes, some persons names comprise no more than a single letter. If that is the case here, then please proceed as normal ... but please be aware that you may independently have to confirm that fact specifically with ASIC in order to get the company registered.)";
			}
			else
			{
				return true;
			}
			validateAlert(message, this);
			this.select();
			this.focus();
			oldValue892_2 = upperCase;
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		return true;
	}
	return true;	
}

// JC 14/08/2003 ref 892 New validation for missing ACN (etc) after Ltd (etc)
var titleIsValid = false;
var oldValue892 = "";
function validateTitle() {
	var value = this.value.replace(/^\s*(.*)\s*$/, '$1');
	var upperCase = value;
	var lowerCase = upperCase.toLowerCase();
	var message;
	if (oldValue892!= upperCase || !titleIsValid) 
	{
		// JC 28/08/2003 ref 925 Added "p./l." check to pattern and checkPatter variables.
		var pattern = /((p(\.*)(\/*)l(\.*))|pty(\.*)|proprietary|ltd(\.*)|limited|nl|n.l.|no liability)(\s*)(a(\.*)c(\.*)n(\.*)|australian company number|a(\.*)b(\.*)n(\.*)|australian business number|arbn|a.r.b.n.|australian registered body number)/;
		var secondPattern = /(pty(\.*)|proprietary)(\s*)(ltd(\.*)|limited)(\s*)(a(\.*)c(\.*)n(\.*)|australian company number|a(\.*)b(\.*)n(\.*)|australian business number|a(\.*)r(\.*)b(\.*)n(\.*)|australian registered body number)/;
		var checkPattern = /(\s+)+(pty|ltd|limited|no liability|proprietary|n(\.*)l(\.*)|p(\.*)l(\.*))$|^(pty|ltd|limited|no liability|proprietary|n(\.*)l(\.*)|p(\.*)l(\.*))+(\s+)|(\s+)(pty|ltd|limited|no liability|proprietary|n(\.*)l(\.*)|p(\.*)l(\.*))+(\s+)/;
		if (lowerCase.search(checkPattern) >= 0)
		{
			if ((lowerCase.search(pattern) >= 0) || (lowerCase.search(secondPattern) >= 0)) 
			{
				return true;
			}
			else
			{
				message = "Incorporator detects that you may have specified a company name in this field without also specifying its ACN (Australian Company Number) or ABN (Australian Business Number) etc. (as is required). If so, and if the company is an Australian company, please specify its ACN or ABN etc. (e.g. 'Smiths Pty Ltd ACN 332 684 776' or 'Jones Limited ABN 92 558 945 675'). If so, and the company is a foreign company registered as such in Australia, please specify its ARBN (Australian Registered Body Number) (e.g. 'Smiths Pty Ltd ARBN 332 684 776'). If so, and the company is a foreign company not registered as such in Australia, Incorporator suggests that you specify its country of incorporation [e.g. 'Westminster Finance Limited (inc. in England)']. Otherwise please proceed as normal (and please note that you will not be given this warning message a second time on your current visit to this page and in respect of the exact same error).";
				validateAlert(message, this);
				this.select();
				this.focus();
				titleIsValid = true;
				oldValue892 = upperCase;
				return false;
			}
		}
	}
	if (!this.mandatory && value == "") {
    		return true;
    	}
  	if (!value || value == "") {
    		this.focus();
    		this.select();
     		if (this.comment) {
   			validateAlert("Please enter some information"+ comment + " %f.", this);
    		}
    		else 
    		{
     			validateAlert("Please enter some information into %f.", this);
	    	}
    		return false;
  	}
	return true;
}

// JC 14/08/2003 ref 891 Added variable so only complains once per page visit for detecting $value = num shares.
var validateShares = false;
var oldNum = 0;
var oldTotal = 0;
var oldAmount = 0;
function validateIntegerShares() {
  if (!this.mandatory && this.value =="")
    return true;

  var pattern = /^(([0-9]+)|([1-9][0-9]{0,2}(,[0-9]{3})+))$/;

  if ((!this.value || this.value == "") || this.value.search(pattern) < 0) {
    this.select();
    this.focus();

    var message;
    if (isNaN(parseInt(this.value.replace(/,/g, ''), 10))) {
      message = "Please enter a number (in digits, not words) into %f.";
    } else {
      message = "Please enter a non-decimal positive number in digits (not words) without anything else into %f.";
    }
    validateAlert(message, this);
    return false;
  }

  var num = this.value
  num = parseInt(removeCommas(num));
  var minValue = Number.MIN_VALUE;
  var maxValue = Number.MAX_VALUE;

  if (!isNaN(this.minValue))
    minValue = Math.max(this.minValue, minValue);
  if (!isNaN(this.maxValue))
    maxValue = Math.min(this.maxValue, maxValue);

  if (num < minValue) {
    this.select();
    this.focus();
    validateAlert("Please enter a number (in digits, not words) greater than or equal to " + minValue + " in %f. (This is an arbitrary minimum imposed by Incorporator.)", this);
    return false;
  } else if (num > this.maxValue) {
    this.select();
    this.focus();
    validateAlert("Please enter a number less than or equal to " + maxValue + " into %f. (This is an arbitrary maximum imposed by Incorporator.)", this);
    return false;
  }
  
  return true;
}

function removeCommas (value)
{
	while (value.indexOf(",") > 0)
  	{
  		value = value.replace(",", "");
  	}
  	return value;
}

// JC 17/08/2004 ref 1254
function largeAmount()
{
	var amountPerShare = "" + document.page.shares_amount_per_share.value;
	var num = "" + document.page.shares_number.value;
	num = removeCommas(num);
  	amountPerShare = removeCommas(amountPerShare);
	var totalAmount = parseFloat(amountPerShare) * parseInt(num);
	// JC 21/09/04 Ref 1347
	// JC 05/03/08 Ref 3583 For ECR integration, changed from 922 trillion to 80 billion
	if (totalAmount > 80000000000)
	{
		alert("Sorry, but the proposed total amount agreed to be paid by this shareholder (proposed number of shares x proposed amount agreed to be paid per share) is too large for this system (this system will accept a proposed total amount agreed to be paid by each shareholder of only up to $80 billion). Accordingly, would you please reduce either (or both of) the proposed number of shares and/or the proposed amount agreed to be paid per share.");
		return false;
		
	}
	if (totalAmount > 10000 && (oldTotal != totalAmount || oldAmount != amountPerShare))
	{
		var totalAmountEdit = "" + totalAmount;
		
		// For total without a decimal point
		if (totalAmountEdit.indexOf(".") < 0)
		{	
			totalAmountEdit = formatWithComma(totalAmountEdit);
			
			// Add decimal point if none there
			totalAmountEdit = totalAmountEdit + ".00";
		}
		else
		{
			var splitTotal = totalAmountEdit.split(".");
			if (splitTotal[1].length == 1)
			{	// For one decimal point, make to 2 decimal points
				splitTotal[1] = splitTotal[1] + "0";
			}
			if (splitTotal[1].length > 2)
			{	// For recurring number, strip to 2 decimal points
				splitTotal[1] = splitTotal[1].charAt(0) + splitTotal[1].charAt(1);
			}
			
			splitTotal[0] = formatWithComma(splitTotal[0]);
			totalAmountEdit = splitTotal[0] + "." + splitTotal[1]
		}
		
		num = formatWithComma (num);
		
		if (amountPerShare.indexOf(".") < 0)
		{
			amountPerShare = formatWithComma(amountPerShare);
			amountPerShare = amountPerShare + ".00";
		}
		else
		{
			var splitAmount = amountPerShare.split(".");
			splitAmount[0] = formatWithComma(splitAmount[0]);
			amountPerShare = splitAmount[0] + "." + splitAmount[1];
		}
		
		var validateMessage = "Incorporator detects that the total amount of money which this shareholder agrees to pay for the shares (and therefore the total amount of money which this shareholder will be LEGALLY BOUND to pay for the shares) is somewhat large, namely $"+totalAmountEdit;
		validateMessage = validateMessage + " (" + num + " shares x $" + amountPerShare + " per share). Incorporator, therefore guesses that maybe you do not in fact intend (or may now not in fact intend) that this shareholder be legally obliged to pay such a large amount of money. If so, please adjust your entries as necessary. Otherwise please proceed as normal (and please note that you will not be given this warning message a second time on this occasion and on your current visit to this page and in respect of the exact same entries).";
		alert(validateMessage);
		oldTotal = totalAmount;
		oldAmount = removeCommas(amountPerShare);
		return false;
	}
	return true;
}

// JC 17/08/2004 Ref 1254 Adding commas into number for presentation
function formatWithComma (Value)
{
	var commaNum = "";
	Value = "" + Value;
	if (Value.indexOf(",") < 0) 
	{
	for (var i=0; i<Value.length;i++)
	{
		if ( ((Value.length-i) % 3 == 0) && (i!=0) )
		{	// Format with comma
			commaNum = commaNum + ",";
		}
		commaNum = commaNum + Value.charAt(i);
	}
	Value = commaNum;
	return commaNum;
}
	return Value;
}

function validateInteger() {
  if (!this.mandatory && this.value =="")
    return true;

  var pattern = /^(([0-9]+)|([1-9][0-9]{0,2}(,[0-9]{3})+))$/;

  if ((!this.value || this.value == "") || this.value.search(pattern) < 0) {
    this.select();
    this.focus();

    var message;
    if (isNaN(parseInt(this.value.replace(/,/g, ''), 10))) {
      message = "Please enter a number (in digits, not words) into %f.";
    } else {
      message = "Please enter a non-decimal positive number in digits (not words) without anything else into %f.";
    }
    validateAlert(message, this);
    return false;
  }

  var num = parseInt(this.value, 10);
  var minValue = Number.MIN_VALUE;
  var maxValue = Number.MAX_VALUE;

  if (!isNaN(this.minValue))
    minValue = Math.max(this.minValue, minValue);
  if (!isNaN(this.maxValue))
    maxValue = Math.min(this.maxValue, maxValue);

  if (num < minValue) {
    this.select();
    this.focus();
    validateAlert("Please enter a number (in digits, not words) greater than or equal to " + minValue + " in %f. (This is an arbitrary minimum imposed by Incorporator.)", this);
    return false;
  } else if (num > this.maxValue) {
    this.select();
    this.focus();
    validateAlert("Please enter a number less than or equal to " + maxValue + " into %f. (This is an arbitrary maximum imposed by Incorporator.)", this);
    return false;
  }
  return true;
}


function validateNeilInteger() {
  if (!this.mandatory && this.value =="")
    return true;

  var pattern = /^(([0-9]+)|([1-9][0-9]{0,2}(,[0-9]{3})+))$/;

  if ((!this.value || this.value == "") || this.value.search(pattern) < 0) {
    this.select();
    this.focus();

    var message;
    if (isNaN(parseInt(this.value.replace(/,/g, ''), 10))) {
      message = "Please enter a number (in digits, not words) into %f.";
       validateAlert(message, this);
    } else {
      message = "If you choose to enter anything into this field it must be a non-decimal \'continuous number\' (i.e. without spaces - not even spaces before or after the number) in digits (not words).";
		alert(message) ;
    }
   
    return false;
  }

  var num = parseInt(this.value, 10);
  var minValue = 0;
  var maxValue = Number.MAX_VALUE;

  if (!isNaN(this.minValue))
    minValue = Math.max(this.minValue, minValue);
  if (!isNaN(this.maxValue))
    maxValue = Math.min(this.maxValue, maxValue);

  if (num < minValue) {
    this.select();
    this.focus();
    validateAlert("Please enter a number (in digits, not words) greater than or equal to " + minValue + " in %f. (This is an arbitrary minimum imposed by Incorporator.)", this);
    return false;
  } else if (num > this.maxValue) {
    this.select();
    this.focus();
    validateAlert("Please enter a number less than or equal to " + maxValue + " into %f. (This is an arbitrary maximum imposed by Incorporator.)", this);
    return false;
  }
  return true;
}


function validatePhoneNumber() {
  if (!this.mandatory && this.value =="")
    return true;

  var pattern = /^(([0-9]+)|([1-9][0-9]{0,2}(,[0-9]{3})+))$/;

  if ((!this.value || this.value == "") || this.value.search(pattern) < 0) {
    this.select();
    this.focus();

    var message;
    if (isNaN(parseInt(this.value.replace(/,/g, ''), 10))) {
      message = "If you choose to enter anything into this field it must be a non-decimal \'continuous number\' (i.e. without spaces - not even spaces before or after the number) in digits (not words).";
      alert(message) ;
    } else {
      message = "If you choose to enter anything into this field it must be a non-decimal \'continuous number\' (i.e. without spaces - not even spaces before or after the number) in digits (not words).";
      alert(message) ;
    }
   
    return false;
  }

  var num = parseInt(this.value, 10);
  var minValue = 1;
  var maxValue = Number.MAX_VALUE;

  if (!isNaN(this.minValue))
    minValue = Math.max(this.minValue, minValue);
  if (!isNaN(this.maxValue))
    maxValue = Math.min(this.maxValue, maxValue);

  if (num < minValue) {
    this.select();
    this.focus();

    message = "If you choose to enter anything into this field it must be a non-decimal \'continuous number\' (i.e. without spaces - not even spaces before or after the number) in digits (not words).";
    alert(message) ;

    return false;
  } else if (num > this.maxValue) {
    this.select();
    this.focus();

    message = "If you choose to enter anything into this field it must be a non-decimal \'continuous number\' (i.e. without spaces - not even spaces before or after the number) in digits (not words).";
    alert(message) ;

    return false;
  }
  return true;
}

function validatePhoneNumberWithSpaces() {
  if (!this.mandatory && this.value =="")
    return true;

  var pattern = /^[\d\s]+$/;

  if ((!this.value || this.value == "") || this.value.search(pattern) < 0) {
    this.select();
    this.focus();

    var message;
    if (isNaN(parseInt(this.value.replace(/,/g, ''), 10))) {
      message = "If you choose to enter anything into this field it must be a non-decimal number in digits (not words or other characters).";
      alert(message) ;
    } else {
      message = "If you choose to enter anything into this field it must be a non-decimal number in digits (not words or other characters).";
      alert(message) ;
    }
   
    return false;
  }

  return true;
}

function validatePIN() {
  if (!this.mandatory && this.value == "")
    return true;

  //var pattern = /^(([0-9]+)|([1-9][0-9]{0,2}(,[0-9]{3})+))$/; // SPEEDWELL weirdness - to validate a 4 digit field! hahahahahaha
  var pattern  = /(^\d{4}$)/;

  if ((!this.value || this.value == "") || this.value.search(pattern) < 0) {
    this.select();
    this.focus();
	
    var message;
	/*
    if (isNaN(parseInt(this.value.replace(/,/g, ''), 10))) {
      message = "Please enter a four digit number into %f.";
    } else {
      message = "Please enter a non-decimal number without anything else into %f.";
    }
	*/
	message = "Please enter a 4 digit number into the PIN field \n"+
		"(without any spaces, or things other than a digit, either before, between, or after each digit.)";
    validateAlert(message, this);
    return false;
  }

  var num = this.value;
  var minValue = Number.MIN_VALUE;
  var maxValue = Number.MAX_VALUE;
  
  if (!isNaN(this.minValue))
    minValue = Math.max(this.minValue, minValue);
  if (!isNaN(this.maxValue))
    maxValue = Math.min(this.maxValue, maxValue);
  
  if (num < minValue) {
    this.select();
    this.focus();
    validateAlert("Please enter a number greater than or equal to " + minValue + " into %f. (This is an arbitrary minimum imposed by Incorporator.)", this);
    return false;
  } else if (num > this.maxValue) {
    this.select();
    this.focus();
    validateAlert("Please enter a number less than or equal to " + maxValue + " into %f. (This is an arbitrary maximum imposed by Incorporator.)", this);
    return false;
  }
  return true;
}

function validateUnpaidCurrency() {
  if (!this.mandatory && this.value == "")
    return true;
  // /^(Nil|[+\-]?(([0-9]+)|([1-9][0-9]{0,2}(,[0-9]{3})+))([\.-]([0-9]){2}))$/i;

  var minValue = (!isNaN(this.minValue)) ? Math.max(this.minValue, MIN_CURRENCY) : MIN_CURRENCY;
  var maxValue = (!isNaN(this.maxValue)) ? Math.min(this.maxValue, MAX_CURRENCY) : MAX_CURRENCY;

  var value = this.value.replace(/(.)\-/g, '$1.');
  while (value.indexOf(",") > 0)
  {
  	value = value.replace(",", "");
  }
  value = parseInt(value);
  if (value < minValue) {
    this.select();
    this.focus();
    validateAlert("Please enter a number greater than or equal to " + MIN_CURR_STRING + " into %f.", this);
    return false;
  } else if (value > maxValue) {
    this.select();
    this.focus();
    validateAlert("Please enter a number less than or equal to " + MAX_CURR_STRING + " into %f. (This is an arbitrary maximum imposed by Incorporator.)", this);
    return false;
  }

  searchValue = this.value;
  if (searchValue.indexOf(",") > 0)
  {
  	if (searchValue.length < 11)
  	{
  		var pattern = /^(\d+)(,)(\d{3})(\.)(\d{2})$/;  
  	}
  	else if (searchValue.length > 11 && searchValue.length < 15)
  	{
  		var pattern = /^(\d+)(,)(\d{3})(,)(\d{3})(\.)(\d{2})$/;
  	}
  	else
  	{
  		var pattern = /^(\d+)(,)(\d{3})(,)(\d{3})(,)(\d{3})(\.)(\d{2})$/;
  	}
  }
  else
  {
	var pattern = /^(\d+)(\.)(\d{2})$/;
  }
  var found = searchValue.search(pattern);

  if (found < 0) {
    this.select();
    this.focus();
    validateAlert("Please enter a \'valid\' currency value (i.e. in digits, not words, showing dollars and cents separated by a decimal place and without typing in the dollar sign and greater than \'0.00\' e.g. \'0.50\') into %f.\n\n(By the way, for electronic company registrations, ASIC allows no more than two decimal places for monetary amounts.)", this);
    return false;
  }

  return true;
}

function validateCurrency() {
  if (!this.mandatory && this.value == "")
    return true;
  // /^(Nil|[+\-]?(([0-9]+)|([1-9][0-9]{0,2}(,[0-9]{3})+))([\.-]([0-9]){2}))$/i;

  var minValue = (!isNaN(this.minValue)) ? Math.max(this.minValue, MIN_CURRENCY) : MIN_CURRENCY;
  var maxValue = (!isNaN(this.maxValue)) ? Math.min(this.maxValue, MAX_CURRENCY) : MAX_CURRENCY;

  var value = this.value.replace(/(.)\-/g, '$1.');
  while (value.indexOf(",") > 0)
  {
  	value = value.replace(",", "");
  }

  value = parseInt(value);
  if (value < minValue) {
    this.select();
    this.focus();
    validateAlert("Please enter a number greater than or equal to " + MIN_CURR_STRING + " into %f.", this);
    return false;
  } else if (value > maxValue) {
    this.select();
    this.focus();
    validateAlert("Please enter a number less than or equal to " + MAX_CURR_STRING + " into %f. (This is an arbitrary maximum imposed by Incorporator.)", this);
    return false;
  }

  searchValue = this.value;
  if (searchValue.indexOf(",") > 0)
  {
  	if (searchValue.length < 11)
  	{
  		var pattern = /^(\d+)(,)(\d{3})(\.)(\d{2})$/;  
  	}
  	else if (searchValue.length > 11 && searchValue.length < 15)
  	{
  		var pattern = /^(\d+)(,)(\d{3})(,)(\d{3})(\.)(\d{2})$/;
  	}
  	else
  	{
  		var pattern = /^(\d+)(,)(\d{3})(,)(\d{3})(,)(\d{3})(\.)(\d{2})$/;
  	}
  }
  else
  {
	var pattern = /^(\d+)(\.)(\d{2})$/;
  }
  var found = searchValue.search(pattern);

  if (found < 0) {
    this.select();
    this.focus();
    validateAlert("Please enter a \'valid\' currency value (i.e. in digits, not words, showing dollars and cents separated by a decimal place and without typing in the dollar sign e.g. \'1.00\') into %f.\n\n(By the way, for electronic company registrations, ASIC allows no more than two decimal places for monetary amounts.)", this);
    //validateAlert("Please enter a valid currency value (i.e. in digits, not words, showing dollars and cents separated by a decimal place and without typing in the dollar sign and greater than \'0.00\' e.g. \'1.00\') into %f.", this);
    return false;
  }

  	// JC 13/10/04 Ref 1383 - If block around here for non-member pages
  	if(this.form.shares_number) 
  	{
  // JC 01/09/2004 Ref 1256 - moved this validation to occur later in validation process
  var sharesAmount = this.form.shares_number.value;
  var num = this.value;
  	num = parseInt(removeCommas(num));
	
	// JC 14/08/2003 ref 891
	if (oldNum != num || !validateShares) {
		sharesAmountNoComma = removeCommas(sharesAmount);
		var result = sharesAmountNoComma/parseInt(num);
		if (num != 1 && result == 1) {
			message = "Incorporator detects that you may have accidently inserted the total amount to be paid on all the shares instead of what is required, namely, the amount agreed to be paid PER EACH INDIVIDUAL SHARE. If so, please correct as necessary. Otherwise please proceed as normal (and please note that you will not be given this warning message a second time on your current visit to this page and in respect of the exact same error).";
		  	validateAlert(message, this);
		  	validateShares = true;
			oldNum = num;
	  		return false;
		}
	}
  
  return largeAmount();
	}
  
  return true;
}


//
// Changed function organising to allow for calling a check of email
//
// 20020827 - Email PDF Add On

function validateEmailAddress( emailFieldRef, boolUseAlerts )
{
    // return if blank and not mandatory
    if ((!emailFieldRef.value || emailFieldRef.value == "") && !emailFieldRef.mandatory)
        return true;

    emailStr = String( emailFieldRef.value );

    // checks if the e-mail address is valid
    var emailPat = /^(\".*\"|[A-Za-z0-9\_][A-Za-z0-9\.\-\_]*)@(\[\d{1,3}(\.\d{1,3}){3}]|([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,})$/;
    var matchArray = emailStr.match(emailPat);
  
    if (matchArray == null) {

      if ( boolUseAlerts )
      {
        // Display alert;
        emailFieldRef.select();
        emailFieldRef.focus();
        validateAlert("Please enter a validly formatted email address into %f.\n(Please check the '@' and '.' characters, and please make sure that there are not any spaces before or after the email address).", emailFieldRef );
      }
      return false;
    }

    // make sure the IP address domain is valid
    var IPArray = matchArray[2].match(/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/);
    if (IPArray != null) {
      for (var i=1; i<=4 ;i++) {
        if (IPArray[i]>255) {
          if( boolUseAlerts )
          {
	      emailFieldRef.select();
              emailFieldRef.focus();
              validateAlert("Please enter a valid destination IP address into %f.", emailFieldRef)
          }
          return false;
        }
      }
    }
    return true;
 
}

function validateEmail() {

    return validateEmailAddress( this, true );
    
}


// 20020827 - Email PDF Add On

function validateEmailWithConfirm()
{
    // Check email field and confirm field being equivalent
    // to confirmation field.
    
    // the email field made up of the field calling this validator
    // ie. this.name and another field called this.name+_confirm
    
    // eg. email_address
    //     email_address_confirm
    
    // If no confirm field return false and fatal error
    //var thisconfirm = ( this.confirmfieldname )? eval( confirmfieldname ) : false ;
    
    if( !this.confirm && !this.servercheck ) alert("Confirm field not found contact webmaster." );
    
    // Both fields are empty
    if( !( validateDataEmpty( this ) && validateDataEmpty( this.confirm ) ) )
    {
        var blankAlertText = (this.bothemptymessage) ? this.bothemptymessage : "Both of the \'"+ this.name +"\' fields are blank";
        alert( blankAlertText );
        return false;
    }

    // Email doesn't check out return false
    if( !( validateEmailAddress( this, true ) ) )
    {
        return false;
    } 

    // Email doesn't check out return false
    if( !( this.value == this.confirm.value ) )
    {
        var confirmFailText = ( this.confirmfailmessage ) ? this.confirmfailmessage : "Sorry, but the \'"+ this.text +"\' and the \'"+ this.confirm.text +"\' don\'t appear to match. Please re-check them both and adjust as necessary (be careful about spaces, either before, amongst, or after the email address, as these are taken into account when comparing the email addresses).";
        alert( confirmFailText );
        return false;
    } 
    
    return true;
}

function validateDataEmpty( fieldRef ) {
  var value = fieldRef.value.replace(/^\s*(.*)\s*$/, '$1');

  if (!fieldRef.mandatory && value == "")
    return true;

  if (!value || value == "") {

      // No data entered so false it is
      return false;

  }
  return true;
}


function validateDecimal() {

  if (!this.mandatory && this.value == "")
    return true;

  if (isNaN(this.value)) {
    this.select();
    this.focus();
    validateAlert("Please enter a number into %f.", this);
    return false;
  }
  else {
    var decimals = (this.decimals) ? this.decimals : 0;
    var regExp = '^[\-+]?[0-9]+' + ((decimals) ? '(\.[0-9]{1,' + decimals + '})?' : '') + '$'
    var matchArray = this.value.match(regExp);

    if (matchArray == null) {
      this.select();
      this.focus();
      validateAlert("Please enter a number with " + ((decimals) ? "up to " + decimals : "no") + " decimal places into %f.", this);
      return false;
    }

    var minValue = (isNaN(this.minValue)) ? Number.negativeInfinity : Number(this.minValue);
    var maxValue = (isNaN(this.maxValue)) ? Number.positiveInfinity : Number(this.maxValue);

    if (this.value < minValue) {
      this.select();
      this.focus();
      validateAlert("Please enter a number greater than or equal to " + minValue + " into %f. (This is an arbitrary minimum imposed by Incorporator.)", this);
      return false;
    } else if (this.value > maxValue) {
      this.select();
      this.focus();
      validateAlert("Please enter a number less than or equal to " + maxValue + " into %f. (This is an arbitrary maximum imposed by Incorporator.)", this);
      return false;
    }
  }
  return true;
}

function validateLength() {
  if (this.maxlength) {
    if (this.value) {
      if (this.value.length > this.maxlength) {
        this.select();
        this.focus();
        validateAlert("You cannot exceed "+this.maxlength+" characters in %f.", this);
        return false;
      }
    }
  }
  return true;
}

function validateChecked() {
  // Get the array for this checkbox/radio button group
  var checkboxes = this.form[this.name];

  if (checkboxes[0] && checkboxes[0].mandatory && !checkboxes[0].disabled) {
    for (var i = 0; i < checkboxes.length && !checkboxes[i].checked; i++);

    if (i >= checkboxes.length) {
      checkboxes[0].focus();

      //alert("Please tick the relevant name(s).");
      validateAlert("Please select an option in %f.", this);
      return false;
    }
  } else {
    if (checkboxes.mandatory && !checkboxes.checked && !checkboxes.disabled) {
      checkboxes.focus();

      alert("Please select the relevant option.");
      //validateAlert("Please select an option in %f.", this);
      return false;
    }
  }
  return true;
}

function validateChecked16cc() {
    // Get the array for this checkbox/radio button group
    var checkboxes = this.form[this.name];

    if (checkboxes[0] && checkboxes[0].mandatory && !checkboxes[0].disabled) {
        for (var i = 0; i < checkboxes.length && !checkboxes[i].checked; i++);

        if (i >= checkboxes.length) {
            checkboxes[0].focus();

            //validateAlert('Please select which set of information you want to access for your current run through Incorporator (by clicking in/on its corresponding "radio button" to the left).',this);
            alert('Please select which set of information you want to access for your current run through Incorporator (by clicking in/on its corresponding "radio button" to the left).');
            return false;
        }
    } else {
        if (checkboxes.mandatory && !checkboxes.checked && !checkboxes.disabled) {
            checkboxes.focus();

            alert('Please select which set of information you want to access for your current run through Incorporator (by clicking in/on its corresponding "radio button" to the left).');
            return false;
        }
    }
    return true;
}



function validate0220Checked() {
  // Get the array for this checkbox/radio button group
  var checkboxes = this.form[this.name];

  if (checkboxes[0] && checkboxes[0].mandatory && !checkboxes[0].disabled) {
    for (var i = 0; i < checkboxes.length && !checkboxes[i].checked; i++);

    if (i >= checkboxes.length) {
      checkboxes[0].focus();

      alert("Please select the relevant option.");
      //validateAlert("Please select an option in %f.", this);
      return false;
    }
  } else {
    if (checkboxes.mandatory && !checkboxes.checked && !checkboxes.disabled) {
      checkboxes.focus();

      alert("Please select the relevant option.");
      //validateAlert("Please select an option in %f.", this);
      return false;
    }
  }
  return true;
}

function validateCheckedSelect() {
  // Get the array for this checkbox/radio button group
  var checkboxes = this.form[this.name];

  if (checkboxes[0] && checkboxes[0].mandatory && !checkboxes[0].disabled) {
    for (var i = 0; i < checkboxes.length && !checkboxes[i].checked; i++);

    if (i >= checkboxes.length) {
      checkboxes[0].focus();

      alert("Please select the relevant name(s).");
      //validateAlert("Please select an option in %f.", this);
      return false;
    }
  } else {
    if (checkboxes.mandatory && !checkboxes.checked && !checkboxes.disabled) {
      checkboxes.focus();

      alert("Please select the relevant name(s).");
      //validateAlert("Please select an option in %f.", this);
      return false;
    }
  }
  return true;
}

function validateOption() {
  // Get the array for this checkbox/radio button group
  var checkboxes = this.form[this.name];

  if (checkboxes[0] && checkboxes[0].mandatory && !checkboxes[0].disabled) {
    for (var i = 0; i < checkboxes.length && !checkboxes[i].checked; i++);

    if (i >= checkboxes.length) {
      checkboxes[0].focus();

      alert("Please select the relevant option.");
      //validateAlert("Please select an option in %f.", this);
      return false;
    }
  } else {
    if (checkboxes.mandatory && !checkboxes.checked && !checkboxes.disabled) {
      checkboxes.focus();

      alert("Please select the relevant option.");
      //validateAlert("Please select an option in %f.", this);
      return false;
    }
  }
  return true;
}

function validatePattern() {
  if (!this.mandatory && this.value == "")
    return true;

  var pattern = this.pattern;
  var found = this.value.search(pattern);
  if (found < 0) {
    var valueType = (this.valueType) ? this.valueType + " " : "value";
    this.select();
    this.focus();
    validateAlert("Please enter a valid " + valueType + " into %f.", this);
    return false;
  }
  return true;
}

function validateCardPattern() {
  if (!this.mandatory && this.value == "")
    return true;

  var pattern = this.pattern;
  this.value = stripSpaces(this.value);
  var found = this.value.search(pattern);
  if (found < 0) {
    var valueType = (this.valueType) ? this.valueType + " " : "value";
    this.select();
    this.focus();
    validateAlert( valueType , this);
    return false;
  }
  return true;
}

// 20030613 - Ref 803 - Removal of client script from before HEAD tags
// Returns true if the date is valid
function lpdt_validateDate() {

  // private month conversion function
  function lpdt_monthName(intMonth) {
    switch(parseInt(intMonth)) {
    case 1:
      return "January";
    case 2:
      return "February";
    case 3:
      return "March";
    case 4:
      return "April";
    case 5:
      return "May";
    case 6:
      return "June";
    case 7:
      return "July";
    case 8:
      return "August";
    case 9:
      return "September";
    case 10:
      return "October";
    case 11:
      return "November";
    case 12:
      return "December";
    }
  }

  var intDay, intMonth, intYear;
  var blnDay, blnMonth, blnYear;

  var valid = false;

  var varForm = this.form;
  var varFirstField = null;

  var strName = this.name;
  strName = strName.substr(0, strName.lastIndexOf("_"));

  var now = new Date();

  var varYear = varForm[strName + "_year"];
  if (varYear) {
    varFirstField = varYear;

    var strYear = varYear.options[varYear.selectedIndex].value;
    if (strYear == "") {
      intYear = now.getFullYear();
    } else {
      blnYear = true;
      intYear = parseInt(strYear, 10);
    }
  } else {
    intYear = now.getFullYear();
  }

  var varMonth = varForm[strName + "_month"];
  if (varMonth) {
    varFirstField = varMonth;

    var strMonth = varMonth.options[varMonth.selectedIndex].value;
    if (strMonth == "") {
      intMonth = now.getMonth() + 1;
    } else {
      blnMonth = true;
      intMonth = parseInt(strMonth, 10);
    }
  } else {
    intMonth = now.getMonth() + 1;
  }

  var varDay = varForm[strName + "_day"];
  if (varDay) {
    varFirstField = varDay;

    var strDay = varDay.options[varDay.selectedIndex].value;
    if (strDay == "") {
      intDay = now.getDate();
    } else {
      blnDay = true;
      intDay = parseInt(strDay, 10);
    }
  } else {
    intDay = now.getDate();
  }

  if (blnDay) {
    switch (intMonth) {
    case 4:
    case 6:
    case 9:
    case 11:
      valid = intDay > 0 && intDay <= 30;
      break;
    case 2:
      var max;
      if (intYear % 100 == 0) {
        if (intYear % 400 == 0) {
          max = 29;
        } else {
          max = 28;
        }
      } else if (intYear % 4 == 0) {
        max = 29;
      } else {
        max = 28;
      }
      valid = intDay > 0 && intDay <= max;
      break;
    default:
      valid = intDay > 0 && intDay <= 31;
      break;
    }
  } else {
    valid = true;
    if (intMonth == (now.getMonth() + 1)) {
      intDay = now.getDate();
    } else {
      intDay = 1;
    }
  }

  if (!valid) {
    if (varFirstField)
      varFirstField.focus();
    alert("The date of birth selected does not exist. (e.g. 29 Feb in a non leap year). Please check the day of the month.");
    return false;
  }

  var date = new Date(intYear, intMonth-1, intDay, 0, 0, 0);
  if (this.maxDate) {
    if (this.maxDate < date) {
      this.focus();
      var strDate = '';
      strDate += (blnDay) ? this.maxDate.getDate() : '';
      strDate += (strDate != '') ? ' ' : '';
      strDate += (blnMonth) ? lpdt_monthName(this.maxDate.getMonth() + 1) : '';
      strDate += (strDate != '') ? ' ' : '';
      strDate += (blnYear) ? this.maxDate.getFullYear() : '';

      var message = 'The date of birth selected must be earlier than (or on) ' + strDate + '. Otherwise this person is less than 18 years of age and is therefore ineligible to be a company director and/or company secretary.';
      alert(message);

      return false;
    }
  }
  if (this.minDate) {
    if (this.minDate > date) {
      this.focus();
      var strDate = '';
      strDate += (blnDay) ? this.minDate.getDate() : '';
      strDate += (strDate != '') ? ' ' : '';
      strDate += (blnMonth) ? lpdt_monthName(this.minDate.getMonth() + 1) : '';
      strDate += (strDate != '') ? ' ' : '';
      strDate += (blnYear) ? this.minDate.getFullYear() : '';

      var message = 'The date of birth selected cannot precede ' + strDate + '.  Otherwise this person is less than 18 years of age and is therefore ineligible to be a company director and/or company secretary.';
      alert(message);
      return false;
    }
  }
  return true;
}

var validateDateYear_MessageShown = false;
function validateDateYear() {
	var yearValue = this.value.replace(/^\s*(.*)\s*$/, '$1');
	var dayValue = document.page.birth_date_day.value;
	var monthValue = document.page.birth_date_month.value;
	if (yearValue == '1901' && dayValue == '1' && monthValue == '1') {
		alert("Please select the correct birth date for this person. Thank you.");
		return false;
	}
	
	if(!validateDateYear_MessageShown && yearValue == '1901')
	{
	    alert('Was this person really born in 1901? If not, please adjust the year of birth. Otherwise please proceed as normal. And please note that you will not be given this warning message a second time on this your current visit to this page. Thank you.');
	    validateDateYear_MessageShown = true;
	    return false;
	}
	
	return true;
}

function validateASICacn (acnValue, msgChoice) 
{
  // JC 3/2/2008 Ref 3546 Check ACN/ARBN according to ASIC test (e.g. 004085616 is valid ACN)
  weight = 0;
  product = 0;
  total = 0;
  for (var i=acnValue.length-1; i--; i>-1)
  {
    if (acnValue.charAt(i) != ' ')
    {
      if (weight <8)
      {
        weight = weight + 1;
        product = weight * acnValue.charAt(i);
        total = total + product;
      }
    }
  }
  total = total % 10;
  total = 10 - total;
  
  if (total == 10) { total = 0; }

  if (total == acnValue.charAt(acnValue.length - 1))
  {
    return true;
  }
  else
  {
    if (msgChoice == 1) // For pages 08/38_0 and 10/40, no "ABN" in message
    {
      alert("The ACN (or ARBN) you have entered is invalid (according to the associated ASIC validation test). Please re-check the ACN (or ARBN) you have entered and adjust it accordingly.");
    }
    else // for pages 08/19e and 08/38_5
    {
        //alert("The ACN (or ARBN or ABN) you have entered is invalid (according to the associated ASIC validation test). Please re-check the ACN (or ARBN or ABN) you have entered and adjust it accordingly.");
        alert("The ACN (or ARBN) you have entered is invalid (according to the associated ASIC validation test). Please re-check the ACN (or ARBN) you have entered and adjust it accordingly.");
    }
    return false;
  }
  
  return true;
}

function validateASICabn(abnValue)
{
    // 3546: http://ato.gov.au/businesses/content.asp?doc=/content/13187.htm
    var checksum = 1;
    var weight = -1;
    abnValue = abnValue.replace(/\s/g, "");
    if (abnValue.length == 11)
    {
        checksum = (abnValue.charAt(0) - 1) * 10;
     
        for (var i=1; i<abnValue.length; i++)
        {
            weight += 2;
            checksum += abnValue.charAt(i) * weight;
        }
    }

    if (checksum % 89 == 0)
    {
        return true;
    }
    else
    {
        alert("The ABN you have entered is invalid (according to the associated ATO validation test). Please re-check the ABN you have entered and adjust it accordingly.");
        return false;
    }

    return true;
}

// JC 16/12/2005 Ref 2160 New function
function birthIsAustralia() 
{
  // Mantis 3834: Supporting outside australia from state list
  var bAustralia = false;
  if( typeof( document.page.birth_location ) != "undefined" )
  {
	  //JC 25/03/03 changed function to suit Mac IE 5.1.4
    var lowercase_birth_country = document.page.birth_location.value.toLowerCase();
	  bAustralia = (lowercase_birth_country.search(/^australia$/) == 0)
  }
  
  return bAustralia;
}

function getStateAbbrFromID(stateID)
{
  switch (parseInt(stateID))
  {
    case 1: // QLD - 4###
      return "QLD";
    case 2: // NSW - 2###
      return "NSW";
    case 3: // VIC - 3###
      return "VIC";
    case 4: // SA - 5###
      return "SA";
    case 5: // WA - 6###
      return "WA";
    case 6: // TAS - 7###
      return "TAS";
    case 7: // NT - 0###
      return "NT";
    case 8: // ACT - 2###
      return "ACT";
    default:
      return "";
  }
}

// KD: Mantis 4065 - Validate Birth Town 
var pendingBirthTownAjax = false;
var prevBirthStateID = "";
var prevBirthTown = "";
var validateBirthTown_Include_POBox = false;
function validateBirthTown()
{
  if (!birthIsAustralia())
    return true;
    
  var otherLocation = false;
  var stateID = document.page.birth_state.value;
  var location = document.page.birth_town.options[document.page.birth_town.selectedIndex].text;
  if (location == "")
  {
  	//this.focus();
  	alert("Please select a City or town or locality of birth (from the City or town or locality of birth 'drop down list').");
	  return false;
  }
  if (location == "OTHER")
  {
    otherLocation = true;
    location = document.page.birth_other.value;
  }

  // Skip this check on empty
  if (location == "")
      return true;

  if (otherLocation && (prevBirthStateID != stateID || prevBirthTown != location))
  {
    // We want to set this prior to making the AJAX call. If the Ajax call crashes then at least the user can continue
    // Re "We do want this done here else someone dblclicking will bypass check, but I have added a timer to the call to all continuing after 5s in case of failures"
    // We would rather not perform the check if the alternative is stopping customer from using the site. The crash problem also stops further code from executing. Overall it's okay that double clicking can bypass this check since it's only an "info" check.
    // Note: The timeout isn't a bad idea but the lastCalled = new Date(); would need to be moved up to just before the Ajax call is made
    prevBirthStateID = stateID;
    prevBirthTown = location;

    var currentTime = new Date();
    if (!pendingBirthTownAjax)
    {
      pendingBirthTownAjax = true;
      $.get("../_INC/ValidateLocality.asp", { locality: location, state: getStateAbbrFromID(stateID), pobox: validateBirthTown_Include_POBox }, function(data) {
          //prevBirthStateID = stateID;
          //prevBirthTown = location;
          pendingBirthTownAjax = false;

          var results = data.split(':');
          var return_postcodes = results[0].split(',');
          var return_states = results[1].split(',');
          var return_states = return_states.unique();
          if (isNaN(parseInt(return_postcodes[0])))
          {
              alert('The entry in the "Other (Australian town or locality of birth)" field (' + location + ') does not look to be an officially spelt, official Australian town or locality. Accordingly, please review and adjust the town or locality of birth you have entered. (If you want to check the official spelling of official Australian towns/localities, you can do so at http://www1.auspost.com.au/postcodes/.)\n\nPlease note that you will not be given this warning message a second time in respect of the exact same entries on this/your current visit to this page.');
              return;
          }
          else if (getStateAbbrFromID(stateID) != return_states[0])
          {
              var strStates = return_states.join(' or ');
              alert('The Australian town or locality of birth you have entered (' + location + ') does not look to be within the State/Territory of birth currently showing/selected (' + getStateAbbrFromID(stateID) + ') but instead looks to be in ' + strStates + '. Accordingly, please review and adjust your entries/selections as necessary.\n\nPlease note that you will not be given this warning message a second time in respect of the exact same entries/selections on this/your current visit to this page.');
              return;
          }

          _loib_onClick(document.page, 'page_continue', '_page_continue(document.page)', true);
      });
      
      lastCalled = new Date();
      return false;
    }
    else if (currentTime.valueOf() - lastCalled.valueOf() < 4000)
    {
      return false;
    }
  }
  return true;
}



