<s08>
    <link rel="stylesheet" href="css/search-top.css">
    <notice-box></notice-box>
    <div class="main">
      <div class="content">
        <div class="page-title">
            <h2>キーワード検索</h2>
        </div>
        <div class="form-wrapper">
            <div class="form-item">
                <form onsubmit={ submit }>
                    <table>
                        <tr>
                            <td style="width: 150px !important;">キーワード</td>
                            <td colspan="2">
                                <input type="text" name="keyword" id="keyword" placeholder="販売元メーカー名・製造元メーカー名・品番・品名・容量・等級名・ＣＡＳ ＮＯ．・EANコード">
                                <input type="hidden" name="cas_code" id="cas_code">
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td class="form-text">
                                ※複数の語を空白で区切ると絞込み検索(AND)ができます
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <div style = 'border: 0.5px solid #3e70a5; margin-top: 15px; margin-bottom: 15px'></div>
                            </td>
                        </tr>
                        <tr>
                            <td style="">品番</td>
                            <td>
                                <input type="text" name="supplier_code" id="supplier_code" placeholder="品番を入力" autocomplete="off">
                            </td>
                            <td>
                                <select id="no_type">
                                    <option value="1">完全一致</option>
                                    <option value="2">から始まる</option>
                                    <option value="3">で終わる</option>
                                    <option value="4" selected>を含む</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>品名</td>
                            <td>
                                <input type="text" name="name" id="name" placeholder="品名を入力" autocomplete="off">
                            </td>
                            <td>
                                <select id="name_type">
                                    <option value="1">完全一致</option>
                                    <option value="2">から始まる</option>
                                    <option value="3">で終わる</option>
                                    <option value="4" selected>を含む</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
<td>製造元/ブランド</td>
                            <td colspan="2">
                                <div class="div-wraper-autocompleter">
                                    <input type="text" name="maker_name" id="maker_name" placeholder="メーカー名を入力（サジェスト）">
                                </div>
                                <div class="multi_select"></div>
                            </td>
                                                    </tr>
                        <tr>
                            <td>CAS No.</td>
                            <td colspan="2">
                                <input type="text" name="search_cas_code" id="search_cas_code" placeholder="CAS No.を入力">
                            </td>
                        </tr>
<!--                         <tr id="search-campaign">
                            <td></td>
                            <td>
                                <div>
                                    <label for="search_campaign" style="display: inline;">キャンペーン中の商品のみ検索</label>
                                    <input type="checkbox" name="search_campaign" id="search_campaign" style="display: inline; width: auto;">
                                </div>
                            </td>
                        </tr> -->
                        <tr>
                            <td>表示件数</td>
                            <td>
                                <select id="limit" style="width:60px">
                                    <option selected="{limit_po_on_page == 20 ? 'selected':''}">20</option>
                                    <option selected="{limit_po_on_page == 50 ? 'selected':''}">50</option>
                                </select>
                                件
                            </td>
                        </tr>
                        <tr>
                          <td class="searchBtnTd">
                            <button class="reset-btn" type="reset"><i class="fa fa-refresh" aria-hidden="true"></i>条件クリア</button>
                          </td>
                          <td></td>
                          <td align="right">
                            <button class="search-btn search_btn_color" type="submit">検索</button>
                          </td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
        <search-result-s08></search-result-s08>
        <div id="paging" class="text-center">
            <ul class="pagination_s08" id="pagination_s08"></ul>
        </div>
      </div>
    </div>
    <script>
        s08_current_search = 's08';
        this.limit_on_page = s08_limit_on_page;
        this.basic_is_active = opts.basic_is_active;
        this.suggest_list = opts.suggest_list;
        this.conditions = [
            {condition: '完全一致'},
            {condition: 'から始まる'},
            {condition: 'を含む'},
        ];
        this.total = 1;
        var user_info = JSON.parse(localStorage.getItem('EcUserInfo'));
        var thisTag = this;
        this.list_show = user_info.list_navigation.S;
        this.list_show_F = user_info.list_navigation.F;
        // var check_detail = arColumn(this.list_show, 'navigation_id', 'S004');
        // if (check_detail.length > 0) {
        //     if (check_detail[0].used_status == 'N' || check_detail[0].display_status == 'N') {
        //         $("#panel_2").remove();
        //         $("#more-option").remove();
        //     }
        // }
        var check_detail = arColumn(this.list_show_F, 'navigation_id', 'F013');
        if (check_detail.length > 0) {
            if (check_detail[0].used_status == 'N' || check_detail[0].display_status == 'N') {
                $("#search-campaign").remove();
            }
        }
        toggle(e) {
            this.basic_is_active = !this.basic_is_active;
            this.antibody_is_active = !this.antibody_is_active;
        }
        var accessTokenCognito = localStorage.getItem('accessTokenCognito');
        this.on('mount', function () {
            var suggest_list = JSON.parse(localStorage.getItem('suggest_list'));
            // $('#maker_name').autocompleter({
            //     limit : 10,
            //     source: suggest_list,
            //     callback : function(val, index, object) {
            //         $('.multi_select').append('<p>'+val+'<i class="fa fa-times x-multi_select-search" aria-hidden="true"></i></p>');
            //         $('#maker_name').val('');
            //         return false;
            //     }
            // });
			if (!IWAI_SITE) {
             $('#maker_name').autocomplete({
                open: function( event, ui ) {
                   return event.target.value;
                },
                source: function( request, response  ) {
                   var convertMatcher3 = '';
                   if (request.term.length > 0) {
                     convertMatcher3 = new RegExp("^" + $.ui.autocomplete.escapeRegex( mb_convert_kana(request.term, 'RNSKHC')), 'i');
                   }
                   var convertMatcher = request.term.replace(/[\uff01-\uff5e]/g,function(ch) { return String.fromCharCode(ch.charCodeAt(0) - 0xfee0); });
                   convertMatcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( convertMatcher ), "i" );
                var convertMatcher2 = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term.toFullWidth() ), "i" );
                   var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term ), "i" );
                   response( $.grep( JSON.parse(JSON.stringify(suggest_list)), function( item ){
                      return  convertMatcher2.test(item) || convertMatcher3.test(item) || convertMatcher.test(item) || matcher.test( item );
                  }) );
                },
                select: function( event, ui ) {
                    $('.multi_select').append('<p>'+ui.item.value+'<i class="fa fa-times x-multi_select-search" aria-hidden="true"></i></p>');
                    $('#maker_name').val('');
                    return false;
                }
             });
			}
			
            $(document).on('click', '.x-multi_select-search', function() {
                $(this).parent().remove();
            });
            // var check_detail = arColumn(this.list_show, 'navigation_id', 'S004');
            // if (check_detail.length > 0) {
            //     if (check_detail[0].used_status == 'N' || check_detail[0].display_status == 'N') {
            //         $("#panel_2").remove();
            //         $("#more-option").remove();
            //     }
            // }
            var check_detail = arColumn(this.list_show_F, 'navigation_id', 'F013');
            if (check_detail.length > 0) {
                if (check_detail[0].used_status == 'N' || check_detail[0].display_status == 'N') {
                    $("#search-campaign").remove();
                }
            }
            $('#keyword').val(s08_keyword);
            // var dis_keyword = false;
            // dis_keyword = $('#keyword').prop('disabled');
            if (s08_keyword) {
            // if (s08_keyword != '' && !dis_keyword) {
                // s08_cas_code = '';
                if (s08_cas_code) {
                    $('.form-item form')[0].reset();
                    // var panel = JSON.parse(localStorage.getItem('data-panel')) ? JSON.parse(localStorage.getItem('data-panel')) : '';
                    // if (panel == 'panel_2') {
                    //     $('.tab-area').find('#more-option').addClass('active');
                    //     $('.panel-area').find('#panel_2').addClass('active');
                    //     $('.tab-area').find('#keyword-option').removeClass('active');
                    //     $('.panel-area').find('#panel_1').removeClass('active');
                    //     $('#panel_2').find('input[type="text"]').val('');
                    //     // $('#search_cas_code').val(search_cas_code);
                        $('#search_cas_code').val(s08_cas_code);
                    //     $('#keyword').prop('disabled', true);
                    // } else {
                    //     $('.tab-area').find('#keyword-option').addClass('active');
                    //     $('.panel-area').find('#panel_1').addClass('active');
                    //     $('.tab-area').find('#more-option').removeClass('active');
                    //     $('.panel-area').find('#panel_2').removeClass('active');
                    //     $('#keyword').val(s08_cas_code);
                    //     $('#keyword').prop('disabled', false);
                    // }
                    submit();
                    s08_cas_code = '';
                    return;
                }
                var result_search = JSON.parse(localStorage.getItem('result_search')) ? JSON.parse(localStorage.getItem('result_search')) : [];


                if (result_search.length > 0) {
					if (!IWAI_SITE) {
						thisTag.searchBack();
					}
                }
            } else if (s08_cas_code) {
                $('.form-item form')[0].reset();
                // var panel = JSON.parse(localStorage.getItem('data-panel')) ? JSON.parse(localStorage.getItem('data-panel')) : '';
                // if (panel == 'panel_2') {
                //     $('.tab-area').find('#more-option').addClass('active');
                //     $('.panel-area').find('#panel_2').addClass('active');
                //     $('.tab-area').find('#keyword-option').removeClass('active');
                //     $('.panel-area').find('#panel_1').removeClass('active');
                //     $('#panel_2').find('input[type="text"]').val('');
                //     // $('#search_cas_code').val(search_cas_code);
                    $('#search_cas_code').val(s08_cas_code);
                //     $('#keyword').prop('disabled', true);
                // } else {
                //     $('.tab-area').find('#keyword-option').addClass('active');
                //     $('.panel-area').find('#panel_1').addClass('active');
                //     $('.tab-area').find('#more-option').removeClass('active');
                //     $('.panel-area').find('#panel_2').removeClass('active');
                //     $('#keyword').val(s08_cas_code);
                //     $('#keyword').prop('disabled', false);
                // }
                submit();
            } else {
                if(s09_back == 's08'){
                    var result_search = JSON.parse(localStorage.getItem('result_search')) ? JSON.parse(localStorage.getItem('result_search')) : [];


                    if (result_search.length > 0) {
						if (!IWAI_SITE) {
							thisTag.searchBack();
						}
                    }
                    // submit();
                }
            }
        })
        this.backToTop = function(){
            $('body,html').animate({
                scrollTop: 0
            }, 0);
        }
		if (!IWAI_SITE) {
         this.searchBack = function(){
             var result_search = JSON.parse(localStorage.getItem('result_search'));
             var last_search = result_search[result_search.length-1];
             var panel = last_search.panel;
             var result_search_page = last_search.page;
             var keyword = last_search.keyword;
             var search_supplier_code = last_search.search_supplier_code;
             var search_name_jp = last_search.search_name_jp;
             var search_maker_name = last_search.search_maker_name;
             var search_cas_code = last_search.search_cas_code;
             var no_type = last_search.no_type;
             var name_type = last_search.name_type;
             var search_campaign = last_search.search_campaign;
             // if (panel == 'panel_2') {
             //     $('.tab-area').find('#more-option').addClass('active');
             //     $('.panel-area').find('#panel_2').addClass('active');
             //     $('.tab-area').find('#keyword-option').removeClass('active');
             //     $('.panel-area').find('#panel_1').removeClass('active');
                 $('#supplier_code').val(search_supplier_code);
                 $('#name').val(search_name_jp);
                 if (search_maker_name.length > 0) {
                     var html = '';
                     for (var i = 0; i < search_maker_name.length; i++) {
                         var item = search_maker_name[i];
                         html += '<p>'+item+'<i class="fa fa-times  x-multi_select-search" aria-hidden="true"></i></p>';
                     }
                     $('.multi_select').append(html);
                 }
                 $('#search_cas_code').val(search_cas_code);
                 $('#no_type').val(no_type);
                 $('#name_type').val(name_type);
                 // $('#keyword').prop('disabled', true);
             // } else {
             //     $('.tab-area').find('#keyword-option').addClass('active');
             //     $('.panel-area').find('#panel_1').addClass('active');
             //     $('.tab-area').find('#more-option').removeClass('active');
             //     $('.panel-area').find('#panel_2').removeClass('active');
                 $('#keyword').val(keyword);
                 // $('#keyword').prop('disabled', false);
             // }
             if (search_campaign) {
                 $('#search_campaign').prop('checked', true);
             }
             if(login_back == true){
                 result_search.pop();
             }
             // result_search.pop();
             localStorage.setItem('result_search', JSON.stringify(result_search));
             riot.mount('search-result-s08', {results: last_search.product_list,total:last_search.total, tag: 's08'});
             thisTag.backToTop();
             var $pagination = $('#pagination_s08');
             var totalPages = Math.ceil(last_search.total/$('#limit').val());
             $pagination.twbsPagination('destroy');
             $pagination.twbsPagination({
                 totalPages: totalPages,
                 visiblePages: 5,
                 startPage: result_search_page,
                 initiateStartPageClick: false,
                 onPageClick: function (event, page) {
                     var url = URL_API + '/v1/get_product_ec102';
                     // var dis_keyword = false;
                     // dis_keyword = $('#keyword').prop('disabled');
                     var keyword = $('#keyword').val();
                     var search_supplier_code = $('#supplier_code').val();
                     var search_name_jp = $('#name').val();
                     var search_maker_name = $('#maker_name').val();
                     var search_cas_code = $('#search_cas_code').val();
                     var no_type = $('#no_type').val();
                     var name_type = $('#name_type').val();
                     var checkKeyword = trimSpaces(keyword).split(/[ 　]/);
                     if (checkKeyword.length >= 6) {
                         alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                         return;
                     }
                     if (search_supplier_code != null) {
                         var checkKeyword = trimSpaces(search_supplier_code).split(/[ 　]/);
                         if (checkKeyword.length >= 6) {
                             alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                             return;
                         }
                     }
                         if (search_name_jp != null) {
                         var checkKeyword = trimSpaces(search_name_jp).split(/[ 　]/);
                         if (checkKeyword.length >= 6) {
                             alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                             return;
                         }
                     }
                     var lstSuggest = new Array();
                     $('.multi_select').find('p').each(function(index, el) {
                         var lstText = $(this).text();
                         lstSuggest.push(lstText);
                     });
                     var query = [];
                     query.push('token=' + accessTokenCognito);
                     query.push('page=' + page);
                     query.push('from=iwai');
                     query.push('limit=' + $('#limit').val());
                     if (keyword) {
                     // if (keyword && !dis_keyword) {
                         query.push('keywords=' + encodeURIComponent(keyword));
                     }
                     // if (panel == 'panel_2') {
                         if (search_supplier_code) {
                             query.push('search_supplier_code=' + encodeURIComponent(search_supplier_code));
                         }
                         if (search_name_jp) {
                             query.push('search_name_jp=' + encodeURIComponent(search_name_jp));
                         }
                         if (lstSuggest.length > 0) {
                             query.push('search_maker_name=' + encodeURIComponent(JSON.stringify((lstSuggest))));
                         }
                         if (search_cas_code) {
                             query.push('search_cas_code=' + encodeURIComponent(search_cas_code));
                         }
                         if (search_supplier_code && no_type) {
                             query.push('no_type=' + encodeURIComponent(no_type));
                         }
                         if (search_name_jp && name_type) {
                             query.push('name_type=' + encodeURIComponent(name_type));
                         }
                     // }
                     if ($('#search_campaign').is(':checked')) {
                         query.push('search_campaign=true');
                     }
                     if (s08_cas_code) {
                         query.push('cas_value=' + s08_cas_code);
                     }
                     url += '?' + query.join('&');
                     $.ajax({
                         url: url,
                         type: 'GET',
                         success: function (data) {
                             if(data.status == 100){
                                 riot.mount('app','maintain',{ messege:data.messege });
                                 return false;
                             }
                             if(data.http == 400){
                                 alert(data.message);
                                 return false;
                             }
                             thisTag.total = data.total;
                             s08_total_page = data.total;
                             var total = data.total;
                             var panel = JSON.parse(localStorage.getItem('data-panel')) ? JSON.parse(localStorage.getItem('data-panel')) : '';
                             var results = data.product_list;
                             var suggest_list = data.suggest_list;
                             var newArray = [];
                             data.page = page;
                             data.panel = panel;
                             data.keyword = keyword;
                             data.search_supplier_code = search_supplier_code;
                             data.search_name_jp = search_name_jp;
                             data.search_maker_name = lstSuggest;
                             data.search_cas_code = search_cas_code;
                             data.no_type = no_type;
                             data.name_type = name_type;
                             data.search_campaign = false;
                             if ($('#search_campaign').is(':checked')) {
                                 data.search_campaign = true;
                             }
                             newArray = JSON.parse(localStorage.getItem('result_search')) ? JSON.parse(localStorage.getItem('result_search')) : [];
                             if (Array.isArray(newArray)) {
                                 newArray.push(data);
                             } else {
                                 newArray = [];
                             }
                             localStorage.setItem('result_search', JSON.stringify(newArray));
                             $('#maker_name').autocomplete({
                                 open: function( event, ui ) {
                                     return event.target.value;
                                 },
                                 source: function( request, response  ) {
                                   var convertMatcher3 = '';
                                   if (request.term.length > 0) {
                                     convertMatcher3 = new RegExp("^" + $.ui.autocomplete.escapeRegex( mb_convert_kana(request.term, 'RNSKHC')), 'i');
                                   }
                                   var convertMatcher = request.term.replace(/[\uff01-\uff5e]/g,function(ch) { return String.fromCharCode(ch.charCodeAt(0) - 0xfee0); });
                                   convertMatcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( convertMatcher ), "i" );
                                   var convertMatcher2 = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term.toFullWidth() ), "i" );
                                   var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term ), "i" );
                                   response( $.grep( JSON.parse(JSON.stringify(suggest_list)), function( item ){
                                       return  convertMatcher2.test(item) || convertMatcher3.test(item) || convertMatcher.test(item) || matcher.test( item );
                                   }) );
                                 },
                                 select: function( event, ui ) {
                                     $('.multi_select').append('<p>'+ui.item.value+'<i class="fa fa-times x-multi_select-search" aria-hidden="true"></i></p>');
                                     $('#maker_name').val('');
                                     return false;
                                 },
                                 response : function(event, ui) {
                                     if (ui.content.length === 0) {
                                         // $('#maker_name').val('');
                                     }
                                 }
                             });
                             localStorage.removeItem('suggest_list');
                             // localStorage.setItem('result_search_s08', JSON.stringify(data));
                             // localStorage.setItem('result_search_page_s08', page);
                             riot.mount('search-result-s08', {results: results,total:total, tag: 's08'});
                             thisTag.backToTop();
                         },
                         error: function (xhr, stt, error) {
                             alert('error');
                         }
                     });
                 }
             });
         }
		}
		
        submit = function (e) {
            if(s08_current_search == 's08'){
                s09_back = 's08';
            }
            var checkKeyword = '';
            var checkSupplierCode = '';
            var checkNameJp = '';
            var checkCasNo = '';
            // var dis_keyword = false;
            // dis_keyword = $('#keyword').prop('disabled');
            var keyword = $('#keyword').val();
            var search_supplier_code = $('#supplier_code').val();
            var search_name_jp = $('#name').val();
            var search_maker_name = $('#maker_name').val();
            var search_cas_code = $('#search_cas_code').val();
            var no_type = $('#no_type').val();
            var name_type = $('#name_type').val();
            var checkKeyword = trimSpaces(keyword).split(/[ 　]/);
            if (checkKeyword.length >= 6) {
                alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                return;
            }
            if (search_supplier_code != null) {
                var checkSupplierCode = trimSpaces(search_supplier_code).split(/[ 　]/);
                if (checkSupplierCode.length >= 6) {
                    alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                    return;
                }
            }
            if (search_name_jp != null) {
                var checkNameJp = trimSpaces(search_name_jp).split(/[ 　]/);
                if (checkNameJp.length >= 6) {
                    alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                    return;
                }
            }
	    if (search_cas_code != null) {
                checkCasNo = trimSpaces(search_cas_code).split(/[ 　]/);
            }
            if (keyword != null && keyword != '') {
                var test = keyword.replace(/[-()/&=[\]\\><{}、。，・：；／＼‘’“”（）〔〕［］｛｝〈〉《》「」『』【】＞＜－＆＝@#＠＃?？_|~～"\',]/g, '');
                if(test == '') {
                    alert('記号のみでの検索はできません。');
                    return;
                }
            }
            if (search_supplier_code != null && search_supplier_code != '') {
                var test = search_supplier_code.replace(/[-()/&=[\]\\><{}、。，・：；／＼‘’“”（）〔〕［］｛｝〈〉《》「」『』【】＞＜－＆＝@#＠＃?？_|~～"\',]/g, '');
                if(test == '') {
                    alert('記号のみでの検索はできません。');
                    return;
                }
            }
            if (search_name_jp != null && search_name_jp != '') {
                var test = search_name_jp.replace(/[-()/&=[\]\\><{}、。，・：；／＼‘’“”（）〔〕［］｛｝〈〉《》「」『』【】＞＜－＆＝@#＠＃\?？_\|~～"\',]/g, '');
                if(test == '') {
                    alert('記号のみでの検索はできません。');
                    return;
                }
            }
            if (search_maker_name != null && search_maker_name != '') {
                var test = search_maker_name.replace(/[-()/&=[\]\\><{}、。，・：；／＼‘’“”（）〔〕［］｛｝〈〉《》「」『』【】＞＜－＆＝@#＠＃?？_|~～"\',]/g, '');
                if(test == '') {
                    alert('記号のみでの検索はできません。');
                    return;
                }
            }
            if (search_cas_code != null && search_cas_code != '') {
                var test = search_cas_code.replace(/[-()/&=[\]\\><{}、。，・：；／＼‘’“”（）〔〕［］｛｝〈〉《》「」『』【】＞＜－＆＝@#＠＃?？_|~～"\',]/g, '');
                if(test == '') {
                    alert('記号のみでの検索はできません。');
                    return;
                }
            }
	    
            if (e) {
                s08_cas_code = '';
                thisTag.total = 1;
                s08_current_page = 1;
                s08_total_page = 1;
            }
            var lstSuggest = new Array();
            $('.multi_select').find('p').each(function(index, el) {
                var lstText = $(this).text();
                lstSuggest.push(lstText);
            });
			if(IWAI_SITE) {
				if (checkKeyword == '' && checkSupplierCode == '' && checkNameJp == '' && checkCasNo == '' && lstSuggest.length == 0) {
					if (search_maker_name != null ) {
						$('#maker_name').val('');
					}
					alert('検索条件を一つ以上指定してください。\n（※製造元/ブランドのみでの検索はできません）');
					return;
				}
				if (checkKeyword == '' && checkSupplierCode == '' && checkNameJp == '' && checkCasNo == '' && lstSuggest.length > 0) {
					alert('製造元/ブランドのみでの検索はできません。');
					return;
				}
			}
            var panel = JSON.parse(localStorage.getItem('data-panel')) ? JSON.parse(localStorage.getItem('data-panel')) : '';
            var $pagination = $('#pagination_s08');
            var totalPages = Math.ceil(s08_total_page/s08_limit_on_page);
            $pagination.twbsPagination('destroy');
            $pagination.twbsPagination({
                totalPages: totalPages,
                visiblePages: 5,
                startPage: s08_current_page,
                onPageClick: function (event, page) {
                    s08_limit_on_page = $('#limit').val();
                    s08_current_page = page;
                    var url = URL_API + '/v1/get_product_ec102';
                    var query = [];
                    query.push('token=' + accessTokenCognito);
                    query.push('page=' + page);
					if (IWAI_SITE) {
						query.push('from=iwai');
					}
                    query.push('limit=' + $('#limit').val());
                    if (keyword) {
                    // if (keyword && !dis_keyword) {
                        query.push('keywords=' + encodeURIComponent(keyword));
                    }
                    // if (panel == 'panel_2') {
                        if (search_supplier_code) {
                            query.push('search_supplier_code=' + encodeURIComponent(search_supplier_code));
                        }
                        if (search_name_jp) {
                            query.push('search_name_jp=' + encodeURIComponent(search_name_jp));
                        }
                        if (lstSuggest.length > 0) {
                            query.push('search_maker_name=' + encodeURIComponent(JSON.stringify((lstSuggest))));
                        }
                        if (search_cas_code) {
                            query.push('search_cas_code=' + encodeURIComponent(search_cas_code));
                        }
                        if (search_supplier_code && no_type) {
                            query.push('no_type=' + encodeURIComponent(no_type));
                        }
                        if (search_name_jp && name_type) {
                            query.push('name_type=' + encodeURIComponent(name_type));
                        }
                    // }
                    if (s08_cas_code) {
                        query.push('cas_value=' + s08_cas_code);
                    }
                    if ($('#search_campaign').is(':checked')) {
                        query.push('search_campaign=true');
                    }
                    // write in storage
                    s08_keyword = keyword;
                    // end write
                    url += '?' + query.join('&');
                    $.ajax({
                        type: 'GET',
                        url: url,
                        timeout: 60000,
                        success: function (data, text) {
                            if(data.status == 100){
                                riot.mount('app','maintain',{ messege:data.messege });
                                return false;
                            }
                            if(data.http == 400){
                                alert(data.message);
                                return false;
                            }
                            thisTag.total = data.total;
                            var total = data.total;
                            var panel = JSON.parse(localStorage.getItem('data-panel')) ? JSON.parse(localStorage.getItem('data-panel')) : '';
                            s08_total_page = total;
                            var results = data.product_list;
							if (IWAI_SITE) {
								var suggest_list = data.suggest_list;
							}
                            var newArray = [];
                            data.page = page;
                            data.panel = panel;
                            data.keyword = keyword;
                            data.search_supplier_code = search_supplier_code;
                            data.search_name_jp = search_name_jp;
                            data.search_maker_name = lstSuggest;
                            data.search_cas_code = search_cas_code;
                            data.no_type = no_type;
                            data.name_type = name_type;
                            data.search_campaign = false;
                            if ($('#search_campaign').is(':checked')) {
                                data.search_campaign = true;
                            }
                            newArray = JSON.parse(localStorage.getItem('result_search')) ? JSON.parse(localStorage.getItem('result_search')) : [];
                            if (Array.isArray(newArray)) {
                                newArray.push(data);
                            } else {
                                newArray = [];
                            }
                            localStorage.setItem('result_search', JSON.stringify(newArray));
							if (IWAI_SITE) {
								$('#maker_name').autocomplete({
									open: function( event, ui ) {
										return event.target.value;
									},
									source: function( request, response  ) {
									  var convertMatcher3 = '';
									  if (request.term.length > 0) {
										convertMatcher3 = new RegExp("^" + $.ui.autocomplete.escapeRegex( mb_convert_kana(request.term, 'RNSKHC')), 'i');
									  }
									  var convertMatcher = request.term.replace(/[\uff01-\uff5e]/g,function(ch) { return String.fromCharCode(ch.charCodeAt(0) - 0xfee0); });
									  convertMatcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( convertMatcher ), "i" );
									  var convertMatcher2 = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term.toFullWidth() ), "i" );
									  var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term ), "i" );
									  response( $.grep( JSON.parse(JSON.stringify(suggest_list)), function( item ){
										  return  convertMatcher2.test(item) || convertMatcher3.test(item) || convertMatcher.test(item) || matcher.test( item );
									  }) );
									},
									select: function( event, ui ) {
										$('.multi_select').append('<p>'+ui.item.value+'<i class="fa fa-times x-multi_select-search" aria-hidden="true"></i></p>');
										$('#maker_name').val('');
										return false;
									},
									response : function(event, ui) {
										if (ui.content.length === 0) {
											// $('#maker_name').val('');
										}
									}
								});
								localStorage.removeItem('suggest_list');
							}
							
                            // localStorage.setItem('result_search_s08', JSON.stringify(data));
                            // localStorage.setItem('result_search_page_s08', page);

                            riot.mount('search-result-s08', {results: results,total:total, tag: 's08'});
                            thisTag.backToTop();
                            var totalPages = Math.ceil(data.total/$('#limit').val());
                            var $pagination = $('#pagination_s08');
                            $pagination.twbsPagination('destroy');
                            $pagination.twbsPagination({
                                totalPages: totalPages,
                                visiblePages: 5,
                                initiateStartPageClick: false,
                                startPage: s08_current_page,
                                onPageClick: function (event, page) {
                                    s08_limit_on_page = $('#limit').val();
                                    s08_current_page = page;
                                    // console.log(ec10_po_current_page);
                                    var url = URL_API + '/v1/get_product_ec102';
                                    var dis_keyword = false;
                                    dis_keyword = $('#keyword').prop('disabled');
                                    var keyword = $('#keyword').val();
                                    var search_supplier_code = $('#supplier_code').val();
                                    var search_name_jp = $('#name').val();
                                    var search_maker_name = $('#maker_name').val();
                                    var search_cas_code = $('#search_cas_code').val();
                                    var no_type = $('#no_type').val();
                                    var name_type = $('#name_type').val();
                                    var checkKeyword = trimSpaces(keyword).split(/[ 　]/);
                                    if (checkKeyword.length >= 6) {
                                        alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                                        return;
                                    }
                                    if (search_supplier_code != null) {
                                        var checkKeyword = trimSpaces(search_supplier_code).split(/[ 　]/);
                                        if (checkKeyword.length >= 6) {
                                            alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                                            return;
                                        }
                                    }
                                        if (search_name_jp != null) {
                                        var checkKeyword = trimSpaces(search_name_jp).split(/[ 　]/);
                                        if (checkKeyword.length >= 6) {
                                            alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                                            return;
                                        }
                                    }
                                    var lstSuggest = new Array();
                                    $('.multi_select').find('p').each(function(index, el) {
                                        var lstText = $(this).text();
                                        lstSuggest.push(lstText);
                                    });
                                    var query = [];
                                    query.push('token=' + accessTokenCognito);
                                    query.push('page=' + s08_current_page);
									if (IWAI_SITE) {
										query.push('from=iwai');
									}
                                    query.push('limit=' + s08_limit_on_page);
                                    if (keyword) {
                                    // if (keyword && !dis_keyword) {
                                        query.push('keywords=' + encodeURIComponent(keyword));
                                    }
                                    // if (panel == 'panel_2') {
                                        if (search_supplier_code) {
                                            query.push('search_supplier_code=' + encodeURIComponent(search_supplier_code));
                                        }
                                        if (search_name_jp) {
                                            query.push('search_name_jp=' + encodeURIComponent(search_name_jp));
                                        }
                                        if (lstSuggest.length > 0) {
                                            query.push('search_maker_name=' + encodeURIComponent(JSON.stringify((lstSuggest))));
                                        }
                                        if (search_cas_code) {
                                            query.push('search_cas_code=' + encodeURIComponent(search_cas_code));
                                        }
                                        if (search_supplier_code && no_type) {
                                            query.push('no_type=' + encodeURIComponent(no_type));
                                        }
                                        if (search_name_jp && name_type) {
                                            query.push('name_type=' + encodeURIComponent(name_type));
                                        }
                                    // }
                                    if ($('#search_campaign').is(':checked')) {
                                        query.push('search_campaign=true');
                                    }
                                    if (s08_cas_code) {
                                        query.push('cas_value=' + s08_cas_code);
                                    }
                                    url += '?' + query.join('&');
                                    $.ajax({
                                        url: url,
                                        type: 'GET',
                                        success: function (data) {
                                            if(data.status == 100){
                                                riot.mount('app','maintain',{ messege:data.messege });
                                                return false;
                                            }
                                            if(data.http == 400){
                                                alert(data.message);
                                                return false;
                                            }

                                            thisTag.total = data.total;
                                            s08_total_page = data.total;
                                            var total = data.total;
                                            var panel = JSON.parse(localStorage.getItem('data-panel')) ? JSON.parse(localStorage.getItem('data-panel')) : '';
                                            var results = data.product_list;
											if (IWAI_SITE) {
												var suggest_list = data.suggest_list;
											}
                                            var newArray = [];
                                            data.page = page;
                                            data.panel = panel;
                                            data.keyword = keyword;
                                            data.search_supplier_code = search_supplier_code;
                                            data.search_name_jp = search_name_jp;
                                            data.search_maker_name = lstSuggest;
                                            data.search_cas_code = search_cas_code;
                                            data.no_type = no_type;
                                            data.name_type = name_type;
                                            data.search_campaign = false;
                                            if ($('#search_campaign').is(':checked')) {
                                                data.search_campaign = true;
                                            }
                                            newArray = JSON.parse(localStorage.getItem('result_search')) ? JSON.parse(localStorage.getItem('result_search')) : [];
                                            if (Array.isArray(newArray)) {
                                                newArray.push(data);
                                            } else {
                                                newArray = [];
                                            }
                                            localStorage.setItem('result_search', JSON.stringify(newArray));
											if (IWAI_SITE) {
												$('#maker_name').autocomplete({
													open: function( event, ui ) {
														return event.target.value;
													},
													source: function( request, response  ) {
													  var convertMatcher3 = '';
													  if (request.term.length > 0) {
														convertMatcher3 = new RegExp("^" + $.ui.autocomplete.escapeRegex( mb_convert_kana(request.term, 'RNSKHC')), 'i');
													  }
													  var convertMatcher = request.term.replace(/[\uff01-\uff5e]/g,function(ch) { return String.fromCharCode(ch.charCodeAt(0) - 0xfee0); });
													  convertMatcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( convertMatcher ), "i" );
													  var convertMatcher2 = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term.toFullWidth() ), "i" );
													  var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term ), "i" );
													  response( $.grep( JSON.parse(JSON.stringify(suggest_list)), function( item ){
														  return  convertMatcher2.test(item) || convertMatcher3.test(item) || convertMatcher.test(item) || matcher.test( item );
													  }) );
													},
													select: function( event, ui ) {
														$('.multi_select').append('<p>'+ui.item.value+'<i class="fa fa-times x-multi_select-search" aria-hidden="true"></i></p>');
														$('#maker_name').val('');
														return false;
													},
													response : function(event, ui) {
														if (ui.content.length === 0) {
															// $('#maker_name').val('');
														}
													}
												});
												localStorage.removeItem('suggest_list');
											}
                                            // localStorage.setItem('result_search_s08', JSON.stringify(data));
                                            // localStorage.setItem('result_search_page_s08', page);

                                            riot.mount('search-result-s08', {results: results,total:total, tag: 's08'});
                                            thisTag.backToTop();

                                        },
                                        error: function (xhr, stt, error) {
                                            alert('error');
                                        }
                                    });
                                }
                            });
                        },
                        error: function (xhr, stt, error) {
                            alert('error');
                        }
                    });
                }
            });
        }
        $(function() {
            // $('#maker_name').autocompleter({
            //     limit : 10,
            //     source: thisTag.suggest_list,
            //     callback : function(val, index, object) {
            //         $('.multi_select').append('<p>'+val+'<i class="fa fa-times x-multi_select-search" aria-hidden="true"></i></p>');
            //         $('#maker_name').val('');
            //         return false;
            //     }
            // });
			if (!IWAI_SITE) {
             $('#maker_name').autocomplete({
                 open: function( event, ui ) {
                     return event.target.value;
                 },
                 source: function( request, response  ) {
                   var convertMatcher3 = '';
                   if (request.term.length > 0) {
                     convertMatcher3 = new RegExp("^" + $.ui.autocomplete.escapeRegex( mb_convert_kana(request.term, 'RNSKHC')), 'i');
                   }
                   var convertMatcher = request.term.replace(/[\uff01-\uff5e]/g,function(ch) { return String.fromCharCode(ch.charCodeAt(0) - 0xfee0); });
                   convertMatcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( convertMatcher ), "i" );
                   var convertMatcher2 = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term.toFullWidth() ), "i" );
                   var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term ), "i" );
                   response( $.grep( JSON.parse(JSON.stringify(thisTag.suggest_list)), function( item ){
                       return  convertMatcher2.test(item) || convertMatcher3.test(item) || convertMatcher.test(item) || matcher.test( item );
                   }) );
                 },
                 select: function( event, ui ) {
                     $('.multi_select').append('<p>'+ui.item.value+'<i class="fa fa-times x-multi_select-search" aria-hidden="true"></i></p>');
                     $('#maker_name').val('');
                     return false;
                 }
             });
			}
			
            $(document).on('click', '.x-multi_select-search', function() {
                $(this).parent().remove();
            });
            $('.reset-btn').on('click', function() {
                $('.multi_select').find('p').remove();
                clearTypeSearch();
            })
            var panel = JSON.parse(localStorage.getItem('data-panel')) ? JSON.parse(localStorage.getItem('data-panel')) : 'panel_1';
            localStorage.setItem('data-panel', JSON.stringify(panel));
            /* tab & panel */
            // $('.tab').on('click',function(){
            //     var keyword = $('#keyword').val();
            //     var search_supplier_code = $('#supplier_code').val();
            //     var search_name_jp = $('#name').val();
            //     var search_maker_name = $('#maker_name').val();
            //     var search_cas_code = $('#search_cas_code').val();
            //     var no_type = $('#no_type').val();
            //     var name_type = $('#name_type').val();
            //     if(!$(this).hasClass('active')){
            //         /*tab*/
            //         $('.tab').removeClass('active');
            //         $(this).addClass('active');
            //         /*panel*/
            //         var panel = $(this).attr('data-panel');
            //         localStorage.setItem('data-panel', JSON.stringify(panel));
            //         if (panel == 'panel_2') {
            //             $('#keyword').prop('disabled', true);
            //             $('#supplier_code').val(search_supplier_code);
            //             $('#name').val(search_name_jp);
            //             $('#maker_name').val(search_maker_name);
            //             $('#search_cas_code').val(search_cas_code);
            //             $('#no_type').val(no_type);
            //             $('#name_type').val(name_type);
            //             riot.mount('search-result-s08', { tag: 's08'});
            //             var $pagination = $('#pagination_s08');
            //             $pagination.twbsPagination('destroy');
            //         } else {
            //             $('#keyword').prop('disabled', false);
            //             $('#keyword').val(keyword);
            //             $('#keyword').prop('disabled', false);
            //             riot.mount('search-result-s08', { tag: 's08'});
            //             var $pagination = $('#pagination_s08');
            //             $pagination.twbsPagination('destroy');
            //         }
            //         $('.panel').removeClass('active');
            //         $('#' + panel).addClass('active');
            //     }
            // });
        });
        String.prototype.toHalfWidth = function() {
            return this.replace(/[Ａ-Ｚａ-ｚ０-９ァ-ン]/g, function(s) {return String.fromCharCode(s.charCodeAt(0) - 0xFEE0)});
        };

        String.prototype.toFullWidth = function() {
            return this.replace(/[A-Za-z0-9\uFF65-\uFF9F]/g, function(s) { return String.fromCharCode(s.charCodeAt(0) + 0xFEE0)});
        };
    </script>

</s08>
