/*
 * (c) Web-Master Co., Saint-Petersburg, Russia <mailbox@webmaster.spb.ru>
 * Version: 0.002_01 21.12.2006 (since 02.07.2005)
 */

var dialog;

function SysDialogCal(dialogId,dialogWidth,dialogHeight,args)
{
	if (typeof(dialog) == 'object') return false;

	if (!(JS==5 || JS==262 || JS==1.5))
	{
		alert('Диалог не может быть вызван. Браузер не поддерживает DOM.');
		return false;
	}

	var wWidth=(window.document.body.clientWidth || window.outerWidth || 800);
	var wHeight=(window.document.body.clientHeight || window.outerHeight || 600);
	var posX=(wWidth-dialogWidth)/2;
	var posY=(wHeight-dialogHeight)/2;
	if (posX < 0) posX=0;
	if (posY < 0) posY=0;

	var oDiv=document.createElement('DIV');
	oDiv.setAttribute('id','dialog');
	oDiv.style.position='absolute';
	oDiv.style.zIndex=1;
	oDiv.style.width=dialogWidth;
	oDiv.style.height=dialogHeight;
	oDiv.style.left=posX;
	oDiv.style.top=posY + document.body.scrollTop;

	var oIframe=document.createElement('IFRAME');
	oIframe.setAttribute('id','dialogFrame');
	oIframe.setAttribute('src','/a0/ru/sysdialogcal/' + dialogId+'/front.thtml');
	oIframe.setAttribute('frameborder','0');
	oIframe.setAttribute('scrolling','no');
	oIframe.setAttribute('marginwidth','0');
	oIframe.setAttribute('marginheight','0');
	oIframe.setAttribute('unselectable','on');
	oIframe.style.width='100%';
	oIframe.style.height='100%';

	oDiv.appendChild(oIframe);
	oDiv.innerHTML = oDiv.innerHTML;  // MSIE 5.0 bugfix
	dialog=document.body.appendChild(oDiv);
	dialog.arguments=args;

	return false;
}

function SysDialogEnd()
{
	if (typeof(dialog) != 'object') return false;

	setTimeout("document.body.removeChild(dialog); dialog=0;", 10); // fix Opera bug
}

