 
 function InputBox(ButtonId, InputTextId) {
	this.objType ="INPUTBOX";
		
	this.ButtonObj = null;
	this.IMEObj = null;

    this.ButtonObjId="";
    	
	this.IMEObjInfo={};
	this.IMEObjInfo.id ="";
	this.IMEObjInfo.x =350;
	this.IMEObjInfo.y = 10;
	this.IMEObjInfo.maxStringlength =50;
	this.IMEObjInfo.initString ="";
	this.IMEObjInfo.currstring = "";
    this.IMEObjInfo.flagPWD = false;
    this.IMEObjInfo.callerObj = null;
    this.IMEObjInfo.flagTextArea = false;
    
    this.IMEObjInfo.wordBox_x =150;
	this.IMEObjInfo.wordBox_y = 10;

	this.maxLengthFunc=null;
	this.onCompleteFunc=null;
	this.imePrevCallFunc=null;
	this.anyKeyFunc=null;
	this.enterFunc=null;
	this.keyFuncArr=new Array();
    
    this.Ready = false;
    
    this.isIMEShow = false;
    
    this.bBlockSpace = false;
	this.bIdType = false;
	
	this.keySetType ="qwerty";
	
	this.ShowHideSting = null;
	
	this.bEngonly = false;
       	
 }

InputBox.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;
    }
}

InputBox.prototype.SetBgImage = function(imgIndex, bgImage){
    
	 this.ButtonObj.SetBgImage(imgIndex, bgImage); 

}

InputBox.prototype.SetButtonTextObjId = function(id, flagPwd){

    if(id)
    {
        if(flagPwd)
        {
            this.ButtonObj.SetTextObjId(id, flagPwd );
         }
         else
         {
            this.ButtonObj.SetTextObjId(id);
         }
    }
}

InputBox.prototype.highlight = function(){

	this.ButtonObj.highlight();
}

InputBox.prototype.blur = function(){

	this.ButtonObj.blur();
}

InputBox.prototype.GetText=function()
{
    if( this.isIMEShow== true)
    {
        return $("#"+this.IMEObjInfo.id).val();
    }
    else
    {
        return this.ButtonObj.GetText();
    }

}

InputBox.prototype.SetText=function(string)
{
    this.ButtonObj.SetText(string);

}

InputBox.prototype.registHelpBar= function(obj){

     this.ButtonObj.registHelpBar(obj);
}

InputBox.prototype.changeHelpBar= function(obj){

     this.ButtonObj.changeHelpBar(obj);
     
}


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

InputBox.prototype.SetInputBoxObjId= function(id){
   
    if(id)
    {
       this.IMEObjInfo.id = id;
    }
    else
    {
        this.IMEObj= null;
    }

}

InputBox.prototype.imeShow= function(obj){

	alert(" InputBox.prototype.imeShow()");
    
    this.IMEObj = obj;
	  
}

InputBox.prototype.imeHide= function(){

	alert(" InputBox.prototype.imeHide()");
    
	if(this.isIMEShow == false)
	{
		return;
	}
	
    this.isIMEShow =false;
    this.ButtonObj.SetText( $("#"+ this.IMEObjInfo.id).val());
	//this.setString("");
	
	var input_id = this.IMEObj.getInputObj();
	if(_g_ime.pluginMouse_use_YN){ //use mouse
	  this.IMEObj._blur();
	  input_id.blur();
	 }
	 else{ //no use mouse
	  input_id.blur();
	 }
	
	$("#"+ this.IMEObjInfo.id).empty();
	$("#"+ this.IMEObjInfo.id).remove();

	this.bEngonly = false;
	ProcMgr.unregisterCallKey();
	sf.scene.returnFocus();
    
}

InputBox.prototype.setReady= function(){
	alert(" InputBox.prototype.setReady()");

	this.setIMEInfo();
	this.setIMEKeyInputCallback();
	this.setStatusCallback();
	
	this.Ready = true;
    
    alert(" InputBox.prototype.setReady()"+this.Ready);
    
    this.isIMEShow =true;
    
   this.imeFocus();
}

InputBox.prototype.imeFocus= function(){
    
    alert(" InputBox.prototype.imefocus()"); 
	ProcMgr.registerCallKey();
	
    //$("#"+this.IMEObjInfo.id).focus();	
	
	var input_id = this.IMEObj.getInputObj();
	if(_g_ime.pluginMouse_use_YN){ //use mouse
	  this.IMEObj._focus();
	  input_id.focus();
	 }
	 else{ //no use mouse
	  input_id.focus();
	 }


	
	alert("start setIMEInfo -> input_id : "+input_id);
	
	this.setString(this.IMEObjInfo.initString, true);
	this.SetText(this.IMEObjInfo.initString); // sync	
}

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


InputBox.prototype.initInputBox= function(flagPWD, initText, maxLen, callerObj)
{
alert(" InputBox.prototype.initInputBox()");
    
		this.setCallerObj(callerObj);
        this.setFlagPWD(flagPWD);
        this.setInitString(initText);
        this.setMaxLength(maxLen);      
}

InputBox.prototype.updateInputBox= function(flagPWD, initText, maxLen, callerObj)
{
alert(" InputBox.prototype.updateInputBox()");
    
		this.setCallerObj(callerObj);
        this.updateFlagPWD(flagPWD);
        this.setInitString(initText);
        this.setMaxLength(maxLen);
}


InputBox.prototype.setFlagTextArea=function(flag_TextArea)
{
alert(" InputBox.prototype.setFlagTextArea()");
    this.IMEObjInfo.flagTextArea = flag_TextArea;
}

InputBox.prototype.setFlagPWD=function(flag_PWD)
{
    alert(" InputBox.prototype.setFlagPWD()");
    
    this.IMEObjInfo.flagPWD = flag_PWD;
	if(this.IMEObjInfo.callerObj != null)
	{
		this.setIdType(this.IMEObjInfo.callerObj.GetFlagIdType());
	}
	else
	{
		this.setIdType(false);
	}
	
    
    if(this.IMEObjInfo.flagTextArea == true)
    {   alert(" InputBox append : type 1");
        $("<textarea id='"+ this.IMEObjInfo.id +"' />").appendTo("#"+ this.ButtonObjId);
    }
    else
    {
        if(this.IMEObjInfo.flagPWD == true)
        {
			alert(" InputBox append : type 2");
            $("<input type='password' id='"+ this.IMEObjInfo.id +"' />").appendTo("#"+ this.ButtonObjId);
        }
        else
        {
			if(this.bIdType==false)
			{
				alert(" InputBox append : type 3");
				if(this.bEngonly==false)
				{
					$("<input type='text' id='"+ this.IMEObjInfo.id +"'  />").appendTo("#"+ this.ButtonObjId);
				}
				else
				{
					$("<input type='text' alt='engonly' id='"+ this.IMEObjInfo.id +"'  />").appendTo("#"+ this.ButtonObjId);
				}
				
			}
			else
			{
				alert(" InputBox append : type 4");
				$("<input type='text' id='"+ this.IMEObjInfo.id +"' alt='id' />").appendTo("#"+ this.ButtonObjId);
			}
            
        }
    }
}

InputBox.prototype.updateFlagPWD=function(flag_PWD)
{
    alert(" InputBox.prototype.updateFlagPWD()");
    
    this.IMEObjInfo.flagPWD = flag_PWD;
    //$("#"+ this.IMEObjInfo.id).remove();
    
    if(this.IMEObjInfo.flagPWD == true)
    {
    	//$("<input type='password' id='"+ this.IMEObjInfo.id +"' />").appendTo("#"+ this.ButtonObjId);
    	$("#"+ this.IMEObjInfo.id).replaceWith("<input type='password' id='"+ this.IMEObjInfo.id +"' />");
    }
    else
    {
		//$("<input type='text' alt='engonly' id='"+ this.IMEObjInfo.id +"'  />").appendTo("#"+ this.ButtonObjId);
    	$("#"+ this.IMEObjInfo.id).replaceWith("<input type='text' alt='engonly' id='"+ this.IMEObjInfo.id +"'  />");
    }
}


InputBox.prototype.setInitString=function(initStr)
{
	alert(" InputBox.prototype.setInitString()");
    this.IMEObjInfo.initString = initStr;
}

InputBox.prototype.setMaxLength=function(max_length)
{
	alert(" InputBox.prototype.setMaxLength()");
    this.IMEObjInfo.maxStringlength = max_length;
   $("#"+this.IMEObjInfo.id).attr("maxLength" , this.IMEObjInfo.maxStringlength);
}

InputBox.prototype.setCallerObj=function(caller_Obj)
{
	alert(" InputBox.prototype.setCallerObj()");
    this.IMEObjInfo.callerObj = caller_Obj;

}

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

InputBox.prototype.setString=function(str)
{
    this.IMEObj.setString(str, true);

}

InputBox.prototype.getString=function()
{
    alert(" InputBox.prototype.getString()"+ $("#"+this.IMEObjInfo.id).val());
    
    return $("#"+this.IMEObjInfo.id).val();

}

InputBox.prototype.setIMEInfo=function(){
	//this.IMEObj.setKeypadPos(this.IMEObjInfo.x, this.IMEObjInfo.y);
	
	this.IMEObj.setKeySetFunc(this.keySetType);
	this.IMEObj.setKeypadPos(this.IMEObjInfo.x, this.IMEObjInfo.y);
	//2013 modify by minseok
	this.IMEObj.setQWERTYPos(570, this.IMEObjInfo.y);
    this.IMEObj.setWordBoxPos(this.IMEObjInfo.wordBox_x, this.IMEObjInfo.wordBox_y);
    this.IMEObj.setBlockSpace(this.bBlockSpace); 
    
	this.IMEObj.setKeypadChangeFunc('12key',this.change12KeyMode);
	this.IMEObj.setKeypadChangeFunc('qwerty',this.changeqwertyMode);    
}

InputBox.prototype.change12KeyMode = function(arg){
	alert("change12KeyMode : " + arg);
	
	WndMgr.ChangeWndPositionFor12Key();
}

InputBox.prototype.changeqwertyMode = function(arg){
	alert("changeqwertyMode : " + arg);
	
	WndMgr.ChangeWndPositionForQwerty();
}

InputBox.prototype.initKeySet = function()
{
	//init left position of Text input scene   
	if(_g_ime.keySet == "12key")
	{
		WndMgr.ChangeWndPositionFor12Key();
	}
	
	if(_g_ime.keySet == "qwerty")
	{
		WndMgr.ChangeWndPositionForQwerty();
	}
}

InputBox.prototype.setIMEKeyInputCallback = function(){
    for(var idx in this.keyFuncArr)
    {
        if(this.keyFuncArr[idx])
        {
            this.IMEObj.setKeyFunc(idx, this.keyFuncArr[idx]);
        }
    }
}

InputBox.prototype.setStatusCallback =function(){

	if(this.maxLengthFunc)
	{
		this.IMEObj.setMaxLengthFunc(this.maxLengthFunc);
	}

	if(this.onCompleteFunc)
	{
		this.IMEObj.setOnCompleteFunc(this.onCompleteFunc);
	}

	if(this.imePrevCallFunc)
	{
		this.IMEObj.setPrevEventLeftFunc(this.imePrevCallFunc);
	}

	if(this.anyKeyFunc)
	{
		this.IMEObj.setAnyKeyFunc(this.anyKeyFunc);
	}

	if(this.enterFunc)
	{
		this.IMEObj.setEnterFunc(this.enterFunc);
	}

	this.IMEObj.setShowHideString(this.ShowHideSting);   
}

InputBox.prototype.setShowHideString = function(str)
{
	this.ShowHideSting = str;
}

InputBox.prototype.setEngOnly = function(flag)
{
	this.bEngonly = flag;
}

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



InputBox.prototype.setKeypadPos= function(x, y){
	this.IMEObjInfo.x = x;
	this.IMEObjInfo.y = y;	
}

InputBox.prototype.setWordBoxPos= function(x, y){
    this.IMEObjInfo.wordBox_x = x;
    this.IMEObjInfo.wordBox_y = y;
}

InputBox.prototype.setAnyKeyFunc=function(func){
     if(func)
     {
        this.anyKeyFunc=func;
     }
}

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

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

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

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

InputBox.prototype.setPrevEventOnLeftFunc=function(func){
    if(func)
    {
        this.imePrevCallFunc=func;
    }
}

InputBox.prototype.setBlockSpace = function(bBlock){
	if(bBlock !== false){
		this.bBlockSpace = true;
	}else{
		this.bBlockSpace = false;
	}
}


InputBox.prototype.setIdType= function(bId){
	if(bId !== false){
		this.bIdType = true;
	}else{
		this.bIdType = false;
	}
}

InputBox.prototype.setKeySetFunc = function(type)
{
	this.keySetType = type;
	
} 






