imagesLoaded = Array();
imagesOrder = Array();
randomize = (Math.random()>0.5) ? true : false;
function imLoaded(num)
{
imagesLoaded[num] = true;
document.getElementById('td'+(num+1)).style.background = "none";
}
function setOrder()
{
for (i=0; i<imNum; i++) 
 if (randomize)
 {
 rand = Math.round(Math.random()*(imNum-1)+1);
 while (checkPresence(rand)) {rand = Math.round(Math.random()*(imNum-1)+1);};
 imagesOrder[i] = rand;
 }
 else imagesOrder[i] = i+1; 
}

function checkPresence(num)
{
for (i=0; i<imagesOrder.length; i++) if (imagesOrder[i]==num) return true;
return false;
}

function showIm(num)
{
if (num!=curnum)
{
document.getElementById('image1').style.opacity = 0;
document.getElementById('image1').style.filter = "Alpha(opacity=0)";
document.getElementById('image1').src = "/i/content/" + num + ".jpg";
imagesLoaded[0] = false;
document.getElementById('td1').style.background = "url('/i/loading2.gif')";
curnum = num;
fadeInAll();
}
}

function fadeInAll()
{
for (i=0; i<imNum; i++) if (!imagesLoaded[i]) { window.setTimeout("fadeInAll();",500); return; }
theFadeIn(0);
}
steps = 25;
function riseOpacity(where)
{
opaqueobj = document.getElementById('image'+(imagesOrder[where]));
opaque = opaqueobj.style.opacity*1;
if (opaque<1) 
{ 
opaqueobj.style.opacity = opaque + 1/steps; 
opaqueobj.style.filter = "Alpha(opacity="+(opaque + 1/steps)*100+")"; 
window.setTimeout("riseOpacity("+where+");",10); 
}
}
function theFadeIn(num)
{
if (num<imNum) { riseOpacity(num); window.setTimeout("theFadeIn("+(num+1)+");",200); }
}

