var currentopacity=10;
var flag=0;
var fader=false;

function setOpacity(id,value)
{
 var obj = document.getElementById(id);
 if (typeof document.body.style.opacity == 'string')
  obj.style.opacity = value/10;
 else if (typeof document.body.style.MozOpacity == 'string')
  obj.style.MozOpacity = value/10;
 else if (typeof document.body.style.KhtmlOpacity == 'string')
  obj.style.KhtmlOpacity = value/10;
 else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5)
  obj.style.filter = 'alpha(opacity=' + value*10 + ')';
}


function fadeImage(id)
{
 var i;
 var j=0;
 if (currentopacity==10)
 {
  currentopacity=5;
  for (i=10;i>=0;i--)
  {
   setTimeout("setOpacity('"+id+"',"+i+")",40*j);
   j++;
  }
  setTimeout("currentopacity=0",40*j);
 }
}


function showImage(id)
{
 var i;
 if(currentopacity==0 && flag==1)
 {
  currentopacity=5;
  for (i=0;i<11;i++)
   setTimeout("setOpacity('"+id+"',"+i+")",40*i);
  setTimeout("currentopacity=10",40*(i+1));
 }
}


function initFade()
{
 if(fader)
 {
  var timeout=30;
  if (flag==1) flag=0; else flag=1;
  if (currentopacity==5) timeout=440;
  setTimeout("fadeImage('PhotoDescr')",timeout);
 }
}


function initShow()
{
 if(fader)
 {
  var timeout=30;
  if (flag==1) flag=0; else flag=1;
  if (currentopacity==5) timeout=440;
  setTimeout("showImage('PhotoDescr')",timeout);
 }
}


function flagon()
{
 fader=true;
 initFade();
}