
function C_Info(name, type, nullable, colLength, precision, scale,
		bPrimaryKey, bUniqueConstraint, tableObj) {
	this.name = name;
	this.type = type;
	this.nullable = nullable;
	this.colLength = colLength;
	this.precision = precision;
	this.scale = scale;
	this.bPrimaryKey = bPrimaryKey;
	this.bUniqueConstraint = bUniqueConstraint;
	this.tableObj = tableObj;
}


function pageColumn(htmlName, sqlName, colInfo, userName) {
	this.htmlName = htmlName;
	this.sqlName = sqlName;
	this.colInfo = colInfo;
	this.userName = userName;
}


function genStringType(form, name, value, stype, htmlName, userName) {

	var st = "";
	switch (stype) {
		case "Begins with":
			st = name + " LIKE '" + value + "%'";
			break;
		case "Contains":
			st = name + " LIKE '%" + value + "%'";
			break;
		case "Ends with":
			st = name + " LIKE '%" + value + "'";
			break;
		case "Equals One":
			st = name + " = '" + value + "'";
			break;
		case "Equals Many":
			var nItems = 0;
			for (var i=0; i < form[htmlName].options.length; i++) {
				if (form[htmlName].options[i].selected) {
					if (nItems == 1) {
						st = "(" + st;
						st += " OR ";
					}
					else if (nItems > 1)
						st += " OR ";
					nItems++;
					var val = form[htmlName].options[i].value;
					if (val.length == 0)
						val = form[htmlName].options[i].text;
					val = cleanUp(val)
					val = hSQ(val);
					st += name + " = '" + val + "'";				
				}
			}
			if (nItems > 1)
				st += ")";
			break;
		default:
			break;
	}
	return st;
}


function getIntType(form, name, value, stype, htmlName, userName) {
	var st = null;
	switch (stype) {
		case "Equals":
			st = name + " = " + value;
			break;
		case "Less than":
			st = name + " < " + value;
			break;
		case "Greater than":
			st = name + " > " + value;
			break;
		case "Between":
			var val2 = form[htmlName + "_2"].value;
			if (val2.length == 0) {
				alert("You must specify a value for the second item in the\n" +
						" between data for name: " + userName);
				st = null;
			}
			else {
				val2 = hSQ(val2);
				st = name + " BETWEEN " + value + " AND " + val2;
			}
			break;
		default:
			st = null;
			break;
	}
	return st;
}


function getDateType(form, name, value, stype, htmlName, userName) {
	var st = null;
	switch (stype) {
		case "Equals":
			st = name + " = '" + value + "'";
			break;
		case "Before":
			st = name + " < '" + value + "'";
			break;
		case "After":
			st = name + " > '" + value + "'";
			break;
		case "Between":
			var val2 = form[htmlName + "_2"].value;
			if (val2.length == 0) {
				alert("You must specify a value for the second item in the\n" +
						" between data for name: " + userName);
				st = null;
			}
			else
				st = name + " BETWEEN '" + value + "' AND '" + val2 +
						"'";
			break;
		default:
			st = null;
			break;
	}
	return st;
}


function generateWhere(form, pArr) {
	var st = "";
	var idx, pc;
	for (idx in pArr) {
		pc = pArr[idx];
		if (typeof(form[pc.htmlName]) != "undefined") {
			var value;
			var htmlType = form[pc.htmlName].type;
			var ii = form[pc.htmlName + "_Search_Type"].selectedIndex;
			var searchType = "";
			if (ii >= 0)
				searchType = form[pc.htmlName + "_Search_Type"].options[ii].text;
			// See if this is a radio box.
			if (typeof(htmlType) == "undefined") {
				if (typeof(form[pc.htmlName][0]) != "undefined") {
					if (form[pc.htmlName][0].type == "radio") {
						for (var i=0; i < form[pc.htmlName].length; i++) {
							if (form[pc.htmlName][i].checked) {
								value = form[pc.htmlName][i].value;
								value = cleanUp(value);
							}
						}
					}
				}
			}
			else if (htmlType == "select-one" || htmlType == "select-multiple") {
				var idx = form[pc.htmlName].selectedIndex;
				if (idx < 0)
					value = "";
				else {
					value = form[pc.htmlName].options[idx].value;
					if (value.length == 0)
						value = form[pc.htmlName].options[idx].text;
					value = cleanUp(value);
				}
			}
			else if (typeof(form[pc.htmlName].value) == "undefined") {
				alert("Cannot lookup value for item: " + pc.userName);
				continue;
			}
			else {
				value = form[pc.htmlName].value;
				value = cleanUp(value);
				form[pc.htmlName].value = value;
			}
			if (value == "")
				continue;
			value = hSQ(value);
			 //alert("name = " + pc.htmlName+ " value = " + value);
			if (st != "")
				st += " AND ";
			switch (pc.colInfo.type) {
				case 0:  // String type.
					var stTmp = genStringType(form, pc.sqlName, value, searchType,
							pc.htmlName, pc.userName);
					if (stTmp == null)
						return null;
					st += stTmp;
					break;
				case 1:  // Integer type.
				case 2:  // Float type.
				case 3:  // Numeric type.
					var stTmp = getIntType(form, pc.sqlName, value, searchType,
							pc.htmlName, pc.userName);
					if (stTmp == null)
						return null;
					st += stTmp;
					break;
				case 4:  // Date type.
					var stTmp = getDateType(form, pc.sqlName, value, searchType,
							pc.htmlName, pc.userName);
					if (stTmp == null)
						return null;
					st += stTmp;
					break;
				default:
					alert("Form item " + pc.userName + 
							" has an unknown column type = " +
							pc.colInfo.colType);
					return null;
					break;
			}  // End switch.
		}
	}
	return st;
}


function convertFromStar(stInput) {
	var re = /%/g;
	var st = stInput.replace(re, "[%]"); 
	re = /_/g;
	st = st.replace(re, "[_]");
	re = /[*]/g;
	var st = st.replace(re, "%25");
	re = /[?]/g;
	st = st.replace(re, "_");
	return st;
}


function generateTextOnlyWhere(form, pArr) {
	var st = "";
	var idx, pc, isMultiple;
	for (idx in pArr) {
		isMultiple = false;
		pc = pArr[idx];
		if (typeof(form[pc.htmlName]) != "undefined") {
			var value;
			var htmlType = form[pc.htmlName].type;
			// See if this is a radio box.
			if (typeof(htmlType) == "undefined") {
				if (typeof(form[pc.htmlName][0]) != "undefined") {
					if (form[pc.htmlName][0].type == "radio") {
						for (var i=0; i < form[pc.htmlName].length; i++) {
							if (form[pc.htmlName][i].checked) {							
								value = form[pc.htmlName][i].value;
								value = cleanUp(value);
							}
							else
								value = "";
						}
					}
				}
			}
			else if (htmlType == "select-one" || htmlType == "select-multiple") {
				var idx = form[pc.htmlName].selectedIndex;
				if (idx < 0)
					value = "";
				else {
					value = form[pc.htmlName].options[idx].value;
					if (value.length == 0)
						value = form[pc.htmlName].options[idx].text;
					else {
						// Handle special case
						if (pc.htmlName != 'ec_credit_cards_accepted') {
							// handle multiple options selected
							isMultiple = true;
							value = "";
							for (var i=0; i < form[pc.htmlName].length; i++) {
								if (form[pc.htmlName][i].selected) {
									if (value != "") value += ",";
									value += form[pc.htmlName].options[i].value;
									//if (i < form[pc.htmlName].length-1 && form[pc.htmlName].length > 0 
									//	&& form[pc.htmlName].size >0  && htmlType == "select-multiple")
									//	value += ","								
								}
							}
							
							//
						}
						else {
							isMultiple = true;
							value = "";							
							for (var i=0; i < form[pc.htmlName].length; i++) {
								if (form[pc.htmlName][i].selected) 
									value += form[pc.htmlName].options[i].value + "%";								
							}
							
						}
					}					
					value = cleanUp(value);												
				}
			}
			else if (typeof(form[pc.htmlName].value) == "undefined") {
				alert("Cannot lookup value for item: " + pc.userName);
				continue;
			}
			else {
				value = form[pc.htmlName].value;
				value = cleanUp(value);
				form[pc.htmlName].value = value;
			}
			if (value == "")
				continue;
			value = hSQ(value);
			//alert("name = " + pc.sqlName + " value = " + value + " type = " + pc.colInfo.type + " length = " + pc.colInfo.colLength);
			if (st != "")
				st += " AND ";
			switch (pc.colInfo.type) {
				case 0:  // String type.
					var iWild = value.indexOf("*");
					if (iWild == -1)
						iWild = value.indexOf("?");
					if (iWild == -1)
						iWild = value.indexOf("[");
					if (iWild != -1) {
						value = convertFromStar(value);
						st += pc.sqlName + " LIKE '" + value + "'";
					}
					else
						// Handle special case
						if (pc.htmlName == 'ec_credit_cards_accepted') 
							st += pc.sqlName + " like '" + value + "'";
						else if (pc.colInfo.colLength == 2147483647) {
							st += pc.sqlName + " like '%" + value + "%'"; // alert("Search on text ... " + st + " name = " + pc.sqlName);
						}
						else if(pc.sqlName == 'company_name' || pc.sqlName == 'title' || pc.sqlName == 'department' || pc.sqlName == 'street1' || pc.sqlName =='street2' ||
							pc.sqlName == 'city' || pc.sqlName == 'billto_first_name' || pc.sqlName == 'billto_last_name' || pc.sqlName == 'billto_middle_name' ||
							pc.sqlName == 'udf_varchar_1' || pc.sqlName == 'udf_varchar_2' || pc.sqlName == 'udf_varchar_3' || pc.sqlName == 'udf_varchar_4'||pc.sqlName == 'udf_varchar_5' ||
							pc.sqlName == 'billto_street1' || pc.sqlName == 'billto_street2' || pc.sqlName == 'billto_city' || pc.sqlName == 'nick_name' || pc.sqlName =='other_state' ||
							pc.sqlName == 'billto_other_state' || pc.sqlName == 'billto_company' || pc.sqlName == 'password_security_ans'){
														
							st += pc.sqlName + " = N'" + value + "'";
						}
											
						else
							st += pc.sqlName + " = '" + value + "'";
					break;
				case 1:  // Integer type.					
				case 2:  // Float type.
				case 3:  // Numeric type.
					var iWild = value.indexOf("*");
					if (iWild == -1)
						iWild = value.indexOf("?");
					if (iWild == -1)
						iWild = value.indexOf("[");
					if (iWild != -1) {
						value = convertFromStar(value);
						st += pc.sqlName + " LIKE '" + value + "'";
					}
					else {
						// Handle "inactive" checkbox
						if ((pc.htmlName == "is_invisible" && !form[pc.htmlName].checked) ||
							(pc.htmlName == "active" && !form[pc.htmlName].checked) ||
							(pc.htmlName == "r_active" && !form[pc.htmlName].checked) ||
							(pc.htmlName == "is_sub_schedule" && !form[pc.htmlName].checked) ||
							(pc.htmlName == "display_status" && !form[pc.htmlName].checked) ||
							(pc.htmlName == "auto_add_subschedules" && !form[pc.htmlName].checked) ||
							(pc.htmlName == "is_online" && form[pc.htmlName].value == "0") ||
							(pc.htmlName == "is_online_host" && form[pc.htmlName].value == "0") ||
							(pc.htmlName == "key_enabled" && !form[pc.htmlName].checked) ||
							(pc.htmlName == "migrated" && form[pc.htmlName].value == "0") ||
							(pc.htmlName == "used_in_schedule_access" && form[pc.htmlName].value == "0") ||
							(pc.htmlName == "used_in_manager" && form[pc.htmlName].value == "0") ||
							(pc.htmlName == "used_in_schedule_pricing" && form[pc.htmlName].value == "0") ||
							(pc.htmlName == "used_in_attendee_group" && form[pc.htmlName].value == "0") ||
							(pc.htmlName == "enable_account" && form[pc.htmlName].value == "0") ||
							(pc.htmlName == "auto_set_payment_received" && form[pc.htmlName].value == "0") ||
							(pc.htmlName == "do_not_contact" && form[pc.htmlName].value == "0") ||
							(pc.htmlName == "lump_transaction" && form[pc.htmlName].value == "0") ||
							(pc.htmlName == "tax_exempt" && !form[pc.htmlName].checked) ||
							(pc.htmlName == "attendee_project_code_required" && !form[pc.htmlName].checked) ||
							(pc.htmlName == "admin_project_code_required" && !form[pc.htmlName].checked) ||
							(pc.htmlName == "enable_new_user_notification_superuser" && !form[pc.htmlName].checked) ||
							(pc.htmlName == "taxable" && !form[pc.htmlName].checked) ||
							(pc.htmlName == "tax_shipto" && !form[pc.htmlName].checked) ||
							(pc.htmlName == "use_event_business_unit" && !form[pc.htmlName].checked)||
							(pc.htmlName == "use_event_duration" && !form[pc.htmlName].checked)||
							(pc.htmlName == "scorm_high_score_feature" && !form[pc.htmlName].checked)||
							(pc.htmlName == "locked" && form[pc.htmlName].value == "0")||
							(pc.htmlName == "expired" && !form[pc.htmlName].checked)||
							(pc.htmlName == "lock" && !form[pc.htmlName].checked)||
							(pc.htmlName == "is_temp_password" && !form[pc.htmlName].checked)
							
							)
							st += "(" + pc.sqlName + " is null or " + pc.sqlName + " = 0)";
						else {
							if (!isMultiple)
								st += pc.sqlName + " = " + value ;
							else
								st += pc.sqlName + " in (" + String(value) + ")" ;
						}
								
					}
					break;
				case 4:  // Date type.
					st += pc.sqlName + " = '" + value + "'";
					break;
				default:
					alert("Form item " + pc.userName + 
							" has an unknown column type = " +
							pc.colInfo.colType);
					return null;
					break;
			}  // End switch.
		}
	}
	return st;
}


function trim(argstring) {
	var return_string = new String(argstring);
	var begin = 0;
	var end = return_string.length;
	while (begin < end)	{
		var ich = return_string.charCodeAt(begin);
		if (ich > 32 && ich != 160)
			break;
	    begin++;
	}
	while (end > begin)	{
		var ich = return_string.charCodeAt(end-1);
		if (ich > 32 && ich != 160)
	        break;
	    end--;
	}
	return return_string.substring(begin, end);
}


function cleanUp(st) {
	if (typeof(st) != "string")
		return st;
	if (st == null || st == "")
		return "";
	st = trim(st);
	if (st == null || st == "")
		return "";
	return st;
}


function verifyInt(name, value, nullable, precision) {
	if (nullable == 0 && (value == "" || value == "-" || value == "+")) {
		alert("Form item " + name + " must be filled in.");
		return false;
	}
	var nprecision = precision;
	var idx = value.indexOf("-");
	if (idx == 0) {
		nprecision++;
		idx = 1;
	}
	else if (idx == -1)
		idx = 0;
	else {
		alert("Form item " + name + 
			" may only have the '-' character as the first character.");
		return false;
	}
	if (value.length > nprecision) {
		alert("Form item " + name + " is too long, maximum numeric digits = " + precision
			+ ".");
		return false;
	}
	if (value > 2147483647) {
		alert("Form item " + name + " is too big, maximum allowed value 2147483647.");
		return false;
	}
	if (value < -2147483647) {
		alert("Form item " + name + " is too little, minimum allowed value -2147483647.");
		return false;
	}
	for (var i=idx; i < value.length; i++) {
		var ch = value.substring(i, i + 1);
		if (ch < "0" || ch > "9") {
			alert("Form item " + name + " may only contain numeric characters.");
			return false;
		}
	}
	return true;
}


function verifyNumeric(name, value, nullable, precision, scale) {
	if (isNaN(value)) {
		alert("Form item " + name + " is not a number");
		return false;
	}
	if (nullable == 0 && (value == "" || value == "-" || value == "+")) {
		alert("Form item " + name + " must be filled in.");
		return false;
	}
	var nprecision = precision;
	var idx = value.indexOf("-");
	if (idx == 0) {
		nprecision++;
		idx = 1;
	}
	else if (idx == -1)
		idx = 0;
	else {
		alert("Form item " + name + 
			" may only have the '-' character as the first character.");
		return false;
	}
	var dot = value.indexOf(".");
	if (dot != -1)
		nprecision++;
	if (value.length > nprecision) {
		alert("Form item " + name + " is too long, maximum numeric digits = " + precision
			+ ".");
		return false;
	}
	if (dot != -1) {
		var nscale = value.length - dot - 1;
		// alert("nscale = " + nscale);
		if (nscale > scale) {
			alert("Form item " + name + " has a maximum of " + scale +
				" digits to the right of the decimal point.");
			return false;		
		}
	}
	for (var i=0; i < value.length; i++) {
		var ch = value.substring(i, i + 1);
		if (ch < "0" || ch > "9") {
			if (ch != "-" && ch != "." && ch != "+") {
				alert("Form item " + name + " may only contain numeric characters.");
				return false;
			}
		}
	}

	return true;
}
function verifyNumeric2(name, value, nullable, precision, scale) {
	if (isNaN(value)) {
		alert("Form item " + name + " is not a number");
		return false;
	}
	if (nullable == 0 && (value == "" || value == "-" || value == "+")) {
		alert("Form item " + name + " must be filled in.");
		return false;
	}
	var nprecision = precision;
	var idx = value.indexOf("-");
	if (idx == 0) {
		nprecision++;
		idx = 1;
	}
	else if (idx == -1)
		idx = 0;
	else {
		alert("Form item " + name + 
			" may only have the '-' character as the first character.");
		return false;
	}
	var dot = value.indexOf(".");
	if (dot != -1)
		nprecision++;
	var mainvalue;
	if (dot != -1) {
		var nscale = value.length - dot - 1;
		// alert("nscale = " + nscale);
		if (nscale > scale) {
			alert("Form item " + name + " has a maximum of " + scale +
				" digits to the right of the decimal point.");
			return false;		
		}
		
		mainvalue=value.substring(0,dot);
		nprecision=nprecision-1;
		
	}
	else
	{
		mainvalue=value;
		
	}
	if (mainvalue.length > (nprecision-scale)) {
		alert("Form item " + name + " is too long, maximum numeric digits = " + precision
			+ "\n("+ (precision-scale) + " digits to the left and  "+scale+" digits to the right of the decimal point).");
		return false;
	}
	for (var i=0; i < value.length; i++) {
		var ch = value.substring(i, i + 1);
		if (ch < "0" || ch > "9") {
			if (ch != "-" && ch != "." && ch != "+") {
				alert("Form item " + name + " may only contain numeric characters.");
				return false;
			}
		}
	}

	return true;
}


function verifyString(name, value, nullable, length) {
	if (nullable == 0 && value == "") {
		alert("Form item " + name + " must be filled in.");
		return false;
	}
	if (value.length > length) {
		alert("Form item " + name + " is too long, maximum = " + length
			+ " characters.");
		return false;
	}
	return true;
}

// Return true if this float type is OK (only 'JScript' float types are supported).
function verifyFloat(name, value, nullable) {
	if (nullable == 0 && (value == "" || value == "-" || value == "+")) {
		alert("Form item " + name + " must be filled in.");
		return false;
	}
	var fChk = parseFloat(value);
	if (isNaN(fChk))
		return false;
	return true;
}

// Return true if the Date type is OK.  We only accept '/', '-', ':' and space as
// non-numeric characters in the date string.
function verifyDate(name, value, nullable) {
	if (nullable == 0 && (value == "" || value == "-")) {
		alert("Form item " + name + " must be filled in.");
		return false;
	}
	if (value.length == 0)
		return true;
	var ch = value.substring(0, 1);
	if (ch < "0" || ch > "9") {
		alert("Form item " + name + " must start with a numeric digit, not: " + ch
			+ ".");
		return false;
	}
	var iDigits = 0;
	var iNonDigits = 0;
	var bLastWasSpace = false;
	var bLastColon = false;
	for (var i=0; i < value.length; i++) {
		ch = value.substring(i, i + 1);
		if (ch < "0" || ch > "9") {
			if ((ch == "/") || (ch == ":") || (ch == "-") || (ch == " ")) {
				iNonDigits++;
				if (iNonDigits == 1) {
					if (iDigits > 2) {
						alert("Form item " + name + " has too many numeric digits" +
								" in the first field.");
						return false;
					}
				}
				else if (iNonDigits == 2) {
					if (iDigits > 2) {
						alert("Form item " + name + " has too many numeric digits" +
								" in the second field.");
						return false;
					}
				}
				else if (iNonDigits == 3) {
					if (ch == " ") {
						if (iDigits > 4) {
							alert("Form item " + name + " can only have up to four" +
									" numeric digits in the year");
							return false;
						}
						bLastWasSpace = true;
					}
					else {
						alert("Form item " + name + " can only have spaces between" +
								" the date and time strings.");
						return false;					
					}
				}
				else {
					if (ch == " " && bLastWasSpace == true)
						continue;
					else if (ch == ":") {
						if (iDigits > 2) {
							alert("Form item " + name + " can only have up to two" +
									" numeric digits in the hour field.");
							return false;					
						}
						bLastColon = true;
					}
					else {
						alert("Form item " + name + " invalid character = " + ch +
								" found in the time string.");
						return false;
					}
				}
				iDigits = 0;
				continue;
			}
			alert("Form item " + name + " contains an invalid date/time character = " +
				ch + ".");
			return false;
		}
		else {
			iDigits++;
		}
	}
	if (bLastColon) {
		if (iDigits > 2) {
			alert("Form item " + name + " can only have up to two" +
					" numeric digits in the minutes field.");
			return false;					
		}
	}
	else {
		if (iDigits > 4) {
			alert("Form item " + name + " can only have up to four" +
					" numeric digits in the years field.");
			return false;					
		}
	}
	return true;
}


function verifyPage(form, pArr, bAllowBlank) {

	for (var idx in pArr) {
		var pc = pArr[idx];
		// alert("pc.htmlName = " + pc.htmlName);
		if (typeof(form[pc.htmlName]) != "undefined") {
			var value;
			var htmlType = form[pc.htmlName].type;
			// See if this is a radio box.
			if (typeof(htmlType) == "undefined") {
				if (typeof(form[pc.htmlName][0]) != "undefined") {
					if (form[pc.htmlName][0].type == "radio") {
						for (var i=0; i < form[pc.htmlName].length; i++) {
							if (form[pc.htmlName][i].checked) {
								value = form[pc.htmlName][i].value;
								value = cleanUp(value);
								form[pc.htmlName][i].value = value;
							}
						}
					}
				}
			}
			else if (htmlType == "select-one" || htmlType == "select-multiple") {
				var idx = form[pc.htmlName].selectedIndex;
				if (idx < 0)
					value = "";
				else {
					value = form[pc.htmlName].options[idx].value;
					if (value.length == 0) {
						value = form[pc.htmlName].options[idx].text;
						value = cleanUp(value);
						form[pc.htmlName].options[idx].text = value;
					}
					else {
						value = cleanUp(value);
						form[pc.htmlName].options[idx].value = value;
					}
				}
			}
			else if (typeof(form[pc.htmlName].value) == "undefined") {
				alert("Cannot lookup value for item: " + pc.userName);
				continue;
			}
			else {
				value = form[pc.htmlName].value;
				value = cleanUp(value);
				form[pc.htmlName].value = value;
			}
			
			//alert("name = " + pc.htmlName+ " value = " + value + " type = " +
			//		pc.colInfo.type);
			
			if (bAllowBlank && value == "")
				continue;
			var ok = false;
			switch (pc.colInfo.type) {
				case 0:  // String type.
					ok = verifyString(pc.userName, value, 
							pc.colInfo.nullable, pc.colInfo.colLength);
					if (!ok)
						return false;
					break;
				case 1:  // Integer type.
					ok = verifyInt(pc.userName, value,
							pc.colInfo.nullable, pc.colInfo.precision);
					if (!ok)
						return false;
					break;
				case 2:  // Float type.
					ok = verifyFloat(pc.userName, value,
							pc.colInfo.nullable);
					if (!ok)
						return false;
					break;
				case 3:  // Numeric type.
					ok = verifyNumeric(pc.userName, value,
							pc.colInfo.nullable, pc.colInfo.precision,
							pc.colInfo.scale);
					if (!ok)
						return false;
					break;
				case 4:  // Date type.
					ok = verifyDate(pc.userName, value,
							pc.colInfo.nullable);
					if (!ok)
						return false;
					break;
				default:
					alert("Form item " + pc.userName + 
							" has an unknown column type = " +
							pc.colInfo.colType);
					return false;
					break;
			}  // End switch.
		}
	}
	return true;
}


function hSQ(st) {
	if (typeof(st) != "string")
		return st;
	if (st == null)
		return st;
	var nst = "";
	var idx = st.indexOf("'");
	var old_idx = 0;
	if (idx == -1)
		return st;
	while (idx != -1) {
		nst += st.substring(old_idx, idx + 1);
		nst += "'";
		old_idx = idx + 1;
		if (idx >= st.length)
			idx = -1;
		else
			idx = st.indexOf("'", old_idx);
	}
	if (old_idx < st.length)
		nst += st.substring(old_idx, st.length);
	return nst;
}


function checkForSearchTypeChange(selList, oldVal) {
	var idx = selList.selectedIndex;
	var curVal = selList.options[idx].text;
	var doRepost = false;
	if (curVal == "Equals One" || curVal == "Equals Many" || curVal == "Between") {
		doRepost = true;
	}
	else if (oldVal == "Equals One" || oldVal == "Equals Many" || oldVal == "Between") {
		doRepost = true;
	}
	if (doRepost)
		rePost(selList.form);
	return;
}


function rePost(f) {
	f.action = stThisPageName;
	return document.CurrentForm.submit();
}


function goSearch(f) {
	var pArr = pageInfo();
	var isOk = verifyPage(f, pArr, true);
	if (!isOk)
		return false;
	var wh = generateWhere(f, pArr);
	f.strWhere.value = wh;
	return true;
}


function goTextOnlySearch(f) {
	var pArr = pageInfo();
	var isOk = verifyPage(f, pArr, true);
	if (!isOk)
		return false;
	var wh = generateTextOnlyWhere(f, pArr);
//	alert("wh=" + wh);
	f.strWhere.value = wh;
	return true;
}

