<!--
gh_dontSave=0; // This will be set to 1 by the Submit routine.
	// This prevents last form trying to save as we move to Thankyou page.
	
var self;
var dataFields;
var blankFields;

function GH_LoadFormData() {
	self = this;
	//   This function loads any stored form data from the hidden frame.
	
	//   Notes for Implementing:
	//   Field names MUST all be UNIQUE throughout all form pages.
	//   Code also assumes form to submit will be in a frame named "dataFrame",
	//   while each form page will be filled out in a frame named "mainFrame".
	//
	//   IMPORTANT: All Hidden fields must go at the BOTTOM of every form in every frame.
	
	
	// Automatically count the number of fields on this page.
	//
	dataFields = top.dataFrame.document.formAll; // Needed to put '.document' in for Netscape 4.71
	blankFields = self.document.form1;  // Needed to put '.document' in for Netscape 4.71
	self.numberOfFields = blankFields.length;
	
	if(window.console) {
		//console.debug('Data fields: ' + dataFields);
		//console.debug('Blank fields: ' + blankFields);
		//console.debug('Total fields: ' + self.numberOfFields);
	}

	// Automatically determine the number of the field in "dataFrame" that matches
	// the first field on THIS page.  (Field names MUST be unique)
	// If a page starts with a Rdb or Chk, it will match the First in that group.
	nameToMatch = blankFields[0].name;
	//alert(nameToMatch);
	self.firstFieldNum = -1;
	findField :
	for (i = 0; i < dataFields.length; i++) {
		if (dataFields[i].name == nameToMatch) {
			if(window.console) {
				//console.debug('First field: ' + dataFields[i].name);
				//console.debug('First field number: ' + i);
			}
			self.firstFieldNum = i;
			//alert(dataFields[i].name);
			break findField; // Stop on first field in a Radio/Checkbox group
		}
	}
	if (self.firstFieldNum == -1) {
		// If it can't find the field, we must report an error, or the user's data
		// could be corrupted or not sent.
		// This should only occur in In-house Testing & QA.
		alert("There appears to be an error in this form,\non your browser.\n\nPlease contact support@groundhog.com.au");
		return false;
	}
	//alert(self.firstFieldNum);

	//   Loop to fill each field on this page, with any data from hidden frame
	//alert("before loop");
	for (i = 0; i < self.numberOfFields; i++) {
		// Need different code for different field types:
		//console.debug(i + self.firstFieldNum);
		curDataField = dataFields[i + self.firstFieldNum];
		curBlankField = blankFields[i];
		//alert(curDataField);
	
		if(window.console) {
		//	console.debug(curDataField);
		//	console.debug(curBlankField);
		}
		
		if(curDataField != undefined) {
		
			curPrefix = curDataField.name.substr(0,4);
			//alert(curPrefix);
			
			if(window.console) {
			//	console.debug('Field prefix: ' + curPrefix);
			}

			if (curPrefix == "rdb_" || curPrefix == "chk_") {
				// Radio Buttons and Check boxes..
				// Assume all in blankFields will have been reset to Checked = 0.
				// So just find and replace any "Checked = true" fields.
				if (curDataField.checked) {
					curBlankField.checked = true;
				}
			} else {
				if (curPrefix == "slt_") {
					// Select List - need to set selectedIndex
					curBlankField.selectedIndex = curDataField.selectedIndex;
				} else {
					// For regular 'input', 'textbox' fields 
					curBlankField.value = curDataField.value;
				}
			}
		}
	}
}

function GH_SaveFormData() {

	self = this;
	
	if (self.firstFieldNum == -1 || gh_dontSave==1) {
		return false;
	}
	//   Assumes 'self.firstFieldNum' has been set in GH_LoadFormData.
	//   and self.numberOfFields, dataFields, blankFields already set.

	//   Loop to save each field value on this page, into the Data form in the hidden frame

	for (i=0;i<self.numberOfFields;i++) {

		// Need different code for different field types:
		curDataField = dataFields[i + self.firstFieldNum];
		//alert(curDataField);
		curBlankField = blankFields[i];
		//alert(curBlankField);
	
		if(window.console) {
		//	console.debug(curDataField);
		//	console.debug(curBlankField);
		}
		
		if(curDataField != undefined) {
			curPrefix = curDataField.name.substr(0,4); //***
			//alert(curPrefix);

			if (curPrefix == "rdb_" || curPrefix == "chk_") {
				// Radio Buttons and Check boxes..
				// Assume all in blankFields will have been reset to Checked = 0.
				// So just find and replace any "Checked = 1" fields.
				if (curBlankField.checked) {
					curDataField.checked = true;
				} else {
					curDataField.checked = false;
				}
			} else {
				if (curPrefix == "slt_") {
					// Select List - need to set selectedIndex
					curDataField.selectedIndex = curBlankField.selectedIndex;
				} else {
					// For regular 'input', 'textbox' fields 
					curDataField.value = curBlankField.value;
				}
			}
		}
	}
}

function GH_validateForm() { //v4.0
  /* Adapted by David, 17 Sep 03.
     Updated by David, 21 Oct 03, to handle Radio Buttons (rdb_).

     This function is designed with the SAME interface as Macromedia's MM_validateForm(),
     built on a snapshot of that function as of Dreamweaver 6.0
     This allows the user to use the DW interface to set required fields, then simply replace
     MM_validateForm(...) with GH_validateForm(...).
     This function will strip the first 4 letters and replace _ with <space> in field names,
     for better presentation. */
	 
  /* NOTE: All field names should begin with a 4 letter prefix, frm_ rdb_ etc. */
	 
  /* DR: The specific changes made to the original MM_validateForm code are;
     - added  g,gChr,displayName  to opening var declaration
     - inserted the block of code below to set displayName
	 - replaced nm with displayName where it was being appended to "errors" string
	 - changed final output text in 2nd last line.  */

  /* Radio Buttons. (DR 20/10/03)
  	 Instead of passing in the argument 'R' to say a rdb_field is required,
	 set this to 'RDB'. The code below looks for this and runs custom code to
	 validate. This was necessary as Macromedia's GH_findObj function below
	 can't seem to find a radio button field and causes an error.
	 Might need to investigate the getElementById() they use.
	 */

  var i,p,q,nm, g,gChr,displayName, test,num,min,max,errors='',args=GH_validateForm.arguments;
   for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; 

    // This block added to test for radio buttons and run separate code.
	if (test.toUpperCase()=='RDB') {
	   
	  // ** MUST pass in form name as 2nd argument, ie just before the 'RDB' **
	  // Validate that a radio button group is checked.
	  // Integrate feedback into normal popup dialog.
	  thisForm=args[i+1]; thisField=args[i];
	  if(thisForm != ""){
	    Opt = -1;
		theObj = eval("document."+thisForm+"."+thisField);
	    for (j=0; j<theObj.length; j++) {
          if (theObj[j].checked) Opt = j;
	    }
		if (Opt == -1) {
	      // Format and append feedback. Similar code to other fields, as below.
 	      if (thisField.length > 4) {
	        displayName = ""; 
	        for (g=4; g<(thisField.length); g++) { // Ignore 4 letter prefix
		      gChr = thisField.substr(g,1);
		      if (gChr == "_") gChr = " "; // Replace _ with <space>
		      if (gChr == "-") gChr = " "; // Replace - with <space>  (optional)
	          displayName += gChr;
	  	    }
		    errors += '- '+displayName+' is required.\n';
	      }
	    }
	  } 
	} else { 
    // End 'RDB' block, added 20/10/03. Plus closing } below.
	 
	val=GH_findObj(args[i]);
    if (val) { nm=val.name;

	  // Code block added to set displayName;
	  if (nm.length > 4) {
	    displayName = ""; 
		for (g=4; g<(nm.length); g++) { // Ignore 4 letter prefix
		  gChr = nm.substr(g,1);
		  if (gChr == "_") gChr = " "; // Replace _ with <space>
		  if (gChr == "-") gChr = " "; // Replace - with <space>  (optional)
	      displayName += gChr;
	  	}
	  }

	  if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+displayName+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+displayName+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+displayName+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+displayName+' is required.\n'; }
	 } // End 'RDB' main if loop.	
  // DR: Changed display text in next line.
  } if (errors) alert('Please complete the following:\n\n'+errors);
  document.MM_returnValue = (errors == '');
}


function GH_findObj(n, d) { //v4.01
  // Snapshot duplicate of MM_findObj as of Dreamweaver 6.0, to lock in this version of code.
  // This is called by GH_validateForm() and also calls itself.
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=GH_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

//-->
