function checkAll(obj, name, id, msgId)
{
	var checks = document.getElementsByName(name);

	//If no id given, we'll asume that we want all the boxes checked/unchecked.
	if(typeof id == "undefined")
	{
		for(var x = 0; x < checks.length; x++)
		{
			/*
			We'll give all the cluster checkboxes the same state as the master.
			This avoids a *stupid* if/else statement in here. (Which is either true or false(Checked/unchecked))
			*/
			checks[x].checked = obj.checked;
		}
	}
	//Else lets see wether to check or uncheck the "master" checker
	else
	{
		var checkall = document.getElementById(id);

		//If we uncheck a cluster then lets uncheck the master
		if(checkall.checked == true && obj.checked == false)
		{
			checkall.checked = false;
		}
		//If we check a cluster, lets see if we should check the master too
		else if(obj.checked == true)
		{
			var bool = true;
			for(var x = 0; x < checks.length; x++)
			{
				if(checks[x].checked != obj.checked)
				{
					bool = false;
					//Only run while bool is true. 
					//(As soon as it turns false all the clusters are not the same state
					break;
				}
			}

			//If bool is true, all clusters are checked, and we should check the master
			if(bool == true)
			{
				checkall.checked = true;
			}
		}
	}

	/*
	This IF is only here because I don't want the button to change if you update the second cluster.
	This part can be intigrated into the script though, where you pass the ID of the button to the function too
	(This is also just eye candy)
	*/
	if(name == "check[]")
	{
		var totalChecked = 0;
		for(var x = 0; x < checks.length; x++)
		{
			//If the current x is checked, lets update totalChecked.
			if(checks[x].checked == true)
			{
				totalChecked++;
			}
		}
		document.getElementById('jazz').value = (totalChecked == checks.length) ? "All boxes is checked" : totalChecked + " boxes is checked";
	}
}