/**
 * title: xmpb.js
 * purpose: Implements an xmoney pressable box
 * licenses: 
 * This script uses jQuery 1.3.2 under the MIT License:
 * Copyright (c) 2009 John Resig, http://jquery.com/
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 * 
 * This script uses jQuery UI 1.7.1 under the MIT License:
 * Copyright (c) 2009 Paul Bakaus, http://jqueryui.com/
 *
 * This software consists of voluntary contributions made by many
 * individuals (AUTHORS.txt, http://jqueryui.com/about) For exact
 * contribution history, see the revision history and logs, available
 * at http://jquery-ui.googlecode.com/svn/
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
function xmpb(_para) {
	// constants
	this.XMPB_DEFL_WDTH = 120;
	this.XMPB_DEFL_HGHT = 30;
	// properties
	this.para = _para;
	this.disx = false;
	// methods
	this.init = xmpb_init;
	this.draw = xmpb_draw;
	this.enab = xmpb_enab;
	this.disa = xmpb_disa;
	this.clbl = xmpb_clbl;
}
function xmpb_init() {
	// prof
	{
		var _obj = this;
		var _prop = {};
		switch(parseInt(this.para["prof"])) {
			case 1 :
				_prop = {
					"styl" :
						{
							"wdth" : "170",
							"hght" : "30",
							"bimg" : "ebta.png"
						}
				};
				break;
			default :
				_prop = {
					"styl" :
						{
							"wdth" : this.XMPB_DEFL_WDTH,
							"hght" : this.XMPB_DEFL_HGHT
						}
				};
				break;
		}
		jQuery.each(_prop,
			function(_k,_v) {
				if(!array_key_exists(_k,_obj.para))
					_obj.para[_k] = _v;
			}
		);
	}
	return this;
}
function xmpb_draw(_para) {
	if(!_para)
		_para = {};
	var _xml = '<div xfco="xmpb" xnam="' + this.para["xnam"] + '" style="width:' + this.para["styl"]["wdth"] + 'px;height:' + this.para["styl"]["hght"] + 'px;' + (array_key_exists("bimg",this.para["styl"]) ? 'background-image:url(' + jQuery.ximg("gene",this.para["styl"]["bimg"],true) + ')' : '') + '" class="xmpb">' + jQuery.wtab({"xml":this.para["labl"]}) + '</div>';
	this.para["subj"].html(_para["cntr"] ? jQuery.wtab({"xml":_xml}) : _xml);
	// even
	{	
		if(in_array(this.para["prof"],["5"])) {
			$("[xfco='xmpb'][xnam='" + this.para["xnam"] + "']").find("td").css({"color":"#000000"});
		}
	}
	// enab
	{
		this.enab(this.para["c_ck"]);
	}
}
function xmpb_enab(_c_ck) {
	var _obj = this;
	$("div[xfco='xmpb'][xnam='" + this.para["xnam"] + "']").unbind().css({"cursor":_c_ck?"pointer":"not-allowed"}).click(
		function() {
			if(_obj.disx)
				return;
			_c_ck ? _c_ck({"xmpb":_obj}) : "";
			return false;
		}
	);
}
function xmpb_disa(_para) {
	$("div[xfco='xmpb'][xnam='" + this.para["xnam"] + "']").css({"cursor":(this.disx = _para["disx"])?"not-allowed":"pointer"}).find("td").html(this.disx && _para["dcon"] ? _para["dcon"] : this.para["labl"]);
}
function xmpb_clbl(_labl) {
	$("div[xfco='xmpb'][xnam='" + this.para["xnam"] + "']").html(jQuery.wtab({"xml":this.para["labl"] = _labl}));
}
