/**
 * Do query
 */
function doQuery() {
    startSearch();
	var obj = document.getElementById("infoLookupForm");
	if (obj != null) {
		obj.submit();
	}
}

/**
 * Check if the browser is Internet Explorer
 */
function isIE() {
	var v = navigator.appName.charAt(0);
	if (v == "M" || v == "m") {
		return true;
	}
	return false;
}

function keyEvent(e) {
	var k = 0;
	if (e != null && e.keyCode) {
		k = e.keyCode;
	} else {
		k = window.event.keyCode;
	}
	if (k == 13) {
		doQuery();
	}
}
if (isIE()) {
	document.onkeyup = keyEvent;
}else{
	document.addEventListener("keyup", keyEvent, true);
}

function startSearch() {
    initProgress();
    if (document.infoLookupForm && document.infoLookupForm.searchWhere) {
		document.infoLookupForm.searchWhere.value = "";
		if (componentNum > 0) {
			var whereClause = "";
			var count = 0;
			for (var ii = 0; ii < componentNum; ii++) {
				var o = document.getElementById("lookup" + ii);
				if (o != null && o.value != null && o.value != "") {
					whereClause += (ii + "," + o.value + ";");
					count++;
				}
			}
	
			if (whereClause != "" && count > 0) {
				document.infoLookupForm.searchWhere.value = whereClause;
			}	
		}
	}
}

function initProgress() {
	Element.show('progressMsg');
}

function resetProgress() {
	Effect.Fade('progressMsg');
}
function checkboxChanged(chkboxObj) {
	if (chkboxObj != null) {
		if (chkboxObj.checked) {
			chkboxObj.value = "Y";
		} else {
			chkboxObj.value = "N";
		}
	}
}
