<!--
var marketingPrefixRE = /[a-zA-Z]{3}\-/;
var marketingPrefixAVERE = /[a-zA-Z]{2}\-/;
var marketingPrefixAVERE2 = /[a-zA-Z]{3}/;
var productNumberRE = /[a-zA-Z]{0,1}\d+\-?\d+[a-zA-Z]{0,}/;
var aveProductNumberSingleLetter = /[a-zA-Z]{0,1}\d+\-?\d+[a-zA-Z]{1}/;
var aveProductNumberDoubleLetter = /[a-zA-Z]{0,1}\d+\-?\d+[a-zA-Z]{2}/;

function doOneClickSearch()
{  
  if (document.search.search_criteria.value == "")
    return false;
  var search_name = document.search.search_criteria.value;
  var mktngPrefix 
      mktngPrefix = search_name.match(marketingPrefixRE);
      if (mktngPrefix != null && mktngPrefix.length > 0)
      {
        if (search_name.charAt(3) == '-')
        {
          search_name = search_name.substring(4);
        }
        if (search_name.charAt(2) == '-')
        {
          search_name = search_name.substring(3);
        }
      }
	var productNumber = search_name.match(productNumberRE);
  if (productNumber != null && productNumber.length > 0)
  {
    search_name = search_name.split('-').join("");
  }
  var arry = search_name.split('<sup>?</sup>');
  search_name = arry.join(" ");
  arry = search_name.split('<sup>&reg;</sup>');
  search_name = arry.join(" ");
  arry = search_name.split('?');
  search_name = arry.join(" ");
  arry = search_name.split('?s');
  search_name = arry.join(" ");
  document.search.search_criteria.value = search_name;

  document.search.method = "get";
  return true;
}


function doSearch()
{
  if (document.search.search_criteria.value == "")
    return false;
  if(navigator.appName == "Netscape")
  {
    if(document.search.user_id.value.length < 6) //the user_id is "" or NULL
      document.search.user_id.value="";
    if(document.search.cust_no.value.length < 3) //the cust_no is "" or NULL
      document.search.cust_no.value="";
    search_name = document.search.search_criteria.value;
    ary = search_name.split(' ');
    search_name = ary[0];
    for(i=1; i<ary.length; i++)
    {
      search_name = search_name + "_" + ary[i];
    }
    document.search.search_criteria.value = search_name;
  }

  search_name = document.search.search_criteria.value;
  search_name = search_name.split('<sup>?</sup>');
  search_name = search_name[0];
  search_name = search_name.split('<sup>&reg;</sup>');
  search_name = search_name[0];
  document.search.search_criteria.value = search_name;
  document.search.method = "get";
  domain = document.domain;
  domain = domain.toLowerCase();

  if (document.search.search_type.selectedIndex == 0)
  {
    document.search.template.value = "search_results_i";
    document.search.tran_id.value = 5;
    return true;
  }
  else if (document.search.search_type.selectedIndex == 1)
  {
    document.search.template.value = "search_results_p";
    document.search.tran_id.value = 7;
    return true;
  }
  else if (document.search.search_type.selectedIndex == 2)
  {
    document.search.template.value = "search_results_i";
    document.search.tran_id.value = 6;
    return true;
  }
  else if (document.search.search_type.selectedIndex == 3)
  {
    document.search.template.value = "search_results_v";
    document.search.tran_id.value = 4;
    return true;
  }
  else if (document.search.search_type.selectedIndex == 4)
  {
    var a = document.URL;
    a = a.substring(0, a.indexOf(".com")+4);
    var b = "&cust_no=" + document.search.cust_no.value + 
      "&user_id=" + document.search.user_id.value + 
      "&ship_no=" + document.search.ship_no.value;
    var c = document.search.search_criteria.value;

    while(c.substring(0,1) == "0")
      c = c.substring(1);
    var pgno = parseInt(c); 
    if (isNaN(pgno))
    {
      if (domain.indexOf('bfeonline') != -1)
        window.location=a + "/ecommerce/eComm?template=iCatalog_bfe/t1" + b;
      else
        window.location=a + "/ecommerce/eComm?template=iCatalog/t1" + b;
    }
    return false;
  }
  else return false;
}

function NetscapeFits() 
{ 
    /**********
    if(navigator.appName == "Netscape")
    {
        for (var i=13; i< document.links.length-14; i+=1)
        {
             var linktext = new String(document.links[i]);
             var idx1 = linktext.indexOf("prod_name");
             var idx2 = linktext.indexOf(" ", idx1);

             if (idx1 >= 0 || idx2 >= 0 )
             {
                 ary = linktext.split(' ');
                 linktext = ary[0];
                 for(j=1; j<ary.length; j++)
                 {
                     linktext = linktext + "_" + ary[j];
                 }
                 document.links[i].href = linktext;              
             }
         }
    }
    **********/
}

function showDiscount(discount_flag, company_name, template, rep_name, rep_email, rep_phone, rep_extension) 
{
  if (discount_flag == "true")
  {
    var domain = document.domain;  
    domain = domain.toLowerCase();
    
    var mvp = "";
    if (domain.indexOf("chdist") != -1 || domain.indexOf("bfeonline") != -1)
      mvp = " MVP member";
      
    if  (template == "vieworder")
    {
      document.write("<table border='0' cellpadding='0' cellspacing='0' width='600'><tr><td align='left'><font face='Arial, Impact' size='2' color='#CC0000'>Welcome" + mvp + ", <font color=blue>" + document.view_order1.user_name.value + "</font> !</font> &nbsp;&nbsp;");
      document.write("<font face='Arial, Impact' size='2' color='#CC0000'>Your <font color=blue><u>" + company_name + "</u></font> discount has been incorporated into net pricing.</font> &nbsp;&nbsp;");
      document.write("<font face='Arial, Impact' size='2' color='#CC0000'>Your personal representative is <font color='blue'><u>" + rep_name + "</u></font> at <font color='blue'>1-" + rep_phone + rep_extension + "</font> or <a href='mailto:" + rep_email + "'><font size=2, face='Arial, Helvetica, sans-serif' color='blue'>" + rep_email + "</font></a>.</font> &nbsp;&nbsp;");
      document.write("<font face='Arial, Impact' size='2' color='#CC0000'>Thank you for your business !</font></td</tr></table>");
    }
    else if (template == "product_group")
    {
      document.write("<table border='0' cellpadding='0' cellspacing='0' width='600'><tr><td align='left'><font face='Arial, Impact' size='2' color='#CC0000'>Welcome" + mvp + ", <font color=blue>" + document.prod_group.user_name.value + "</font> !</font> &nbsp;&nbsp;");
      document.write("<font face='Arial, Impact' size='2' color='#CC0000'>Your <font color=blue><u>" + company_name + "</u></font> discount has been incorporated into net pricing.</font> &nbsp;&nbsp;");
      document.write("<font face='Arial, Impact' size='2' color='#CC0000'>Your personal representative is <font color='blue'><u>" + rep_name + "</u></font> at <font color='blue'>1-" + rep_phone + rep_extension + "</font> or <a href='mailto:" + rep_email + "'><font size=2, face='Arial, Helvetica, sans-serif' color='blue'>" + rep_email + "</font></a>.</font> &nbsp;&nbsp;");
      document.write("<font face='Arial, Impact' size='2' color='#CC0000'>Thank you for your business !</font></td</tr></table>");
    }
    else
    {
      document.write("<font face='Arial, Impact' size='2' color='#CC0000'>Your <font color=blue><u>" + company_name + "</u></font> discount has been incorporated into net pricing.</font>");
    }
  }
}

function indexMessage()   //  For C&H and BFE index message displaying
{
  //Check for login
  if ((document.search.cust_no.value == "?") || (document.search.cust_no.value == "") || (document.search.cust_no.value == "0"))
  {
    var domain = document.domain;  
    domain = domain.toLowerCase();
    if (domain.indexOf("chdist") != -1)
      document.write("<br>&nbsp;&nbsp;&nbsp;To login or register, please click <a class='LinkBlue1' href='eComm?template=login&cust_no=?&user_id=?&ship_no=?'>here</a>.");
    else if (domain.indexOf("bfeonline") != -1)
      document.write("<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;To login or register please <a class='button5' href='eComm?template=login&cust_no=?&user_id=?&ship_no=?'>click here &gt;&gt;</a>");
  }
}

function checkDozierNumber()
{
  if (document.searchdoziernumber.dozier_sku.value == "")
    return false;

  var dozier_sku = document.searchdoziernumber.dozier_sku.value;

  // Remove '-'
  var a = dozier_sku.split('-');
  dozier_sku = a[0];
         for(i=1; i<a.length; i++)
    dozier_sku = dozier_sku + "" + a[i];    

  // Remove ' '
    while ((dozier_sku.substring(0,1) == ' ') || (dozier_sku.substring(0,1) == '\n') || (dozier_sku.substring(0,1) == '\r'))
    {
        dozier_sku = dozier_sku.substring(1,dozier_sku.length);
    }

    // Remove trailing spaces and carriage returns
   while ((dozier_sku.substring(dozier_sku.length-1,dozier_sku.length) == ' ') || (dozier_sku.substring(dozier_sku.length-1,dozier_sku.length) == '\n') || (dozier_sku.substring(dozier_sku.length-1,dozier_sku.length) == '\r'))
    {
        dozier_sku = dozier_sku.substring(0,dozier_sku.length-1);
    }


  if (dozier_sku.length == 0)
    return false;
    
  //alert(dozier_sku);
  
  // check whether a valid dozier model number
  var dz_itemNo_format1=new RegExp("^[a-zA-Z]{1}[0-9]{3,4}[a-zA-Z]{0,2}$");  //  a1200 or a120BL
  if ( !(dz_itemNo_format1.test(dozier_sku)) )
  {
    alert ("Please enter a valid Dozier Model Number!");
    return false;
  }
  else
    document.searchdoziernumber.dozier_sku.value = dozier_sku;
    
  return true;
}
//-->

