function $(id) {
	return document.getElementById(id);
}
function getBodyHeight() {
	if(document.body.offsetHeight) {
		return document.body.offsetHeight;
	}
	if(document.documentElement && document.documentElement.scrollHeight) {
		return document.documentElement.scrollHeight;
	}
	return 0;
}
function getCurrentTop() {
	if(document.documentElement && document.documentElement.scrollTop) {
		return document.documentElement.scrollTop;
	}
	if(document.body.scrollTop) {
		return document.body.scrollTop;
	}
	return 0;
}
function getWindowWidth() {
	if(window.self && self.innerWidth) {
		return self.innerWidth - 20;
	}
	if(document.documentElement && document.documentElement.clientWidth) {
		return document.documentElement.clientWidth;
	}
	return 0;
}
function showImage(imgSrc, imgWidth, imgHeight, alt) {
	if(alt == undefined || alt == '') {
		alt = 'Brak opisu';
	}
	imgSrc = '/img/galeria/' + imgSrc;
	
	imgBg = document.createElement('div');
	imgBg.style.position = 'absolute';
	imgBg.style.top = '0px';
	imgBg.style.left = '0px';
	imgBg.style.width = getWindowWidth() + 'px';
	imgBg.style.height = getBodyHeight() + 'px';
	imgBg.style.backgroundColor = '#000';
	imgBg.style.opacity = 0.8;
	imgBg.style.MozOpacity = 0.8;
	imgBg.style.KhtmlOpacity = 0.8;
	imgBg.style.filter = "alpha(opacity=80)";
	imgBg.style.zIndex = 998;
	imgBg.id = 'imgBg';
	imgBg.onclick = closeImage;
	document.body.appendChild(imgBg);
		
	img = new Image();
	img.src = imgSrc;
	imgFg = document.createElement('div');
	imgFg.style.position = 'absolute';
	imgFg.style.backgroundColor = '#fff';
	imgFg.style.top = (parseInt(getCurrentTop()) + parseInt(imgHeight/4) - 30) + 'px';
	imgFg.style.left = (parseInt(getWindowWidth()/2) - parseInt(imgWidth/2) - 10) + 'px';
	imgFg.style.width = imgWidth + 'px';
	imgFg.style.height = (imgHeight + 10)  + 'px';
	imgFg.style.padding = '10px';
	imgFg.style.fontSize = '10px';
	imgFg.style.color = '#333';
	imgFg.innerHTML = '<img src="' + imgSrc + '" width="' + imgWidth + '" height="' + imgHeight + '" alt="' + alt + '"/><br />';
	imgFg.innerHTML += '<i>' + alt + '</i>';
	imgFg.style.zIndex = 999;
	imgFg.id = 'imgFg';
	document.body.appendChild(imgFg);
		
	imgX = document.createElement('div');
	imgX.style.position = 'absolute';
	imgX.style.backgroundColor = '#fff';
	imgX.style.width = '19px';
	imgX.style.height = '19px';
	imgX.style.top = '5px';
	imgX.style.right = '5px';
	imgX.onclick = closeImage;
	imgc = new Image();
	imgc.src = '/img/img_close.gif';
	imgX.innerHTML = '<img src="/img/img_close.gif" alt="Zamknij" title="Zamknij" />';
	imgX.style.cursor = 'pointer';
	imgX.style.zIndex = 1000;
	$('imgFg').appendChild(imgX);
}
function closeImage() {
	document.body.removeChild($('imgBg'));
	document.body.removeChild($('imgFg'));
}
function mapInit() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		map.setCenter(new GLatLng(50.3034,18.7725), 14);
		map.addControl(new GSmallZoomControl());
		var marker = new GMarker(new GLatLng(50.3034,18.7725));
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml('<span style="color:#333"><b>Klub Taneczny FORUM</b><br />ul. Fabryczna 1<br />Zabrze</span>');
		});
		map.addOverlay(marker);
		GEvent.trigger(marker, "click");
	}
}
