
// Put user-interface (wrt an HTML page) JavaScript functions here

// Good for auto-tabbing to the next input field once the max length of the current field is reached
function moveOnMax(field, nextFieldID){
	if (field.value.length >= field.maxLength) {
		document.getElementById(nextFieldID).focus();
	}
}

// Good for OPTIONALLY clearing the value so long as it only contains the given value
function clear_value_on_match(el_id, value) {
	if ($(el_id).value == value) {
		$(el_id).value = '';
	}
}

// you should attach this to "onkeydown" and "onkeyup" events on a textarea.
function char_limit_check(limit_field_id, limit, countdown_id) {
	if ($(limit_field_id).value.length > limit) {
		$(limit_field_id).value = $(limit_field_id).value.substring(0, limit);
	} else {
		$(countdown_id).innerHTML = limit - $(limit_field_id).value.length;
	}
}
