toggleDisplay = function(divName, isChecked)
{
	if (divName != '') {
		var div = document.getElementById(divName);
		if (div) {
			if (isChecked)
				document.getElementById(divName).style.display = 'block';
			else
				document.getElementById(divName).style.display = 'none';
		}
	}
}

toggleCustomControl= function(hazardID)
{
	var div = document.getElementById("customControl_"+hazardID);
	var anchorTag = document.getElementById("customControlLink_"+hazardID);
	
	// switch controls on
	if (anchorTag.firstChild.nodeValue=="Add custom control"){
		anchorTag.firstChild.nodeValue="Hide custom control";
		div.style.display = 'block';
	// switch controls off
	}else{
		anchorTag.firstChild.nodeValue="Add custom control";
		var controlTextField = document.getElementById("customControlText_"+hazardID);
		var skillsField = document.getElementById("skills_"+hazardID);
		var toolsField = document.getElementById("tools_"+hazardID);
		var protectiveField = document.getElementById("protective_"+hazardID);
		controlTextField.value="";
		skillsField.value="";
		toolsField.value="";
		protectiveField.value="";
		div.style.display = 'none';
	}
	
}

toggleTextField = function(divName, isChecked)
{
	if (divName != '') {
		var div = document.getElementById(divName);
		if (div) {
			if (isChecked){
				document.getElementById(divName).disabled = false;
				document.getElementById(divName).style.backgroundColor = '#fff'; 
			}else{
				document.getElementById(divName).disabled = true;
				document.getElementById(divName).style.backgroundColor = '#e5e4e4'; 
			}
		}
	}
}

addControl = function(hazardID)
{
	var div = document.getElementById("customControl_"+hazardID);
	// add a table row
	var tableRow = document.createElement('tr');
	// add a table cell
	var tableCell1 = document.createElement('td');
	tableCell1.setAttribute('class', 'customInput');
	var tableCell2 = document.createElement('td');
	// add the input field
	var inputField = document.createElement('input');
	inputField.setAttribute('name', 'customControl_'+hazardID+'[]');
	// add the select tag
	var dropdown = document.createElement('select');
	dropdown.setAttribute('name', 'customAtionedBy_'+hazardID+'[]');
	// add the option 1 tag
	var option1 = document.createElement('option');
	// add the option 1 label
	var option1Label = document.createTextNode("Employer"); 
	// add the option 2 tag
	var option2 = document.createElement('option');
	// add the option 2 label
	var option2Label = document.createTextNode("Painter"); 
	// add the option 3 tag
	var option3 = document.createElement('option');
	// add the option 3 label
	var option3Label = document.createTextNode("Occupier");
	
	
	option1.appendChild(option1Label); 
	option2.appendChild(option2Label); 
	option3.appendChild(option3Label); 
	dropdown.appendChild(option1); 
	dropdown.appendChild(option2); 
	dropdown.appendChild(option3); 
	tableCell1.appendChild(inputField); 
	tableCell2.appendChild(dropdown); 
	tableRow.appendChild(tableCell1);
	tableRow.appendChild(tableCell2); 
	div.appendChild(tableRow); 
}