<div id="mjointbox">
    <div class="title">이 위젯(<span class="b"><?php echo getFolderName($g['path_widget'].$swidget)?></span>)을 추가하시겠습니까?</div>

    <form name="procform" onsubmit="return saveCheck(this);">
    <table>
        <tr>
            <td class="td1">위젯 타이틀</td><td class="td2">:</td>
            <td class="td3"><input type="text" name="title" value="<?php echo htmlspecialchars($wdgvar['title']?$wdgvar['title']:'인기 검색어',ENT_QUOTES,'UTF-8')?>" size="24" class="input" /> <label><input type="checkbox" name="notuse" value="1"<?php if($wdgvar['notuse']):?> checked="checked"<?php endif?> /> 사용안함</label></td>
        </tr>
        <tr>
            <td class="td1">보조 설명</td><td class="td2">:</td>
            <td class="td3"><input type="text" name="subtitle" value="<?php echo htmlspecialchars($wdgvar['subtitle']?$wdgvar['subtitle']:'지금 많이 찾는 키워드',ENT_QUOTES,'UTF-8')?>" size="24" class="input" /></td>
        </tr>
        <tr>
            <td class="td1">검색어 노출수</td><td class="td2">:</td>
            <td class="td3"><select name="limit"><?php for($i=5;$i<=20;$i+=5):?><option value="<?php echo $i?>"<?php if((int)$wdgvar['limit']===$i||(!$wdgvar['limit']&&$i===10)):?> selected="selected"<?php endif?>>ㆍ<?php echo $i?>개</option><?php endfor?></select></td>
        </tr>
        <tr>
            <td class="td1">집계 기간</td><td class="td2">:</td>
            <td class="td3"><select name="term"><?php foreach(array(1,3,7,14,30) as $i):?><option value="<?php echo $i?>"<?php if((int)$wdgvar['term']===$i||(!$wdgvar['term']&&$i===7)):?> selected="selected"<?php endif?>>ㆍ최근 <?php echo $i?>일 이내</option><?php endforeach?></select></td>
        </tr>
    </table>

    <div class="btnbox">
        <input type="button" value="미리보기" class="btngray" onclick="previewToggle();" />
        <?php if($isWcode=='Y'):?><input type="button" value="위젯코드" class="btnblue" onclick="widgetCode();" />
        <?php else:?><input type="submit" value="<?php echo $option?'속성변경':'위젯추가'?>" class="btnblue" /><?php endif?>
    </div>
    </form>

    <div id="hotPreview" class="preview hide"><?php getWidget($swidget,array('widget_id'=>$swidget,'title'=>'인기 검색어','subtitle'=>'지금 많이 찾는 키워드','limit'=>10,'term'=>7))?></div>
</div>

<style>
#mjointbox{max-width:390px;font-family:"Noto Sans KR","Malgun Gothic",sans-serif;color:#344054}
#mjointbox .title{border-bottom:1px dashed #dfe4ea;padding:0 0 12px;margin:0 0 20px}
#mjointbox table{border-collapse:collapse}#mjointbox td{padding:4px 0}
#mjointbox .td1{width:95px;letter-spacing:-1px}#mjointbox .td2{padding-right:15px;color:#c0c0c0}#mjointbox .td3{white-space:nowrap}
#mjointbox .td3 .input{box-sizing:border-box;width:230px;height:28px;border:1px solid #cfd8e3;padding:0 8px}#mjointbox .td3 select{box-sizing:border-box;width:230px;height:28px;border:1px solid #cfd8e3;background:#fff}
#mjointbox .td3 label{font-size:11px;color:#667085}#mjointbox .td3 input[type=checkbox]{vertical-align:-2px}
#mjointbox .btnbox{text-align:center;padding:20px 0 0;margin:20px 0 0;border-top:1px dashed #dfe4ea}
#mjointbox .btnbox input{height:30px;margin:0 2px;padding:0 13px;border:0;color:#fff;font-weight:bold;cursor:pointer}.btnbox .btngray{background:#8a8f98}.btnbox .btnblue{background:#20aee5}.btnbox .btnblue:hover{background:#0a95cf}
#mjointbox .preview{width:220px;margin:18px auto 0}#mjointbox .hide{display:none}
</style>

<script>
var RB_widgetCode;
function getWidgetInfo(f){var a=[];if(f.title.value)a.push("'title'=>'"+f.title.value.replace(/'/g,"\\'")+"'");if(f.subtitle.value)a.push("'subtitle'=>'"+f.subtitle.value.replace(/'/g,"\\'")+"'");if(f.notuse.checked)a.push("'notuse'=>'1'");a.push("'limit'=>'"+f.limit.value+"'");a.push("'term'=>'"+f.term.value+"'");return a.join(',');}
function widgetCode(){var f=document.procform;RB_widgetCode="<"+"?php getWidget('<?php echo $swidget?>',array("+getWidgetInfo(f)+"))?"+">";OpenWindow('<?php echo $g['s']?>/?r=<?php echo $r?>&system=popup.widgetcode&iframe=Y');}
function previewToggle(){var p=document.getElementById('hotPreview');p.className=p.className.indexOf('hide')>-1?'preview':'preview hide';}
function saveCheck(f){
<?php if(!$option):?>var i,n=0;for(i=0;i<opener.maxTiles;i++){if(opener.moveObject[i].style.display=='block')n=i+1;}<?php else:?>var n=<?php echo $dropfield?>;<?php endif?>
<?php if(!$option):?>opener.createTile('220px','390px','0px','0px');<?php endif?>
opener.blocktitle[n]='인기검색어';opener.blockarray[n]="<?php echo $swidget?>,title^"+f.title.value+",subtitle^"+f.subtitle.value+",notuse^"+(f.notuse.checked?'1':'')+",limit^"+f.limit.value+",term^"+f.term.value;opener.getId('wtitle'+n).innerHTML=opener.blocktitle[n];top.close();return false;}
</script>
