if (typeof(browserDetect) == 'undefined') {
	var browserDetect = detectBrowser('', '');
}
function Button_(width, label, command, path) {
	var code = generateCodeNumber + '' + generateCode();
	generateCodeNumber ++;
	this.getCode = getCode;
	this.create = create;
	this.show = show;
	this.hide = hide;
	this.enable = enable;
	this.disable = disable;
	
	var tag = '<table id="' + code + 'Button" border="0" cellspacing="0" cellpadding="0" onMouseOver="buttonMouseOver(' + "'" + code + "'" + ')" onMouseOut="buttonMouseOut(' + "'" + code + "'" + ')" onMouseUp="buttonMouseUp(' + "'" + code + "'," + "'" + command + "'" + ')" style="cursor:pointer">';
		 tag += '<tr style="display:none" id="'+ code + 'command">';
			 tag += '<td></td>';
		 tag += '</tr>';
		  tag += '<tr>';
			 tag += '<td id="'+ code + '">';
				 tag += '<table border="0" cellspacing="0" cellpadding="0">';
				   tag += '<tr>';
					 tag += '<td><img src="' + path + 'images/button/left.png"></td>';
					 tag += '<td id="' + code + 'Label" width="' + width + '" background="' + path + 'images/button/center.png" align="center">';
					 	tag += '<table border="0" cellspacing="0" cellpadding="0">';
							tag += '<tr>';
								tag += '<td class="buttonText1">' + label + '</td>';
							tag += '</tr>';
							tag += '<tr>';
								tag += '<td height="2"></td>';
							tag += '</tr>';
						tag += '</table>';
					 tag += '</td>';
					 tag += '<td><img src="' + path + 'images/button/right.png"></td>';
				   tag += '</tr>';
				 tag += '</table>';
			 tag += '</td>';
			if ((browserDetect[0] == 'msie') && (browserDetect[1] < 7)) {
				tag += '<td id="'+ code + 'MouseOver">';
			}
			else {
				tag += '<td id="'+ code + 'MouseOver" style="display:none">';
			}
				tag += '<table border="0" cellspacing="0" cellpadding="0">';
				  tag += '<tr>';
					tag += '<td><img src="' + path + 'images/button/left-mouse-over.png"></td>';
					tag += '<td width="' + width + '" background="' + path + 'images/button/center-mouse-over.png" align="center">';
						tag += '<table border="0" cellspacing="0" cellpadding="0">';
							tag += '<tr>';
								tag += '<td class="buttonText2">' + label + '</td>';
							tag += '</tr>';
							tag += '<tr>';
								tag += '<td height="2"></td>';
							tag += '</tr>';
						tag += '</table>';
					 tag += '</td>';
					if ((browserDetect[0] == 'msie') && (browserDetect[1] < 7)) {
						tag += '<td><img src="' + path + 'images/button/right-mouse-over.png" onload = "buttonMouseOut(' + "'" + code + "'" + ')"></td>';
					}
					else {
						tag += '<td><img src="' + path + 'images/button/right-mouse-over.png"></td>';
					}
				  tag += '</tr>';
				tag += '</table>';
			tag += '</td>';
		  tag += '</tr>';
		tag += '</table>';
	
	function create() {
		return tag;
	}
	
	function show() {
		var button = document.getElementById(code + 'Button');
		if (button != null) {
			button.style.display = '';
		}
	}
	
	function hide() {
		var button = document.getElementById(code + 'Button');
		if (button != null) {
			button.style.display = 'none';
		}
	}
	
	function enable() {
		enableButton(code);
	}
	
	function disable() {
		disableButton(code);
	}
	
	function getCode() {
		return code;
	}
	
	// command_ ต้องเป็น String ไม่ใช่ function
	function setCommand(command_) {
		setCommandButton(code, command_);
	}
}
