
function NumberInputBox(ButtonId, InputTextId, caller_obj) {
	this.objType = "NUMBERINPUTBOX";

	this.ButtonObj = null;
	this.InputBoxObj = null;

	this.m_BufferText = "";
	this.m_posOfCaret = 0;
	this.m_NewText = "";

	this.onLeftFunc = null;
	this.onRightFunc = null;
	this.onDownFunc = null;
	this.onUpFunc = null;
	this.onReturnFunc = null;
	this.onExitFunc = null;
	this.onInfolinkFunc = null;
	this.onBlockFunc = null;

	this.flagFocus = false;

	this.maxLengthFunc = null;
	this.onCompleteFunc = null;
	this.imePrevCallFunc = null;
	this.anyKeyFunc = null;
	this.enterFunc = null;
	this.onBlueFunc = null;
	this.onRedFunc = null;

	this.keyFuncArr = new Array();

	this.initString = "";
	this.currString = "";

	this.ButtonObjId = "";
	this.InputBoxObjId = "";

	this.maxStringlength = 100;

	this.flagPhoneNumber = true;

	this.onClickCallbackFunc = null;
	this.onMouseOverCallbackFunc = null;
	this.inputBoxClicked = false;
	
	this.commonKeyPadMode = true;
	this.HelpBarSceneName=null;
}

NumberInputBox.prototype.GetObjId = function() {
	return this.ButtonObjId;
}
NumberInputBox.prototype.SetButtonObjId = function(id, OptionDivide) {

	if(id) {
		//2013 modify by minseok
		this.ButtonObj = new Button();
		this.ButtonObj.SetImageObjId(id, OptionDivide);
		this.ButtonObjId = id;
	} else {
		this.ButtonObj = null;
	}
}

NumberInputBox.prototype.SetButtonTextObjId = function(id) {

	if(id) {
		this.ButtonObj.SetTextObjId(id);
	}
}

NumberInputBox.prototype.SetBgImage = function(imgIndex, bgImage) {

	this.ButtonObj.SetBgImage(imgIndex, bgImage);

}

NumberInputBox.prototype.SetInputBoxObjId = function(id) {

	//this.InputBoxObj = new Object();
	this.InputBoxObjId = id;
	// this.InputBoxObj = document.getElementById(id);
	// this.InputBoxObj.style.visibility = hidden;
}

NumberInputBox.prototype.GetText = function() {

	return this.ButtonObj.GetText();
}

NumberInputBox.prototype.SetText = function(text_string) {

	this.ButtonObj.SetText(text_string);
}

NumberInputBox.prototype.setMaxLength = function(max_length) {
	alert(" NumberInputBox.prototype.setMaxLength()");
	this.maxStringlength = max_length;

}

NumberInputBox.prototype.setFlagPhoneNumber = function(flag_phone_number) {
	alert(" NumberInputBox.prototype.setFlagPhoneNumber()");
	this.flagPhoneNumber = flag_phone_number;

}

NumberInputBox.prototype.GetPosOfCaret = function() {
	return this.m_posOfCaret;
}

NumberInputBox.prototype.keydown = function() {
	var keycode = event.keyCode;
	var device = event.inputDevice;
	var keypadtype = event.keypadType;
	alert("NumberInputBox.keydown() -> key code :" + keycode);
	alert("NumberInputBox.keydown() -> device :" +device);
	alert("NumberInputBox.keydown() -> keypadtype :" +keypadtype);
	/*if(device ==1)  //BT
	 {
	 switch(keycode)
	 {
	 case 8: //backspace
	 case 127: //Del
	 keyCode = 259;
	 break;
	 }
	 }*/
	 
	PluginAPIMgr.PlayAudio(keycode);

	switch(keycode) {
		case sf.key.N1:
		case sf.key.N2:
		case sf.key.N3:
		case sf.key.N4:
		case sf.key.N5:
		case sf.key.N6:
		case sf.key.N7:
		case sf.key.N8:
		case sf.key.N9:
		case sf.key.N0:

			PluginAPIMgr.PlayAudioByIndex(ENUM_AUDIO_TYPE.AUDIO_TYPE_KEYPAD_ENTER);

			this.processNumberKey(keycode);

			/*if(this.anyKeyFunc)
			 {
			 this.anyKeyFunc(keycode);
			 }*/

			event.preventDefault();
			this.InputBoxObj.scrollLeft = 99999;

			break;
		
		case 35:
			//plus100 usa
			/*alert("ProcMgr.isTTXMIX : " + ProcMgr.isTTXMIX);
			alert("this.flagPhoneNumber : " + this.flagPhoneNumber);
			if(ProcMgr.isTTXMIX == true) {
				event.preventDefault();
				this.InputBoxObj.scrollLeft = 99999;
				return;
			}*/
			PluginAPIMgr.PlayAudioByIndex(ENUM_AUDIO_TYPE.AUDIO_TYPE_KEYPAD_ENTER);

			if(this.flagPhoneNumber == true) {
				this.processNumberKey(keycode);

				/*if(this.anyKeyFunc)
				 {
				 this.anyKeyFunc(keycode);
				 }*/
			}

				event.preventDefault();
				this.InputBoxObj.scrollLeft = 99999;

			break;
		case sf.key.STOP:
			if(event instanceof KeyboardEvent){	//if press remote controller
				event.preventDefault();
				this.InputBoxObj.scrollLeft = 99999;
				break;	
			}
			PluginAPIMgr.PlayAudioByIndex(ENUM_AUDIO_TYPE.AUDIO_TYPE_KEYPAD_ENTER);
			if(this.flagPhoneNumber == true) {
				this.processNumberKey(keycode);

				/*if(this.anyKeyFunc)
				 {
				 this.anyKeyFunc(keycode);
				 }*/
			}
				event.preventDefault();
				this.InputBoxObj.scrollLeft = 99999;
			break;
		case  650 :
			// TTXMIX EU
			/*if(ProcMgr.isTTXMIX == false) {
				event.preventDefault();
				this.InputBoxObj.scrollLeft = 99999;
				return;
			}*/

			PluginAPIMgr.PlayAudioByIndex(ENUM_AUDIO_TYPE.AUDIO_TYPE_KEYPAD_ENTER);
			if(this.flagPhoneNumber == true) {
				this.processNumberKey(keycode);

				/*if(this.anyKeyFunc)
				 {
				 this.anyKeyFunc(keycode);
				 }*/
			}
				event.preventDefault();
				this.InputBoxObj.scrollLeft = 99999;
			
			break;
		case sf.key.PLAY:
			if(event instanceof KeyboardEvent){	//if press remote controller
				event.preventDefault();
				this.InputBoxObj.scrollLeft = 99999;
				break;	
			}
		case 65288:
			if(device==2 && keypadtype==2)
				alert("keyboard backspace");
		case  259 :
			//sf.key.PRECH:
			PluginAPIMgr.PlayAudioByIndex(ENUM_AUDIO_TYPE.AUDIO_TYPE_KEYPAD_DEL);
			this.processPreChKey();
			
			event.preventDefault();
			this.InputBoxObj.scrollLeft = 99999;
			/*if(this.anyKeyFunc)
			 {
			 this.anyKeyFunc(keycode);
			 }*/
			break;
		case 72: //>>
			if(event instanceof KeyboardEvent){	//if press remote controller
				event.preventDefault();
			}
			else{
				this.startKeyPad();
				event.preventDefault();
			}
			break;	
		case sf.key.DOWN:
			this.processDownKey();
			event.preventDefault();
			break;

		case sf.key.UP:
			this.processUpKey();
			break;

		case sf.key.LEFT:
			this.processLeftKey();
			event.preventDefault();
			break;

		case sf.key.RIGHT:
			this.processRightKey();
			event.preventDefault();
			break;

		case sf.key.RED:
			PluginAPIMgr.PlayAudioByIndex(ENUM_AUDIO_TYPE.AUDIO_TYPE_KEYPAD_ENTER);
			this.processRedKey();
			event.preventDefault();
			break;

		case sf.key.BLUE:
			this.processBlueKey();
			event.preventDefault();
			break;

		case sf.key.ENTER:
			if(keypadtype==1){
				if(PluginAPIMgr.FlagSmartControlNumber() ==1)
					this.processEnterKey();
				else
					this.startKeyPad();
			}else{
				this.processEnterKey();
			}
			break;

		case sf.key.RETURN:
			this.processReturnKey();
			//2013 modify by minseok
			sf.key.preventDefault();
			break;

		case sf.key.EXIT:
			this.processExitKey();
			//2013 modify by minseok
			sf.key.preventDefault();
			break;

		case 147:
		//infolink
		case 261:
		//contents
		case 115:
			//wiselink
			if(this.onInfolinkFunc) {
				this.onInfolinkFunc();
			}
			break;

		default:
			if(this.onBlockFunc) {
				this.onBlockFunc(keycode);
				//$.sf.returnFocus();
			}
			event.preventDefault();
			break
	}
}

NumberInputBox.prototype.keypress = function() {
	var keycode = event.keyCode;
	alert("NumberInputBox.keypress() -> key code :" + keycode);

	switch (keycode) {
		case  259 :
			//sf.key.PRECH:
			this.processPreChKey();

			/*if(this.anyKeyFunc)
			 {
			 this.anyKeyFunc(keycode);
			 }*/

			break;
	}

}

NumberInputBox.prototype.processNumberKey = function(keycode) {

alert(" NumberInputBox.prototype.processNumberKey : "+ keycode);

	var m_NewText = "";

	switch(keycode) {

		case sf.key.N1:
			alert(" KEY_1");
			m_NewText = "1";
			break;

		case sf.key.N2:
			alert(" KEY_2");
			m_NewText = "2";
			break;

		case sf.key.N3:
			alert(" KEY_3");
			m_NewText = "3";
			break;

		case sf.key.N4:
			alert(" KEY_4");
			m_NewText = "4";
			break;

		case sf.key.N5:
			alert(" KEY_5");
			m_NewText = "5";
			break;

		case sf.key.N6:
			alert(" KEY_6");
			m_NewText = "6";
			break;

		case sf.key.N7:
			alert(" KEY_7");
			m_NewText = "7";
			break;

		case sf.key.N8:
			alert(" KEY_8");
			m_NewText = "8";
			break;

		case sf.key.N9:
			alert(" KEY_9");
			m_NewText = "9";
			break;

		case sf.key.N0:
			alert(" KEY_0");
			m_NewText = "0";
			break;
		case sf.key.STOP:
		case 35:
		//plus100
		case  650 :
			// TTXMIX
			if(this.flagPhoneNumber == false) {
				alert("flagphonenumber false!!!");
				return;
			}
			alert(" KEY_plus100");
			m_NewText = "+";
			break;
		//2013 modify by minseok
		case sf.key.PLAY:
		case 259:
			this.deleteText();
			alert(" PRE_CH");
			break;

	}

	this.addText(m_NewText);

	if(this.anyKeyFunc) {
		this.anyKeyFunc(keycode);
	}

}

NumberInputBox.prototype.processPreChKey = function() {
	alert(" NumberInputBox.prototype.processPreChKey ");

	this.deleteText();

	if(this.anyKeyFunc) {
		this.anyKeyFunc(259);
	}
}

NumberInputBox.prototype.processRedKey = function() {
	alert(" NumberInputBox.prototype.processRedKey ");

	// this.deleteAllText();
	if(this.onRedFunc) {
		this.onRedFunc();
		return;
	}
}

NumberInputBox.prototype.processBlueKey = function() {
	alert(" NumberInputBox.prototype.processBlueKey ");
	if(this.onBlueFunc) {
		this.onBlueFunc();
		return;
	}
}

NumberInputBox.prototype.processLeftKey = function() {
	alert(" NumberInputBox.prototype.processLeftKey ");
	if(this.m_posOfCaret == 0) {
		if(this.onLeftFunc) {
			this.onLeftFunc();
			return;
		}
	}

	this.moveLeft();
}

NumberInputBox.prototype.moveLeft = function() {
	alert(" NumberInputBox.prototype.moveLeft ");

	if(this.m_posOfCaret > 0) {
		this.m_posOfCaret--;
		this.InputBoxObj.cursorPosition = this.m_posOfCaret;
		//for webkit (webkit don't have cursorPosition property)
		this.InputBoxObj.selectionStart = this.InputBoxObj.cursorPosition;
		this.InputBoxObj.selectionEnd = this.InputBoxObj.cursorPosition;

		alert(" [processLeftKey] InputBoxObj.value : " + this.InputBoxObj.value);
		alert(" [processLeftKey] InputBoxObj.cursorPosition : " + this.InputBoxObj.cursorPosition);

		if(this.anyKeyFunc) {
			this.anyKeyFunc(sf.key.LEFT);
		}
	}
	this.changeHelpBar();
}

NumberInputBox.prototype.processRightKey = function() {
	alert(" NumberInputBox.prototype.processRightKey ");
	if(this.m_posOfCaret == this.InputBoxObj.value.length) {
		if(this.onRightFunc) {
			this.onRightFunc();
			return;
		}
	}

	this.moveRight()
}

NumberInputBox.prototype.moveRight = function() {
	alert(" NumberInputBox.prototype.moveRight ");

	if(this.m_posOfCaret < this.InputBoxObj.value.length) {
		this.m_posOfCaret++;
		this.InputBoxObj.cursorPosition = this.m_posOfCaret;
		//for webkit (webkit don't have cursorPosition property)
		this.InputBoxObj.selectionStart = this.InputBoxObj.cursorPosition;
		this.InputBoxObj.selectionEnd = this.InputBoxObj.cursorPosition;

		alert(" [processRightKey] InputBoxObj.value : " + this.InputBoxObj.value);
		alert(" [processRightKey] InputBoxObj.cursorPosition : " + this.InputBoxObj.cursorPosition);

		if(this.anyKeyFunc) {
			this.anyKeyFunc(sf.key.RIGHT);
		}
	}
	this.changeHelpBar();

}

NumberInputBox.prototype.processDownKey = function() {
	alert(" NumberInputBox.prototype.processDownKey ");
	if(this.onDownFunc) {

		this.onDownFunc();
		return;
	}
}

NumberInputBox.prototype.processUpKey = function() {
	alert(" NumberInputBox.prototype.processUpKey ");
	if(this.onUpFunc) {
		this.onUpFunc();
		return;
	}
}

NumberInputBox.prototype.processReturnKey = function() {
	alert(" NumberInputBox.prototype.processReturnKey ");
	if(this.onReturnFunc) {
		this.onReturnFunc();
		//$.sf.returnFocus();
		return;
	}
}

NumberInputBox.prototype.processEnterKey = function() {
	alert(" NumberInputBox.prototype.processEnterKey ");
	
	if(this.enterFunc) {
		this.enterFunc();
		return;
	}
	
	
}

NumberInputBox.prototype.processExitKey = function() {
	alert(" NumberInputBox.prototype.processEixtKey ");
	if(this.onExitFunc) {
		this.onExitFunc();
		//$.sf.returnFocus();
		return;
	}
}

NumberInputBox.prototype.isMaxLength = function() {
	if(this.InputBoxObj.value.length == this.InputBoxObj.maxLength) {
		return true;
	} else {
		return false;

	}
}
NumberInputBox.prototype.addTextOverWrite = function(m_NewText) {
	alert(" NumberInputBox.prototype.addTextOverWrite()");
	if(m_NewText==null||m_NewText == "") {
		return;
	}
	if(this.m_BufferText.indexOf("+")!=-1&&this.m_posOfCaret==0){
		return ;
	}
	var befor = "";
	var after = "";
	if(this.InputBoxObj.selectionStart != this.InputBoxObj.selectionEnd) {
		alert("block area delete")
		this.deleteText();
	}
	if(this.isMaxLength()) {
		alert(" isMaxLength() == true");
		
		this.m_BufferText="";
		
		 this.m_posOfCaret=this.m_BufferText.length;
	}
	befor = this.m_BufferText.substr(0, this.m_posOfCaret);
	after = this.m_BufferText.substr(this.m_posOfCaret, this.m_BufferText.length);

	this.m_BufferText = befor + m_NewText + after;

	alert(" Current Buffer : " + this.m_BufferText);

	this.m_posOfCaret++;
	alert(" Current Catet : " + this.m_posOfCaret);

	this.updateInputBox();
}
NumberInputBox.prototype.addText = function(m_NewText) {
	alert(" NumberInputBox.prototype.addText()");
	// if(this.flagFocus==false)
	//{
	//this.m_posOfCaret = this.m_BufferText.length;
	if(this.flagPhoneNumber==false){
		this.addTextOverWrite(m_NewText);
		return;
	}
	if(m_NewText == "+" && this.m_posOfCaret != 0) {
		return;
	}
	if(m_NewText == "") {
		return;
	}
	
	if(this.m_BufferText.indexOf("+")!=-1&&this.m_posOfCaret==0){
		return ;
	}
	
	var befor = "";
	var after = "";
	if(this.InputBoxObj.selectionStart != this.InputBoxObj.selectionEnd) {
		alert("block area delete")
		this.deleteText();
	}
	if(this.isMaxLength()) {
		alert(" isMaxLength() == true");
		return;
	}
	befor = this.m_BufferText.substr(0, this.m_posOfCaret);
	after = this.m_BufferText.substr(this.m_posOfCaret, this.m_BufferText.length);

	this.m_BufferText = befor + m_NewText + after;

	alert(" Current Buffer : " + this.m_BufferText);

	this.m_posOfCaret++;
	alert(" Current Catet : " + this.m_posOfCaret);

	this.updateInputBox();
}

NumberInputBox.prototype.deleteText = function() {
	alert(" NumberInputBox.prototype.deleteText()");

	if(this.flagFocus == false) {
		this.m_posOfCaret = this.m_BufferText.length;
	}
	if(this.m_posOfCaret<=0){
		return ;
	}
	var before = "";
	var after = "";

	if(this.m_BufferText.length > 0) {
		if(this.InputBoxObj.selectionStart ==this.InputBoxObj.selectionEnd){
			this.m_posOfCaret--;
			before = this.m_BufferText.substr(0, this.m_posOfCaret);
			after = this.m_BufferText.substr(this.m_posOfCaret + 1, this.InputBoxObj.value.length);
		}else{
			before = this.m_BufferText.substr(0, this.InputBoxObj.selectionStart);
			after = this.m_BufferText.substr(this.InputBoxObj.selectionEnd, this.InputBoxObj.value.length);
			this.m_posOfCaret =this.InputBoxObj.selectionStart;
		}
		this.m_BufferText = before + after;
		//this.m_posOfCaret = this.m_BufferText.length;
		alert(" Current Buffer : " + this.m_BufferText);
		alert(" Current Catet : " + this.m_posOfCaret);

		this.updateInputBox();
	}
}

NumberInputBox.prototype.deleteAllText = function() {
	alert(" NumberInputBox.prototype.deleteAllText()");

	if(this.m_posOfCaret >= 0) {
		this.m_BufferText = "";
		this.m_posOfCaret = this.m_BufferText.length;

		alert(" Current Buffer : " + this.m_BufferText);
		alert(" Current Catet : " + this.m_posOfCaret);

		this.updateInputBox();
	}
}

NumberInputBox.prototype.updateInputBox = function() {
	this.InputBoxObj.value = this.m_BufferText;
	if(this.flagFocus) {
		this.InputBoxObj.cursorPosition = this.m_posOfCaret;
		//for webkit (webkit don't have cursorPosition property)
		this.InputBoxObj.selectionStart = this.InputBoxObj.cursorPosition;
		this.InputBoxObj.selectionEnd = this.InputBoxObj.cursorPosition;
	}

	alert(" [updateInputBox] InputBoxObj.value : " + this.InputBoxObj.value);
	alert(" [updateInputBox] InputBoxObj.cursorPosition : " + this.InputBoxObj.cursorPosition);

	this.ButtonObj.SetText(this.InputBoxObj.value);
	
	this.changeHelpBar();
	//for sync
}

NumberInputBox.prototype.updateCursorPosition = function() {

	if(this.flagFocus) {
		alert(" [updateCursorPosition] InputBoxObj.selectionStart : " + this.InputBoxObj.selectionStart);
		alert(" [updateCursorPosition] InputBoxObj.selectionEnd : " + this.InputBoxObj.selectionEnd);
		//this.m_posOfCaret = this.InputBoxObj.cursorPosition;

		this.m_posOfCaret = this.InputBoxObj.selectionStart;
		//this.InputBoxObj.selectionEnd ;
		this.InputBoxObj.cursorPosition = this.m_posOfCaret;

		if(this.anyKeyFunc) {
			this.anyKeyFunc(sf.key.RIGHT);
		}
	}
	this.changeHelpBar();

}

NumberInputBox.prototype.setString = function(str) {
	//9.3 modify
	alert("setString : "+String(str));
	this.InputBoxObj.value = String(str);
	this.InputBoxObj.cursorPosition = String(str).length;

	this.m_BufferText = String(str);
	this.m_posOfCaret = String(str).length;
}

NumberInputBox.prototype.getString = function() {
	return this.InputBoxObj.value;
}

NumberInputBox.prototype.setAnyKeyFunc = function(func) {
	this.anyKeyFunc = func;
	alert("NumberInputBox : setAnyKeyFunc");
}

NumberInputBox.prototype.setKeyFunc = function(keyCode, func) {
	alert("NumberInputBox : setKeyFunc keycode : " + keyCode);
	this.keyFuncArr[keyCode] = func;
}

NumberInputBox.prototype.setEnterFunc = function(func) {
	if(func) {
		this.enterFunc = func;
	}
	
}

NumberInputBox.prototype.setMaxLengthFunc = function(func) {
	if(func) {
		this.maxLengthFunc = func;
	}
}

NumberInputBox.prototype.setOnCompleteFunc = function(func) {
	if(func) {
		this.onCompleteFunc = func;
	}
}

NumberInputBox.prototype.setPrevEventOnLeftFunc = function(func) {
	if(func) {
		this.onLeftFunc = func;
	}
}

NumberInputBox.prototype.setPrevEventOnRightFunc = function(func) {
	if(func) {
		this.onRightFunc = func;
	}
}

NumberInputBox.prototype.setPrevEventOnDownFunc = function(func) {
	if(func) {
		this.onDownFunc = func;
	}
}

NumberInputBox.prototype.setPrevEventOnUpFunc = function(func) {
	if(func) {
		this.onUpFunc = func;
	}
}

NumberInputBox.prototype.setPrevEventOnReturnFunc = function(func) {
	if(func) {
		this.onReturnFunc = func;
	}
}

NumberInputBox.prototype.setPrevEventOnBlueFunc = function(func) {
	if(func) {
		this.onBlueFunc = func;
	}
}

NumberInputBox.prototype.setPrevEventOnRedFunc = function(func) {
	if(func) {
		this.onRedFunc = func;
	}
}

NumberInputBox.prototype.setPrevEventOnExitFunc = function(func) {
	if(func) {
		this.onExitFunc = func;
	}
}

NumberInputBox.prototype.setPrevEventOnInfolinkFunc = function(func) {
	if(func) {
		this.onInfolinkFunc = func;
	}
}

NumberInputBox.prototype.setPrevEventOnBlockFunc = function(func) {
	if(func) {
		this.onBlockFunc = func;
	}
}

NumberInputBox.prototype.setInitString = function(initStr) {
	this.initString = initStr;
	this.ButtonObj.SetText(this.initString);
}

NumberInputBox.prototype.highlight = function() {

	if(this.flagFocus == true) {
		return;
	}

	ProcMgr.setNumericRemoteType();
	this.ButtonObj.highlight();

	this.flagFocus = true;

	$("<input  id='" + this.InputBoxObjId + "' type='text'/>").appendTo("#" + this.ButtonObjId);
	$("#" + this.InputBoxObjId).attr("maxLength", this.maxStringlength);

	this.InputBoxObj = document.getElementById(this.InputBoxObjId);

	var _THIS_ = this;
	this.InputBoxObj.focus();
	g_NumObj = this;
	g_AppCommon.OnMessage = BT_Input;
	g_AppCommon.SubscribeEvent(APPCOMMON_MESSAGE_QWERTY_KEY_INPUT);

	this.setString(this.ButtonObj.GetText());

	this.InputBoxObj.onkeydown = function() {
		_THIS_.keydown();
	};

	this.InputBoxObj.onblur = function() {
		if(_THIS_.flagFocus == true) {
			_THIS_.InputBoxObj.focus();
		}
	};
	if(this.onClickCallbackFunc != null) {
		this.InputBoxObj.onclick = function() {
			_THIS_.inputBoxClicked = true;
			_THIS_.updateCursorPosition();
			_THIS_.startKeyPad();
			_THIS_.onClickCallbackFunc(_THIS_);
		};
		$("#" + this.InputBoxObjId).css({
			'cursor' : 'pointer'
		});
	}
	this.InputBoxObj.scrollLeft = 99999;
	
	
	alert("NumberInputBox : highlight :cursorPosition : " + this.InputBoxObj.cursorPosition);
	this.changeHelpBar();
}

NumberInputBox.prototype.blur = function() {
	alert("NumberInputBox : blur  ");
	ProcMgr.setDefaultRemoteType();
	this.ButtonObj.blur();
	
	this.stopKeyPad();

	//2013 add by minseok
	this.m_posOfCaret = this.m_BufferText.length;
	alert("NumberInputBox : blur -> update position : " + this.m_posOfCaret);
	
	if($("#" + this.InputBoxObjId).val()) {
		this.ButtonObj.SetText($("#" + this.InputBoxObjId).val());
	}
	g_NumObj = null;
	g_AppCommon.UnsubscribeEvent(APPCOMMON_MESSAGE_QWERTY_KEY_INPUT);

	this.InputBoxObj.onblur = null;
	this.flagFocus = false;

	$("#" + this.InputBoxObjId).blur();
	$("#" + this.InputBoxObjId).empty();
	$("#" + this.InputBoxObjId).remove();

	sf.scene.returnFocus();
	
	//for preventing default key event
	if(event){
	event.stopPropagation();
	}
	// sf.key.preventDefault();
	//$.sf.returnFocus();

}

NumberInputBox.prototype.registHelpBar = function(obj) {

	this.ButtonObj.registHelpBar(obj);
}
NumberInputBox.prototype.SetHelpbarChangeEnable = function(sceneName){
	this.HelpBarSceneName=sceneName;
}
NumberInputBox.prototype.changeHelpBar = function() {
	if(this.HelpBarSceneName==null)
		return ;
	alert("NumberInputBox.changeHelpBar");
	var dataInfo="";
	if(this.m_posOfCaret==0)
	{
		if(this.m_BufferText.indexOf('+')!=-1){
			dataInfo = {
				'return' : SID_RETURN
			};
		}else
		{
			if(this.flagPhoneNumber == false) {
				dataInfo = {
					'ff' : SID_NUMBER,
					'return' : SID_RETURN
				};
			}else{
				dataInfo = {
					'ff' : SID_NUMBER,
					'stop' : "+",
					'return' : SID_RETURN
				};
			}
		}
	}else{
		dataInfo = {
			'ff' : SID_NUMBER,
			'play' : SID_DELETE, //not support
			'return' : SID_RETURN
		};
	}
	alert("numberinputbox !! current popup name : "+this.HelpBarSceneName);
	sf.scene.get(this.HelpBarSceneName).ChangeHelpbar(0,dataInfo);
}

NumberInputBox.prototype.SetFlagDim = function(b_dim) {
	this.ButtonObj.SetFlagDim(b_dim);
}

NumberInputBox.prototype.SetTextStyle = function(styleIndex, textStyle) {
	this.ButtonObj.SetTextStyle(styleIndex, textStyle);
}

NumberInputBox.prototype.SetOnClickCallbackFunc = function(func) {
	if(WndMgr.MouseClickEnable == false) {
		return;
	}

	if(this.ButtonObj != null) {
		alert("NumberInputBox.SetOnClickCallbackFunc() set on image_layer");

		this.onClickCallbackFunc = func;
		var this_ = this;
		var btnClickCF = function(obj) {
			this_.processBtnClickEvent(obj);
		};
		this.ButtonObj.SetOnClickCallbackFunc(btnClickCF);
	}
}

NumberInputBox.prototype.processBtnClickEvent = function(obj) {
	alert("NumberInputBox.processBtnClickEvent() ");

	if(this.ButtonObj == obj) {
		
		var this_ = this;
		if(this_.inputBoxClicked == false) {
			this.onClickCallbackFunc(this_);
		} else {
			this_.inputBoxClicked = false;
		}
	}
}
NumberInputBox.prototype.SetOnMouseOverCallbackFunc = function(func) {
	if(WndMgr.MouseClickEnable == false) {
		return;
	}

	if(this.ButtonObj != null) {
		alert("NumberInputBox.SetOnMouseOverCallbackFunc() set on image_layer");

		this.onMouseOverCallbackFunc = func;
		var this_ = this;
		var btnOverCF = function(obj) {
			this_.processBtnMouseOverEvent(obj);
		};
		this.ButtonObj.SetOnMouseOverCallbackFunc(btnOverCF);
	}
}

NumberInputBox.prototype.processBtnMouseOverEvent = function(obj) {
	alert("NumberInputBox.processBtnMouseOverEvent() ");

	if(this.ButtonObj == obj) {
		
		var this_ = this;
		this.onMouseOverCallbackFunc(this_);
	}
}
NumberInputBox.prototype.setCommonKeyPadMode = function(flag) {
	alert("NumberInputBox.setCommonKeyPadMode() " + flag);
	this.commonKeyPadMode = flag;
}

NumberInputBox.prototype.startKeyPad = function() {
	if(this.commonKeyPadMode==false)
	{
		return;
	}
	
	alert("NumberInputBox.startKeyPad() ");
	
	if(PluginAPIMgr.FlagSmartControlNumber() !=1)
	{
		PluginAPIMgr.ShowSmartControlNumber();
		WndMgr.holdPopupHideTimer();
	}
}

NumberInputBox.prototype.stopKeyPad = function() {
	if(this.commonKeyPadMode==false)
	{
		return;
	}
	
	alert("NumberInputBox.stopKeyPad() ");
	
	
	if(PluginAPIMgr.FlagSmartControlNumber() ==1)
	{
		PluginAPIMgr.HideSmartControlNumber();
		WndMgr.restartPopupHideTimer();
	}
}

NumberInputBox.prototype.SetReverseDisable = function(flag) {
	this.ButtonObj.SetReverseDisable(flag);
}

NumberInputBox.prototype.GetFlagPwd = function() {
	return this.ButtonObj.GetFlagPwd();
}
NumberInputBox.prototype.GetFlagBlockSpace= function() {
	return this.ButtonObj.GetFlagBlockSpace();
}
NumberInputBox.prototype.GetMaxStringLength= function() {
	return this.ButtonObj.GetMaxStringLength();
}
NumberInputBox.prototype.GetFlagIdType= function() {
	return this.ButtonObj.GetFlagIdType();
}
NumberInputBox.prototype.GetTextEditorPopupTitle = function(){
	return this.ButtonObj.GetTextEditorPopupTitle();
}
NumberInputBox.prototype.GetTextEditorTitle = function() {
	return this.ButtonObj.GetTextEditorTitle();
}

NumberInputBox.prototype.GetTextEditorMsg = function() {
	return this.ButtonObj.GetTextEditorMsg();
}
NumberInputBox.prototype.SetTextEditorInfo = function(s_titie, s_msg) {
	this.ButtonObj.SetTextEditorInfo(s_titie, s_msg);
}
NumberInputBox.prototype.SetHelpText  = function(msg) {
	this.ButtonObj.SetHelpText(msg);
}
