var oEditors = [];

var editor = {
	submitHandler : function(){
		$("textarea[data_type=editor]").each(function(){
			oEditors.getById[$(this).attr("id")].exec("UPDATE_IR_FIELD", []);
			
			// 줄간격을 %값으로 변환
			if ($("#pEditor").length > 0) {
				$("#pEditor").html($(this).val());
				$("#pEditor p").each(function() {
					if (!isNaN($(this).css("lineHeight"))) {
						$(this).css("line-height", String($(this).css("lineHeight") * 100) + "%");
					}
				});
				$(this).val($("#pEditor").html());
			}
		});
	}
};

jQuery.extend(editor);

$(function(){
	$("textarea[data_type=editor]").each(function(){
		nhn.husky.EZCreator.createInIFrame({
		  oAppRef: oEditors,
		  elPlaceHolder: $(this).attr("id"),
		  sSkinURI: "/html/css/smart_editor/SEditorSkin.html",
		  fCreator: "createSEditorInIFrame"
	   });
	});
	
	if($("textarea[data_type=editor]").length){
    $("form").submit(function(){
      editor.submitHandler();	
      //return true;
    });
  }
});

