

if (typeof _ptools == 'undefined') {
	var _ptools = {};
};

_ptools.Bubble = function(settings)
{
	var t   = this;
	var _FX = null;

	var attributes = settings || {};

	t.SHOW    = false;
	t.obj     = null;
	t.content = null;

	t.getAttribute = function(name)
	{
		if (attributes[ name ]) {
			return attributes[ name ];
		};

		return false;
	};

	t.setAttribute = function(name, value)
	{
		attributes[ name ] = value;

		switch (name)
		{
			case 'content':
				this.iContent.innerHTML = value;
			break;

			case 'top':
				this.obj.style.top = value +'px';
			break;

			case 'left':
				this.obj.style.left = value +'px';
			break;
		};
	};


	t.show = function()
	{
		t.SHOW = true;
		t.obj.style.display = '';
	};

	t.hide = function()
	{
		t.SHOW = false;
		t.obj.style.display = 'none';
	};
};

_ptools.Bubble.prototype.create = function()
{
	var t   = this;
	var obj = document.createElement('div');

	var oTopLeft     = obj.cloneNode(true);
	var oTopRight    = obj.cloneNode(true);
	var oBottomLeft  = obj.cloneNode(true);
	var oBottomRight = obj.cloneNode(true);
	var oTPoint      = obj.cloneNode(true);

	oTopLeft.className     = 'pt_bubble_topleft';
	oTopRight.className    = 'pt_bubble_topright';
	oBottomLeft.className  = 'pt_bubble_bottomleft';
	oBottomRight.className = 'pt_bubble_bottomright';

	switch (t.getAttribute('type'))
	{
		case 'TOP':
			oTPoint.className = 'pt_bubble_point_top';
		break;

		case 'TOPLEFT':
			oTPoint.className = 'pt_bubble_point_topleft';
		break;

		default:
			oTPoint.className = 'pt_bubble_point';
	};

	var oContent            = obj.cloneNode(true);
	var oInnerContent       = obj.cloneNode(true);
	oContent.className      = 'pt_bubble_content';
	oInnerContent.className = 'pt_bubble_icontent';

	obj.appendChild(oTopLeft);
	obj.appendChild(oTopRight);
	obj.appendChild(oBottomLeft);
	obj.appendChild(oBottomRight);
	obj.appendChild(oTPoint);
	obj.appendChild(oContent);

	if (t.getAttribute('top')) {
		obj.style.top = t.getAttribute('top') +'px';
	};

	if (t.getAttribute('bottom')) {
		obj.style.bottom = t.getAttribute('bottom') +'px';
	};

	if (t.getAttribute('left')) {
		obj.style.left = t.getAttribute('left') +'px';
	};

	obj.className     = 'pt_bubble';
	obj.style.display = 'none';

	oInnerContent.innerHTML = t.getAttribute('content');

	oContent.appendChild(oInnerContent);

	this.obj      = obj;
	this.content  = oContent;
	this.iContent = oInnerContent;

	return this.obj;
};

