
	function debug_output( str )
	{
		window.status = 'DEBUG: '+str.toString();
		return true;
	}

	function switchDiv(div_id)
	{
		var style_sheet = getStyleObject(div_id);
		if( style_sheet )
		{
			hideAll();
			changeObjectVisibility(div_id, "visible");
		}
		else
		{
			alert("sorry, this only works in browsers that do Dynamic HTML");
		}
	}
	function getStyleObject(objectId)
	{
		// checkW3C DOM them MSIE 4, then NN4
		if( document.getElementById && document.getElementById(objectId))
		{
			return document.getElementById(objectId).style;
		}
		else if( document.all && document.all(objectId))
		{	
			return document.all(objectId).style;
		}	
		else if (document.layers && document.layers[objectId] )
		{
			return document.layers[objectId];
		}
		else 
		{
			return false;
		}
	}
	function changeObjectVisibility(objectId, newVisibility)
	{	
		// fist get the objects stylesheet
		var styleObject = getStyleObject(objectId);
		// then if we find a stylesheet, set its visibility as requested
		if( styleObject ) 
		{	
			styleObject.visibility = newVisibility;
			return true;		
		}
		else 
		{
			return false;
		}
	}
	function changeObjectDisplay(objectId, newDisplay)
	{	
		// fist get the objects stylesheet

		var styleObject = getStyleObject(objectId);
		// then if we find a stylesheet, set its visibility as requested
		if( styleObject ) 
		{	
			styleObject.display = newDisplay;
			return true;		
		}
		else 
		{
			return false;
		}
	}
	
	function getObjectDisplay( objectId )
	{
		var styleObject = getStyleObject(objectId);
		return styleObject.display;
	}
	
	
	
function switchIfDone(the_form, this_div, next_div)
{

  var complete = true;
  for (var loop=0; loop < the_form.elements.length; loop++)
  {
	/* FSL:TODO - you will need to setup lots more checking / error handling to manage the Aardvark form here.
	// this is specific to the page so should be done locally on the page.
	// maybe have a function for each field, e.g. 
		isOkay_byType(fieldType, attemptedFieldValue); which returns true or false. // in the library file
		if (isOkay_byType) isOkay_byName(fieldName, attemptedFieldValue); // in the page file. can apply ADDITIONAL restrictions
		
		isOkay_byName( name, val )
		{
				switch name
				{
						case "xyz":
							apply additional checks, and return true or false accordingly. note you don't need to check 
							gemeral items that apply to the "type".
							break;
						case defaut:
							return true; // return true by default. this function can only apply additional restrictions.
							break;
				}
		}
		
	*/ 
    if (the_form.elements[loop].value == "")
    {
      complete = false;
    }
  }
  if ((complete == true) && (next_div == "finished")) 
  {
    submitTheInfo();
  } 
  else if (complete == true) 
  {
    switchDiv(this_div, next_div);
  } else {
    alert('please complete the form before moving on');
  }
}	

	function copyTo(type,from, to)
	{
		switch(type)
		{
			case 'text':
				document.getElementById(to).value = document.getElementById(from).value;
				break;
			case 'select':
				document.getElementById(to).selectedIndex = document.getElementById(from).selectedIndex;
				break;
			case 'address':
				// copy multiple fields postfixed with: A1, A2, T, C
				document.getElementById(to+"H").value = document.getElementById(from+"H").value;
				document.getElementById(to+"A1").value = document.getElementById(from+"A1").value;
				document.getElementById(to+"A2").value = document.getElementById(from+"A2").value;
				document.getElementById(to+"T").value = document.getElementById(from+"T").value;
				document.getElementById(to+"C").value = document.getElementById(from+"C").value;
				break;				
		}
	}


function switchDiv(this_div, next_div)
{
  if (getStyleObject(this_div) && getStyleObject(next_div)) {
    changeObjectDisplay(this_div, "none");
    changeObjectDisplay(next_div, "block");
  }
}
	//kjp-11/12/4
	function toggleDivDisplay(this_div)
	{
		if (getStyleObject(this_div) ) 
		{
			if( getObjectDisplay(this_div) == "none") changeObjectDisplay( this_div, "block");
			else ( changeObjectDisplay( this_div, "none") );
		}
	}




function submitTheInfo()
{
  var submission_string="";
  // iterate through each form in the page and collect data into submission_string
  for (var form_loop=0; form_loop<document.forms.length; form_loop++) 
  {
    for (var elems=0; elems<document.forms[form_loop].length;elems++)
    {
      if (document.forms[form_loop].elements[elems].name != "")
      {
        submission_string += document.forms[form_loop].name + "_" +
          document.forms[form_loop].elements[elems].name + "=" +
          document.forms[form_loop].elements[elems].value + "\n";
      }
    }
  }
  document.hiddenform.the_text.value = submission_string;

  // the next two lines are written for debugging - 
  // to put the script into action
  // comment out the changeObjectVisibility() line
  // and uncomment the document.hidden.form.submit() line
  //

  //document.hiddenform.submit(); 
  changeObjectDisplay("hiddenstuff","block");
}


	