function doBCT(index, page, showAll) {
    var myForm = document.form1;
    var url = "";
    if (index < 3) {
        for (var i = 0; i <= index; i++) {
	    url += bct[i][0];
	}
        window.location = url;
        return false;
    }
    //psWorking();
    for (var i = 3; i <= index; i++) {
        url += bct[i][0];
    }
    if (myForm.itemsperpage) {
        url += "&itemsperpage=" + myForm.itemsperpage.value;
    }	
    if (page) {
        url += "&pagenum=" + page;
        if (false) {
	    url +="&searchwithinresults=" + encodeURIComponent(myForm.searchwithinresults.value);
            if (myForm.searchwithin) {
	        var swork = myForm.searchwithin.value;
                //if (swork != "Search Within Results" {
	            url += "&searchwithin=" + encodeURIComponent(swork);
                //}
            }
	}    
    } else {
        url +="&pagenum=1";
    }
    if (showAll) {
        if (showAll == "showAll") {
            url += "&expand=1";
	}
    } else {
        if (myForm.expand.value == "1") {
	    url += "&expand=1";
	}
    }
    if (document.form1.instockonly) {
        if (document.form1.instockonly.checked == true) {
            url +="&instockonly=y";
	}
    }
    if (myForm.qo) {
       url +="&qo=" + encodeURIComponent(myForm.qo.value);
    }
    window.location = url;
    return false;
}

function doURL(page) {
   var myForm = document.cartform;
   var url = myForm.pageURL.value;
   url += "&itemsperpage=" + myForm.itemsperpage.value;
   url += "&pagenum=" + page;
   if (url.indexOf("line=") == -1 && document.form1.line) {
       url += "&line=" + document.form1.line.value;
   }
   if (document.form1.navfamily) {
       url += "&navfamily=" + document.form1.navfamily.value;
   }
   if (url.indexOf("mfg=") == -1 && document.form1.mfg) {
      url += "&mfg=" + document.form1.mfg.value;
   }
   window.location = url;
   return false;
}

function searchWithinBlur() {
    var myForm = document.form1;
    var searchWithin = deleteLeadingSpaces(deleteTrailingSpaces(reduceSpaces(myForm.searchwithin.value)));
    myForm.searchwithin.value = searchWithin;
    if (searchWithin == "") {
        myForm.searchwithin.value = "Search Within Results";
        myForm.refine.disabled = true;
        return;
    }
    if (searchWithin == "Search Within Results") {
        myForm.refine.disabled = true;
        return;
    }
    myForm.refine.disabled = false;
    myForm.refine.focus();
}

function searchWithinFocus() {
    var myForm = document.form1;
    var searchWithin = myForm.searchwithin.value;
    if (searchWithin == "Search Within Results") {
        myForm.searchwithin.value = "";
    }
}

function searchWithinKeyPress() {
    var myForm = document.form1;
    var searchWithin = myForm.searchwithin.value;
    if (searchWithin == "") {
        myForm.refine.disabled = true;
        return;
    }
    if (searchWithin == "Search Within Results") {
        myForm.refine.disabled = true;
        return;
    }
    myForm.refine.disabled = false;
}

function buildURL() {
    var url = "/scripts/cgiip.exe/wa/wcat/r_browse.htm";
    var del = "?";
    if (document.form1.wsc_family) {
       url += del + "cat=" + document.form1.wsc_family.value;
       del = "&";
    }
    if (document.form1.wsc_subfamily) {
       url += del + "sub=" + document.form1.wsc_subfamily.value;
       del = "&";
    }
    if (document.form1.mfgrcode) {
       url += del + "mfg=" + document.form1.mfgrcode.value;
       del = "&";
    }
    if (document.form1.searchwithinprev) {
       url += del + "searchwithin=" + document.form1.searchwithinprev.value;
    }
    return url;
}
function submitmfg() {
    psWorking();
    if (document.form1.mfgrcodes && document.form1.mfgrcodes.value == "REPAIR MFGRS") {
      document.location = buildURL();
      return true;
    }
    document.form1.pagenum.value = 1;
    document.form1.submit();
    return true;
}
function submitsubfamily() {
    psWorking();
    if (document.form1.subfamilycodes && document.form1.subfamilycodes.value == "IR") {
       document.location = buildURL();
       return true;
    }
    if (document.form1.qo) {
       document.form1.qo.value = "";
    }
    document.form1.pagenum.value = 1;
    document.form1.submit();
    return true;
}
function submitter() {
    psWorking();
    if (document.form1.qo) {
       document.form1.qo.value = "";
    }
    document.form1.submit();
    return true;
}

function psWorking() {
    var oObject = document.getElementById("ps-working");
    if (oObject) {
        oObject.innerHTML = '<b><i><font color="#FF0000">Working...</font></i></b>';
    }
}

function myValidator() {
    myForm = document.form1;
    myForm.selseqnum.value = "";
    psWorking();
}
