running = 0;
function preload()
{
  if (document.images)
  {
    gimg = new Array();
    gimg[0] = new Image;
    gimg[0].src = "uploads/images/hlavni/uvodni.jpg";
    gimg[1] = new Image;
    gimg[1].src = "uploads/images/hlavni/uvodni2.jpg";
    gimg[2] = new Image;
    gimg[2].src = "uploads/images/hlavni/uvodni3.jpg";
    gimg[3] = new Image;
    gimg[3].src = "uploads/images/hlavni/uvodni4.jpg";
    gimg[4] = new Image;
    gimg[4].src = "uploads/images/hlavni/uvodni5.jpg";
    gimg[5] = new Image;
    gimg[5].src = "uploads/images/hlavni/uvodni6.jpg";
  }
}

function imagechange(image_id, image_nr)
{
  if (running == 0)
  {
    running = 1;
    image_id = image_id;
    for (i = 1; i<= 10; i++)
    {
      pass = 1 - i/10;
      setTimeout("fade('"+image_id+"','"+pass+"')", 30 * i);
    } 
    if (typeof(image_id) != "undefined" && typeof(gimg[image_nr]) != "undefined" && document.images)
    {
      setTimeout("document.getElementById('"+image_id+"').src = '"+gimg[image_nr].src+"'", 300);
    } 
    for (i = 1; i<= 10; i++)
    {
      pass = i/10;
      setTimeout("fade('"+image_id+"','"+pass+"')", 300 + 30 * i);
    }
    setTimeout("running = 0", 600);  
  } 
}

function fade(image_id, pass)
{
  image = document.getElementById(image_id);  
	if (typeof image.style.MozOpacity != "undefined")
	{
    image.style.MozOpacity = pass;
	}
	else if (typeof image.style.opacity != "undefined")
	{
    image.style.opacity = pass;
	}
  else if (typeof image.filters != "undefined")
  {
    image.style.filter = "alpha(opacity ="+pass * 100+")"; 
  }  
	else if (typeof image.style.KhtmlOpacity != "undefined")
	{
    image.style.KhtmlOpacity = pass;
	}
}
