// --------------------------------------------------------------------------------
// nsatt_form.js
// --------------------------------------------------------------------------------

var nsatt_form_pre = "tmpl_nsatt_Form_nsattForm_";

// --- Attach JS to document elements and execute simple statements. ---
ow_f_AppendLoadEvent(
function() {

	if (document.getElementById(nsatt_form_pre + "subm") != null) ow_f_AddEvent(document.getElementById(nsatt_form_pre + "subm"), "click", nsatt_form_Click, false);

	if (document.getElementById("nsatt_form") != null) {
		var inp = document.getElementById("nsatt_form").getElementsByTagName("input");
		for (var i = 0; i < inp.length; i++) {
			if (inp[i].type == "text") ow_f_AddEvent(inp[i], "keypress", nsatt_form_Key, false);
		}
	}
	
}
);

// --------------------------------------------------------------------------------
// nsatt_form_Key()
// Fires when a textfield had focus and ENTER was pressed.
// --------------------------------------------------------------------------------
function nsatt_form_Key(e) {
	var code;
	if (!e) var e = window.event;
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;

	if (code == 13) {
		document.getElementById(nsatt_form_pre + "subm").click();
		if (e.preventDefault) e.preventDefault(); else e.returnValue = false;
	}
}

// --------------------------------------------------------------------------------
// nsatt_form_Click()
// Fires when the submit button was clicked.
// --------------------------------------------------------------------------------
function nsatt_form_Click(e) {
	if (!nsatt_form_Valid()) {
		if (!e) var e = window.event;
		if (e.preventDefault) e.preventDefault(); else e.returnValue = false;
	} else {
		return;
	}
}

// --------------------------------------------------------------------------------
// nsatt_form_Valid()
// Validates the data entered in the Accommodations app.
// --------------------------------------------------------------------------------
// Arguments:
//	- none
// Returns:
//	- the results of the validation [boolean]
// --------------------------------------------------------------------------------

function nsatt_form_Valid() {
	return true;
}