function displayHintDiv() {
	setVisDisp("hintDiv", getObject("hintDisplay").checked);	
}
function divdisplay() {
	setVisDisp("markdiv", getObject("markcheck").checked);
	setVisDisp("designdiv", getObject("designcheck").checked);
	setVisDisp("goodsdiv", getObject("goodscheck").checked);
	setVisDisp("drawdiv", getObject("drawcheck").checked);
	setVisDisp("ownerdiv", getObject("ownercheck").checked);
	setVisDisp("usclassdiv", getObject("usclasscheck").checked);
	setVisDisp("intgoodsdiv", getObject("intgoodscheck").checked);
}
function updateQueryString() {
	var sections = new Array("mark", "design", "goods", "owner", "draw", "us", "int");
	var index = new Array("BI", "DC", "GS", "OW", "MD", "US", "IC");
	var num = new Array(0, 0, 0, 0, 8, 64, 46);

	var txt = txt1 = txt2 = "";
	var i = 0;
	var first = true;
	while (i < 7) {
		// get the first non-empty section
		while (txt1 == "" && i < 7) {
			if (i > 3) 
				txt1 = updateCheck(sections[i], index[i], num[i]);
			else 
				txt1 = updateQuery(sections[i], index[i]);
			i++;
		}
		// get the second non-empty section
		while (txt2 == "" && i < 7) {
			if (i > 3) 
				txt2 = updateCheck(sections[i], index[i], num[i]);
			else 
				txt2 = updateQuery(sections[i], index[i]);
			i++;
		}
		if (txt1 != "" && txt2 != "") {
			if (!first) txt += " AND ";
			txt += "(" + txt1 + ") AND (" + txt2 + ")";		
		} else if (txt1 != "" && txt2 == "") {
			if (!first) {
				txt += " AND ";
				txt += "(" + txt1 + ")";
			} else {
				txt += txt1;
			}
		}
		first = false;
		txt1 = txt2 = "";
	}
	getFormObject("hiddenform","p_s_ALL").value = txt;
	getForm("hiddenform").submit(); 
	return true;
}
function updateQuery(parentDiv, abbrv) {
	var obj = getObject(parentDiv);
	var num;
	num = (obj.numChild * 1) || 0;
	var txt = '';
	for(var i=0; i < num; i++) {
		if (getObject(parentDiv+i).value != "") {
			if (i!=0) txt += " " + getObject(parentDiv+"Select"+i).value + " ";
			txt += "(" + getObject(parentDiv+i).value + ")";
			txt += "[" + abbrv + "]";
		}
	}
	return txt;
}
function updateCheck(div, abbrv, num) {
	var chk;
	var andOr;
	if (div == "draw") 
		andOr = "or";
	else 
		andOr = getObject(div).value;
		
	var txt = "";
	for (var i=1; i<num; i++) {
		chk = getObject(div+i);
		if (chk.checked) {
			if (txt != "") txt += " "+andOr+" ";
			txt += "("+chk.value+")["+abbrv+"]";
		}
	}
	return txt;
}
function addTerm(parentDiv, add) {
	var html;
	var div;
	var obj;
	obj = getObject(parentDiv);
	var num;
	num = (obj.numChild * 1) || 0;
	if (add == 1) {
		div = document.createElement('div');
		div.id = parentDiv+"Item"+num;
		div.className = "padded";
		if (num != 0) 
			html = '<p><div style="padding-bottom:25px"><div style="width:10%;float:left"><select id="'+parentDiv+'Select'+(num)+'"><option value="and">And</option><option value="or">Or</option></select></div><div style="width:89%;float:left"> Search Term: <input type="text" size="50" id="'+parentDiv+(num)+'"></div></div></p>';	
		else 
			html = '<p><div style="padding-bottom:25px"><div style="width:10%;float:left">&nbsp;</div><div style="width:89%;float:left"> Search Term: <input type="text" size="50" id="'+parentDiv+(num)+'"></div></div></p>';	
		div.innerHTML = html;
		obj.appendChild(div);
		obj.numChild = num + 1;
	} else {
		div = getObject(parentDiv+"Item"+(num-1));
		obj.removeChild(div);
		obj.numChild = num - 1;
	}
	if (obj.numChild <= 1)
	{
		getObject(parentDiv + "Remove").disabled = true;
	} else {
		getObject(parentDiv + "Remove").disabled = false;
	}
	return false;
}