var current_photo = 1;
var slideshow = "ok";
		
$(document).ready(function(){

    $("#link01").mouseover(function(){
		$("#homePhoto0").hide(0);
		$("#homePhoto1").fadeIn("fast");
    });
	
    $("#link01").mouseout(function(){
		$("#homePhoto1").hide(0);
		$("#homePhoto0").fadeIn("fast");
    });
		
    $("#link02").mouseover(function(){
		$("#homePhoto0").hide(0);
		$("#homePhoto2").fadeIn("fast");
    });
	
    $("#link02").mouseout(function(){
		$("#homePhoto2").hide(0);
		$("#homePhoto0").fadeIn("fast");
    });
	
	
    $("#link03").mouseover(function(){
		$("#homePhoto0").hide(0);
		$("#homePhoto3").fadeIn("fast");
    });
	
    $("#link03").mouseout(function(){
		$("#homePhoto3").hide(0);
		$("#homePhoto0").fadeIn("fast");
    });






    $("#fotograficy").mouseenter(function(){
	  $("#fotograficy_menu").show().animate({top: -1}, "fast");
	  $("#fotograficy_menu_wrapper").show().animate({height: 100}, "fast");
	  $("#fotograficy_wrapper").show().animate({height: 130}, "fast");
    });	
		
    $("#fotograficy_wrapper").mouseleave(function(){
      $("#fotograficy_menu").show().animate({top: -82}, "fast");
	  $("#fotograficy_menu_wrapper").show().animate({height: 2}, "fast");
	  $("#fotograficy_wrapper").show().animate({height: 30}, "fast");
	   });	
	  
    $("#fotograficy_wrapper2").mouseleave(function(){
      $("#fotograficy_menu").show().animate({top: -82}, "fast");
	   });	
	  
    $("#fotograficy_wrapper3").mouseleave(function(){
      $("#fotograficy_menu").show().animate({top: -82}, "fast");
		});	




   $("#go_one_down").mouseover(function(){
      $("#left_arrow").fadeTo("fast", 0.4);
    });
    $("#go_one_up").mouseover(function(){
      $("#right_arrow").fadeTo("fast", 0.4);
    });
		
    $("#go_one_down").mouseout(function(){
      $("#left_arrow").fadeTo("fast", 0.0);
    });
    $("#go_one_up").mouseout(function(){
      $("#right_arrow").fadeTo("fast", 0.0);
    });



   $("#go_one_up").click(function(){
	NextPhoto();
    });


   $("#go_one_down").click(function(){
	PrevPhoto();
    });

});



/*#########################################################*/

	function SlideShow(){
		if(current_photo<max){
			
			if(slideshow == "ok"){
			setTimeout("NextPhotoShow()", 5000);
			}
		}
		
		if(current_photo == max){
				setTimeout("location.href = 'home'", 5000);
			}
	}
	
	function NextPhotoShow(){
		if(slideshow == "ok"){
		NextPhoto(slideshow);
		SlideShow();
		}
	
	}
	
	function SlideShowPlay(){	
		if(slideshow !== "ok"){
			if(current_photo<max){
				NextPhoto('ok');
				slideshow = "ok";
				SlideShow();
			}
		}			
			

	}
	
	function SlideShowPause(){
		slideshow = "stop";
	}


/*#########################################################*/


		function NextPhoto(show){
	
		if(show !== "ok")
		{
			SlideShowPause();
		}
		
			var nr = current_photo+1;
			$("#foto"+current_photo).fadeTo("fast", 0.0);
			$("#foto"+nr).fadeTo("slow", 1.0);
			current_photo = nr;
			
				if(current_photo>1)
				{
				$("#go_one_down").show(0);
				$("#go_one_down").fadeTo(0, 0.0);
				}
				else
				{
				$("#go_one_down").hide(0);
				}
			
				if(max!=0 && current_photo==max)
				{
				$("#go_one_up").hide(0);
				}
				else
				{
				$("#go_one_up").show(0);
				$("#go_one_up").fadeTo(0, 0.0);
				}
		
	document.getElementById('counter').innerHTML = current_photo;
	

		
		}



/*#########################################################*/


		function PrevPhoto(){
	
			var nr = current_photo-1;
			$("#foto"+current_photo).fadeTo(0, 0.0);
			$("#foto"+nr).fadeTo("slow", 1.0);
			current_photo = nr;
			
				if(current_photo>1)
				{
				$("#go_one_down").show(0);
				$("#go_one_down").fadeTo(0, 0.0);
				}
				else
				{
				$("#go_one_down").hide(0);
				}
			
				if(max!=0 && current_photo==max)
				{
				$("#go_one_up").hide(0);
				}
				else
				{
				$("#go_one_up").show(0);
				$("#go_one_up").fadeTo(0, 0.0);
				}

	document.getElementById('counter').innerHTML = current_photo;
			
		}
		


/*#########################################################*/


		function showUpPhoto(){
		showPhoto(current_photo+1);
		}

/*#########################################################*/


		function showDownPhoto(){
		if(current_photo==7 || current_photo==13 || current_photo==19 || current_photo==25){
		scroll_left(89);
		}
		showPhoto(current_photo-1);
		}


/*#########################################################*/

		function scrollto(id,size) {
		 
		 maximum = getMax(current);
		 
		 if(miniaturki_current!=id)
			 {
				if(id>0&&id<=maximum)
				 {
					var liczba=-1*((id-1)*size);
					$("#"+current+"_miniaturki").show().animate({left: liczba},"slow");
				
					miniaturki_current=id;
				}
				if((maximum-id)<6)
				 {
					$("#goright").hide("slow");

				}
				else
				{
					$("#goright").show("slow");

				}
			 }
		 }

/*#########################################################*/
 
	 function scroll_left(size) {

	 scrollto(miniaturki_current-6, size);

	 }

/*#########################################################*/

	 function scroll_right(size) {
	 
	 scrollto(miniaturki_current+6, size);

	 }




/*#########################################################*/

$(document).ready(function(){

    $("#linki_box").mouseover(function(){
      $("#linki_over").fadeIn("slow");
    });
		
		
    $("#linki_box").mouseout(function(){
      $("#linki_over").fadeOut("slow");
    });
		
		
    $("#linki_box").click(function(){
			if(current=="kontakt"){
      $("#kontakt_text").show().animate({left: -300}, 500);
      $("#linki_text").animate({opacity: 1.0}, 500);
      $("#linki_text").show().animate({left: 5}, 1000);
			current="linki";
			}
			else if(current=="linki"){
      $("#linki_text").show().animate({left: -300}, 500);
      $("#linki_pion").animate({opacity: 1.0}, 500);
      $("#linia_pion").show().animate({top: 431}, 1500);
			current="home_page";
			}
			else
			{
      $("#linia_pion").show().animate({top: 0}, 1500);
      $("#linki_text").animate({opacity: 1.0}, 1250);
      $("#linki_text").show().animate({left: 5}, 1000);
				current="linki";
			}
    });
		

		
    $("#publikacje_box").mouseover(function(){
		
		if(current=="kontakt"){
      $("#kontakt_text").show().animate({left: -300}, 500);
      $("#linia_pion").animate({opacity: 1.0}, 500);
      $("#linia_pion").show().animate({top: 361}, 1500);
			current="home_page";
			}
			
		if(current=="linki"){
      $("#linki_text").show().animate({left: -300}, 500);
      $("#linia_pion").animate({opacity: 1.0}, 500);
      $("#linia_pion").show().animate({top: 361}, 1500);
			current="home_page";
			}
		
      $("#publikacje_over").fadeIn("slow");
    });
		
		
    $("#publikacje_box").mouseout(function(){
      $("#publikacje_over").fadeOut("slow");
    });
		
		
    $("#publikacje_box").click(function(){
			
			
				if(current=="linki"){
				$("#linki_text").show().animate({left: -300}, 500);
				$("#linki_pion").animate({opacity: 1.0}, 500);
				$("#linia_pion").show().animate({top: 361}, 1500);
				}
				else if(current=="kontakt"){
				$("#kontakt_text").show().animate({left: -300}, 500);
				$("#linia_pion").animate({opacity: 1.0}, 500);
				$("#linia_pion").show().animate({top: 361}, 1500);
				}

			resetHome();
			$("#"+current).hide(0);
			showGaleria("publikacje");
    });
		
    $("#publikacje_tomekpikula").mouseenter(function(){
		if(kontakt_top==1){
		$("#kontakt_top").fadeOut("fast");
		$("#kontakt_top").show().animate({left: 370}, "slow");
		$("#podpis").fadeIn("slow");
		kontakt_top = 0;
		}
			$("#publikacje_tomekpikula").show().animate({width: 250}, "slow");
      $("#publikacje_portret").show().animate({left: 15}, "slow");
      $("#publikacje_biznes").show().animate({left: 85}, "slow");
      $("#publikacje_reportaz").show().animate({left: 155}, "slow");
			
    });	
		
    $("#publikacje_tomekpikula_wrapper").mouseleave(function(){
			$("#publikacje_tomekpikula").show().animate({width: 100}, "slow");
      $("#publikacje_portret").show().animate({left: -210}, "slow");
      $("#publikacje_biznes").show().animate({left: -140}, "slow");
			$("#publikacje_reportaz").show().animate({left: -80}, "slow");

    });	
		
    $("#publikacje_portret").click(function(){
			hideGaleria();
			showGaleria("portret");
    });	
		
    $("#publikacje_biznes").click(function(){
			hideGaleria();
			showGaleria("biznes");
    });
		
    $("#publikacje_reportaz").click(function(){
			hideGaleria();
			showGaleria("reportaz");
    });
		
    $("#kontakt_box").mouseover(function(){
      $("#kontakt_over").fadeIn("slow");
    });
		
		
    $("#kontakt_box").mouseout(function(){
      $("#kontakt_over").fadeOut("slow");
    });
		
		
    $("#kontakt_box").click(function(){
			if(current=="linki"){
      $("#linki_text").show().animate({left: -300}, 500);
      $("#kontakt_text").animate({opacity: 1.0}, 500);
      $("#kontakt_text").show().animate({left: 5}, 1000);
				current="kontakt";
			}
			else if(current=="kontakt"){
      $("#kontakt_text").show().animate({left: -300}, 500);
      $("#linia_pion").animate({opacity: 1.0}, 500);
      $("#linia_pion").show().animate({top: 361}, 1500);
			current="home_page";
			}
			else
			{
      $("#linia_pion").show().animate({top: 0}, 1500);
      $("#kontakt_text").animate({opacity: 1.0}, 1250);
      $("#kontakt_text").show().animate({left: 5}, 1000);
				current="kontakt";
			}
    });
		
		
    $("#portret_box").mouseover(function(){
		if(current=="kontakt"){
      $("#kontakt_text").show().animate({left: -300}, 500);
      $("#linia_pion").animate({opacity: 1.0}, 500);
      $("#linia_pion").show().animate({top: 361}, 1500);
			current="home_page";
			}
			
		if(current=="linki"){
      $("#linki_text").show().animate({left: -300}, 500);
      $("#linia_pion").animate({opacity: 1.0}, 500);
      $("#linia_pion").show().animate({top: 361}, 1500);
			current="home_page";
			}

				$("#portret_over").fadeIn("slow");
				$("#portret_out").fadeOut("slow");
				$("#subpage").fadeOut(0);
				$("#subpage_portret").fadeIn(0);
    });
		
		
    $("#portret_box").mouseout(function(){
      $("#portret_over").fadeOut("slow");
				$("#portret_out").fadeIn("slow");
				$("#subpage").fadeIn(0);
				$("#subpage_portret").fadeOut(0);
    });
		
    $("#portret_box").click(function(){
			
			
				if(current=="linki"){
				$("#linki_text").show().animate({left: -300}, 500);
				$("#linki_pion").animate({opacity: 1.0}, 500);
				$("#linia_pion").show().animate({top: 361}, 1500);
				}
				else if(current=="kontakt"){
				$("#kontakt_text").show().animate({left: -300}, 500);
				$("#linia_pion").animate({opacity: 1.0}, 500);
				$("#linia_pion").show().animate({top: 361}, 1500);
				}
				
			resetHome();
			$("#"+current).hide(0);
			showGaleria("portret");
    });
		
		
    $("#biznes_box").mouseover(function(){
		if(current=="kontakt"){
      $("#kontakt_text").show().animate({left: -300}, 500);
      $("#linia_pion").animate({opacity: 1.0}, 500);
      $("#linia_pion").show().animate({top: 361}, 1500);
			current="home_page";
			}
			
		if(current=="linki"){
      $("#linki_text").show().animate({left: -300}, 500);
      $("#linia_pion").animate({opacity: 1.0}, 500);
      $("#linia_pion").show().animate({top: 361}, 1500);
			current="home_page";
			}
	
	
				$("#biznes_over").fadeIn("slow");
				$("#biznes_out").fadeOut("slow");
				$("#subpage").fadeOut(0);
				$("#subpage_biznes").fadeIn(0);
    });
		
		
    $("#biznes_box").mouseout(function(){
      $("#biznes_over").fadeOut("slow");
				$("#biznes_out").fadeIn("slow");
				$("#subpage").fadeIn(0);
				$("#subpage_biznes").fadeOut(0);
    });
		
		
    $("#biznes_box").click(function(){
			
			
				if(current=="linki"){
				$("#linki_text").show().animate({left: -300}, 500);
				$("#linki_pion").animate({opacity: 1.0}, 500);
				$("#linia_pion").show().animate({top: 361}, 1500);
				}
				else if(current=="kontakt"){
				$("#kontakt_text").show().animate({left: -300}, 500);
				$("#linia_pion").animate({opacity: 1.0}, 500);
				$("#linia_pion").show().animate({top: 361}, 1500);
				}

			resetHome();
			$("#"+current).hide(0);
			showGaleria("biznes");
    });
		
    $("#reportaz_box").mouseover(function(){
		
	if(current=="kontakt"){
      $("#kontakt_text").show().animate({left: -300}, 500);
      $("#linia_pion").animate({opacity: 1.0}, 500);
      $("#linia_pion").show().animate({top: 361}, 1500);
			current="home_page";
			}
			
		if(current=="linki"){
      $("#linki_text").show().animate({left: -300}, 500);
      $("#linia_pion").animate({opacity: 1.0}, 500);
      $("#linia_pion").show().animate({top: 361}, 1500);
			current="home_page";
			}
		
				$("#reportaz_over").fadeIn("slow");
				$("#reportaz_out").fadeOut("slow");
				$("#subpage").fadeOut(0);
				$("#subpage_reportaz").fadeIn(0);
    });
		
		
    $("#reportaz_box").mouseout(function(){
      $("#reportaz_over").fadeOut("slow");
				$("#reportaz_out").fadeIn("slow");
				$("#subpage").fadeIn(0);
				$("#subpage_reportaz").fadeOut(0);
    });
	
	
    $("#reportaz_box").click(function(){
			
			
				if(current=="linki"){
				$("#linki_text").show().animate({left: -300}, 500);
				$("#linki_pion").animate({opacity: 1.0}, 500);
				$("#linia_pion").show().animate({top: 361}, 1500);
				}
				else if(current=="kontakt"){
				$("#kontakt_text").show().animate({left: -300}, 500);
				$("#linia_pion").animate({opacity: 1.0}, 500);
				$("#linia_pion").show().animate({top: 361}, 1500);
				}

			resetHome();
			$("#"+current).hide(0);
			showGaleria("reportaz");
    });
	
	
	
	
	
    $("#bottom_home").click(function(){
		$("#kontakt_top").show().animate({left: 370}, "slow");
		hideGaleria();
		
		
		current="home_page";
      	$("#home_page").fadeIn("fast");
		

    });		
		
		
    $("#bottom_kontakt").click(function(){

			$("#podpis").fadeOut("fast");
			$("#kontakt_top").show().animate({left: 0}, "slow");
			
			kontakt_top = 1;

    });	
		
		
    $("#bottom_menu").mouseenter(function(){
		if(kontakt_top==1){
		$("#kontakt_top").fadeOut("fast");
		$("#kontakt_top").show().animate({left: 370}, "slow");
		$("#podpis").fadeIn("slow");
		kontakt_top = 0;
		}
			$("#bottom_menu").show().animate({width: 150}, "slow");
      $("#bottom_home").show().animate({left: 100}, "slow");
      $("#bottom_kontakt").show().animate({left: 140}, "slow");

    });	
		
    $("#bottom_menu_outwrapper").mouseleave(function(){
			$("#bottom_menu").show().animate({width: 35}, "slow");
      $("#bottom_home").show().animate({left: 200}, "slow");
      $("#bottom_kontakt").show().animate({left: 240}, "slow");

    });	
		
		
    $("#portret_tomekpikula").mouseenter(function(){
		if(kontakt_top==1){
		$("#kontakt_top").fadeOut("fast");
		$("#kontakt_top").show().animate({left: 370}, "slow");
		$("#podpis").fadeIn("slow");
		kontakt_top = 0;
		}
			$("#portret_tomekpikula").show().animate({width: 250}, "slow");
      $("#portret_biznes").show().animate({left: 15}, "slow");
      $("#portret_reportaz").show().animate({left: 85}, "slow");

    });	
		
    $("#portret_tomekpikula_wrapper").mouseleave(function(){
			$("#portret_tomekpikula").show().animate({width: 100}, "slow");
      $("#portret_biznes").show().animate({left: -140}, "slow");
      $("#portret_reportaz").show().animate({left: -80}, "slow");

    });	
		
    $("#portret_biznes").click(function(){
			hideGaleria();
			showGaleria("biznes");
    });	
		
    $("#portret_reportaz").click(function(){
			hideGaleria();
			showGaleria("reportaz");
    });	
		
		
		
		
    $("#biznes_tomekpikula").mouseenter(function(){
		if(kontakt_top==1){
		$("#kontakt_top").fadeOut("fast");
		$("#kontakt_top").show().animate({left: 370}, "slow");
		$("#podpis").fadeIn("slow");
		kontakt_top = 0;
		}
			$("#biznes_tomekpikula").show().animate({width: 250}, "slow");
      $("#biznes_portret").show().animate({left: 15}, "slow");
      $("#biznes_reportaz").show().animate({left: 85}, "slow");

    });	
		
    $("#biznes_tomekpikula_wrapper").mouseleave(function(){
			$("#biznes_tomekpikula").show().animate({width: 100}, "slow");
      $("#biznes_portret").show().animate({left: -140}, "slow");
      $("#biznes_reportaz").show().animate({left: -80}, "slow");

    });	
		
    $("#biznes_portret").click(function(){
			hideGaleria();
			showGaleria("portret");
    });	
		
    $("#biznes_reportaz").click(function(){
			hideGaleria();
			showGaleria("reportaz");
    });	
		
		
		
		
    $("#reportaz_tomekpikula").mouseenter(function(){
		if(kontakt_top==1){
		$("#kontakt_top").fadeOut("fast");
		$("#kontakt_top").show().animate({left: 370}, "slow");
		$("#podpis").fadeIn("slow");
		kontakt_top = 0;
		}
			$("#reportaz_tomekpikula").show().animate({width: 250}, "slow");
      $("#reportaz_portret").show().animate({left: 15}, "slow");
      $("#reportaz_biznes").show().animate({left: 85}, "slow");

    });	
		
    $("#reportaz_tomekpikula_wrapper").mouseleave(function(){
			$("#reportaz_tomekpikula").show().animate({width: 100}, "slow");
      $("#reportaz_portret").show().animate({left: -140}, "slow");
      $("#reportaz_biznes").show().animate({left: -70}, "slow");

    });	
		
    $("#reportaz_portret").click(function(){
			hideGaleria();
			showGaleria("portret");
    });	
		
    $("#reportaz_biznes").click(function(){
			hideGaleria();
			showGaleria("biznes");
    });
		
		

    $("#goright_transparent").mouseover(function(){
      $("#goright_white").fadeIn("fast");
		});
		
    $("#goright_transparent").mouseout(function(){
      $("#goright_white").fadeOut("fast");
		});
		
    $("#goleft_transparent").mouseover(function(){
		if(miniaturki_current != 1){
      $("#goleft_white").fadeIn("fast");
		}
		});
		
    $("#goleft_transparent").mouseout(function(){
      $("#goleft_white").fadeOut("fast");
		});
		
    $("#go_one_down").mouseover(function(){
      $("#left-arrow").fadeIn("fast");
    });
    $("#go_one_up").mouseover(function(){
      $("#right-arrow").fadeIn("fast");
    });
		
    $("#go_one_down").mouseout(function(){
      $("#left-arrow").fadeOut("fast");
    });
    $("#go_one_up").mouseout(function(){
      $("#right-arrow").fadeOut("fast");
    });
		
    $("#portret0").mouseover(function(){
		$("#podpis").stop(true, true);							  
		$("#podpis").fadeIn("slow");
    });
	
    $("#portret0").mouseleave(function(){
		$("#podpis").fadeOut("slow");
    });
		
    $("#biznes0").mouseover(function(){
		$("#podpis").stop(true, true);
		$("#podpis").fadeIn("slow");
    });
		
    $("#biznes0").mouseout(function(){
		$("#podpis").fadeOut("slow");
    });
		
    $("#reportaz0").mouseover(function(){
		$("#podpis").stop(true, true);
		$("#podpis").fadeIn("slow");
    });
		
    $("#reportaz0").mouseout(function(){
		$("#podpis").fadeOut("slow");
    });
		
	$("#publikacje0").mouseover(function(){
		$("#podpis").stop(true, true);
		$("#podpis").fadeIn("slow");
    });
		
    $("#publikacje0").mouseout(function(){
		$("#podpis").fadeOut("slow");
    });
  });
