function SceneTextEditor(options) {
	this.options = options;
   // this.Bg_Image =null;
    this.TitleBar = null;    
    this.MsgLabel = null;
    this.MsgLengthLabel = null;
    this.MsgNormalLengthLabel = null;
    this.MsgAreaLengthLabel = null;
	
    this.TextEditorView=null;
    this.TextEditorNormalView=null;
    this.TextEditorTextAreaView=null;
    this.TextEditorBG=null;
	this.TextEditorDim=null;
    
    this.TextInputBox = null;
    this.TextNormalInputBox = null;
    this.TextAreaBox = null;
    
    this.flagPWD = false;
    this.initText ="";
    this.maxStringLenght = 50;
    this.callerObj = null;
    this.flagBlockSpace = false;
    this.flagID= false;
    this.inputTitle = "";
    
    this.flagCreate = false;
    this.flagTextArea = false;
    this.flagPwdShow = false;
    this.flagInit =false;    
	
	this.TextInputTimer = false;
	
	
	//13년 테스트 ime
	this.imeBox = null;
	this.str = null;
	this.imeIsShow = false;
	

}

SceneTextEditor.prototype.initialize = function () {
	alert("SceneTextEditor.initialize()");
	// this function will be called only once when the scene manager show this scene first time
	// initialize the scene controls and styles, and initialize your variables here 
	// scene HTML and CSS will be loaded before this function is called
    
   this.create();
}

SceneTextEditor.prototype.handleShow = function () {
	alert("SceneTextEditor.handleShow()");
	//defensive code DF131217-01284
	if(this.TextEditorDim===null){
		this.create();
	}
	this.TextEditorDim.show();
	this.updateIMEBox();
	
}

SceneTextEditor.prototype.handleHide = function () {
	alert("SceneTextEditor.handleHide()");
	// this function will be called when the scene manager hide this scene
	this.TextEditorDim.hide();  
}

SceneTextEditor.prototype.handleFocus = function () {
	alert("SceneTextEditor.handleFocus()");
	// this function will be called when the scene manager focus this scene   
	this.imeBox.onShow();
	this.imeIsShow = true;
    // this.highlight(this.TextInputBox);	
}

SceneTextEditor.prototype.handleBlur = function () {
	alert("SceneTextEditor.handleBlur()");
	// this function will be called when the scene manager move focus to another scene from this scene
	if(this.imeIsShow==true){
		this.imeBox.onClose();
	}
}

SceneTextEditor.prototype.handleKeyDown = function (keyCode) {
	alert("SceneTextEditor.handleKeyDown(" + keyCode + ")");
	// TODO : write an key event handler when this scene get focued
	PluginAPIMgr.PlayAudio(keyCode);
	if(ProcMgr.checkWidgetHighlight()==false){
		return;
	}
	switch (keyCode) {
		case sf.key.LEFT:
		case sf.key.RIGHT:
             //this.processLeftRightKey();
			break;
		case sf.key.UP:

			break;
		case sf.key.DOWN:

			break;

		case sf.key.ENTER:
             //this.processEnterKey();
			break;
            
        case sf.key.RETURN:
            //this.processReturnKey();
            //2013 modify by minseok
            sf.key.preventDefault();
            //sf.key.block(event);
			break;
            
         case sf.key.EXIT:
            //this.processExitKey();
            //2013 modify by minseok
            sf.key.preventDefault();
            //sf.key.block(event);
			break;
            
         case 147:  //infolink
           //2013 modify by minseok
            sf.key.preventDefault();
            //sf.key.block(event);
			break;
	}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////

SceneTextEditor.prototype.create = function(){
	this.TextEditorDim=new DimBg("TextEditorDim","TextEditor");
	
}
SceneTextEditor.prototype.onKeyCallback= function(key, str, id){
	 alert("SceneTextEditor.onKeyCallback() ===================: " + key + " ID = " + id + " STR = " + str);
	 var Scene = sf.scene.get("TextEditor");
	 Scene.imeIsShow = false;
    switch (key) {
        case sf.key.ENTER: // Enter Key
            alert("ENTER - str is "+str);
            Scene.str = str;
            Scene.processEnterKey();
            break;
        case sf.key.RETURN:  //return
            alert("RETURN");
            Scene.processReturnKey();
            break;
        case sf.key.EXIT:  //exit
            alert("EXIT");
            Scene.processReturnKey();
            break;
    }
	
	
}
SceneTextEditor.prototype.updateIMEBox= function(){
	alert("SceneTextEditor.updateIMEBox()");
	this.imeBox = new IMEShell_Common();
	//this.imeBox.inputboxID = "TextEditorImeTest";
   	this.imeBox.inputTitle=this.inputTitle;
    //this.imeBox.context = this;
    if(this.flagPWD)
    	this.imeBox.setPasswordMode(this.flagPWD);
    this.imeBox.setBlockSpace(this.flagBlockSpace); //첫번째 스페이스 입력 막기
    this.imeBox.setMaxlength(this.maxStringLenght); //최대값 지정
    this.imeBox.onKeyPressFunc = this.onKeyCallback; //enter,return,exit 를 반환합니다. 입력완료(enter), 취소(return)로 사용중입니다.
    if(this.flagID)
    	this.imeBox.setUseIDMode(this.flagID);
    	
    this.imeBox.onTextChangeFunc = this.onTextChange;
    this.imeBox.setMinlength(null);

    //document.getElementById('searchText1').setAttribute("maxlength", 20); //최대값 지정(inputbox 있을때는 이방식도 지원)
    //document.getElementById('searchText1').value ="test text123";
    this.imeBox.inputString = this.initText; //inputbox 없을때는 위해서 처음입력값 넣기
}

SceneTextEditor.prototype.onTextChange= function(string){
	alert("SceneTextEditor.onTextChange()");
	var Scene = sf.scene.get("TextEditor");
	Scene.imeBox._SetDoneButtonDimFlag(false,false);
}

SceneTextEditor.prototype.initInputBox = function(callerObj)
{
    alert("SceneTextEditor.initInputBox()");

    this.flagPWD = callerObj.GetFlagPwd();
	this.initText =  callerObj.GetText();    
	this.flagBlockSpace = callerObj.GetFlagBlockSpace();
    this.maxStringLenght = callerObj.GetMaxStringLength();
    this.flagID = callerObj.GetFlagIdType()
    this.callerObj = callerObj;
    if(this.callerObj.GetTextEditorMsg()){
    	this.inputTitle = this.callerObj.GetTextEditorMsg();
    }else if(this.callerObj.GetTextEditorTitle()){
    	this.inputTitle = this.callerObj.GetTextEditorTitle();
    }else{
    	this.inputTitle="";
    }
    alert("********InitInputBox**********");
    alert("flagPWD : "+this.flagPWD);
    alert("initText : "+this.initText);
    alert("flagBlockSpace : "+this.flagBlockSpace);
    alert("maxStringLenght : "+this.maxStringLenght);
    alert("flagID : "+this.flagID );
    alert("callerObj : "+this.callerObj);
    alert("inputTitle : "+this.inputTitle);
    this.flagPwdShow = false;    
}


SceneTextEditor.prototype.initTextEditor= function()
{
     
}


SceneTextEditor.prototype.highlight=function(obj)
{
	alert("SceneTextEditor.highlight() ");
	

}

SceneTextEditor.prototype.processReturnKey = function(){
    alert("SceneTextEditor.processReturnKey() ");
	
	// this.highlight(null);
	
	WndMgr.CancelTextEditor();
	
	sf.key.preventDefault();
}

SceneTextEditor.prototype.processEnterKey = function(){
    alert("SceneTextEditor.processEnterKey() ");

	// this.highlight(null);
    WndMgr.StopTextEditor();

}




SceneTextEditor.prototype.updateMsgLength = function()
{
	alert("SceneTextEditor.updateMsgLength() ");
	
    var obj = this.TextEditorView.getCurrentHighlight();
    var input_string = obj.getString();
	
	if(input_string.length>0)
	{
		obj.SetText(input_string);
	}
	else
	{
		obj.SetText("");
	}
	
	this.MsgLengthLabel.SetText(String(input_string.length) +"/" +String(this.maxStringLenght)); 	
}

SceneTextEditor.prototype.updateHelpBar = function()
{
}

SceneTextEditor.prototype.GetInputText = function()
{
	alert("SceneTextEditor.GetInputText() return  "+this.str);
    //var TextInputBox = this.TextEditorView.getCurrentHighlight();
   // return this.TextInputBox.getString();
   // return this.TextInputBox.GetText();
   return this.str;
}

SceneTextEditor.prototype.DeleteAllText = function()
{
	// this.resetTimer();
	WndMgr.resetPopupHideTimer();
	
    if(this.flagPWD == true)
    {
        this.TogglePWDShowMode();
    }
    else
    {
        var obj = this.TextEditorView.getCurrentHighlight();
        obj.setString("");
		this.updateMsgLength();
    }
}

SceneTextEditor.prototype.TogglePWDShowMode = function()
{
    alert("SceneTextEditor.TogglePWDShowMode() ");
    
	var obj = this.TextEditorView.getCurrentHighlight();
	var curr_string = obj.GetText();
    obj.setEngOnly(true);
    
    this.TextInputBox.updateInputBox( this.flagPwdShow, curr_string, this.maxStringLenght,  this.callerObj );
    if( sf.scene.get('TextEditor').flagPwdShow == false)
    {
        obj.setBlockSpace(true);
    }
    
    if(this.flagPwdShow == false)
    {
        this.flagPwdShow = true;
        
    }
    else
    {
        this.flagPwdShow = false;
        
    }  
    
    //2012 modify by minseok
    // this.update();
    var scene = sf.scene.get("TextEditor");
    var ime = new IMEShell(obj.IMEObjInfo.id, scene.imeReady, 'en' /*, 'en' ,  "2_35_259"*/);
    
    
    //this.updateMsgLength();

}
SceneTextEditor.prototype.setFlagTextArea = function(flag){
	this.flagTextArea = flag;	
}
SceneTextEditor.prototype.getFlagTextArea = function(){
	return this.flagTextArea;
}

