function checkCookie()
{
	kukisy = document.cookie.split("; ");
	for (i=0; i<kukisy.length; i++) 
	{
		if ('dachyPopUp' == kukisy[i].split("=")[0]) 
		{
			return true;
		}
	}
	return false;
}

function ustaw_cookie()
{
	document.cookie = "dachyPopUp=tak";
}

function openPopUp(width, height)
{
	// ustalenie rozmiaru okna
	if ((document.body.clientWidth < width) || (document.body.clientHeight < height))
	{
		if (document.body.clientWidth < width)
		{
			width = document.body.clientWidth;
		}
		if (document.body.clientHeight < height)
		{
			height = document.body.clientHeight;
		}
		autoScroll = 'yes';
	}
	else
	{
		height = height+5;
		autoScroll = 'no';
	}
	// ustalenie pozycji okna
	posLeft = parseInt(screen.width / 2 - width / 2);
	posTop = parseInt(screen.height / 2 - height / 2);
	
	
	if (checkCookie() == false)
	{
		ustaw_cookie();
		popup = window.open('http://www.dachy.malbork.pl/banner.html','GajaDachy'+width+'x'+height,'top='+posTop+',left='+posLeft+',toolbar=no,scrollbars='+autoScroll+',directories=no,status=no,menubar=no,resizable=no,width='+width+',height='+height);
		popup.focus();
	}
}
