/*
Copyright (C) NAVER corp.  

This library is free software; you can redistribute it and/or  
modify it under the terms of the GNU Lesser General Public  
License as published by the Free Software Foundation; either  
version 2.1 of the License, or (at your option) any later version.  

This library is distributed in the hope that it will be useful,  
but WITHOUT ANY WARRANTY; without even the implied warranty of  
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  
Lesser General Public License for more details.  

You should have received a copy of the GNU Lesser General Public  
License along with this library; if not, write to the Free Software  
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA  
*/
/*
 * Smart Editor 2 Configuration : This setting must be changed by service
 */
window.nhn = window.nhn || {};
nhn.husky = nhn.husky || {};
nhn.husky.SE2M_Configuration = nhn.husky.SE2M_Configuration || {};

/**
 * CSS LazyLoad瑜� �꾪븳 寃쎈줈
 */
nhn.husky.SE2M_Configuration.SE2B_CSSLoader = {
	sCSSBaseURI : "css"
};

/**
 * �몄쭛�곸뿭 �ㅼ젙
 */
nhn.husky.SE2M_Configuration.SE_EditingAreaManager = {
	sCSSBaseURI : "css",					// smart_editor2_inputarea.html �뚯씪�� �곷�寃쎈줈
	sBlankPageURL : "smart_editor2_inputarea.html",
	sBlankPageURL_EmulateIE7 : "smart_editor2_inputarea_ie8.html",
	aAddtionalEmulateIE7 : [] // IE8 default �ъ슜, IE9 ~ �좏깮�� �ъ슜
};

/**
 * [�뱀젒洹쇱꽦]
 * �⑥텞�� ALT+,  ALT+. �� �댁슜�섏뿬 �ㅻ쭏�몄뿉�뷀꽣 �곸뿭�� �댁쟾/�댄썑 �붿냼濡� �대룞�� �� �덈떎.
 * 		sBeforeElementId : �ㅻ쭏�몄뿉�뷀꽣 �곸뿭 �댁쟾 �붿냼�� id
 * 		sNextElementId : �ㅻ쭏�몄뿉�뷀꽣 �곸뿭 �댄썑 �붿냼�� id 
 * 
 * �ㅻ쭏�몄뿉�뷀꽣 �곸뿭 �댁쇅�� �쒕ぉ �곸뿭 (��:�ㅻ쭏�몄뿉�뷀꽣媛� �곸슜�� 釉붾줈洹� �곌린 �섏씠吏��먯꽌�� �쒕ぉ �곸뿭) �� �대떦�섎뒗 �섎━癒쇳듃�먯꽌 Tab�ㅻ� �꾨Ⅴ硫� �먮뵒�� �곸뿭�쇰줈 �ъ빱�ㅻ� �대룞�쒗궗 �� �덈떎.
 * 		sTitleElementId : �쒕ぉ�� �대떦�섎뒗 input �붿냼�� id. 
 */
nhn.husky.SE2M_Configuration.SE2M_Accessibility = {
    ed_nonce : (typeof parent.ed_nonce !='undefined') ? parent.ed_nonce : '',
    sBeforeElementId : '',
    sNextElementId : '',
    sTitleElementId : ''
};

/**
 * 留곹겕 湲곕뒫 �듭뀡
 */
nhn.husky.SE2M_Configuration.SE2M_Hyperlink = {
	bAutolink : true	// �먮룞留곹겕湲곕뒫 �ъ슜�щ�(湲곕낯媛�:true)
};

nhn.husky.SE2M_Configuration.Quote = {
	sImageBaseURL : 'http://static.se2.naver.com/static/img'
};

nhn.husky.SE2M_Configuration.SE2M_ColorPalette = {
	bUseRecentColor : false
};

nhn.husky.SE2B_Customize_ToolBar = jindo.$Class(/** @lends nhn.husky.SE2B_Customize_ToolBar */{
	name : "SE2B_Customize_ToolBar",
	/**
	 * @constructs
	 * @param {Object} oAppContainer �먮뵒�곕� 援ъ꽦�섎뒗 而⑦뀒�대꼫
	 */
	$init : function(oAppContainer) {
		this._assignHTMLElements(oAppContainer);
	},
	$BEFORE_MSG_APP_READY : function(){
		this._addEventMoreButton();
	},
	
	/**
	 * @private
	 * @description DOM�섎━癒쇳듃瑜� �섏쭛�섎뒗 硫붿냼��
	 * @param {Object} oAppContainer �대컮 �ы븿 �먮뵒�곕� 媛먯떥怨� �덈뒗 div �섎━癒쇳듃
	 */
	_assignHTMLElements : function(oAppContainer) {
		this.oAppContainer = oAppContainer;
		this.elTextToolBarArea =  jindo.$$.getSingle("div.se2_tool");
		this.elTextMoreButton =  jindo.$$.getSingle("button.se2_text_tool_more", this.elTextToolBarArea);
		this.elTextMoreButtonParent = this.elTextMoreButton.parentNode;
		this.welTextMoreButtonParent = jindo.$Element(this.elTextMoreButtonParent);
		this.elMoreLayer =  jindo.$$.getSingle("div.se2_sub_text_tool");
	},

	_addEventMoreButton : function (){
		this.oApp.registerBrowserEvent(this.elTextMoreButton, "click", "EVENT_CLICK_EXPAND_VIEW");
		this.oApp.registerBrowserEvent(this.elMoreLayer, "click", "EVENT_CLICK_EXPAND_VIEW");			
	},
	
	$ON_EVENT_CLICK_EXPAND_VIEW : function(weEvent){
		this.oApp.exec("TOGGLE_EXPAND_VIEW", [this.elTextMoreButton]);
		weEvent.stop();
	},
	
	$ON_TOGGLE_EXPAND_VIEW : function(){
		if(!this.welTextMoreButtonParent.hasClass("active")){
			this.oApp.exec("SHOW_EXPAND_VIEW");
		} else {
			this.oApp.exec("HIDE_EXPAND_VIEW");
		}
	},
	
	$ON_CHANGE_EDITING_MODE : function(sMode){
		if(sMode != "WYSIWYG"){
			this.elTextMoreButton.disabled =true;
			this.welTextMoreButtonParent.removeClass("active");
			this.oApp.exec("HIDE_EXPAND_VIEW");
		}else{
			this.elTextMoreButton.disabled =false;
		}
	},
	
	$AFTER_SHOW_ACTIVE_LAYER : function(){
		this.oApp.exec("HIDE_EXPAND_VIEW");
	},
	
	$AFTER_SHOW_DIALOG_LAYER : function(){
		this.oApp.exec("HIDE_EXPAND_VIEW");
	},
	
	$ON_SHOW_EXPAND_VIEW : function(){
		this.welTextMoreButtonParent.addClass("active");
		this.elMoreLayer.style.display = "block";
	},
	
	$ON_HIDE_EXPAND_VIEW : function(){
		this.welTextMoreButtonParent.removeClass("active");
		this.elMoreLayer.style.display = "none";
	},
	
	/**
	 * CHANGE_EDITING_MODE紐⑤뱶 �댄썑�� �몄텧�섏뼱�� ��. 
	 * WYSIWYG 紐⑤뱶媛� �쒖꽦�붾릺湲� �꾩뿉 �몄텧�� �섎㈃ APPLY_FONTCOLOR�먯꽌 �먮윭 諛쒖깮.
	 */
	$ON_RESET_TOOLBAR : function(){
		if(this.oApp.getEditingMode() !== "WYSIWYG"){			
			return;
		}
		//�ㅽ렆泥댄겕 �リ린 
		this.oApp.exec("END_SPELLCHECK");		
		//�대┛ �앹뾽�� �リ린 �꾪빐��
		this.oApp.exec("DISABLE_ALL_UI");
		this.oApp.exec("ENABLE_ALL_UI");
		//湲��먯깋怨� 湲��� 諛곌꼍�됱쓣 �쒖쇅�� �명똿
		this.oApp.exec("RESET_STYLE_STATUS");
		this.oApp.exec("CHECK_STYLE_CHANGE");
		//理쒓렐 �ъ슜�� 湲��먯깋 �뗮똿.
		this.oApp.exec("APPLY_FONTCOLOR", ["#000000"]);
		//�붾낫湲� �곸뿭 �リ린.
		this.oApp.exec("HIDE_EXPAND_VIEW");
	}
});