function oneOrNoCheckboxGroup (checkbox) {
  var checkboxGroup = checkbox.form[checkbox.name];
  for (var c = 0; c < checkboxGroup.length; c++)
  if (checkboxGroup[c] != checkbox) checkboxGroup[c].checked = false;
}

function Calculate(obj) {
  var truescore = 0;
  var counter = 11;
  var i = 1;
  if (obj == "Work") {i=1};
  if (obj == "Finances") {i=11};
  if (obj == "Home") {i=21};
  if (obj == "Health") {i=31};
  if (obj == "Relationships") {i=41};
  if (obj == "Personal") {i=51};
  while(document.Form["True"+ obj+ parseFloat(i)]) 
   {
	  if (document.getElementById("True"+ obj + i).checked && document.getElementById("True"+ obj + i).value == "true") {truescore += 1;}
	  if (document.getElementById("True"+ obj + i).checked || document.getElementById(obj + i).checked) {counter++;}
	  i++;
	}
	
	if (counter < 11) {
		alert("You have not checked all of the boxes on this page. Please do so, and re-click the Calculate button.")
		return;
	}
	
	boxname = obj + "_Score";
	document.getElementById(boxname).innerHTML = truescore;
	
	if (obj == "Work") {show('Finances');hide('Work')};
  	if (obj == "Finances") {show('Home');hide('Finances')};
 	if (obj == "Home") {show('Health');hide('Home')};
 	if (obj == "Health") {show('Relationships');hide('Health')};
 	if (obj == "Relationships") {show('Personal');hide('Relationships')};
 	if (obj == "Personal") {
		show('Final');
		hide('Personal');
		hide('TestPadding');
		
		if (parseFloat(document.getElementById("Work_Score").innerHTML) < 5) {show('WorkResults')}
		if (parseFloat(document.getElementById("Finances_Score").innerHTML) < 5) {show('FinancesResults')}
		if (parseFloat(document.getElementById("Home_Score").innerHTML) < 5) {show('HomeResults')}
		if (parseFloat(document.getElementById("Health_Score").innerHTML) < 5) {show('HealthResults')}
		if (parseFloat(document.getElementById("Relationships_Score").innerHTML) < 5) {show('RelationshipsResults')}
		if (parseFloat(document.getElementById("Personal_Score").innerHTML) < 5) {show('PersonalResults')}
	};
}

function CallContact(result)
{
	if(result.value)
	{
		hide("Loading")
		hide("Panel1")
		show("Panel2");
	}
	else {
		show("Panel1");
		hide("Loading");
		alert("We aplogise for this error: "+ result.value)
	}
}

function Contact()
{
	hide("Panel1");
	show("Loading");
	Cindy.Testing.SendMail(
		document.getElementById("FullName").value, 
		document.getElementById("Email").value,
		document.getElementById("TelNo").value,
		CallContact
		);
}

  function ValidateData() {
	   var CanSubmit = false;
	   var errormessage = "Please make sure that you have filled in the following fields before clicking Send:\n\n"

	   // Check to make sure that the full name field is not empty.
	   CanSubmit = ForceEntry(document.forms[0].FullName);
	   if (CanSubmit == false) 
		{
			errormessage += "Full Name.\n";
		}
	   CanSubmit = ForceEntry(document.forms[0].TelNo);
	   if (CanSubmit == false) 
		{
			errormessage += "Contact number.\n";
		}
	   CanSubmit = ForceEntry(document.forms[0].Email);
	   if (CanSubmit == false) 
		{
			errormessage += "E-mail address.\n";
		}
		CanSubmit = checkEmailAddress(document.forms[0].Email);
	   if (CanSubmit == false) 
		{
			errormessage += "Please enter a Valid E-mail Address.\n";
		}

	   // Check to make sure ranking is between 1 and 10
	   if (errormessage == 'Please make sure that you have filled in the following fields before clicking Send:\n\n')
	   {
		return true;
	   }
	   else 
	   {
		alert(errormessage)
		return false;
	   }
  }