function DoCustomSearch(
					strPageToRedirectTo,
					strStartingPage,
					strPageSize,
					strTableName,
					strIdFieldName,
					strSortFieldName,
					strSortOrder,
					strSortOrderOverrideClause,
					strSearchFieldName,
					strSearchFieldType,
					strSearchValue,
					strSearchOperator,
					strAllFieldsTableNameForSearch,
					intProductTypeId 
					){

	var strRedirect = strPageToRedirectTo;
	var strNewVal = '';
	var oDDL;
	
	// note:  where clause is built at the server end
	
	strRedirect += '?startingPage=' + strStartingPage;
	strRedirect += '&pageSize=' + strPageSize;
	strRedirect += '&tableName=' + strTableName;
	strRedirect += '&idFieldName=' + strIdFieldName;
	strRedirect += '&sortFieldName=' + strSortFieldName;
	strRedirect += '&sortOrder=' + strSortOrder;
	strRedirect += '&sortOrderOverrideClause=' + strSortOrderOverrideClause;
	strRedirect += '&searchFieldName=' + strSearchFieldName;
	strRedirect += '&searchFieldType=' + strSearchFieldType;
	strRedirect += '&searchValue=' + strSearchValue;
	strRedirect += '&searchOperator=' + strSearchOperator;
	strRedirect += '&allFieldsTableNameForSearch=' + strAllFieldsTableNameForSearch;
	//if (intProductTypeId != 0) {
		strRedirect += '&productType=' + intProductTypeId;
	//}
	strRedirect += '&partNumber=' + CleanUpString(document.getElementById('id_txtPartNumber').value);
	strRedirect += '&description=' + CleanUpString(document.getElementById('id_txtDescription').value);
	strRedirect += '&modelNumber=' + CleanUpString(document.getElementById('id_txtModelNumber').value);
	strRedirect += '&partName=' + CleanUpString(document.getElementById('id_txtPartName').value);

	oDDL = document.getElementById('id_ddlManufacturer');
	strNewVal = oDDL.options[oDDL.selectedIndex].value;
	strRedirect += '&selectedManufacturerIndex=' + strNewVal;
	
	oDDL = document.getElementById('id_ddlPartType');
	strNewVal = oDDL.options[oDDL.selectedIndex].value;
	strRedirect += '&selectedPartTypeId=' + strNewVal;

	switch (intProductTypeId){
		case 0:
			// whole database
			/*
			oDDL = document.getElementById('id_ddlProductTypes');
			strNewVal = oDDL.options[oDDL.selectedIndex].value;
			strRedirect += '&productType=' + strNewVal;
			*/
			break;	
		case 2:
			// crane specific

			oDDL = document.getElementById('id_ddlArea');
			strNewVal = oDDL.options[oDDL.selectedIndex].value;
			strRedirect += '&selectedAreaId=' + strNewVal;


            /* TODO:  when this is uncommented then the corresponding code in Products/Products.aspx.vb must be uncommented also */
			/*
			oDDL = document.getElementById('id_ddlComponent');
			strNewVal = oDDL.options[oDDL.selectedIndex].value;
			strRedirect += '&selectedComponentId=' + strNewVal;
			*/

			break;
		default:
	}

	window.location.href = strRedirect;
	
}

function CleanUpString(strInput){
	return strInput.replace(/'/g, "%27").replace(/&/g, "%26");
}

function ResetSearchFields(intProductTypeId){
	var oDDL;
	
	document.getElementById('id_txtPartNumber').value = '';
	document.getElementById('id_txtDescription').value = '';
	document.getElementById('id_txtModelNumber').value = '';
	document.getElementById('id_txtPartName').value = '';

	oDDL = document.getElementById('id_ddlManufacturer').value = '0';
	oDDL = document.getElementById('id_ddlPartType').value = '0';
	switch (intProductTypeId){
		case 0:
			// whole database
			/*
			oDDL = document.getElementById('id_ddlProductTypes').value = '0';
			*/
			break;
		case 2:
			// crane specific
			oDDL = document.getElementById('id_ddlArea').value = '0';
			//oDDL = document.getElementById('id_ddlComponent').value = '0';
			break;
		default:
	}
}