function changeImage(thisDiv){
  var check = document.getElementById('a').value;
  var adres;
  if (check=='1'){
  adres = "gallery/zjazd/2009_09_15/"+thisDiv.id+".jpg";
  document.getElementById('image_x').src = adres;  
  }
  if(check=='2'){
  adres = "gallery/zjazd/2009_09_16/"+thisDiv.id+".JPG";
  document.getElementById('image_x').src = adres;
  }
  if(check=='3_1'){
  adres = "gallery/zjazd/2009_09_17/01/"+thisDiv.id+".JPG";
  document.getElementById('image_x').src = adres;
  }
  if(check=='3_2'){
  adres = "gallery/zjazd/2009_09_17/02/"+thisDiv.id+".JPG";
  document.getElementById('image_x').src = adres;
  }
  if(check=='3_3'){
  adres = "gallery/zjazd/2009_09_17/03/"+thisDiv.id+".JPG";
  document.getElementById('image_x').src = adres;
  }
  if(check=='3_4'){
  adres = "gallery/zjazd/2009_09_17/04/"+thisDiv.id+".JPG";
  document.getElementById('image_x').src = adres;
  }
  if(check=='3_5'){
  adres = "gallery/zjazd/2009_09_17/05/"+thisDiv.id+".JPG";
  document.getElementById('image_x').src = adres;
  }
  if(check=='3_6'){
  adres = "gallery/zjazd/2009_09_17/06/"+thisDiv.id+".JPG";
  document.getElementById('image_x').src = adres;
  }
  if(check=='3_7'){
  adres = "gallery/zjazd/2009_09_17/07/"+thisDiv.id+".JPG";
  document.getElementById('image_x').src = adres;
  }
  if(check=='4'){
  adres = "gallery/zjazd/2009_09_18/"+thisDiv.id+".JPG";
  document.getElementById('image_x').src = adres;
  }
  if(check=='5'){
  adres = "gallery/zjazd/2009_09_19/"+thisDiv.id+".JPG";
  document.getElementById('image_x').src = adres;
  }
  
  
  CaricaFoto(adres);
  Controlla(adres);
 viewFoto(adres);
}

function CaricaFoto(adres){
 foto1= new Image();
 foto1.src=(adres);
 
}
function Controlla(adres){
 if((foto1.width!=0)&&(foto1.height!=0)){
   viewFoto(adres);
 }
 else{
   funzione="Controlla('"+adres+"')";
   intervallo=setTimeout(funzione,1);
 }
}
function viewFoto(adres){
 largh=foto1.width;
 altez=foto1.height;
   var z=0;
  if (altez>370){
	  z=370/altez;
	  largh=largh*z;
	  altez=370;}
  if (largh>640){
	  z=640/largh;
	  altez=altez*z;
	  largh=640;
	  }
  
  document.getElementById('image_x').width=largh;
  document.getElementById('image_x').height=altez;
  $("p#id2").css('height',altez+45);
  $("p#id2").css('width',largh);
  $("p#id2").css('marginTop',-(altez/2));
  $("p#id2").css('marginLeft',-(largh/2));
}

    jQuery.preload = function()
    {
      for(var i = 0; i<arguments.length; i++)
      {
            jQuery("<img>").attr("src", arguments[i]);
      }
    }
$.preload("gallery/zjazd/2009_09_15/1.jpg","gallery/zjazd/2009_09_15/2.jpg","gallery/zjazd/2009_09_15/3.jpg","gallery/zjazd/2009_09_15/4.jpg","gallery/zjazd/2009_09_15/5.jpg","gallery/zjazd/2009_09_15/6.jpg","gallery/zjazd/2009_09_15/7.jpg","gallery/zjazd/2009_09_15/8.jpg","gallery/zjazd/2009_09_15/9.jpg","gallery/zjazd/2009_09_15/10.jpg","gallery/zjazd/2009_09_15/11.jpg","gallery/zjazd/2009_09_15/12.jpg","gallery/zjazd/2009_09_15/13.jpg");



$(document).ready(
function() {
	$('.ukrywacz').click(function () {
			$("p#id2").css({opacity: 0.0, visibility: "visible"}).animate({opacity: 1.0},750);
			$("p#id1").css({opacity: 0.0, visibility: "visible"}).animate({opacity: 0.7},750);/*.wait().delay(300);*/
			return false;
	});
	
	$('.ukrywacz2').click(function () {
		
		var idbloku = $(this).attr('href'); //tworzy zmienną idbloku z wartością z atrybutu href
		$("p#id1").animate({opacity: 0.0},{queue:false, duration:500, complete: function(){
$(this).attr({"style": 'visibility:hidden'})}});
		$("p#id2").animate({opacity: 0.0},{queue:false, duration:500, complete: function(){
$(this).attr({"style": 'visibility:hidden'})}}).delay(500); 
		/*document.getElementById('image_x').src = "gallery/preloader.gif";*/
		return false;
	});

})
