function openWindow(id, dir, 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
	{
		autoScroll = 'no';
	}
	// ustalenie pozycji okna
	posLeft = parseInt(screen.width / 2 - width / 2);
	posTop = parseInt(screen.height / 2 - height / 2);
	window.open('index.php?m=System&f=ViewPicture&id='+id+'&dir='+dir,'Motosprzet'+width+'x'+height,'top='+posTop+',left='+posLeft+',toolbar=no,scrollbars='+autoScroll+',directories=no,status=no,menubar=no,resizable=no,width='+width+',height='+height);
}

function MenuOff(name)
{
	getElement('submenu'+name).style.visibility = 'hidden';
}

function MenuOn(name)
{
	getElement('submenu'+name).style.visibility = 'visible';
}

function openMovie(id)
{
	// ustalenie pozycji okna
	posLeft = parseInt(screen.width / 2 - 355 / 2);
	posTop = parseInt(screen.height / 2 - 355 / 2);
	window.open('index.php?m=System&f=FilmView&id='+id,'MotoMovie','top='+posTop+',left='+posLeft+',toolbar=no,scrollbars=no,directories=no,status=no,menubar=no,resizable=no,width=355,height=355');
}

function openMovieMedia(path)
{
	// ustalenie pozycji okna
	posLeft = parseInt(screen.width / 2 - 355 / 2);
	posTop = parseInt(screen.height / 2 - 355 / 2);
	window.open(path,'MotoMovie','top='+posTop+',left='+posLeft+',toolbar=no,scrollbars=no,directories=no,status=no,menubar=no,resizable=no,width=355,height=355');
}

function getElement(id)
{
	with (document) var element = getElementById ? getElementById(id) : all ? all[id] : layer[id];
	if(!element.style) element.style = element;
	return element;
}

function OffLoader()
{
	getElement('loaderBanner').style.visibility = 'hidden';
}

function elementOnOff(name)
{
	if (getElement(name).style.display == 'none')
		getElement(name).style.display = 'block';
	else
		getElement(name).style.display = 'none';
}

function hideElement(name)
{
	getElement(name).style.display = 'none';
}

function viewElement(name)
{
	getElement(name).style.display = 'block';
}

function timeDecrement(timerId, buttonId)
{
	var div = document.getElementById(timerId);
	var t = div.innerHTML;
	var time = t.split(':');

	if(time.length == 3)
	{
  		if(t != '0:00:00')
		{
   			var quantitySek = 3600 * Math.floor(time[0]) + 60 * Math.floor(time[1]) + Math.floor(time[2]);
   			quantitySek = quantitySek - 1;
   			var hour = Math.floor(quantitySek/3600);
   			var min = Math.floor((quantitySek - hour*3600)/60);
   			var sek = Math.floor(quantitySek - hour*3600 - min*60);

   			if (min < 10) min = "0" + min;
   			if (sek < 10) sek = "0" + sek;

   			div.innerHTML = hour + ':' + min + ':' + sek;

   			setTimeout('timeDecrement(\'' + timerId + '\', \'' + buttonId + '\')', 1000);
		}
		else
		{
			document.getElementById(buttonId).innerHTML = '';
			div.innerHTML = 'Zakończono';
		}
 	}
}

