function SceneRename(options) {
	this.options = options;
    
    //this.RenameView=null;
	//this.RenamePopupView=null;
	this.RenameDim=null;
    
   // this.TitleBar = null;    
    
    //this.TextInputBox = null;
	//this.MsgLengthLabel = null;
    
    this.flagPWD = false;
    this.initText ="";
    this.maxStringLenght = 50;//32;
    this.callerObj = null;
    
	this.TargetIdentity = null;	

    //this.flagInit = false;
    
	//timer
    // this.TextInputTimer = false;
	
	this.isRenameEnable = false;
	
	//2013 ime : by minseok
	this.imeBox = null;
	this.str = null;
	this.imeIsShow = false;
}

SceneRename.prototype.initialize = function () {
	alert("SceneRename.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();
}

SceneRename.prototype.handleShow = function () {
	alert("SceneRename.handleShow()");
	// this function will be called when the scene manager show this scene 
    this.RenameDim.show();
    
    /*this.TextInputBox.initKeySet();
	
  	var callbackFunction =  function(){
  		sf.scene.get('Rename').popupTimerCallback();
  	};
  	
	WndMgr.startPopupHideTimer(60000,callbackFunction);*/
	this.updateIMEBox();
	
}

SceneRename.prototype.handleHide = function () {
	alert("SceneRename.handleHide()");
	// this function will be called when the scene manager hide this scene
	this.RenameDim.hide();
	  
   /* var obj = this.RenameView.getCurrentHighlight();
	if(obj != null)
	{
		 obj.imeHide();
	}
   
	this.MsgLengthLabel.SetText("");
	
	WndMgr.stopPopupHideTimer();*/
}

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

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

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

			break;
		case sf.key.UP:

			break;
		case sf.key.DOWN:

			break;

		case sf.key.ENTER:
			this.processEnterKey();
			break;
            
        case sf.key.RETURN:
            this.processReturnKey();
			sf.key.preventDefault();
			break;
            
         case sf.key.EXIT:
			sf.key.preventDefault();
			break;
            
         case 147:  //infolink
            ProcMgr.processInfolinkKey(); 
			break;
	}
}

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

SceneRename.prototype.create = function(){
    alert("SceneRename.create()");

    // this.RenameView = new View("Rename");
// 	
    // this.RenamePopupView = new View("Rename_BG");
    // this.RenamePopupView.CreatePopupBG(1,"Rename_BG");
	// this.RenamePopupView.SetTitleTextofPopupBG(SID_RENAME);
    
	this.RenameDim = new DimBg("RenameDim", "Rename"); 
    
    // this.TextInputBox= new InputBox();
	// this.TextInputBox.SetButtonObjId("rename_input_box", 30);
    // this.TextInputBox.SetButtonTextObjId("rename_input_box_text");
	// this.TextInputBox.SetInputBoxObjId("rename_input_box_editor");
	// this.TextInputBox.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_INPUT_BOX_NORMAL);
	// this.TextInputBox.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_INPUT_BOX_NORMALFOCUS);	
	// this.TextInputBox.setKeypadPos(704,93);
    // this.TextInputBox.setWordBoxPos(236,50);
// 	
	// this.MsgLengthLabel = new Label(null,"rename_msg_length");
    // this.MsgLengthLabel.SetTextStyle("rename_msg_length_style");
    // this.MsgLengthLabel.SetText("");
    
}
SceneRename.prototype.onKeyCallback= function(key, str, id){
	 alert("SceneRename.onKeyCallback() ===================: " + key + " ID = " + id + " STR = " + str);
	 var Scene = sf.scene.get("Rename");
	 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;
    }
    sf.scene.returnFocus();
	
	
}
SceneRename.prototype.updateIMEBox= function(){
	alert("SceneRename.updateIMEBox()");
	this.imeBox = new IMEShell_Common();
    this.imeBox.inputTitle=SID_RENAME;					//타이틀
    if(this.flagPWD)
    	this.imeBox.setPasswordMode(this.flagPWD);
    this.imeBox.setMaxlength(this.maxStringLenght); //최대값 지정
    this.imeBox.onKeyPressFunc = this.onKeyCallback; //enter,return,exit 를 반환합니다. 입력완료(enter), 취소(return)로 사용중입니다.
	this.imeBox.onCompleteFunc = this.checkRenameEnable; //글자변경되었을때 사용함.(자동완성 데이터 넣어줄때 사용할수 있음)

    this.imeBox.inputString = this.initText; //inputbox 없을때는 위해서 처음입력값 넣기
}/*
SceneRename.prototype.highlight=function(obj)
{
    this.RenameView.setCurrenHighlight(obj);
   
   	if(obj != null)
	{
		var scene = sf.scene.get("Rename");

		// if(this.flagInit ==false)
		// {
			// this.TextInputBox.initInputBox( this.flagPWD, this.initText, this.maxStringLenght,  this.callerObj );
			// this.flagInit =true;
		// }
		// else
		// {
			// this.TextInputBox.initInputBox( this.flagPWD, this.initText, this.maxStringLenght,  this.callerObj );
		// }
    	 
    	this.TextInputBox.initInputBox( this.flagPWD, this.initText, this.maxStringLenght,  this.callerObj );
    	    	
    	var ime = new IMEShell(obj.IMEObjInfo.id, scene.imeReady, 'en' /*, 'en' ,  "2_35_259");
	}
	else
	{
		this.TextInputBox.imeHide();
	}
}
*/
SceneRename.prototype.processReturnKey = function(){
    alert("SceneRename.processReturnKey() ");
	
//	this.highlight(null);	
	
	StateMgr.Stop_Rename_State(true);
	
	//TEMPCODE
//	var scene = sf.scene.get("ListMainContact");
//	scene.Activation();	

}

SceneRename.prototype.initInputBox = function(flagPWD, initText, maxLen, callerObj)
{
    alert("SceneRename.initInputBox()");
    this.flagPWD = flagPWD;
    this.initText = initText;
    this.maxStringLenght = maxLen;
    this.callerObj = callerObj;
}
/*
SceneRename.prototype.imeReady = function(imeObject){
    alert("SceneRename.imeReady() ");

	var this_ = sf.scene.get('Rename');
	var obj = this_.RenameView.getCurrentHighlight();
	
	obj.imeShow(imeObject);
	
    obj.setKeyFunc(88,  function(keyCode){this_.processReturnKey(); sf.key.preventDefault(); return false;}); // return key
   	obj.setKeyFunc(45,  function(keyCode){this_.processReturnKey(); sf.key.preventDefault(); return false;}); // exit key
    obj.setKeyFunc(108, function(keyCode){this_.DeleteAllText(); return false;}); // red key
    obj.setKeyFunc(222, function(keyCode){sf.key.preventDefault();  return false;}); // source
    
	obj.setKeyFunc(147, function(keyCode){sf.key.preventDefault();  return false;}); // infolink
	obj.setKeyFunc(261, function(keyCode){sf.key.preventDefault();  return false;}); // contents
	obj.setKeyFunc(115, function(keyCode){sf.key.preventDefault();  return false;}); // wiselink
    
	obj.setOnCompleteFunc(function(keyCode){this_.updateMsgLength(); this_.checkRenameEnable(); WndMgr.resetPopupHideTimer(); return false;})
	obj.setAnyKeyFunc(function(keyCode){WndMgr.resetPopupHideTimer();  return false;}); 
    obj.setEnterFunc( function(keyCode){this_.processEnterKey(); return false;}); // enter key
    
    obj.setKeySetFunc("qwerty");
    
	obj.setReady();
	
	this_.updateMsgLength();
}
*/
SceneRename.prototype.GetInputText = function()
{
    var obj = this.RenameView.getCurrentHighlight();
    return obj.getString();
}

SceneRename.prototype.DeleteAllText = function()
{
	this.resetTimer();
    var obj = this.RenameView.getCurrentHighlight();
    obj. setString("");
	
	this.updateMsgLength();
	this.checkRenameEnable();
}

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

	var DisplayName = this.str;
	alert("DisplayName = " + DisplayName);

	if(this.isRenameEnable==true)
	{	
		PluginAPIMgr.RenameContact(this.TargetIdentity, DisplayName);
		//added 10.5
		var scene = sf.scene.get(WndMgr.GetMainSubSceneID());	
			scene.Activation();		
		this.processReturnKey();		
	}
	else{
		this.processReturnKey();
	}
}

SceneRename.prototype.Init = function(Identity){
    alert("SceneRename.Init() ");

	this.TargetIdentity = Identity;
}
/*
SceneRename.prototype.updateMsgLength = function()
{
	alert("SceneRename.updateMsgLength() ");
    var obj = this.RenameView.getCurrentHighlight();
    var input_string = obj.getString();
	
	obj.SetText(input_string);
	this.MsgLengthLabel.SetText(String(input_string.length) +"/" +String(this.maxStringLenght));  	
}
*/
SceneRename.prototype.checkRenameEnable = function(string)
{
    var input_text = string;
    var Scene = sf.scene.get("Rename");
    if(input_text.length ==0)
    {
        Scene.isRenameEnable = false;
    }
    else
    {
        var a=0;
        for(a=0; a<input_text.length; a++)
        {
            Scene.isRenameEnable = false;
             var ch = input_text.substring(a,  a+1);
             if(ch !=" ")
             {
                 Scene.isRenameEnable = true;
                 break;
			}
        }
    }
    
    alert("SceneRename.checkRenameEnable()  :  " +Scene.isRenameEnable);
}

