<script src="/ckeditor/ckeditor.js"></script>
<div class="contents">
    <div class="mypage_right">
        <div class="mypage_right_top">
            <span class="mypage_title">1:1 문의</span>
        </div>
        <form name="input_form" id="input_form" action="/web/mypage/qna_add_proc" method="post">
        <div class="bookmark_add">
            <span style="padding-right:20px;">제목 </span>
            <span class="url" style="margin-right:20px;"><input type="text" name="title" id="title" style="width:440px"></span>
            <span><span class="red" id="title_count">0</span>/60자</span>
            <td><a href=""> </a><span class="chain"><img src="/img/web/chain.jpg"></span></td>
        </div>
        <div class="mypage_board">
            <!-- <textarea id="content" name="content" style="width:730px;"></textarea> -->
            <textarea name="content" id="ir1" style="width:720px; height:450px;" /></textarea>
            <div class="form-group" style=" display:block; text-align:center; padding:30px 0;">
                <button type="button" onclick="qna_add_proc();" class="btn btn-success br20" style="padding:7px 40px; font-size:16px">글쓰기 </button>
                <button type="button" onclick="location.href='/web/mypage/qna'" class="btn btn-default_bb br20" style="padding:7px 40px; font-size:16px">목록으로</button>
            </div>
        </div>
        </form>
    </div>
</div>

<script type="text/javascript">
var oEditors = [];
var oEditors2 = [];

$(function(){
      nhn.husky.EZCreator.createInIFrame({
          oAppRef: oEditors,
          elPlaceHolder: "ir1",
          sSkinURI: "/smarteditor/SmartEditor2Skin.html",  
          htParams : {
              bUseToolbar : true,             
              bUseVerticalResizer : true,     
              bUseModeChanger : true,         
              fOnBeforeUnload : function(){
              }
          }, 
          fOnAppLoad : function(){
          },
          fCreator: "createSEditor2"
      });
      
      nhn.husky.EZCreator.createInIFrame({
          oAppRef: oEditors2,
          elPlaceHolder: "ir2", 
          sSkinURI: "/smarteditor/SmartEditor2Skin.html",  
          htParams : {
              bUseToolbar : true,             
              bUseVerticalResizer : true,     
              bUseModeChanger : true,         
              fOnBeforeUnload : function(){
              }
          }, 
          fOnAppLoad : function(){
          },
          fCreator: "createSEditor2"
      });

});
</script>

<script type="text/javascript">
$(document).ready(function() {
    /*
	CKEDITOR.replace('content', {
        height: '400px'
    });
	*/
});


$('#title').on('keyup', function(event) {
	var len = $(this).val().length;
   	if (len >= 60) {
      	$(this).val($(this).val().substring(0, 60));
		len = 60;
   	}
   	$("#title_count").html(len);
});

function qna_add_proc(){
    //CKEDITOR.instances.content.updateElement();
	oEditors.getById["ir1"].exec("UPDATE_CONTENTS_FIELD", []);
	//oEditors2.getById["ir2"].exec("UPDATE_CONTENTS_FIELD", []);

    if($("#title").val()=="") {
        alert("제목을 입력해주세요.");
        return false;
    }
    /*
	if($("#content").val()=="") {
        alert("내용을 입력해주세요.");
        return false;
    }
	*/
	if($("#ir1").val()=='' || $("#ir1").val()=='null' || $("#ir1").val()=='&nbsp;' || $("#ir1").val()=='<p>&nbsp;</p>') {
        alert("내용을 입력해주세요.");
		oEditors.getById["ir1"].exec("focus");
		return false;
	}

    $("#input_form").submit();
}


</script>