imageFlag = 0
function setFlag()  {
   imageFlag = 1
}

function searchEntry(event, obj, params)
{
   nullFlag = 1
   
   if (document.forms[0].PRODCAT.selectedIndex > 1) {
     nullFlag = 0
   }
   if (document.forms[0].COMBO1.selectedIndex > 1) {
     nullFlag = 0
   }
   if (document.forms[0].COMBO3.selectedIndex > 1) {
     nullFlag = 0
   }
   if (document.forms[0].TEXTBOX1.value != "") {
     nullFlag = 0
   }
   if (document.forms[0].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 = document.forms[0]
   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(obj) {
   // populate the subcategory combo box based on the selection made
   // in the category box
   var frm = document.forms[0]
   if (obj == "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 {
   	//alert('pre');
     var hid_string = frm.HID_WEB_CAT.value
	 //alert('post');
     timez = smsDcount(field(hid_string,'|',1),'!')
     var pos = 0
     for (var i=1 ; i <= timez ; i++) {
       if (field(field(hid_string,'|',1),'!',i) == obj) {	   
         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
   //history.go(0)
   //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;
}
function openWin(url) {
       winStats='toolbar=no,location=no,directories=no,menubar=no,'
       winStats+='scrollbars=no,width=270,height=300'
       if (navigator.appName.indexOf("Microsoft")>=0) {
          winStats+=',left=360,top=155'
        }else{
          winStats+=',screenX=360,screenY=155'
        }
       floater=window.open(url,"",winStats)     
    }

