
/**
 * @author Samsung
 */


function Label(imageId, textId) {
    this.objType ="LABEL";

    this.image_layer =null;
	this.fgImage_layer = null;
    this.text_layer =null;
    
    if(imageId)
    {
       this.SetImageObjId(imageId);
    }
    
    if(textId)
    {
        this.SetTextObjId(textId);
    }
	
	this.flag_Pwd = false;
    this.flag_block_space = false;
	this.flag_id_type = false;
	
    this.TextString = "";
	this.TextStyle= "";
    this.HelpTextString = "";
    this.HelpTextStyle = "";
    this.HelpTextShowState = false;
	
	this.MaxStringLength = 100;
    this.MinStringLength = 1;
	
	this.textEditorTitle="";
    this.textEditorMsg="";
    
    this.onClickCallbackFunc = null;
	this.flagClickEnable = false;
	
	this.onMouseOverCallbackFunc = null;
	this.onMouseOutCallbackFunc = null;
	this.mouseOutImage = "";
	this.mouseOverImage = "";
}

Label.prototype.SetImageObjId= function(id){

    if(id)
    {
        this.image_layer = new ImageLayer(id);
    }
    else
    {
        this.image_layer= null;
    }

}

Label.prototype.GetImageObjId= function(){

    return this.image_layer.GetObjectId(); 
}

Label.prototype.SetTextObjId= function(id){

    if(id)
    {
        this.text_layer = new TextLayer(id);
    }
    else
    {
        this.text_layer= null;
    }
    
}

Label.prototype.SetBgImage = function(bgImage){

    this.image_layer.SetBgImage(bgImage);

}

Label.prototype.SetText = function(string)
{
    this.TextString = string;

    this.HelpStringShowState = false;

    if (this.TextString.length == 0 && this.HelpTextString.length > 0) 
	{
		if (this.text_layer != null) 
		{
			this.text_layer.SetText(this.HelpTextString);
			this.HelpStringShowState = true;
			if (this.HelpTextStyle.length > 0) 
			{
				this.text_layer.SetTextStyle(this.HelpTextStyle);
			}
			else 
			{
				if (this.TextStyle.length > 0) 
				{
					this.text_layer.SetTextStyle(this.TextStyle);
				}
			}
		}
	}
	else 
	{
		if (this.text_layer != null) 
		{
			this.text_layer.SetText(this.TextString);
			
			if (this.TextStyle.length > 0) 
			{
				this.text_layer.SetTextStyle(this.TextStyle);
			}
		}
	}
}

Label.prototype.SetTextStyle = function(style)
{
	this.TextStyle = style;
    this.text_layer.SetTextStyle(this.TextStyle);
}

Label.prototype.GetText = function()
{
    return this.TextString;
}

Label.prototype.AppendFgImage = function(id,h_space, v_space, w, h, img_src)
{
	if(h_space == null || v_space == null || w == null || h == null) {
		if(id) {
			this.fgImage_layer = new ImageLayer(id);
		} else {
			this.fgImage_layer = null;
		}
	}
	else {
    	this.image_layer.AppendFgImage(id,h_space, v_space, w, h, img_src);
	}
}

Label.prototype.SetFgImage = function(img_src)
{
	if(this.fgImage_layer == null) {
	    this.image_layer.SetFgImage(img_src);
	}
	else {
	    this.fgImage_layer.SetBgImage(img_src);
	}
}

Label.prototype.SetHelpText = function(helpString, helpStyle)
{
    this.HelpTextString = helpString;
    
    if(helpStyle)
    {
        this.HelpTextStyle = helpStyle;
    }
    
    this.SetText(this.TextString);
} 

Label.prototype.SetTextEditorInfo = function(s_titie, s_msg){
     if(s_titie)
     {
        this.textEditorTitle=s_titie;
     }
     if(s_msg)
     {
        this.textEditorMsg=s_msg;
     }
}

Label.prototype.GetTextEditorTitle = function(){
    return this.textEditorTitle; 
}

Label.prototype.GetTextEditorMsg = function(){
    return this.textEditorMsg; 
}

Label.prototype.SetFlagPwd = function(flagPWD)
{
     if(flagPwd)
    {
         this.flag_Pwd = flagPwd;
         
         this.SetText(this.TextString);
    }
}

Label.prototype.GetFlagPwd = function() {
    return  this.flag_Pwd;
}

Label.prototype.SetFlagBlockSpace= function(flagBlockSpace)
{
     if(flagBlockSpace)
    {
         this.flag_block_space = flagBlockSpace;
    }
}

Label.prototype.GetFlagBlockSpace = function() {
    return  this.flag_block_space;
}

Label.prototype.SetFlagIdType= function(flagIdType)
{
     if(flagIdType)
    {
         this.flag_id_type = flagIdType;
    }
}

Label.prototype.GetFlagIdType= function(flagIdType)
{
  	return  this.flag_id_type;
}

Label.prototype.GetTextStringLength= function()
{
  	return  this.TextString.length;
}

Label.prototype.SetMaxStringLength = function(max_Length){
     this.MaxStringLength = max_Length;
}

Label.prototype.GetMaxStringLength = function(){
	return this.MaxStringLength; 
}

Label.prototype.SetMinStringLength = function(min_Length){
	this.MinStringLength = min_Length;
}

Label.prototype.GetMinStringLength = function(){
    return this.MinStringLength; 
}

Label.prototype.visibleObj=function()
{
    if(this.image_layer)
    {
        this.image_layer.visibleObj();
    }

    if(this.text_layer)
    {
        this.text_layer.visibleObj();
    }
}

Label.prototype.hiddenObj=function()
{
    if(this.image_layer)
    {
        this.image_layer.hiddenObj();
    }

    if(this.text_layer)
    {
        this.text_layer.hiddenObj();
    }
}

Label.prototype.SetIsTextInTable = function(flagInTable)
{
    this.text_layer.SetIsTextInTable(flagInTable) ;
}

Label.prototype.SetOnClickCallbackFunc = function(func)
{
	if(WndMgr.MouseClickEnable==false)
	{
		return;	
	}
	
	if(this.image_layer != null)
	{
		alert("Label.SetOnClickCallbackFunc() set on image_layer");
		
		this.onClickCallbackFunc = func;
		this.EnableOnClick();			
	}
}
//2013 add by minseok
Label.prototype.SetOnMouseOverCallbackFunc = function(func){
	if(WndMgr.MouseClickEnable==false)
	{
		return;	
	}
	if(this.image_layer != null)
	{
		alert("Label.SetOnMouseOverCallbackFunc() set on image_layer");
		
		this.onMouseOverCallbackFunc = func;
		this.EnableOnMouseOver();			
	}
	
}
Label.prototype.SetOnMouseOutCallbackFunc = function(func){
	if(WndMgr.MouseClickEnable==false)
	{
		return;	
	}
	if(this.image_layer != null)
	{
		alert("Label.SetOnMouseOutCallbackFunc() set on image_layer");
		
		this.onMouseOutCallbackFunc = func;
		this.EnableOnMouseOut();			
	}
}

Label.prototype.SetOnMouseOutOverImage = function( outImage, overImage)
{
	if(WndMgr.MouseClickEnable==false)
	{
		return;	
	}
	
	if(this.image_layer != null)
	{
		alert("Label.SetOnMouseOutOverImage()");
		
		this.mouseOutImage = outImage;
		this.mouseOverImage = overImage;
		
		if(this.flagClickEnable==true )
		{
			this.EnableOnMouseOverImage();
			this.EnableOnMouseOutImage();
		}		
	}
}

Label.prototype.EnableOnClick = function()
{
	if(this.flagClickEnable == false)
	{
		var object = this.image_layer.GetObjectId();
		var this_ = this;
		document.getElementById(object).onclick = function(){this_.onClickCallbackFunc(this_);};
		//document.getElementById(object).onmousedown = function(){if(event.button==2){this_.onClickCallbackFunc(this_);} };
		this.flagClickEnable = true;
		$("#"+this.image_layer.GetObjectId()).css({'cursor' : 'pointer'});
		
		if(this.mouseOverImage!="")	
		{
			this.EnableOnMouseOverImage();
		}
		
		if(this.mouseOutImage!="")	
		{
			this.EnableOnMouseOutImage();
		}
	}
}

Label.prototype.DisableOnClick = function()
{
	if(this.flagClickEnable == true)
	{
		var object = this.image_layer.GetObjectId();
		document.getElementById(object).onclick = null;
		//document.getElementById(object).onmousedown = null;
		this.flagClickEnable = false;
		$("#"+this.image_layer.GetObjectId()).css({'cursor' : ''});	
		
		if(this.mouseOverImage!="")	
		{
			this.DisableOnMouseOverImage();
		}
		
		if(this.mouseOutImage!="")	
		{
			this.DisableOnMouseOutImage();
		} 
	}
}

Label.prototype.SetEnableOnClick = function(b_flag)
{
	if(b_flag==true)
	{
		this.EnableOnClick();
	}		
	else
	{
		this.DisableOnClick();
	}
}
Label.prototype.EnableOnMouseOver = function(){
	var object = this.image_layer.GetObjectId();
	var this_ = this;
	document.getElementById(object).onmouseover = function(){
															this_.onMouseOverCallbackFunc(this_); 
															if(this_.mouseOverImage!=""){
																this_.image_layer.SetBgImage(this_.mouseOverImage);
																}
															};
}
Label.prototype.DisableOnMouseOver = function(){
	var object = this.image_layer.GetObjectId();
	document.getElementById(object).onmouseover = null;
}
Label.prototype.EnableOnMouseOut = function(){
	var object = this.image_layer.GetObjectId();
	var this_ = this;
	document.getElementById(object).onmouseout = function(){
															this_.onMouseOutCallbackFunc(this_); 
															if(this_.mouseOutImage!=""){
																this_.image_layer.SetBgImage(this_.mouseOutImage);
																}
															};
}
Label.prototype.DisableOnMouseOut = function(){
	var object = this.image_layer.GetObjectId();
	document.getElementById(object).onmouseout = null;
}
Label.prototype.EnableOnMouseOverImage = function()
{
	var object = this.image_layer.GetObjectId();
	var this_ = this;
	document.getElementById(object).onmouseover = function(){
															this_.image_layer.SetBgImage(this_.mouseOverImage); 
															if(this_.onMouseOverCallbackFunc !=null){
																this_.onMouseOverCallbackFunc(this_);
																}
															};
}

Label.prototype.EnableOnMouseOutImage = function()
{
	var object = this.image_layer.GetObjectId();
	var this_ = this;
	document.getElementById(object).onmouseout = function(){
															this_.image_layer.SetBgImage(this_.mouseOutImage); 
															if(this_.onMouseOutCallbackFunc!=null){
																this_.onMouseOutCallbackFunc(this_);
																}
														   };
}

Label.prototype.DisableOnMouseOverImage = function()
{
	var object = this.image_layer.GetObjectId();
	document.getElementById(object).onmouseover = null;
}

Label.prototype.DisableOnMouseOutImage = function()
{
	var object = this.image_layer.GetObjectId();
	document.getElementById(object).onmouseout = null;
}

Label.prototype.SetMarqueeEnable = function(maxWidth, enableStyle, disableStyle)
{
	this.text_layer.SetMarqueeEnable(maxWidth, enableStyle, disableStyle);
}

Label.prototype.SetReverseDisable = function(flag)
{
	this.text_layer.SetReverseDisable(flag);
}

Label.prototype.SetIsPlainText= function(flag)
{
    this.text_layer.SetIsPlainText(flag);   
}




