﻿function search(industry,product){
       var industryId=document.getElementById(industry);
       var productName=encodeURIComponent(document.getElementById(product).value);
       var selectText=industryId.options[industryId.selectedIndex].value;
       if(productName.length>0&&selectText.length>0){
       location.href="../Product/Search.aspx?industryId="+selectText+"&productName="+productName;
       }else if(productName.length>0){
         location.href="../Product/Search.aspx?productName="+productName;
       }else if(selectText.length>0){
          location.href="../Product/Search.aspx?industryId="+selectText;
       }
  }

  function searchNews(industry, product) {
      var productName = encodeURIComponent(document.getElementById(product).value);
      if (productName.length > 0) {
          location.href = "../News/NewsList.aspx?typeId=" + industry + "&newsTitle=" + productName;
      }
  }

  function searchBrand(industryId, categoryId, brand) {
      var industry = document.getElementById(industryId);
      var category = document.getElementById(categoryId);
      var selectIndustryText = industry.options[industry.selectedIndex].value;
      var selectCategoryText = category.options[category.selectedIndex].value;
      var brandName = encodeURIComponent(document.getElementById(brand).value);
      if (selectIndustryText.length > 0 && selectCategoryText.length > 0 && brandName.length > 0) {
          location.href = "../mark/brandlist.aspx?industryId=" + selectIndustryText + "&categoryId=" + selectCategoryText + "&brandName=" + brandName;
      } else {
          var varFilter = "../mark/brandlist.aspx";
          if (selectIndustryText.length > 0) {
              varFilter = varFilter + "?industryId=" + selectIndustryText;
          }
          if (selectCategoryText.length > 0) {
              if (varFilter.indexOf('?') == -1) {
                  varFilter = varFilter + "?categoryId=" + selectCategoryText;
              } else {
              varFilter = varFilter + "&categoryId=" + selectCategoryText;
              }
      }
      if (brandName.length > 0) {
          if (varFilter.indexOf('?') == -1) {
              varFilter = varFilter + "?brandName=" + brandName;
          } else {
          varFilter = varFilter + "&brandName=" + brandName;
          }
      }
      location.href = varFilter;
      }
  }
