function request()
{
 var req;
 if(window.XMLHttpRequest && !(window.ActiveXObject)) {
 try {
 req = new XMLHttpRequest();
 } catch(e) {
 req = false;
 }
 } else if(window.ActiveXObject) {
 try {
 req = new ActiveXObject("Msxml2.XMLHTTP");
 } catch(e) {
 try {
 req = new ActiveXObject("Microsoft.XMLHTTP");
 } catch(e) {
 req = false;
 }
 }
 }
 return req;
}
var oldtext;
function nextSlide(id,oid)
{
  req=request();
  if(req) {
  req.onreadystatechange = function() {
    if(req.readyState == 4){
      if(req.responseText!=""&&req.responseText!=oldtext) 
      {
	simg="./obrazky/frontpagegallery/"+req.responseText;
	document.getElementById(oid).src=simg;
	animate(simg,0.1,id,oid);
	oldtext=req.responseText;
      }
    }
  };
  req.open("GET", 'gal.php', true);
  req.send("");
  }
}
function galInit()
{
  //nextSlide();
  setInterval ( "nextSlide(\"slideshow\",\"slideshowoverlay\")", 10000 );
  setInterval ( "nextSlide(\"slideshow2\",\"slideshowoverlay2\")", 15000 );
}
function animate(simg,op,id,oid)
{
  if(op>=1)
  {
    document.getElementById(id).src=simg;
    //document.getElementById(oid).style.opacity=0;
    return;
  }
  document.getElementById(oid).style.opacity=op;
  document.getElementById(oid).style.filter="alpha(opacity = "+Math.round(op*100)+")";
  setTimeout("animate(\""+simg+"\","+(op+0.025)+",\""+id+"\",\""+oid+"\")",50);
}


