// ###    eXtensible Button utilities for client              ###
// ###    Programed by Kool.Sk8er.YJ (endy21@naver.com)       ###
// ###    Copyright (c) 2006 Millesky Inc.                    ###
// ###    All rights reserved.                                ###

function XBTNEnable(msImgPath)
{
	XBTN = new _XBTN_Object();
	XBTN.setImgPath(msImgPath);
}

function _XBTN_Object()
{
	this.psImgPath;

	this.setImgPath = _XBTN_setImgPath;
	this.generation = _XBTN_generation;
}

function _XBTN_setImgPath(msImgPath)
{
	this.psImgPath = msImgPath;
}

function _XBTN_generation(msTitle, msColor, msWidth, msHeight, msRoundType, msColorType, msAncherType, msAncherValue)
{
	var lsTitle = "";
	var lsColor = "#757575";
	var lsWidth = "65";
	var lsHeight = "21";
	var lsRoundType = "1";
	var lsColorType = "wh";
	var liArgLen = arguments.length;
	var lsAncherStr = "";
	var lsClassType = "1";
	var lsSource = "";

	if(msTitle != null)
		lsTitle = msTitle;
	if(msColor != null)
		lsColor = msColor;
	if(msWidth != null)
		lsWidth = msWidth;
	if(msHeight != null)
		lsHeight = msHeight;
	if(msRoundType != null)
		lsRoundType = msRoundType;
	if(msColorType != null)
		lsColorType = msColorType;
	if(msAncherType != null && msAncherValue != null)
	{
		switch(msAncherType)
		{
			case "function" :
				lsAncherStr = " onclick=\"javascript:" + msAncherValue + "\"";
				break;
			case "ancher" :
				lsAncherStr = " onclick=\"javascript:__XBTN_ancher('" + msAncherValue + "');\"";
				break;
		}
	}
	lsSource = "<span style=\"position:absolute\"><table width=\"" + lsWidth + "\" height=\"" + lsHeight + "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"cursor:pointer;\"" + lsAncherStr + " onselectstart=\"return false\">";
	lsSource += "<tr><td><img src=\"" + this.psImgPath + "/btn_r" + lsRoundType + "_" + lsColorType + "_h" + lsHeight + "l.gif\"></td>";
	lsSource += "<td width=\"100%\" background=\"" + this.psImgPath + "/btn_r" + lsRoundType + "_" + lsColorType + "_h" + lsHeight + "b.gif\" align=\"center\" ";
	lsSource += "style=\"xmouseup\" onMouseDown=\"javascript:__XBTN_MouseDown(this);\" onMouseUp=\"javascript:__XBTN_MouseUp(this);\" onMouseOut=\"javascript:__XBTN_MouseUp(this);\"><font class=\"xbtn\" color=\"" + lsColor + "\">" + lsTitle + "</font></td>";
	lsSource += "<td><img src=\"" + this.psImgPath + "/btn_r" + lsRoundType + "_" + lsColorType + "_h" + lsHeight + "r.gif\"></td></tr></table></span><span style=\"padding:0 0 0 " + lsWidth + "px;height:" + lsHeight + "px;line-height:" + lsHeight + "px;\" valign=\"middle\"></span>";
	document.write(lsSource);
}

function __XBTN_ancher(msURL)
{
	document.location.href = msURL;
}

function __XBTN_MouseDown(moObject)
{
	moObject.className = "xmousedown";
}

function __XBTN_MouseUp(moObject)
{
	moObject.className = "xmouseup";
}