function openCalendarWindow(nameField, nameForm)
{
	width = 200;
	height = 200;
	posLeft = parseInt(screen.width / 2 - width / 2);
	posTop = parseInt(screen.height / 2 - height / 2);
	window.open('index.php?m=System&f=Calendar&name='+nameField+'&name_form='+nameForm,'Orion','top='+posTop+',left='+posLeft+',toolbar=no,scrollbars=no,directories=no,status=no,menubar=no,resizable=no,width='+width+',height='+height);
}

function getElement(id)
{
	with (document) var element = getElementById ? getElementById(id) : all ? all[id] : layer[id];
	if(!element.style) element.style = element;
	return element;
}

function hideElement(name)
{
	getElement(name).style.display = 'none';
}

function viewElement(name)
{
	getElement(name).style.display = 'block';
}

function elementOnOff(name)
{
	if (getElement(name).style.display == 'none')
		getElement(name).style.display = 'block';
	else
		getElement(name).style.display = 'none';
}


// ##############################################
// ### Webton.pl Michal Barcikowski (04/2008) ###
// ### WebtonGallery 1.3 ########################
// ##############################################


function createWebtonGallery(urlPic)
{
	// margines
	var webtonMargin = 10;

	// pobranie danych dotyczacych okna
	var webtonPageSize = getPageSize();
	var webtonBrowserSize = getBrowserSize();
	var webtonScroll = scrollFromTop();

	// preloader size
	var preloaderWidth = 126;
	var preloaderHeight = 22;
	var preloaderLeft = (webtonBrowserSize[0] / 2) - (preloaderWidth / 2);
	var preloaderTop = (webtonBrowserSize[1] / 2) - (preloaderHeight / 2) + webtonScroll;

	// przechwycenie strony
	var webtonBody = document.getElementsByTagName("body").item(0);

	// utworzenie tla
	var webtonBg = document.createElement("div");
	webtonBg.setAttribute('id','webtonBg');
	webtonBg.style.background = 'url("http://www.alfin.pl/_images/bg.png")';
	webtonBg.style.position = 'absolute';
	webtonBg.style.top = '0';
	webtonBg.style.left = '0';
 	webtonBg.style.width = webtonPageSize[0];
 	webtonBg.style.height = webtonPageSize[1];
	webtonBg.style.zIndex = '100';
	webtonBg.onclick = function () { hideWebtonBg(); return false; }
	webtonBody.insertBefore(webtonBg, webtonBody.firstChild);

	// zaladowanie preloadera
	var webtonPreloader = document.createElement("img");
	webtonPreloader.setAttribute('id','webtonPreloader');
	webtonPreloader.src = 'http://www.alfin.pl/_images/loading.gif';
	webtonPreloader.style.position = 'absolute';
	webtonPreloader.style.top = preloaderTop;
	webtonPreloader.style.left = preloaderLeft;
	webtonPreloader.style.zIndex = '101';
	webtonPreloader.onclick = function () { hideWebtonBg(); return false; }
	webtonBg.appendChild(webtonPreloader);

	// zaladowanie obrazka
	var mainPicture = new Image();
	mainPicture.onload = function()
	{
		// pobranie rozmiarow obrazka
		var picWidth = mainPicture.width;
		var picHeight = mainPicture.height;

		// wycentrowanie galerii
		var webtonGalleryLeft = (webtonBrowserSize[0] / 2) - (picWidth / 2);
		var webtonGalleryTop = (webtonBrowserSize[1] / 2) - (picHeight / 2) + webtonScroll;

		// zaladowanie galerii
		var webtonGallery = document.createElement("div");
		webtonGallery.setAttribute('id','webtonGallery');
		webtonGallery.style.background = '#FFFFFF';
		webtonGallery.style.border = '1px solid #888888';
		webtonGallery.style.position = 'absolute';
		webtonGallery.style.top = webtonGalleryTop - webtonMargin;
		webtonGallery.style.left = webtonGalleryLeft - webtonMargin;
	 	webtonGallery.style.width = picWidth + webtonMargin * 2;
	 	webtonGallery.style.height = picHeight + webtonMargin * 2;
		webtonGallery.style.zIndex = '102';
		webtonGallery.onclick = function () { hideWebtonBg(); return false; }
		webtonBg.appendChild(webtonGallery);

		// zaladowanie zdjecia
		var webtonImage = document.createElement("img");
		webtonImage.setAttribute('id','webtonImage');
		webtonImage.src = mainPicture.src;
		webtonImage.style.position = 'absolute';
		webtonImage.style.top = webtonMargin;
		webtonImage.style.left = webtonMargin;
		webtonImage.style.zIndex = '103';
		webtonImage.onclick = function () { hideWebtonBg(); return false; }
		webtonGallery.appendChild(webtonImage);

		// utworzenie linku zamykajacego
		var webtonLinkClose = document.createElement("a");
		webtonLinkClose.innerHTML = '<font style="font-size: 10px; font-family: verdana; color: #777777">[<font style="color: #CA0000">X</font>]</font>';
		webtonLinkClose.style.position = 'absolute';
		webtonLinkClose.style.background = '#FFFFFF';
		webtonLinkClose.style.cursor = 'pointer';
		webtonLinkClose.style.padding = '4px';
		webtonLinkClose.style.top = 3;
		webtonLinkClose.style.left = picWidth - webtonMargin;
		webtonLinkClose.onclick = function () { hideWebtonBg(); return false; }
		webtonLinkClose.style.zIndex = '104';
		webtonGallery.appendChild(webtonLinkClose);

		// zakonczenie funkjci
		return false;
	}

	// przekazanie adresu obrazka
	mainPicture.src = urlPic;
}

function hideWebtonBg()
{
	getElement('webtonBg').style.display = 'none';
}

// pobranie rozmiaru html
function getPageSize()
{
	var webtonWidth, webtonHeight;

	if (window.innerHeight && window.scrollMaxY)
	{
		webtonWidth = document.body.scrollWidth;
		webtonHeight = window.innerHeight + window.scrollMaxY;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{
		webtonWidth = document.body.scrollWidth;
		webtonHeight = document.body.scrollHeight;
	}
	else
	{
		webtonWidth = document.body.offsetWidth;
		webtonHeight = document.body.offsetHeight;
	}

	return new Array(webtonWidth, webtonHeight);
}

// zwraca wymiary aktualnego wewnetrznego rozmiaru okna
function getBrowserSize()
{
	// zmienne
	var webtonWidth;
	var webtonHeight;
	webtonWidth = document.body.clientWidth;
	webtonHeight = document.body.clientHeight;
	return new Array(webtonWidth, webtonHeight);
}


// zwraca wartosc aktualnego przesuniecia strony
function scrollFromTop()
{
	var scrollFromTop;

	if (self.pageYOffset)
	{
		scrollFromTop = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
	{
		scrollFromTop = document.documentElement.scrollTop;
	}
	else if (document.body)
	{
		scrollFromTop = document.body.scrollTop;
	}

	return scrollFromTop;
}