//these functions don't work in early browsers, so set up some browser detection first

if (document.getElementById || document.all || document.layers) {
	var isOK = true;// assuming OK
}

else { // if none of these is supported
	var isIE5 = true;
	// we'll refer to IE5 for not supporting DHTML but it's not the only culprit
}
//Oos - toggle comment box on removal form 
function displayComment(reason_code) {
  document.getElementById('withdrawComment').style.display='none';

  if (document.getElementById('withdrawalReason').value == 3) {
    document.getElementById('withdrawComment').style.display='block';
  }
}

function formToggle() {
	if (isIE5) return;
	var inputs = document.getElementsByTagName("input");
	for (var i=0; i<inputs.length; i++) { // loop through and find all input tags 
	var input = inputs[i];
	// below: check the a input is of type "checkbox" 
	if (input.getAttribute("type") == "checkbox") 
	{
		if (input.disabled == true) 
		{
		input.disabled = false;
		cboxPanel = document.getElementById("checkboxGroup");
		cboxPanelInstruction = document.getElementById("specificOrgansInstruction");
		cboxPanel.style.color = "#000";
		cboxPanelInstruction.style.display = "block";

		}
		else {
		input.disabled = true;
		cboxPanel = document.getElementById("checkboxGroup");
		cboxPanelInstruction = document.getElementById("specificOrgansInstruction");
		cboxPanel.style.color = "#999";
		cboxPanelInstruction.style.display = "none";
		}
	}
 }
}

function styleText(enabled) {
	if (enabled) {
		alert("There we go!");
	}
	else {
		alert("Not so much huh?");
	}
}


function disableOnload() {
	if (isIE5) return;

	var inputs = document.getElementsByTagName("input");

	for (var i=0; i<inputs.length; i++) { // loop through and find all input tags 
	var input = inputs[i];
	// below: check the a input is of type "checkbox" 
	
	if (input.getAttribute("type") == "checkbox")  {
		
		input.disabled = true;
	}

	
	} // end loop
	
}

function checkRbState() {
	var cb = document.forms[1].elements[14]; // checks to see if radio button a is selected
	if (cb.checked) {
		disableOnload() // yes it is so call the function to disable the checkboxes
	}
	else {
		return; // B must be selected; take no action
	}
}
onload = checkRbState;


/*
following script better if/when checkboxes all have the same name

function checkAll(check) {
   for (i=0;i<6;i++) {
     if (check) { 
        document.forms[0].chbx[i].checked=true;
        }
     else {
        document.forms[0].chbx[i].checked=false;
        }
     }
   }
*/


function uncheckBoxes() {
	if (isIE5) return;
	var inputs = document.getElementsByTagName("input");
	for (var i=0; i<inputs.length; i++)
	{ // loop through and find all input tags 
		var input = inputs[i];
		// below: check the a input is of type "checkbox" 
		if (input.getAttribute("type") == "checkbox") 
		{
	//		if (input.getAttribute("name") == "emailNewsUpdates") 
			if (input.getAttribute("name") == "contactConsent") 
			{
				input.disabled=false;
				if (input.checked)
				{
					input.checked=true;
				}
			}
			else 
			{
				input.checked = false;
				input.disabled = true;
			}
		}
	}
}

function enableBoxes() {
	var inputs = document.getElementsByTagName("input");
	for (var i=0; i<inputs.length; i++) { // loop through and find all input tags 
	var input = inputs[i];
	// below: check the input is of type "checkbox" 
	if (input.getAttribute("type") == "checkbox") {		
		input.disabled = false;
		}
	}
}
