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

_plugins.accounting =
{
	openOrderInfo : function(oid)
	{
		// hintergrund
		var oBackg = document.createElement('div');
		oBackg.id  = 'accounting-bill-info-bg';

		var style  = oBackg.style;

		style.width  = '100%';
		style.height = '100%';
		style.top    = '0px';
		style.left   = '0px';

		style.position   = 'fixed';
		style.zIndex     = 10000;
		style.background = '#000';

		style.opacity    = '0.6';
		style.MozOpacity = '0.6';
		style.filter     = 'progid:DXImageTransform.Microsoft.Alpha(opacity=60)';

		document.body.appendChild( oBackg );

		// container
		var oContainer = document.createElement('div');
		oContainer.id  = 'accounting-bill-info-container';

		oContainer.innerHTML = '' +
			'<div id="accounting-bill-info-container-text"></div>' +
			'<div id="accounting-bill-info-container-btns"></div>';

		document.body.appendChild( oContainer );

		$('accounting-bill-info-container-btns').appendChild(
			new _ptools.Button({
				name    : '',
				text    : 'schließen',
				width   : 100,
				onclick : function(Btn)
				{
					_plugins.accounting.closeOrderInfo();
				}
			}).create()
		);

		_Ajax.asyncPost('ajax_plugins_accounting_order_get_product_list', function(result, Ajax)
		{
			var str = '<h1>Bestellte Artikel</h1>' +
				'<div class="accounting-bill-info-container-list">' +
				'<ul>';

			for (var i = 0, len = result.length; i < len; i++) {
				str = str + '<li>'+ result[i]['name'] +'</li>';
			};

			str = str + '</ul></div>';

			$('accounting-bill-info-container-text').innerHTML = str;
		}, {
			plugin  : 'accounting',
			orderid : 'AccountingBillCreated_'+ oid
		});
	},

	closeOrderInfo : function()
	{
		if ($('accounting-bill-info-bg'))
		{
			$('accounting-bill-info-bg').parentNode.removeChild(
				$('accounting-bill-info-bg')
			);
		};

		if ($('accounting-bill-info-container'))
		{
			$('accounting-bill-info-container').parentNode.removeChild(
				$('accounting-bill-info-container')
			);
		};
	},

	switchOrderInfo : function(counter)
	{
		if ($('bill-infos-'+ counter))
		{
			if ($('bill-infos-'+ counter).style.display == 'none')
			{
				$('bill-infos-'+ counter).style.display = '';
			} else
			{
				$('bill-infos-'+ counter).style.display = 'none';
			};
		};

		if ($('bill-debit-infos-'+ counter))
		{
			if ($('bill-debit-infos-'+ counter).style.display == 'none')
			{
				$('bill-debit-infos-'+ counter).style.display = '';
				$('bill-debit-infos-'+ counter).parentNode.className = '';
				return;
			};

			$('bill-debit-infos-'+ counter).style.display = 'none';
			$('bill-debit-infos-'+ counter).parentNode.className = 'noborder';
		};
	}
};
