/**
For checking numeric values, checks that the value of 'question to change' is lower than than 'question to check' after modification by factor in whatever actions chosen... what?.
Sets 'question to change' max possible if test fails.
**/
function min_max(question_to_check, question_to_change, action, factor)
{
	var question_to_check_value = document.getElementById(question_to_check).value;
	var question_to_change_value = document.getElementById(question_to_change).value;
	
	if (action !== undefined)
	{
		switch(action)
		{
			case "minus":
				var check_value = question_to_check_value - factor;
			break;    
			case "add":
				var check_value = question_to_check_value + factor;
			break;
			case "divide":
				var check_value = question_to_check_value / factor;
			break
			default:
			//multiply
				var check_value = question_to_check_value * factor;
		}
	}
	else
	{
		var check_value = question_to_check_value;
	}
	
	if(question_to_change_value > check_value)
	{
		document.getElementById(question_to_change).value = check_value;
	}
}

function min_max_new(question_to_check, question_to_change, allow_greater_than)
{
	var question_to_check_value = document.getElementById(question_to_check).value;
	var question_to_change_value = document.getElementById(question_to_change).value;
	var check_value = question_to_check_value;
	
	if (question_to_check_value < allow_greater_than)
	{
		if(question_to_change_value > check_value)
		{
			document.getElementById(question_to_change).value = check_value;
		}
	}
}


/**
Disable the question to change is value of question to check is null, blank or zero.
**/
function disable_enable(question_to_check, question_to_change)
{
	var question_to_check_value = document.getElementById(question_to_check).value;
	var question_to_change_object = document.getElementById(question_to_change);
	
	if(question_to_check_value == null || question_to_check_value == "" || question_to_check_value == 0)
	{
		question_to_change_object.disabled = true;
	}
	else
	{
		question_to_change_object.disabled = false;
	}
}


/**
show the question to change is value of question to check is null, blank or zero.
**/
function show_hide(question_to_check, question_to_change, trigger_value, is_checked)
{
	var question_to_check_object = document.getElementById(question_to_check);
	var question_to_change_object = document.getElementById(question_to_change+'_div');
	
	if((is_checked == true) && (question_to_check_object.checked == true) || ((is_checked === undefined) && (question_to_check_object.value == trigger_value)))
	{
		question_to_change_object.style.display = 'block';
	}
	else
	{
		question_to_change_object.style.display = 'none';
	}
}

/**
show the question to change is value of question to check is null, blank or zero.
**/
function show_hide_multiple(question_to_check, question_to_change, trigger_values, is_checked)
{
	var question_to_check_object = document.getElementById(question_to_check);
	var question_to_change_object = document.getElementById(question_to_change+'_div');
	var is_shown = false;
	var values = trigger_values.split(',');
	
	for (var i = 0; i < values.length; i++)
	{
		trigger_value = values[i];
		if((is_checked == true) && (question_to_check_object.checked == true) || ((is_checked === undefined) && (question_to_check_object.value == trigger_value)))
		{
			question_to_change_object.style.display = 'block';
			return;
		}
	}
	
	question_to_change_object.style.display = 'none';
}

