function openWindow() {
  var popupWin = window.open('searchhelp.html', 'newWin','width=475,height=500,resizable=yes,scrollbars=yes');
}

function openCat() {
  var popupCat = window.open('cathelp.html', 'newCat','width=475,height=700,resizable=yes,scrollbars=yes');
}

//Print out options 
function prtOption(aryObjVal, aryObjTxt) {
	var i =0;
	var intCount = aryObjVal.length
	for (i=0; i<intCount; i++) {
		document.writeln("<option value='" + aryObjVal[i] + "'>" + aryObjTxt[i] + "</option>");
	}
	return;
}

//Print out options, set selected by matching a string
function prtOption2(aryObjVal, aryObjTxt, strMatch) {
	var i =0;
	var intCount = aryObjVal.length
	for (i=0; i<intCount; i++) {
		if ( aryObjVal[i].indexOf(strMatch) == 0 ) {
			document.writeln("<option value='" + aryObjVal[i] + "' selected>" + aryObjTxt[i] + "</option>");
		} else {
			document.writeln("<option value='" + aryObjVal[i] + "'>" + aryObjTxt[i] + "</option>");
		}
	}
	return;
}
function prtEmptyOptionList(strFirst) {
	var i;
	document.writeln("<option value=''>" + strFirst + "</option>");
	for (i=0; i<intArySize; i++) {
		document.writeln("<option value=''> </option>");
	}
}

function ClearList(OptionList, TitleName) {	
    OptionList.length = 0;
  	OptionList.options[0] = new Option(TitleName, 'All', true, true);
	return;
}

function LoadList(Index, obj1) {	
	var strTmp = cats[Index];
	var emptyFlag = false;
	if ( strTmp.indexOf(",") < 0 ) {
		strTmp = strTmp + ",";
		emptyFlag = true;
	}
	var CurrentDepts = strTmp.split(',');
	var len = CurrentDepts.length
	if ( emptyFlag ) {
		len = len - 1;
	}
	for (var i=0; i<len; i++) {
		obj1.options[i] = new Option(CurrentDepts[i], CurrentDepts[i], false, false);
	}
	//next line added by JLK to set "Model" to selected state until chosen
 	obj1.options[0].selected = true;
  	return;
}

  
function ChangeList(CalledFromOnLoad, obj, obj1) {	
    	// Clear both of the lists first then add the options if valid Make has been selected. -GDC 
	var CurrItem = obj1.selectedIndex;
	ClearList(obj1, 'All');
	LoadList(obj.selectedIndex, obj1);
	// if ChangeList was called when loading the page then restore the choice that was already here. -GDC 
	if (CalledFromOnLoad == 1) {	
  	  	obj1.selectedIndex = CurrItem;
  	}			
}

function initList(theForm) {
	ChangeList(1, theForm.Sponsor, theForm.Category);
	return;
}  

function reSelectDept(theForm, strMatch) {
	var dCount = theForm.Category.options.length;
	for (var i=0; i<dCount; i++) {
		if ( theForm.Category.options[i].value.indexOf(strMatch) == 0 ) {
			theForm.Category.selectedIndex = i;
			i = dCount;
		}
  	}
	return;
} 