text: var keywrodLength=0;
  var itemIndex=-1;
  var flag = false;
  var cookie_consent;
  
  $(function() {
      var windowHeight = $(window).height();
      var contentDiv = $("#content-div").outerHeight();
      var footHeight = $("#footerSection").outerHeight();
      if((windowHeight-footHeight)>contentDiv){
          $("#content-div").css("min-height", (windowHeight-footHeight-20)+'px');
      }
      $("#product_keyword").bind('keypress', function(event){
          if(event.keyCode=="13"){
              clearItems();
              doSubmit();
          }
      });
  
       $("#submit-button").on("click",function(){
          doSubmit();
      });
  
      cookie_consent = readCookie("cookie_consent");
  
      if (cookie_consent == null && $('#cookie_consent').length) {
          $("#cookie_consent").show();
          $("#cookie_consent").css("display", "flex");
      }
  
      $("#cookie_consent").click(function () {
          $('#cookie_consent').remove();
          createCookie("cookie_consent", "1", 150, true);
      });    
      /*$("#product_keyword").keyup(function () {
          if($("#product_keyword").val().length>0){
              if($("#product_keyword").val().length!=keywrodLength){
                  if(flag){
                      clearTimeout(timer);
                      flag = false;
                  }
                  timer = setTimeout(function(){
                      getRecommendWords($("#product_keyword").val());
                      keywrodLength=$("#product_keyword").val().length;
                      itemIndex=-1;
                  }, 300);
                  flag = true;
              }
          }else{
              clearItems();
          }
      });
  
      $("#product_keyword").keydown(function (event) {
          if(event.keyCode==38 && itemIndex>0){
              itemIndex--;
              $(".recommend-word-div").removeClass("recommend-word-div-selected");
              $("#recommend_item_"+itemIndex).addClass("recommend-word-div-selected");
          } else  if(event.keyCode==40 && itemIndex<($(".recommend-word-div").length-1)){
              itemIndex++;
              $(".recommend-word-div").removeClass("recommend-word-div-selected");
              $("#recommend_item_"+itemIndex).addClass("recommend-word-div-selected");                    
          } else if(event.keyCode==13&&itemIndex>=0){
               $("#product_keyword").val($("#recommend_item_"+itemIndex).text());
               clearItems();
          }
      });
  
      $(document.body).on('click','.recommend-word-div',function(){
          $("#product_keyword").val($(this).text());
          clearItems();
  
      });
  
      $(document.body).on('mouseover','.recommend-word-div', function () {
          $(this).addClass('recommend-word-div-selected');
      });
      $(document.body).on('mouseout','.recommend-word-div',function () {
          $(this).removeClass('recommend-word-div-selected');
      });
  
      $("body").on('click', function () {
          clearItems();
      });*/
  });
  
  String.prototype.resetBlank=function(){
      var regEx = /\s+/g; 
      return this.replace(regEx, '-'); 
  };
  String.prototype.trim = function(){
      return this.replace(/(^\s*)|(\s*$)/g,"");
  }
  String.prototype.filter = function(){
      return this.replace(/[^0-9a-zA-Z \']/ig,""); 
  }
  
  function clearItems(){
      $("#recommend_div").css('display', 'none');
      $("#recommend_div").children('div').remove();
      itemIndex=-1;
  }
  
  function showItems(){
      var width = $("#product_keyword").width()+24;
      $("#recommend_div").width(width);
      $("#recommend_div").css('display', 'block');
  }
  
  function getRecommendWords(word){
      $.ajax({
          url: '/getRecommend?word='+word,
          type: 'get',
          contentType: "application/json",
          dataType: "json",
          async: true,
          beforeSend: function(data) {
          },
          success: function(data) {
              if (data.return_code == 0) {
                  var wordList = data.data.rwords;
                  var word = data.data.word;
                  $("#rw").val(word);
                  if(wordList.length==0){
                      clearItems();
                  }else{
                      showItems();
                      var $topSellers = $('#group-list');
                      var source = $topSellers.text();
                      var template = Handlebars.compile(source);
                      var dataTemplate = {
                        wordList: wordList,
                        "error": "no data!"
                      };                                                
                      var divs =  $("#recommend_div").children('div');                        
                      var html = template(dataTemplate);                                      
                      $topSellers.before(html);
                      divs.remove();    
                  }
              }else{
                  console.log(data.message);
              }                       
          },
          error: function() {
          }
      });
  }
  
  function doSubmit(){
      var keyword = $("#product_keyword").val();
      $("#akeyword").val("");
      $("#skeyword").val("");
      $("#tid").val("");
      $("#page_number").val("1");
      $("#list-form").attr('action','/s/' + keyword.filter().trim().resetBlank()); 
      $("#stype").val('2');
      $("#list-form").submit();
  }
  
  function getQueryString(name) { 
      var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 
      var r = window.location.search.substr(1).match(reg); 
      if (r != null) {
          return unescape(r[2]); 
      }else{
          return ""; 
      } 
  }
  
  function createCookie(name, value, days) {
      var expires;
  
      if (days) {
          var date = new Date();
          date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
          expires = "; expires=" + date.toGMTString();
      } else {
          expires = "";
      }
      document.cookie = encodeURIComponent(name) + "=" + encodeURIComponent(value) + expires + "; path=/";
  }
  
  function readCookie(name) {
      var nameEQ = encodeURIComponent(name) + "=";
      var ca = document.cookie.split(';');
      for (var i = 0; i < ca.length; i++) {
          var c = ca[i];
          while (c.charAt(0) === ' ')
              c = c.substring(1, c.length);
          if (c.indexOf(nameEQ) === 0)
              return decodeURIComponent(c.substring(nameEQ.length, c.length));
      }
      return null;
  }