// Make sure no less than two and no more than three checkboxes are selected.
var maxBoxes = 5;
var boxesChecked = 0;

function checkIt(theBox) {

  if (boxesChecked+1 > maxBoxes) {
    alert('Sorry, you may only select a maximum of 5 charities to compare.');
    return false;
  }
  boxesChecked++
  return true;
}

function checkIt2(theBox) {
/*  if (myaction==1 && boxesChecked+1 > maxBoxes) {
    alert('Sorry, you may only select a maximum of 5 charities to compare.');
    return false;
  }*/
  boxesChecked++
  return true;
}

function checkSubmit() {
  if (boxesChecked<2) {
    alert('You must select between 2 and 5 charities for a side-by-side comparison.');	  
	  }
  return (boxesChecked>1);
}

function checkSubmit2() {
var myaction=document.getElementById('action').value;
var mygroup=document.getElementById('group').value;

/*switch(myaction) {
case 1:
	checkSubmit();
	break;
case 2:
	if(mygroup=="") {
		alert('You must choose a group.');
		return false;
	}
	else if(boxesChecked<1) {
		alert('You must select at least one charity.');
		return false;
		}
	else 
		return true;
		break;
case 3:
	if(boxesChecked<1) {	
	alert('You must select at least one charity.');
	return false;
	}
	break;

default:
	return false;
	break;

}*/



	if (myaction==1 && boxesChecked<2) {
		alert('You must select between 2 and 5 charities for a side-by-side comparison.');	  
		return (boxesChecked>1);  
		 }
	else if (myaction==2 && mygroup=="") {
		alert('You must choose a group.');
		return false;
		}	
	else if (boxesChecked<1) {
		alert('You must select at least 1 charity to peform that function.');
		return (boxesChecked>=1);
	}
	else 
		return true;
	  
}



function togglegroup() {
	var myaction = document.getElementById('action').value;
	if (myaction==2)
		document.getElementById('group').disabled=false;
	else
		document.getElementById('group').disabled=true;	
}
