function wyswietl_zdjecie(id,akcja,pozycja)
{	
	var rozmiarStr = getPageSize();
 if (akcja==1)
	{
		var array_zdjecia=document.getElementById('array_obrazy').value.split(',');
			
		if(pozycja<0 || pozycja>=array_zdjecia.length) {return false};
			
		var newIMG = new Image();	
		
		newIMG.src = array_zdjecia[pozycja];
		szerImg = newIMG.width;
		wysImg = newIMG.height;
		
		document.getElementById(id).src=array_zdjecia[pozycja];
		
		document.getElementById('sub_k2k5').style.visibility='hidden';
		document.getElementById('kontener3').style.visibility='hidden';
		document.getElementById('logo').style.visibility='hidden';

		document.getElementById('cien').style.height=rozmiarStr[1]+40+'px';

		srodekSze=(rozmiarStr[2]/2) - (szerImg/2)-5;
		srodekWys=(rozmiarStr[3]/2) - (wysImg/2)-5;

	//	document.getElementById('cien').innerHTML=pozycja+'---'+pozycja;
		
		document.getElementById('kontener_zdjecie').style.top=srodekWys+'px';
		document.getElementById('kontener_zdjecie').style.left=srodekSze+'px';
		
		
		pozycjaY=getScrollY(); 
	
		document.getElementById('kontener_zdjecie').style.top=srodekWys+pozycjaY+'px';

		document.getElementById('cien').style.display='block';
		document.getElementById('kontener_zdjecie').style.display='block'; 
		
		document.getElementById('prawy').style.left=szerImg-90+'px';
		document.getElementById('img_n').style.display='none';
		document.getElementById('img_w').style.display='none';
	}else{
		 document.getElementById('cien').style.display='none';
		 document.getElementById('kontener_zdjecie').style.display='none';
		 document.getElementById('sub_k2k5').style.visibility='visible';
		 document.getElementById('kontener3').style.visibility='visible';
		 document.getElementById('logo').style.visibility='visible';
	 }
	 
	 document.getElementById('h_pozycja').value=pozycja;
}

function reLoadDiv(warstwa,link)
{
	document.getElementById(warstwa).innerHTML=link;
}


function przewijanie(akcja)
{
	 akt_pozycja=document.getElementById('h_pozycja').value;
	
	if(akcja==1)
	{
	 pozycja=akt_pozycja*1+1;
	}else{
	 pozycja=akt_pozycja-1;
	}
	wyswietl_zdjecie('ch_obraz',1,pozycja);
}

function obraz_NP(id,akcja,on)
{
	var akt_pozycja=document.getElementById('h_pozycja').value;
	var array_zdjecia=document.getElementById('array_obrazy').value.split(',');
	var iloscElem = array_zdjecia.length;
	
	switch (akcja)
	{
		case 'wstecz':
			if(on==1 && iloscElem>1 && akt_pozycja*1!=0)
				{
				  document.getElementById(id).style.display='block';
				}else{
				  document.getElementById(id).style.display='none';
				}						
		break
		case 'przod':
			if(on==1 && iloscElem>1 && akt_pozycja*1!=iloscElem-1)
				{
				  document.getElementById(id).style.display='block';
				}else{
				  document.getElementById(id).style.display='none';
				}
			
		break
	}
}



function getScrollY() {
	var sy = 0;
	if (document.documentElement && document.documentElement.scrollTop)
	{
			sy = document.documentElement.scrollTop;
		}else if (document.body && document.body.scrollTop) {
			sy = document.body.scrollTop; 
		}else if (window.pageYOffset){
			sy = window.pageYOffset;
		}else if (window.scrollY){
			sy = window.scrollY;
	}
	return sy;
}

function getPageSize()
{
   var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}

//		return [pageWidth,pageHeight];

		return [xScroll,yScroll,windowWidth,windowHeight];
}