/**
 * @author Samsung
 */

var BtnImgIndex = {
	BTN_NORMAL_IMG : 0,
	BTN_NORMAL_FOCUS_IMG : 1,
	BTN_SELECTED_IMG : 2,
	BTN_SELECTED_FOCUS_IMG : 3,
	BTN_DIM_IMG : 4
};
var BtnIconIndex = {
	BTN_NORMAL_ICON : 0,
	BTN_NORMAL_FOCUS_ICON : 1,
	BTN_SELECTED_ICON : 2,
	BTN_SELECTED_FOCUS_ICON : 3,
	BTN_DIM_ICON : 4
};
var BtnTextStyleIndex = {
	BTN_TEXT_NORMAL_STYLE : 0,
	BTN_TEXT_FOCUS_STYLE : 1,
	BTN_TEXT_SELECTED_STYLE : 2,
	BTN_TEXT_SELECTED_FOCUS_STYLE : 3,
	BTN_TEXT_DIM_STYLE : 4
};

function Button(imageId, textId, flagPwd, flagDivide, iconId) {

	this.objType = "BUTTON";

	this.image_layer = null;
	this.fgImage_layer = null;
	this.left_image_layer = null;
	this.center_image_layer = null;
	this.right_image_layer = null;
	this.icon_layer = null;
	this.text_layer = null;
	this.check_box = null;
	//2013 add by minseok
	this.parent_id = null;
	this.divide_width = null;

	this.flag_Pwd = false;
	this.flag_block_space = false;
	this.flag_id_type = false;
	this.flag_visible = false;

	if(flagDivide) {
		this.flag_divide = flagDivide;
	} else {
		this.flag_divide = false;
	}

	if(imageId) {
		this.SetImageObjId(imageId);
	}

	if(iconId) {
		this.SetIconObjId(iconId);
	}

	if(textId) {
		if(flagPwd) {
			this.SetTextObjId(imageId, flagPwd);
		} else {
			this.SetTextObjId(imageId);
		}
	}

	this.BtnImg = new Array(4);
	this.BtnLeftImg = new Array(4);
	this.BtnCenterImg = new Array(4);
	this.BtnRightImg = new Array(4);

	this.initImg = 0;

	this.initIcon = 0;
	this.BtnIcon = new Array(4);

	this.MaxStringLength = 50;
	this.MinStringLength = 1;

	this.TextString = "";
	this.HelpTextString = "";
	this.HelpTextStyle = "";
	this.HelpTextShowState = false;

	this.BtnTextStyle = new Array(5);
	this.initTextStyle = 0;
	this.SetText(this.TextString);

	this.onTextChangeFunc = null;

	this.flag_highlight = false;
	this.flag_dim = false;

	this.textEditorTitle = "";
	this.textEditorMsg = "";
	//2013 add by minseok
	this.textEditorPopupTitle=null;


	this.onClickCallbackFunc = null;
	this.flagClickEnable = false;

	this.onRightClickCallbackFunc = null;
/*8.6 add*/
	this.onImeTextEndFunc = null;
	this.marqueeStyle =  null;
	
//for KIP Log
	this.textKPILog ="";
}

Button.prototype.SetImeTextEndFunc = function(func) {
	if(func)
		this.onImeTextEndFunc = func;
}

Button.prototype.GetBGLayer = function() {
	return this.image_layer;
}

Button.prototype.GetLeftBGLayer = function() {
	if(this.flag_divide == true) 
		return this.left_image_layer;
}
Button.prototype.GetCenterBGLayer = function() {
	if(this.flag_divide == true) 
		return this.center_image_layer;
}
Button.prototype.GetRightBGLayer = function() {
	if(this.flag_divide == true) 
		return this.right_image_layer;
}
Button.prototype.GetTextLayer = function() {
	return this.text_layer;
}

Button.prototype.GetDivideFlag = function() {
	return this.flag_divide;
}

Button.prototype.GetObjId = function() {
	return this.parent_id;
}

Button.prototype.SetImageObjId = function(id, OptionDivide, OptionDivideRight) {

	if(id) {
		//2013 add by minseok
		this.parent_id = id;
		if(OptionDivide > 0) {
			this.flag_divide = true;

			var LeftBtnHTML = "<div id = '" + id + "_left'></div>";
			var CenterBtnHTML = "<div id = '" + id + "_center'></div>";
			var RightBtnHTML = "<div id = '" + id + "_right'></div>";

			//alert("##mini##LeftBtnHTML  : " + LeftBtnHTML);
			//alert("##mini##CenterBtnHTML  : " + CenterBtnHTML);
			//alert("##mini##RightBtnHTML  : " + RightBtnHTML);

			//insert html
			$("#" + id).append(LeftBtnHTML);
			$("#" + id).append(CenterBtnHTML);
			$("#" + id).append(RightBtnHTML);

			var OrginWidth = $("#" + id).css('width');
			var OrginHeight = $("#" + id).css('height');

			var WidthLen = OrginWidth.indexOf("px");
			var HeightLen = OrginHeight.indexOf("px");

			var w_int = parseInt(OrginWidth.substring(0, WidthLen));
			var h_int = parseInt(OrginHeight.substring(0, HeightLen));

			//alert("##mini##w_int  : " + w_int);
			//alert("##mini##h_int  : " + h_int);
			
			//2013 add by minseok : for diffrent left, right image...T.T
			var leftValue = OptionDivide;
			var rightValue = (OptionDivideRight==null ? OptionDivide : OptionDivideRight);
			var centerValue = w_int - (leftValue + rightValue); 
			//alert(w_int);
			//alert("##mini##width value left : "+leftValue+", right : "+rightValue+", center : "+centerValue);
			
			//add style class
			$("#" + id + "_left").addClass('cButtonWithTreeObject');
			$("#" + id + "_left").css('left', '0');
			$("#" + id + "_left").css('width', leftValue);
			$("#" + id + "_left").css('height', h_int);
			
			$("#" + id + "_center").addClass('cButtonWithTreeObject');
			$("#" + id + "_center").css('left', leftValue);
			$("#" + id + "_center").css('width', centerValue);
			$("#" + id + "_center").css('height', h_int);
			
			$("#" + id + "_right").addClass('cButtonWithTreeObject');
			$("#" + id + "_right").css('left', w_int - rightValue);
			$("#" + id + "_right").css('width', rightValue);
			$("#" + id + "_right").css('height', h_int);

			this.left_image_layer = new ImageLayer(id + '_left');
			this.center_image_layer = new ImageLayer(id + '_center');
			this.right_image_layer = new ImageLayer(id + '_right');

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

	} else {
		this.image_layer = null;
	}

}
Button.prototype.SetChkObjId = function(id) {
	if(id) {
		this.check_box = new ImageLayer(id);
	}
}
Button.prototype.SetIconObjId = function(id) {

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

}

Button.prototype.SetTextObjId = function(id, flagPwd) {

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

	if(flagPwd) {
		this.flag_Pwd = flagPwd;
	}
}

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

	if(this.flag_divide == true) {
	//	alert("##mini##bgImage : " + bgImage);
		if(bgImage != null) {
			var result = bgImage.indexOf('_center');
			var Url;
			if(result != -1) {
				Url = bgImage.substring(0, result);

			//	alert("##mini##Url : " + Url);
			}

			this.BtnLeftImg[imgIndex] = Url + '_left.png';
			this.BtnCenterImg[imgIndex] = Url + '_center.png';
			this.BtnRightImg[imgIndex] = Url + '_right.png';
		}
	} else {
		this.BtnImg[imgIndex] = bgImage;
	}

	if(this.initImg == 0 && imgIndex == 0) {
		this.initImg = 1;

		if(this.flag_divide == true) {
			this.left_image_layer.SetBgImage(this.BtnLeftImg[0]);
			this.center_image_layer.SetBgImage(bgImage);
			this.right_image_layer.SetBgImage(this.BtnRightImg[0]);
		} else {
			this.image_layer.SetBgImage(bgImage);
		}
	}
}

Button.prototype.SetBgIcon = function(iconIndex, bgIcon) {
	this.BtnIcon[iconIndex] = bgIcon;
	if(this.flag_highlight){
		if(iconIndex == 1)
			this.icon_layer.SetBgImage(this.BtnIcon[iconIndex]);
	}else{
		if(iconIndex == 0)
			this.icon_layer.SetBgImage(this.BtnIcon[iconIndex]);
	}
}
Button.prototype.SetBgCheckBox = function(url) {
	this.check_box.SetBgImage(url);
}
Button.prototype.SetTextStyle = function(styleIndex, textStyle) {

	this.BtnTextStyle[styleIndex] = textStyle;

	if(this.initTextStyle == 0 && styleIndex == 0) {
		this.initTextStyle = 1;
		this.text_layer.SetTextStyle(textStyle);
	}
}

Button.prototype.SetText = function(string) {
	// alert("##mini##Button.prototype.SetText()");
	if(string==null)
		string = "";
	this.TextString = string;
	var PwdString = "";
	this.HelpStringShowState = false;

	if(this.TextString.length == 0 && this.HelpTextString.length > 0) {
		if(this.text_layer != null) {
			this.SetReverseDisable(false);

			this.text_layer.SetText(this.HelpTextString);
			this.HelpStringShowState = true;
			if(this.HelpTextStyle.length > 0) {
				this.text_layer.SetTextStyle(this.HelpTextStyle);
			}
		}
	} else {
		if(this.HelpTextString.length > 0) {
			this.SetReverseDisable(true);
		}

		if(this.flag_Pwd == true) {
			var a = 0;
			for( a = 0; a < this.TextString.length; a++) {
				PwdString = PwdString + "*";
			}

			if(this.text_layer != null) {
				this.text_layer.SetText(PwdString);
			}
		} else {
			if(this.text_layer != null) {
				this.text_layer.SetText(this.TextString);
			}
		}

		if(this.flag_highlight == true) {
			if(this.BtnTextStyle[BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE]) {
				if(this.checkforMarquee()){
			//		alert("&&&&&&&&&&&SSetMarQueestyle!!!!!!!!!higlight");
					this.text_layer.SetTextStyle(this.marqueeStyle);
				}else{
				this.text_layer.SetTextStyle(this.BtnTextStyle[BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE]);
				}
			} else if(this.BtnTextStyle[BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE]) {
				this.text_layer.SetTextStyle(this.BtnTextStyle[BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE]);
			}

		} else {
			if(this.flag_dim == true) {
				if(this.BtnTextStyle[BtnTextStyleIndex.BTN_TEXT_DIM_STYLE]) {
					this.text_layer.SetTextStyle(this.BtnTextStyle[BtnTextStyleIndex.BTN_TEXT_DIM_STYLE]);
				} else if(this.BtnTextStyle[BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE]) {
					this.text_layer.SetTextStyle(this.BtnTextStyle[BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE]);
				}
			} else {
				if(this.BtnTextStyle[BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE]) {
					this.text_layer.SetTextStyle(this.BtnTextStyle[BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE]);
				}
			}
		}

	}

	if(this.onTextChangeFunc ) {
		this.onTextChangeFunc();
	}
}

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

Button.prototype.SetFlagPwd = function(flagPWD) {
	if(flagPwd) {
		this.flag_Pwd = flagPwd;

		this.SetText(this.TextString);
	}
}

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

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

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

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

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

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

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

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

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

Button.prototype.SetHelpText = function(helpString, helpStyle) {
	this.HelpTextString = helpString;

	if(helpStyle) {
		this.HelpTextStyle = helpStyle;
	}

	this.SetText(this.TextString);
}

Button.prototype.SetOnTextChangeFunc = function(func) {

	if(func) {
		this.onTextChangeFunc = func;
	}
}

Button.prototype.SetTextEditorInfo = function(s_titie, s_msg) {
	if(s_titie) {
		this.textEditorTitle = s_titie;
	}
	if(s_msg) {
		this.textEditorMsg = s_msg;
	}
}
Button.prototype.GetTextEditorPopupTitle = function(){
	return this.textEditorPopupTitle;
}
Button.prototype.GetTextEditorTitle = function() {
	return this.textEditorTitle;
}

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

Button.prototype.highlight = function() {

	this.flag_highlight = true;

	if(this.flag_divide == true) {
		this.left_image_layer.SetBgImage(this.BtnLeftImg[BtnImgIndex.BTN_NORMAL_FOCUS_IMG]);
		this.center_image_layer.SetBgImage(this.BtnCenterImg[BtnImgIndex.BTN_NORMAL_FOCUS_IMG]);
		this.right_image_layer.SetBgImage(this.BtnRightImg[BtnImgIndex.BTN_NORMAL_FOCUS_IMG]);
	} else {
		this.image_layer.SetBgImage(this.BtnImg[BtnImgIndex.BTN_NORMAL_FOCUS_IMG]);
	}

	if(this.BtnIcon[BtnIconIndex.BTN_NORMAL_FOCUS_ICON])
		this.icon_layer.SetBgImage(this.BtnIcon[BtnIconIndex.BTN_NORMAL_FOCUS_ICON]);

	if(this.HelpStringShowState == true && this.HelpTextStyle.length > 0) {
		this.text_layer.SetTextStyle(this.HelpTextStyle);
	} else {
		if(this.BtnTextStyle[BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE]) {
			if(this.checkforMarquee()){
					//alert("&&&&&&&&&&&SSetMarQueestyle!!!!!!!!!higlight");
					this.text_layer.SetTextStyle(this.marqueeStyle);
			}else{
			this.text_layer.SetTextStyle(this.BtnTextStyle[BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE]);
			}
		} else if(this.BtnTextStyle[BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE]) {
			this.text_layer.SetTextStyle(this.BtnTextStyle[BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE]);
		}
	}
	
//for KPI Log
	this.printKPILog();
}

Button.prototype.blur = function() {

	this.flag_highlight = false;

	if(this.flag_dim == false) {
		if(this.flag_divide == true) {
			this.left_image_layer.SetBgImage(this.BtnLeftImg[BtnImgIndex.BTN_NORMAL_IMG]);
			this.center_image_layer.SetBgImage(this.BtnCenterImg[BtnImgIndex.BTN_NORMAL_IMG]);
			this.right_image_layer.SetBgImage(this.BtnRightImg[BtnImgIndex.BTN_NORMAL_IMG]);
		} else {
			this.image_layer.SetBgImage(this.BtnImg[BtnImgIndex.BTN_NORMAL_IMG]);
		}

		if(this.BtnIcon[BtnIconIndex.BTN_NORMAL_ICON])
			this.icon_layer.SetBgImage(this.BtnIcon[BtnIconIndex.BTN_NORMAL_ICON]);

		if(this.HelpStringShowState == true && this.HelpTextStyle.length > 0) {
			this.text_layer.SetTextStyle(this.HelpTextStyle);
		} else {
			if(this.BtnTextStyle[BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE]) {
				this.text_layer.SetTextStyle(this.BtnTextStyle[BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE]);
			}
		}
	}

}

Button.prototype.select = function() {

	if(this.BtnImg[BtnImgIndex.BTN_SELECTED_IMG]) {
		if(this.flag_divide == true) {
			this.left_image_layer.SetBgImage(this.BtnLeftImg[BtnImgIndex.BTN_SELECTED_IMG]);
			this.center_image_layer.SetBgImage(this.BtnCenterImg[BtnImgIndex.BTN_SELECTED_IMG]);
			this.right_image_layer.SetBgImage(this.BtnRightImg[BtnImgIndex.BTN_SELECTED_IMG]);
		} else {
			this.image_layer.SetBgImage(this.BtnImg[BtnImgIndex.BTN_SELECTED_IMG]);
		}
	}

	if(this.BtnIcon[BtnIconIndex.BTN_SELECTED_ICON]) {
		this.icon_layer.SetBgImage(this.BtnIcon[BtnIconIndex.BTN_SELECTED_ICON]);
	}

	if(this.BtnTextStyle[BtnTextStyleIndex.BTN_TEXT_SELECTED_STYLE]) {
		this.text_layer.SetTextStyle(this.BtnTextStyle[BtnTextStyleIndex.BTN_TEXT_SELECTED_STYLE]);
	}

}

Button.prototype.flagHighlight = function() {

	return this.flag_highlight;
}

Button.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 {
	if(this.flag_divide==true){
		this.center_image_layer.AppendFgImage(id, h_space, v_space, w, h, img_src);
	}else{
	this.image_layer.AppendFgImage(id, h_space, v_space, w, h, img_src);
}
	}
}

Button.prototype.SetFgImage = function(img_src) {

	if(this.fgImage_layer == null) {
	if(this.flag_divide==true){
		this.center_image_layer.SetFgImage(img_src);
	}else{
	this.image_layer.SetFgImage(img_src);
	}
	} else {
		this.fgImage_layer.SetBgImage(img_src);
}
}


Button.prototype.SetFlagDim = function(b_dim) {

	if(this.flag_dim == b_dim || this.flag_highlight == true) {
		return;
	}

	this.flag_dim = b_dim;

	if(this.flag_dim == true) {
		//2013 modify by minseok
		//because flag_divide : true -> BtnImg array is null
			if(this.flag_divide == true) {
			if(this.BtnCenterImg[BtnImgIndex.BTN_DIM_IMG]) {
				this.left_image_layer.SetBgImage(this.BtnLeftImg[BtnImgIndex.BTN_DIM_IMG]);
				this.center_image_layer.SetBgImage(this.BtnCenterImg[BtnImgIndex.BTN_DIM_IMG]);
				this.right_image_layer.SetBgImage(this.BtnRightImg[BtnImgIndex.BTN_DIM_IMG]);
			}
			} else {
			if(this.BtnImg[BtnImgIndex.BTN_DIM_IMG]) {
				this.image_layer.SetBgImage(this.BtnImg[BtnImgIndex.BTN_DIM_IMG]);
			}
		}

		if(this.BtnIcon[BtnIconIndex.BTN_DIM_ICON]) {
			this.icon_layer.SetBgImage(this.BtnIcon[BtnIconIndex.BTN_DIM_ICON]);
		}

		if(this.BtnTextStyle[BtnTextStyleIndex.BTN_TEXT_DIM_STYLE]) {
			this.text_layer.SetTextStyle(this.BtnTextStyle[BtnTextStyleIndex.BTN_TEXT_DIM_STYLE]);
		}

		this.DisableOnClick();
	} else {
		this.blur();

		this.EnableOnClick();
	}
}

Button.prototype.GetFlagDim = function() {
	return this.flag_dim;
}
Button.prototype.visibleChkBox = function() {
	if(this.check_box)
		this.check_box.visibleObj();
}
Button.prototype.hiddenChkBox = function() {
	if(this.check_box)
		this.check_box.hiddenObj();
}
Button.prototype.visibleObj = function() {
	// alert("##mini##Button.prototype.visibleObj()");
	if(this.image_layer) {
		this.image_layer.visibleObj();
	}else if(this.flag_divide == true){
		this.left_image_layer.visibleObj();
		this.center_image_layer.visibleObj();
		this.right_image_layer.visibleObj();
	}

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

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

    this.flag_visible = true;

}

Button.prototype.hiddenObj = function() {
	//alert("##mini##Button.prototype.hiddenObj()");
	if(this.image_layer) {
		this.image_layer.hiddenObj();
	}else if(this.flag_divide == true){
		this.left_image_layer.hiddenObj();
		this.center_image_layer.hiddenObj();
		this.right_image_layer.hiddenObj();
	}

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

	if(this.text_layer) {
		this.text_layer.hiddenObj();
	}
	this.DisableOnClick();
    this.flag_visible = false;	
}

Button.prototype.GetFlagVisible= function(){
    return this.flag_visible;
}

Button.prototype.SetIsTextInTable = function(flagInTable) {

	this.text_layer.SetIsTextInTable(flagInTable);

}

Button.prototype.setLeft = function(left_value) {
	var image_id = this.image_layer.GetObjectId();
	$("#" + image_id).css('left', left_value);
}

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

	//if(this.image_layer != null)
	//{
	alert("##mini##Button.SetOnClickCallbackFunc() set on image_layer");

	this.onClickCallbackFunc = func;
	this.EnableOnClick();
	//}
}

Button.prototype.SetOnRightClickCallbackFunc = function(func) {
	if(WndMgr.MouseClickEnable == false) {
		return;
	}

	//if(this.image_layer != null)
	//{
	alert("##mini##Button.SetOnRightClickCallbackFunc() set on image_layer");

	this.onRightClickCallbackFunc = func;
	if(this.flagClickEnable == true) {
		this.EnableOnRightClick();
	}
	//}
}

Button.prototype.EnableOnClick = function() {
	if(WndMgr.MouseClickEnable == false) {
		return;
	}

	if(this.flagClickEnable == false && this.flag_dim == false) {
		//alert("##mini##Button.EnableOnClick()");
		var this_ = this;
		document.getElementById(this.parent_id).onclick = function() {
			this_.onClickCallbackFunc(this_);
		};
		if(this.onRightClickCallbackFunc != null) {
			this.EnableOnRightClick();
		}
		this.flagClickEnable = true;
		$("#" + this.parent_id).css({
			'cursor' : 'pointer'
		});
	}
}

Button.prototype.DisableOnClick = function() {
	if(WndMgr.MouseClickEnable == false) {
		return;
	}

	if(this.flagClickEnable == true) {
		//alert("##mini##Button.DisableOnClick()");
		document.getElementById(this.parent_id).onclick = null;
		if(this.onRightClickCallbackFunc != null) {
			this.DisableRightOnClick();
		}
		this.flagClickEnable = false;
		$("#" + this.parent_id).css({
			'cursor' : ''
		});
	}
}

Button.prototype.EnableOnRightClick = function() {

	//var object = this.image_layer.GetObjectId();
	var this_ = this;

	document.getElementById(this.parent_id).onmousedown = function() {
		if(event.button == 2) {
			this_.onRightClickCallbackFunc(this_);
		}
	};
	//document.getElementById(object).onmousedown = function(){if(event.button==2){this_.onRightClickCallbackFunc(this_);} };

}

Button.prototype.DisableRightOnClick = function() {
	//this.parent_id
	if(this.flagClickEnable == true) {
		//var object = this.image_layer.GetObjectId();
		document.getElementById(this.parent_id).onmousedown = null;
	}
}
//

Button.prototype.SetOnMouseOverCallbackFunc = function(func){
	if(WndMgr.MouseOverEnable==false)
	{
		return;	
	}
	if(this.parent_id != null)
	{
		alert("Button.SetOnMouseOverCallbackFunc() set on image_layer");
		
		this.onMouseOverCallbackFunc = func;
		this.EnableOnMouseOver();			
	}
}

Button.prototype.EnableOnMouseOver = function(){
	var object = this.parent_id;
	var this_ = this;
	$("#"+object).bind("mouseenter",function(){
		this_.onMouseOverCallbackFunc(this_);
	});
		//document.getElementById(object).onmouseover = function(){this_.onMouseOverCallbackFunc(this_);};
}
Button.prototype.DisableOnMouseOver = function(){
	var object = this.parent_id;
	$("#"+object).unbind("mouseenter");
		//document.getElementById(object).onmouseover = null;
}

Button.prototype.SetOnMouseOutCallbackFunc = function(func){
	if(WndMgr.MouseOverEnable==false)
	{
		return;	
	}
	if(this.parent_id != null)
	{
		alert("Button.SetOnMouseOutCallbackFunc() set on image_layer");
		
		this.onMouseOutCallbackFunc = func;
		this.EnableOnMouseOut();			
	}
}
Button.prototype.EnableOnMouseOut = function(){
	var object = this.parent_id;
	var this_ = this;
	$("#"+object).bind("mouseleave",function(){
		this_.onMouseOutCallbackFunc();
	});
	//document.getElementById(object).onmouseout = function(){this_.onMouseOutCallbackFunc(this_);};
}
Button.prototype.DisableOnMouseOut = function(){
	var object = this.parent_id;
	$("#"+object).unbind("mouseleave");
	//document.getElementById(object).onmouseout = null;
}

//

Button.prototype.SetReverseDisable = function(flag) {
	this.text_layer.SetReverseDisable(flag);
}
Button.prototype.SetOverflowMarquee = function(marqueestyle){
	this.marqueeStyle = marqueestyle;
	
}
Button.prototype.checkforMarquee = function(){
	//alert("checkforMarquee ----------------------");
	if(this.marqueeStyle==null){
		return ;
	}
	return this.isTextOverflow();
}
Button.prototype.isTextOverflow = function(){
    //alert("checkforMarquee ----------------------");
    var textMaxWidth = $("#"+this.text_layer.GetObjectId()).width()+1;
    var fontsize = $("#"+this.text_layer.GetObjectId()).css("font-size");
    $("body").append("<div id='tmpid'></div>");
    $('#tmpid').css({
        'position':'absolute',
        'left': '0px',  
        'font-size':fontsize, 
        'visibility': 'hidden'
        });
        $('#tmpid').text(this.TextString);
    var width = $("#tmpid").width()+1;
    //alert("width is "+width);
    //alert("textMaxWidth is "+textMaxWidth);
    $("#tmpid").remove();
    if(width>textMaxWidth){
        return true;
    }else{
        return false;
    }
}

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


////////////////// for KPI Log

Button.prototype.setTextKPILog = function(text)
{
	this.textKPILog = text;
}

Button.prototype.printKPILog = function()
{
	if(this.textKPILog.length <= 0)
	{
		return;
	}
	
	$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).PrintKPILog(this.textKPILog);
}
