/*************************************************************************************

<div id="galeria" style="visibility:hidden;">
<div id="galeria_przyslona" style="position:absolute; top:0; left:0; width:100%; height:100%; background:#818181; filter:Alpha(Opacity=70); opacity:0.7;"></div>
<div style="position:absolute; top:0; left:0; width:100%; height:100%">
<table cellpadding="0" cellspacing="0" height="100%" width="100%"><tr><td valign="middle" align="center">
<a href="javascript:ukryj()"><img id="galeria_img" src="wczytywanie.gif" title="Zamknij" style="border:5px solid #0099FF;" /></a>
</td></tr></table>
</div>
</div>

-------------------------------------------------------------------------------------

<a href="javascript:wyswietl('big1.jpg')"><img src="mini1.jpg"></a>

*************************************************************************************/




var obraz = new Image();
var iid = 0;
var iid2 = 0;
var przyslona_wysokosc = 0;


function przyslona(pierwszy)
{
	przyslona_wys = document.getElementById('galeria_px').offsetTop;
	
	if(document.getElementById("galeria_img").height+20 > przyslona_wys)
	{
		przyslona_wys = document.getElementById("galeria_img").height+20;
	}	
	
	if(document.getElementById('galeria_px2').offsetTop > przyslona_wys)
	{
		przyslona_wys = document.getElementById('galeria_px2').offsetTop;
	}	
	
	przyslona_sze = document.getElementById('galeria_px').offsetLeft;

	if(document.getElementById("galeria_img").width+20 > przyslona_sze)
	{
		przyslona_sze = document.getElementById("galeria_img").width+20;
	}

	if(document.getElementById('galeria_px2').offsetLeft > przyslona_sze)
	{
		przyslona_sze = document.getElementById('galeria_px2').offsetLeft;
	}
	
	document.getElementById('galeria_przyslona').style.height = przyslona_wys + 'px';
	document.getElementById('galeria_przyslona').style.width = przyslona_sze + 'px';
	
	document.getElementById('galeria_tab').style.height = document.getElementById('galeria_px').offsetTop + 'px';
	document.getElementById('galeria_tab').style.width = document.getElementById('galeria_px').offsetLeft + 'px';
	
	if(pierwszy)
	{
		document.getElementById('galeria_img').style.top = getScrollXY()[1] + 'px';
	}
}

function zaladowano()
{
	if((obraz.complete) && (iid))
	{
		document.getElementById('galeria_img').src = obraz.src;

		clearInterval(iid);
		iid = 0;
	}
}

function wyswietl(adres)
{	
	obraz.src = adres;
	
	if(! iid)
	{
		iid = setInterval("zaladowano()", 100);
		iid2 = setInterval("przyslona(0)", 100);
		przyslona(1);
	}
	
	document.getElementById('galeria_cala').style.visibility = 'visible';
}

function ukryj()
{
	document.getElementById('galeria_cala').style.visibility = 'hidden';

	clearInterval(iid2);
	iid2=0;
	
	document.getElementById('galeria_przyslona').style.height = '1px';
	document.getElementById('galeria_przyslona').style.width = '1px';
	document.getElementById('galeria_tab').style.height = '1px';
	document.getElementById('galeria_tab').style.width = '1px';
	
	document.getElementById('galeria_img').src = 'cms/graf/wczytywanie.gif';
}


function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}
/*
function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  window.alert( 'Width = ' + myWidth );
  window.alert( 'Height = ' + myHeight );
}
*/