imageFlag = 0
function setFlag()  {
   imageFlag = 1
}

function searchEntry(objForm)
{
   nullFlag = 1
   if (objForm.PRODCAT.selectedIndex > 1) {
     nullFlag = 0
   }
   if (objForm.COMBO1.selectedIndex > 1) {
     nullFlag = 0
   }
   if (objForm.COMBO3.selectedIndex > 1) {
     nullFlag = 0
   }
   if (objForm.TEXTBOX1.value != "") {
     nullFlag = 0
   }
   if (objForm.COMBO5.selectedIndex > 0) {
     nullFlag = 0
   }

   // Netscape hack to write HID_WEBLIST now rather than earlier due to Netscape 
   // dumping the value when refeshing to redimension the select list
   frm = objForm
   i = 1
   arWebCat = frm.COMBO1.length
   strWebList = ""
   for (i=1;i<arWebCat;i++)  {
     if (strWebList == "") {
       strWebList += frm.COMBO1.options[i].value 
     }else{
       strWebList += "!" + frm.COMBO1.options[i].value 
     }     
   }
   frm.HID_WEBLIST.value = strWebList   
         
   if (nullFlag == 1)
   {   
     alert("Due to our extensive product line, please make a selection\nfrom one of the lists provided to narrow your search.")
	return false
   } else {
    return true//CallHandler('','',',IC294FRM(`GO`)')
   }
}

function smsDcount(string, delim)  {
  var cnt = 0;
  var val = "" + string;
  if (val.length > 0)   {
    var ind  = 0;
    var next = 0;
    var chr  = "" + delim;
    while ((ind = val.indexOf(chr, next)) >= 0)  {
      cnt++;
      next = ind + chr.length;
      if (next >= val.length)
        break;
    }
    cnt++;
  }
  return ( cnt );
}


function popSubCat(objElement) {
	// populate the subcategory combo box based on the selection made
	// in the category box
   
	var frm = objElement.form
	var objValue = objElement[objElement.selectedIndex].value
   	if (objValue == "ALL") {
    	// changed it from something back to all
		frm.COMBO1.options.length = 1
		frm.COMBO1.options[0].text = '-- All --'
		frm.COMBO1.options[0].value = 'ALL'
		frm.COMBO1.options[0].selected = 1
	}else{
		var hid_string = frm.HID_WEB_CAT.value
	 	timez = smsDcount(field(hid_string,'|',1),'!')
		var pos = 0
		for (var i=1 ; i <= timez ; i++) {
       		if (field(field(hid_string,'|',1),'!',i) == objValue) {	   
         		pos = i
         		break
       		}
     	}
	 
    	// the next line clears all the existing options
     	frm.COMBO1.options.length = 0
     	frm.COMBO1.options[0] = new Option('-- All --','ALL','',1)
     	if (pos == 0) {
       		// this should never happen
       		return
     	}
	 
	 	var strStringToPass = ""
     	timez = smsDcount(field(field(hid_string,'|',2),'!',pos),'~')
     	for (var i=1 ; i <= timez ; i++) {
       		text = field(field(field(hid_string,'|',3),'!',pos),'~',i)
       		value = field(field(field(hid_string,'|',2),'!',pos),'~',i)
	   		// 3/2/01 rer begin
	   		strStringToPass = strStringToPass + text + '~' + value + '|'
	   		// 3/2/01 rer end
       		frm.COMBO1.options[i] = new Option(text,value)
     	}
   	}

	// annoying little trap for Netscape to refresh the page
	if (navigator.appName == "Netscape") {
   		// 3/2/01 rer begin
		//strProductValue = frm.PRODCAT.value
		//location.href = "ic294frm.asp?HID_WEBLIST=" + strStringToPass
		frm.HID_WEBLIST.value = strStringToPass
		frm.action = "ic294frm_adv.asp"
		frm.submit()
   		// 3/2/01 rer end
	}	 
}

function field(textValue,delim,occurance) {
   var startPos = 0
   var endPos = ''     
   var chunk = ''
   for (var i=1; i <= occurance; i++) {
     endPos = textValue.indexOf(delim,startPos)
     if (endPos == -1) {
       // delimeter not found
       endPos = textValue.length
       if (startPos >= textValue.length) {
         // this means that it is past the last field
         chunk = ""
         break
       }
     }
     chunk = textValue.substring(startPos,endPos)
     startPos = endPos + 1
   }
   return chunk;
}
