function getScrollY() {
	var scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
	//Netscape compliant
		scrOfY = window.pageYOffset;
	}
	else if( document.body && (document.body.scrollTop ) ) {
	//DOM compliant
		scrOfY = document.body.scrollTop; 
	}
	else if( document.documentElement && (document.documentElement.scrollTop)) {
	//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
	}
  return scrOfY;
}
function loadPhoto(path) {
		
	var coverHeight = $(document).height();
	var coverWidth = document.body.clientWidth;
	var windowHeight = $(window).height();
	if(coverHeight == windowHeight) windowHeight = window.innerHeight; //opera fix
	var curentPosition = getScrollY();
	var animVertPos = parseInt(curentPosition + (windowHeight - 37)/2);
	var imgEmbed = new Image();

	$('<div id="imgPopup"><div id="imgPopupCover"></div><div id="imgObject" class="loading"><a title="Kliknij by zamkn±æ podgl±d" href="javascript:imgPopupClose()"></a></div><div id="popupClose"><a href="javascript:imgPopupClose()"></a></div></div>').appendTo('body');
	$('#imgObject').height(coverHeight).css('background-position', 'center ' + animVertPos + 'px');
	$('#imgPopup, #imgPopupCover').height(coverHeight);


	$(imgEmbed).load(function () {    
		$(this).hide();
		$('#imgObject').removeClass('loading').children('a').append(this);
		var imgTotalWidth = parseInt($(this).width()) + 2*(parseInt($(this).css('padding-left')));
		var imgTotalHeight = parseInt($(this).height()) + 2*(parseInt($(this).css('padding-top')));
		
		var closeButtonPosition = parseInt((coverWidth - imgTotalWidth)/2);
		 	closeButtonPosition = (closeButtonPosition > 0) ? closeButtonPosition : '0';
		
		var imgVertPos = parseInt(curentPosition + (windowHeight - imgTotalHeight)/2);
			imgVertPos = (imgVertPos > 0) ? imgVertPos : '0';
		
		//if image too wide
		if (imgTotalWidth > coverWidth) {
			$('body,#imgPopup, #imgPopupCover').css('width', imgTotalWidth);
		}
		
		$('#popupClose a').css('top', imgVertPos - 6 ).css('left', closeButtonPosition - 6 ).show();
		$(this).css('top', imgVertPos).show('2000');
	}).attr('src',path);
}
		
function imgPopupClose(){
	$('#imgPopup').remove();
	$('body').css('width','auto');
}