var przycisk = 0;
var nr = null;
function wyswietl(n)
{
  	przycisk = 0;
	if (n <= 0)
	{
		n = 0;
		przycisk = 1;
	}
	else if (n >= obrazki.length-1)
	{
   		n = obrazki.length-1;
   		przycisk = 2;
 	}
 	
 	if (document.images)
 	{
    		document.zdjecie.src = obrazki[n].src;
    		
    		document.getElementById("zdjecie1").style.visibility = "visible";
    		document.getElementById("zdjecie2").style.visibility = "visible";
    		document.getElementById("zdjecie3").style.visibility = "visible";
    		
                document.getElementById("zdjecie5").style.visibility = "visible";
    		document.getElementById("zdjecie6").style.visibility = "visible";
    		document.getElementById("zdjecie7").style.visibility = "visible";                                                                                    		
    		if(n-3 >= 0)
    		{
    		       document.zdjecie1.src = miniatury[n-3].src;
    		}
    		else
    		{
                       document.getElementById("zdjecie1").style.visibility = "hidden";
                       document.pokaz.start.style.color = "black";
                }
    		if(n-2 >= 0)
    		{
    		       document.zdjecie2.src = miniatury[n-2].src;
    		}
    		else
    		{
                       document.getElementById("zdjecie2").style.visibility = "hidden";
                }
    		if(n-1 >= 0)
    		{
    		       document.zdjecie3.src = miniatury[n-1].src;
    		}
    		else
    		{
                       document.getElementById("zdjecie3").style.visibility = "hidden";
                }
                
                document.zdjecie4.src = miniatury[n].src;

    		if(n+1 <= obrazki.length-1)
    		{
    		       document.zdjecie5.src = miniatury[n+1].src;
    		}
    		else
    		{
                       document.getElementById("zdjecie5").style.visibility = "hidden";
                }
    		if(n+2 <= obrazki.length-1)
    		{
    		       document.zdjecie6.src = miniatury[n+2].src;
    		}
    		else
    		{
                       document.getElementById("zdjecie6").style.visibility = "hidden";
                }
    		if(n+3 <= obrazki.length-1)
    		{
    		       document.zdjecie7.src = miniatury[n+3].src;
    		}
    		else
    		{
                       document.getElementById("zdjecie7").style.visibility = "hidden";
                }

  	}

	var p = n + 1;
	nr = n;
  	
  	
  	document.pokaz.elements[4].value = "zdjęcie " +p;
	document.pokaz.elements[4].style.fontFamily = "Courier New";
	document.pokaz.elements[4].style.backgroundColor = "transparent";
	document.pokaz.elements[4].style.border = "none";
	document.pokaz.elements[4].style.marginLeft = "0";
	document.pokaz.elements[4].style.marginTop = "0";
  	document.pokaz.elements[4].style.marginBottom = "15px";
  	document.pokaz.elements[4].style.fontSize = "16px";
  	document.pokaz.elements[5].style.textAlign = "left";
  	
  	document.pokaz.elements[5].value = opis[n+1];
	document.pokaz.elements[5].style.fontFamily = "Courier New";
	document.pokaz.elements[5].style.backgroundColor = "transparent";
	document.pokaz.elements[5].style.border = "none";
	document.pokaz.elements[5].style.marginRight = "0";
	document.pokaz.elements[5].style.marginTop = "0";
  	document.pokaz.elements[5].style.marginBottom = "0";
  	document.pokaz.elements[5].style.fontSize = "16px";
  	document.pokaz.elements[5].style.textAlign = "right";
  	
if (autor[n] == 0 || autor == "brak") {document.pokaz.zdjecie.alt = ""}
if (autor[n] == 1 || autor == "wojtek") {document.pokaz.zdjecie.alt = "autor: Wojtek Chaładaj"}
if (autor[n] == 2 || autor == "marcin") {document.pokaz.zdjecie.alt = "autor: Marcin Kruczyk"}
  	

	przyciski (przycisk);

}



var przerwa = null;
function animacja()
{
	if (nr < obrazki.length)
	{
		wyswietl(nr);
		
		przyciski_pokaz();

		nr++;
		przerwa = setTimeout('animacja()',4000)
	}
	
	else if (nr = obrazki.length)
	{
		nr = 0;
		wyswietl(nr);
		przerwa = null;
	}
}

var t = null;
function wlacz(t)
{
 
 	if (t == "start")
	{
		document.pokaz.start.style.color = "red";
	}

 	if (t == "stop")
	{
		document.pokaz.stop.style.color = "red";
	}

 	if (t == "poprzednie")
	{
	  	document.pokaz.poprzednie.style.color = "red";
	}

 	if (t == "nastepne")
	{
	  	document.pokaz.nastepne.style.color = "red";
	}

}


var l=null;
function wylacz(l)
{
 	if (l == "start")
	{
	  	document.pokaz.start.style.color = "black";
	}

 	if (l == "stop")
	{
	  	document.pokaz.stop.style.color = "black";
	}

 	if (l == "poprzednie")
	{
	  	document.pokaz.poprzednie.style.color = "black";
	}

 	if (l == "nastepne")
	{
	  	document.pokaz.nastepne.style.color = "black";
	}


}

function wlacz2(x)
{
	document.getElementById(x).style.border = " solid #986e41 6px";
}

function wylacz2(x)
{
	document.getElementById(x).style.border = "transparent solid 0";		  	  
}



function przyciski(przycisk)
{
	document.pokaz.start.value="Pokaz slajdów";
  	document.pokaz.start.disabled= false;
	document.pokaz.start.style.textAlign="right";
	document.pokaz.start.style.marginRight="10px";
	document.pokaz.start.style.fontFamily = "Courier New";
	document.pokaz.start.style.width="150px";

  	document.pokaz.stop.value="";
	document.pokaz.stop.disabled = true;
	document.pokaz.stop.style.textAlign="right";
	document.pokaz.stop.style.marginRight="0";
	document.pokaz.stop.style.fontFamily = "Courier New";	
	document.pokaz.stop.style.width="0";

  	document.pokaz.poprzednie.value="poprzednie";
  	document.pokaz.poprzednie.disabled= false;
	document.pokaz.poprzednie.style.textAlign="left";
	document.pokaz.poprzednie.style.marginLeft="10px";
	document.pokaz.poprzednie.style.fontFamily = "Courier New";


  	document.pokaz.nastepne.value="następne";
  	document.pokaz.nastepne.disabled= false;
	document.pokaz.nastepne.style.textAlign="right";
	document.pokaz.nastepne.style.marginRight="10px";
	document.pokaz.nastepne.style.fontFamily = "Courier New";
	
	if(przycisk == 1)
	{
		document.pokaz.poprzednie.disabled = true;		
		document.pokaz.poprzednie.value = ""; 
		document.pokaz.poprzednie.style.color  = "black";
	}
	
	else if(przycisk == 2)
	{
		document.pokaz.nastepne.disabled = true;		
		document.pokaz.nastepne.value = "";
		document.pokaz.nastepne.style.color  = "black";		
	}
}

function przyciski_pokaz()
{
	document.pokaz.start.value = "";
	document.pokaz.start.disabled = true;		
	document.pokaz.start.style.textAlign="right";
	document.pokaz.start.style.marginRight="0";
	document.pokaz.start.style.fontFamily = "Courier New";
	document.pokaz.start.style.width="0";

	document.pokaz.stop.value = "stop";
	document.pokaz.stop.disabled = false;
	document.pokaz.stop.style.textAlign="right";
	document.pokaz.stop.style.marginRight="10px";
	document.pokaz.stop.style.fontFamily = "Courier New";	
	document.pokaz.stop.style.width="50px";

	document.pokaz.poprzednie.disabled = true;		
	document.pokaz.poprzednie.value = "";
	document.pokaz.poprzednie.style.color  = "black";

	document.pokaz.nastepne.disabled = true;		
	document.pokaz.nastepne.value = "";
	document.pokaz.nastepne.style.color  = "black";		

}
