var els;
var mbMode=0;
$(function() {
    if(window.innerWidth<=768){mbMode=1}

    if(mbMode==1){
        $('[class*=ef_delay-]').each(function(){
            $(this).attr('class',$(this).attr('class').split('ef_delay-').join('_ef_delay-'));
        });
    }
    //■参加申し込み
    var keys=['entry_section','entry_lunch','entry_get_program'];
    $('#bt_submit').click(function(){
        alertTx='';
        for(var i=0;i<keys.length;i++){
            $inp=$('[name='+keys[i]+']');
            // console.log($('[name='+keys[i]+']').prop('tagName').toLowerCase()+'/'+$('[name='+keys[i]+']').attr('type')+'/'+keys[i]+'/'+$('[name='+keys[i]+']').val()+'/'+$('[name='+keys[i]+']').val());
            if($('[name='+keys[i]+']').length>0){
                if($('[name='+keys[i]+']').attr('type')=='radio'){
                    if($('[name='+keys[i]+']:checked').val()===undefined){
                        // console.log($('[name='+keys[i]+']:checked').val());
                        console.log(keys[i]);
                        alertTx='必須項目を入力して下さい';
                    }else{
    
                    }
                }else if($('[name='+keys[i]+']').prop('tagName').toLowerCase()=='select'){
                    if($('[name='+keys[i]+']').val()==''){
                        console.log(keys[i]);
                        alertTx='必須項目を入力して下さい';
                    }
                }else{
                    if($('[name='+keys[i]+']').val()==''){
                        alertTx='必須項目を入力して下さい';
                    }
                }
            }
        }
        if(alertTx==''){
            $('form.registration-form').submit();
        }else{
            alert(alertTx);
        }
    });

    var time_line1=new Date(2024,(8-1), 1, 0, 0, 0);//申込開始ライン//【注意】月のみ -1して入力
    var time_line2=new Date(2024,(9-1),14,23,59,59);//前期募集締め切りライン//【注意】月のみ -1して入力

    var time_line3=new Date(2024,(10-1),5,17,50, 0);//後期募集締め切りライン//【注意】月のみ -1して入力
    var time_line3_2=new Date(2024,(10-1),6, 0, 0, 0);//オンデマンド受付開始
    var time_line3_3=new Date(2024,(11-1),15,23,59,59);//オンデマンド配信終了
    // var time_line3=new Date(2024,(10-1),4, 0, 0, 0);//後期募集締め切りライン//【注意】月のみ -1して入力
    // var time_line3_2=new Date(2024,(10-1),5, 0, 0, 0);//オンデマンド受付開始
    // var time_line3_3=new Date(2024,(10-1),6, 0, 0, 0);//オンデマンド配信終了

    var time_line4=new Date(2024,(9-1),20,23,59,59);//ランチセミナー締め切りライン
    var time_line5=new Date(2024,(9-1),30,23,59,59);//実技講習会締め切りライン
    var now_time=new Date();

    if(now_time<time_line3){//来場型モード（オンデマンド領域非表示）
        $('.registration-table .ondemand').css({display:'none'});
        $('input.ondemand').parent('td').css({display:'none'});
    }else{//オンデマンドモード
        $('.early[name=entry_section]').prop('disabled',true);
        $('.entry-block2').css({display:'block'});
        $('.entry-block').remove();
        $('.registration-table').find('th.early,th.normal').css({display:'none'});
        $('input.early,input.normal').parent('td').css({display:'none'});
    }

    if(now_time<time_line1){
        $('.registration-form input').prop('disabled',true);
        $('#bt_submit').off('click').addClass('gray').html('お申込み開始前');
    }else if(time_line1<now_time && now_time<=time_line2){
        $('.normal[name=entry_section]').prop('disabled',true);
    }else if(time_line2<now_time && now_time<time_line3){//後期登録機関・開催当時まで
        $('.early[name=entry_section]').prop('disabled',true);
    }else if(time_line3<=now_time && now_time<time_line3_2){//開催終了・オンデマンド受付開始前
        $('.registration-form input').prop('disabled',true);
        $('#bt_submit').off('click').addClass('gray').html('オンデマンド受付は10/6より開始');
    }else if(time_line3_2<now_time && now_time<time_line3_3){//オンデマンド受付
        

    }else{
        $('.registration-form input').prop('disabled',true);
        $('#bt_submit').off('click').addClass('gray').html('お申込み終了');
    }
    if(time_line4<now_time){
        $('select[name=entry_lunch]').before('お弁当の申込を締め切りました。');
        $('select[name=entry_lunch], .required2.lunch').remove();
    }

    if($('.registration-form').length>0){
        $('tr[class*=entry_hands-on-]').each(function(){
            var id=$(this).find('input').val();
            console.log(id);
            $(this).find('.stock').html(item[id]['stock']+' / ');
            if(item[id]['stock']<=0){
                $(this).find('input').attr('disabled',true);
            }
        });
    }
    console.log(item[311]);
    if(item[311]['stock']<=0){
        $('input[value=311]').prop('disabled',true)
        $('input[value=311]').before('<span style="color:#f00">満席となりましたので、申込みを締切りました。</span><br>');
    }else if(time_line5<now_time){
        $('input[value=311]').prop('disabled',true)
        $('input[value=311]').before('<span style="color:#f00">申込を締め切りました。</span><br>');
    }
    $('[name=billing_wooccm15]').change(function(){
        if($(this).prop('checked')){
            $('[name=billing_wooccm14]').val('非会員')
        }
    });
    $('.form-row .description').removeClass('description');
        
//    $.when(
//        $(".accordionMenu li").each(function(){
//            var width=parseInt($(this).css("width"));
//            $(this).attr("width",width);
//        })
//	).done(function(){ 
//		//後に実行したい処理
//        $(".accordionMenu").css({display:"none"});
//        $("#header").addClass("fadeIn");
//	});
//    $("#navMenu-pc>ul>li").mouseenter(function(){
//        if($(this).find(".accordionMenu").hasClass("navOpen")==false){
//            $(this).find(".accordionMenu").off();            
//            $(this).find(".accordionMenu").slideToggle(500,function(){
//                $(".navOpen").each(function(){
//                    $(this).removeClass("navOpen");
//                    $(this).slideToggle(500);
//                })
//                $(this).addClass("navOpen");
//                $(this).off();
//                $(this).mouseleave(function(){
//                    $(this).slideToggle(500,function(){
//                        $(this).removeClass("navOpen");
//                    });
//                });
//            });
//        }
//    });
    $(".btSubMenu").click(function(){//開く
        $(this).next().slideToggle(300);
    });
    $(".accordionMenu").mouseleave(function(){
        if($(this).css('display')!='none' && $(this).hasClass('processing')==false){
            $(this).addClass('processing').slideToggle(300,function(){
                $(this).removeClass('processing');
            });
        }
    });
    $('.pulldown-box').click(function(){
        if($(this).hasClass('open')){
            $(this).removeClass('open');
        }else{
            $(this).addClass('open');
        }
    });
    
    if(formInfo['pageSlug']=='cart'){//カート
        var sec=0;
        $('.wc-block-components-quantity-selector__input').click(function(){
            alert('参加証が発行されますので、複数の方も1名ずつお申し込みください。');
        });
        if(formInfo['items'].indexOf('744')==-1){
            var timer=setInterval(function(){
                if($('.wc-block-cart__submit-container').length>0 && $('.wc-block-cart__totals-title').length){
                    $('.entry-title').html('参加登録').css({display:'block'});
                    $('.wc-block-cart-items__header-image').html('項目').css({display:'block'});
                    $('.wc-block-cart__totals-title').html('項目').css({display:'block'});
                    $('.wc-block-components-button__text').html('支払い手続きに進む');
                    $('.wc-block-components-quantity-selector__button--plus').prop('disabled',true)
                    $('.wc-block-components-quantity-selector__input').prop('disabled',true)
                    clearInterval(timer);
                }
                sec+=500;
            },500);
        }
    }else if(formInfo['pageSlug']=='checkout' && location.href.indexOf('order-received')==-1){//決済ページ
        if(formInfo['items'].indexOf('744')!=-1 || time_line3<=now_time){
            var timer=setInterval(function(){
                $('.wooccm-field-wooccm13').remove();
                $('.checkout #order_review .woocommerce-Price-amount').each(function(){
                    if($(this).text()!='¥0'){
                    $(this).css({color:'#000'})
                    }
                });
                $('button#place_order').css({display:'block'});
                // clearInterval(timer);
            },1000)
        }else{
            $('.entry-title').css({display:'block'});
            $('.woocommerce-billing-fields h3').html('基本情報');
            $('h3#order_review_heading').html('申込内容');
            $('#order_review th.product-name').html('項目');
            var timer=setInterval(function(){
                $('.checkout #order_review .woocommerce-Price-amount').each(function(){
                    if($(this).text()!='¥0'){
                    $(this).css({color:'#000'})
                    }
                });
                $('button#place_order').html('登録する').css({display:'block'});
                // clearInterval(timer);
            },1000)
        }
    }else if(formInfo['pageSlug']=='checkout' && location.href.indexOf('order-received')!=-1){//決済完了ページ
        if(formInfo['items'].indexOf('744')==-1 && now_time<=time_line3){
            $('.entry-title').html('参加登録').css({display:'block'});
            $('body.checkout .woocommerce-notice--success').html('参加登録を完了いたしました。<br>ご登録いただいたメールアドレスにお申込内容、参加費領収書、ネームカード兼参加証明書を送信しております。<br>当日はネームカード兼参加証明書を各自プリントアウトしていただき、持参してください。').css({display:'block'});
            $('.woocommerce-order-overview__order').html($('.woocommerce-order-overview__order').html().replace('注文番号','登録番号'))
            $('.woocommerce-order-details__title').html('申込内容');
            $('th.woocommerce-table__product-name.product-name').html('項目');
            $('.woocommerce-column__title').html('基本情報');
            $('.woocommerce-table--order-details .woocommerce-Price-amount').each(function(){
                if($(this).text()=='¥0'){
                   $(this).css({color:'transparent'});
                }
            });
        }
    }else if(location.href.indexOf('check')!=-1){
        $('#entry_QR').each(function(){
            var size=$(this).innerWidth();
            
            var url=$(this).attr('data-url');
            $(this).html("");
            $(this).qrcode({width:size,height:size,text:url});
        });         
    }else if(location.href.indexOf('/certification')!=-1){
        $('#bt_pdf_download').click(function(){
            var content = document.getElementById('pdf-content');
            const scale = 210 / 1200; // A4横幅は210mmで計算
            const options = {
                margin:       0,        // ページの余白 (インチ単位)
                filename:     'ネームカード兼参加証明書.pdf',  // 出力するファイル名
                image:        { type: 'jpeg', quality: 1 }, // 画像の品質
                html2canvas:  { scale: 3 },    // HTML2Canvasの設定
                jsPDF:        { unit: 'px', format: [1000,1400], orientation: 'portrait' }
                 // A4サイズ (約 8.27 x 11.69 インチ) 向き landscape/portrait
            };
            
            html2pdf().set(options).from(content).save();
        });
        $('#bt_pdf_print').click(function(){
            window.print();
        });
        // const button = document.getElementById('bt_pdf_download');
        // button.addEventListener('click', (event) => {
        //     const source = $('.certification')[0]
        //     html2canvas(source).then(capture => {
        //         const imgData = capture.toDataURL('image/png')
        //         const doc = new jsPDF()
        //         const width = doc.internal.pageSize.width
        //         doc.addImage(imgData, 'PNG', 10, 10, width * 0.9, 0)
        //         doc.save("ネームカード兼参加証明書.pdf")
        //     })
        // })
    }else if(formInfo['temp_name']=='single-3d-flip-book.php'){
        setTimeout(function(){
            $bt_sound=$('._3d-flip-book iframe').contents().find('.cmdSounds');
            // console.log($bt_sound);
            if($bt_sound.hasClass('active')==true){
                $bt_sound.click();
                // console.log($bt_sound);
            }
        },5000)
    }else if(formInfo['pageSlug']=='textbook'){
        $('#bt_get_textbook').click(function(){
            if($(this).hasClass('gray')){
                alert('利用規約への同意をお願い致します');
            }else{
                $('#textbook-form').submit();
            }
        });
        $('#textbook_policy').change(function(){
            if($(this).prop('checked')==true){
                $('#bt_get_textbook').removeClass('gray').addClass('orange');
            }else{
                $('##bt_get_textbook').removeClass('orange').addClass('gray');
            }
        });
    }
//    $("[class*=btSubMenu]").mouseenter(function(){
//        alert(0);
//        
//        $("[class*=btSubMenu]").next().each(function(){
//            if($(this).css("display")!="none"){
//                $(this).slideToggle();
//            }
//        });
//        $(this).next().slideToggle();
//    });
    
    if(document.getElementById("content-index")){
        var index=$(".content").find("h2,h3");
        for(var i=0;i<index.length;i++){
            var id="index-"+i;
            if(index[i].hasAttribute("id")==false){
                $(index[i]).attr("id",id);
            }else{
                id=index[i].id;
            }
            var tx=$(index[i]).html();
            if($(index[i]).prop("tagName").toLowerCase()=="h2"){
            }else if($(index[i]).prop("tagName").toLowerCase()=="h3"){
                tx="－ "+tx;
            }
            $("#content-index").append("<a href='#"+id+"'>"+tx+"</a>");
        }
    }
    scrollLink("header");
    
    $("#bt_naviW").click(function(){
        btMotion(100,this.id,{mode:'cross-span'},function(){
            slideToggleW(100,"pulldownMenu");
        })
        if($("#mb_sidebar").html().length<10){
//            var sidebar=$("#sidebar").clone(true);
//            $("#mb_sidebar").append(sidebar);
        }
    });
    $("#bt_scrollTop").click(function(){
        $("body,html").animate({scrollTop:"0px"},700,"swing");
    });
    
    //customエリア
    if($("#topParts1")[0]!=null){
        var parts=$("#topParts1").clone();
        $("#topParts1")[0].id="topPartsBack";
        $("#topArea").append(parts);
    }
    $('.tab-flow').click(function(){
        var now_flow=$('.bt_tab-focus').attr('name').split('tab_')[1];
        var next_flow=$(this).attr('name').split('tab_')[1];
        console.log(now_flow+'/'+next_flow);
        $('.bt_tab-focus').removeClass('bt_tab-focus');
        $(this).addClass('bt_tab-focus');
        $('.block_'+now_flow).animate({opacity:0},{duration:300,complete:function(){
            $(this).addClass('esc_dispNone');
            $('.block_'+next_flow).removeClass('esc_dispNone').animate({opacity:1},{duration:300});
        }});
    });
      
//    $(".slide0").slick({
//            dots: false,
//            arrows: false,
//            infinite: true,
//            speed: 5000,
//            autoplay: true,
//            slidesToShow: 1,
//            centerMode: true,
//            fade: true,
////            variableWidth: true,
//            adaptiveHeight: true,
//        });
    $('.on-motion img').on('mouseover',function(){
        var srcSeg=$(this).attr('src').split('.');
        srcSeg[srcSeg.length-2]+='_on';
        $(this).attr('src',srcSeg.join('.'));
    });
    $('.on-motion img').on('mouseleave',function(){
        $(this).attr('src',$(this).attr('src').replace('_on.','.'));
    });
    $('.esc-span-font').find('span').each(function(){
        if(this.hasAttribute('style')){
            var style=$(this).attr('style');
            var styleHash=getHash(style,':',';');
//            console.log(styleHash);
            if('font-size' in styleHash){
                delete styleHash['font-size'];
            }
            $(this).attr('style',packHash(styleHash,':',';'))
        }    
    });
    afterCss();
    if(window.innerWidth<=768){
	   afterCss('mbCss-');
    }
    //Gutenberg調整
    $(".content img").each(function(){
        $(this).removeAttr("height");//.removeAttr("width");//
    });
    $('.maxH_to_dotEnd').each(function(){//max-height設定だけでもdotEndを作動させる
        var height=parseInt($(this).css('height'));
        var maxHeight=parseInt($(this).css('max-height'));
        if(height==maxHeight){
            $(this).css({height:height+'px',maxHeight:'initial'});
            dotEnd(this)
        }
    });
    $('.fitHeight').each(function(){//親要素の下端まで高さを伸ばす
        var offsetH=$(this).position().top;
        var parentH=parseInt($(this).parent().height());
        var paddingBottom=parseInt($(this).parent().css('padding-bottom'));
        $(this).css({height:(parentH-offsetH-paddingBottom)+'px'});
//        alert(parentH+'/'+paddingBottom);
    });
    $('.dotEnd').each(function(){dotEnd(this)});
})

function afterCss(prefix='css-'){
	//(※1)　現状ブロックエディターへの対応はwidthのみを想定
	
	$('[class*='+prefix+']').each(function(){
		var clsAry=$(this).attr('class').split(' ');
		var cssHash={};
		var cssHash_block=null;//ブロックエディターの場合のdiv.wp-block-imageへの適応(※1)
		for(var i=0;i<clsAry.length;i++){
			if(clsAry[i].indexOf(prefix)!=-1){
				var cssSet=clsAry[i].replace(prefix,'').split('-');
				if(cssSet.length>=2){
					if(window.innerWidth<=768 && cssSet[0].indexOf('mb_')!=-1){
						cssSet[0]=cssSet[0].replace('mb_','');
					}
					var value=parseInt(cssSet[1]);
					var unit=cssSet[1].replace(value,'').toLowerCase();
					if(unit=='per' || unit==''){unit='%';}
					if(isNaN(value)){
						cssHash[cssSet[0]]=cssSet[1];
					}else{
						cssHash[cssSet[0]]=value+unit;
					}
					//ブロックエディターの場合(※1)
					if($(this).hasClass('wp-block-image')){
						//<div class="wp-block-image"><figure><img>に成形される
						//追加クラスはdiv、alignleft系はfigureにつく
						//alignleft,alignrightの場合はそのまま
						if($(this).find('figure').hasClass('aligncenter') && cssSet[0]=='width'){
							cssHash_block={'width':'100%'};
							$(this).find('img').addClass('aligncenter');
						}
						if(window.innerWidth<=768){
							if($(this).attr('class').indexOf('css-mb_width')==-1){
								//imgで特にmb-widthの指定がない場合は特別に
								$(this).find('img').addClass('mb_img-default');
								delete cssHash['width'];
							}
						}
					}else{//クラシックエディターの場合
					}
				}
				
			}
		}
		if(cssHash_block!=null){
			$(this).find('img').css(cssHash);
			$(this).css(cssHash_block);
		}else{
			$(this).css(cssHash);
		}
	});
}
function closePulldown(selecta){
}
function btMotion(time,btEle,motion={mode:""}
                   ,onFunc=null,offFunc=null){
    //motion['mode']=image/""➡onImgName,offImgNameの切り替え
    //motion['mode']=
	if(offFunc==null){offFunc=onFunc;}
	btEle=getEle(btEle);
    
    if(motion['mode']=='cross-span'){
        if($(btEle).hasClass("btFuncOn")==false){
            $("#bt_naviW span:nth-child(1)").css({width:"80%"
                    ,right:"22%",top:"22%",transform:"rotate(-45deg)"});
            $("#bt_naviW span:nth-child(2)").css({width:"0%"});
            $("#bt_naviW span:nth-child(3)").css({width:"80%"
                    ,right:"22%",top:"78%",transform:"rotate(45deg)"});
            $(btEle).addClass("btFuncOn");
            onFunc();
        }else if($(btEle).hasClass("btFuncOn")){
            $("#bt_naviW span:nth-child(1)").css({width:"70%"
                    ,right:"15%",top:"28%",transform:"rotate(0deg)"});
            $("#bt_naviW span:nth-child(2)").css({width:"70%"});
            $("#bt_naviW span:nth-child(3)").css({width:"70%"
                    ,right:"15%",top:"72%",transform:"rotate(0deg)"});
            $(btEle).removeClass("btFuncOn");
            offFunc();
        }
    }else{//image
        onImgName='bt-open_default.png';
        offImgName='bt-close_default.png';
        if($(btEle).css("backgroundImage").indexOf(onImgName)!=-1){
            $(btEle).animate({opacity:0},{duration:time,easing:"linear",complete:function(){
                onFunc();
                var imgVal=$(this).css("backgroundImage");
                var nextImgVal=imgVal.replace(onImgName,offImgName);
                $(this).css({backgroundImage:nextImgVal});
                $(this).animate({opacity:1},{duration:time,easing:"linear",complete:function(){
                    $(this).addClass("btFuncOn");
                }});
            }});
        }else if($(btEle).hasClass("btFuncOn")){
            $(btEle).animate({opacity:0},{duration:time,easing:"linear",complete:function(){
                offFunc();
                var imgVal=$(this).css("backgroundImage");
                var nextImgVal=imgVal.replace(offImgName,onImgName);
                $(this).css({backgroundImage:nextImgVal});
                $(this).animate({opacity:1},{duration:time,easing:"linear",complete:function(){
                    $(this).removeClass("btFuncOn");
                }});
            }});
        }
    }
    
}
function onFadeArea(time,btEle,fadeEle){
	btEle=getEle(btEle);
	fadeEle=getEle(fadeEle);
	var rect=btEle.getBoundingClientRect();
	var rect2=$("body")[0].getBoundingClientRect();
	var btBtmLine=0;//rect.top+rect.height;//fixedでのNaviバー重なりを補正する場合
	$(fadeEle).css({top:btBtmLine+"px",height:rect2.height+"px"});
	if($(fadeEle).css("display")=="none"){
		$(fadeEle).css({display:"block",top:btBtmLine+"px",zIndex:8});
		$(fadeEle).animate({opacity:1},{duration:time,easing:"swing"});
	}else{
		$(fadeEle).css({top:btBtmLine+"px",zIndex:1});
		$(fadeEle).animate({opacity:0},{duration:time,easing:"swing",complete:function(){
			$(this).css({display:"none"});
		}});
	}
}
function slideToggleW(time,ele){
	ele=getEle(ele);
	if($(ele).css("display")=="none"){
		var width=$(ele).css("width");
		$(ele).css({display:"block",width:0});
		$(ele).animate({width:width},{duration:time,easing:"swing"});
	}else{
		var width=$(ele).css("width");
		$(ele).animate({width:0},{duration:time,easing:"swing",complete:function(){
			$(this).css({display:"none",width:width});
		}});
	}
}
function slideToggleW2(time,ele){//イチヤマ用
    var els=$(ele).children();
	if($(ele).css("display")=="none"){
		$(ele).css({display:"block"});//,width:0
		els.each(function(){
            var width=parseInt($(this).attr("width"));
            $(this).css({width:0});
            $(this).animate({width:width+"px"},{duration:time,easing:"swing"});
        })
        $(ele).css({display:"block"});
	}else{
        $.when(
            els.each(function(){0
                $(this).animate({width:0},{duration:time,easing:"swing"});
            })
        ).done(function(){
            $(ele).css({display:"none"});
        })
	}
}
function scrollLink(headerID){
	var els=$("a[href*=\\\#]");
	//自動スクロール
	for(var i=0;i<els.length;i++){
        if($(els[i]).attr("href")==undefined || $(els[i]).attr("target")=="_blank"){
        }else if($(els[i]).attr("href").indexOf("#")!=-1){
			$(els[i]).attr("data-scrlink",$(els[i]).attr("href"))
                .removeAttr("href").click(function(){
				var link=$(this).attr("data-scrlink").split("#")[0];
                var id=$(this).attr("data-scrlink").split("#")[1];
                var headerH=0;
                if(document.getElementById(headerID)){
                    headerH=parseInt($("#"+headerID).css("height"));
                }
                if(link==""){link=formInfo["home_url"];}
				if(document.getElementById(id)==null){
					window.location.href=link+"?scrl="+id;
				}else{
					var pos=$("#"+id).offset().top-headerH;
					$("body,html").animate({scrollTop:pos+"px"},700,"swing");
				}
			});
		}
	}
	if(formInfo["scrl"]!=""){
		if(document.getElementById(formInfo["scrl"])!=null){
			var pos=$("#"+formInfo["scrl"]).offset().top//-parseInt($("#"+formInfo["scrl"]).css("height"))*2;
			$("body,html").animate({scrollTop:pos+"px"},700,"swing");
		}
	}
}
function dotEnd(p_ele) {//複数行でもはみ出した文字に…を付けれる
	if((typeof p_ele)=="string"){p_ele=document.getElementById(p_ele);}
    var $target=$(p_ele);
    // オリジナルの文章を取得する
    var html = $target.html();
    // 対象の要素を、高さにautoを指定し非表示で複製する
    var $clone = $target.clone();
    $clone.css({display: 'none',position : 'absolute',overflow : 'visible'})
      .width($target.width())
      .height('auto');
    // DOMを一旦追加
    $target.after($clone);
    // 指定した高さになるまで、1文字ずつ消去していく
    while((html.length > 0) && ($clone.height() > $target.height())) {
      html = html.substr(0, html.length - 1);
      $clone.html(html + '...');
    }
    // 文章を入れ替えて、複製した要素を削除する
    $target.html($clone.html());
    $clone.remove();
}
function packHash(hash,asColon=':',asComma=','){
	if($.isPlainObject(hash)==false){return hash;}
	var ary=[];
	for(var key in hash){
		ary.push(key+asColon+hash[key]);
	}return ary.join(asComma);
}
function getHash(line,asColon=':',asComma=','){
    if($.isPlainObject(line)==true){return line;}
    if(line==''){return {}}
    var hash={};
    var seg=line.split(asComma);
    for(var i=0;i<seg.length;i++){
        if(seg[i].indexOf(asColon)!=-1){
            var seg2=seg[i].split(asColon);
            hash[seg2[0]]=seg2[1];
        }
    }
    return hash;
}
function getEle(id_or_ele){
	if((typeof id_or_ele)=="string"){id_or_ele=document.getElementById(id_or_ele);}
	return id_or_ele;
}