
function makeDiv(iLeft,iWidth,oWindow,fnFunk1,fnFunk2){
var oDiv = document.createElement('div');
   oDiv.style.width = iWidth + 'px';
   oDiv.style.height = oWindow.offsetHeight + 'px';
   oDiv.style.position = 'absolute';
   oDiv.style.left = iLeft+'px';
   oDiv.style.top = '0px';
   oDiv.style.display = 'block';
   oDiv.style.backgroundImage = 'url(images/spacer.gif)';
   //oDiv.style.backgroundColor = '#fff';
oDiv.onmouseover = function(){
clearTimeout(iTimer);
fnFunk1();
}   
oDiv.onmouseout = function(){
clearTimeout(iTimer);
fnFunk2();
}
oDiv.onmousedown = function(){
clearTimeout(iTimer)
this.parentNode.removeChild(this);
}
oDiv.onmouseup = function(){
fnFunk1()
}
return oDiv;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var iWidthImg = 0;
var iTimer;

function makeImages(aTabIm,aTabAdr,sId,iIle){
var oPasek = document.getElementById(sId);
var oOkno = oPasek.parentNode;
var iDivWidth = parseInt(oOkno.offsetWidth/3);

oDivLeft = makeDiv(0,iDivWidth,oOkno,function(){toForward('fotos',-1,25)},function(){toForward('fotos',-1,60)})
oDivCenter = makeDiv(iDivWidth,iDivWidth,oOkno,function(){},function(){toForward('fotos',-1,60)})
oDivRight = makeDiv(iDivWidth*2,iDivWidth,oOkno,function(){toBack('fotos',1,25)},function(){toForward('fotos',-1,60)})

 var oTable = document.createElement('table');
var oPadding = document.createAttribute('cellpadding');
oPadding.value = 0
oTable.setAttributeNode(oPadding);
var oSpacing = document.createAttribute('cellspacing');
oSpacing.value = 0
oTable.setAttributeNode(oSpacing);
oTbody = document.createElement('tbody'); 
var oTr = document.createElement('tr');
var oImg = null;
for(i=0; i<aTabIm.length; i++){
oTd = document.createElement('td');
oImg = document.createElement('img');
oImg.src = aTabIm[i];
oImg.id = aTabAdr[i];
oImg.onmouseup = function(){
location.href = this.id;
}
iWidthImg += oImg.width
oTd.appendChild(oImg);
oTr.appendChild(oTd);
}
for(i=0; i<iIle; i++){
oTd = document.createElement('td');
oImg = document.createElement('img');
oImg.src = aTabIm[i];
oImg.id = aTabAdr[i];
oImg.onmouseup = function(){
location.href = this.id;
}
oTd.appendChild(oImg);
oTr.appendChild(oTd);
}
oTbody.appendChild(oTr);
oTable.appendChild(oTbody);
oPasek.appendChild(oTable);
oOkno.appendChild(oDivLeft);
oOkno.appendChild(oDivCenter);
oOkno.appendChild(oDivRight);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
function krok(dx,sId){
var oDiv = document.getElementById(sId);
oDiv.style.left = oDiv.offsetLeft + dx+'px';
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////

function toForward(sId,iStamp,iDelay){
var oDiv = document.getElementById(sId);
//var oParent = oDiv.parentNode;
krok(iStamp,sId);          
if(oDiv.offsetLeft <= -iWidthImg)
oDiv.style.left = '0px';
iTimer = setTimeout('toForward(\''+sId+'\','+iStamp+','+iDelay+')',iDelay);
}

function toBack(sId,iStamp,iDelay){
var oDiv = document.getElementById(sId);
var oParent = oDiv.parentNode;
krok(iStamp,sId);          
if(oDiv.offsetLeft > 0)
oDiv.style.left = -iWidthImg+'px';
iTimer = setTimeout('toBack(\''+sId+'\','+iStamp+','+iDelay+')',iDelay);
}


