function $(id){
   var obj_id=document.getElementById(id);
   return obj_id;
}

var wybrany="shImgCont0";
var wybranyId=0;
var blokId="Bl0";
var kolejka=false;
var wstecz=false;
function changePhoto(id,sr,w,h){
   var i=$("photo");i.src='0'; i.title='';
   
   
   if(w>=h){
      $("img_hold").style.height=Math.round(h*440/w)+"px";
      $("coverDiv").style.width="401px";
      $("coverDiv").style.height=Math.round(h*401/w)+"px";
      i.style.width="400px";
      i.style.height=(h*400/w)+"px";
   }else{
      $("img_hold").style.height="440px";
      $("coverDiv").style.height="401px";
      $("coverDiv").style.width="401px"; 
      //$("coverDiv").style.width=Math.round(w*441/h)+"px";
      i.style.height="400px";
      i.style.width=(w*400/h)+"px";
   }
   if(wstecz){
   if(id%12==11){
      fotoChange(Math.round(id/12),0);
   }
   }
   else{
   if(id!=0 & id%12==0)
   {
      fotoChange(Math.round(id/12)-1,1);
   }
   }
   var shic=$("shImgCont"+id); 
   var numerek=$("numerek");
   numerek.innerHTML = id+1;
   shic.style.border="2px solid #a97700";
   var shic_old=$(wybrany);
   shic_old.style.border="2px solid #E2E6E5";
   wybrany="shImgCont"+id;
   wybranyId=id;
   //var shicX=getPosition(shic).x;
   var t=$("t");
   //var pos=t.scrollLeft;
   //var scrollval=parseInt(shicX-getPosition($("shImgCont2")).x);
   //if(scrollval<=scrollEnd){t.scrollLeft=scrollval;}
   i.src=sr; i.title=id;
   //$("coverDiv").toFade=true;fadeOut("coverDiv",100);
   //$("coverDiv_wait").style.display="none";
   return true;
}
function fadeOut(targetId,opacity)
{
   var target = $(targetId);
   if(!target || !target.toFade || opacity <= 0) return;

   if(opacity < 0) opacity = 0;

   if(null !== target.style.opacity)
   {
       target.style.opacity = opacity/100-0.1;
       
   }
   if(null !== target.style.MozOpacity)
   {
      target.style.MozOpacity = opacity/100-0.1;
            
   }
   if(null !== target.style.filter)
   {  
      
      target.style.filter = "alpha(opacity="+(opacity-10)+")";
     
   }
   
   opacity -= 10;
   setTimeout("fadeOut('"+targetId+"',"+opacity+")",50);
}
