function imgSwitch(img,count,step) {
  var copacity = 1-(step/100);
  var msopacity = 100-step;
  var idnext=img+1;
  if(idnext>count) {
    idnext=1;
  }
  var idprev=img-1;
  if(idprev==0) {
    idprev=count;
  }

  document.getElementById('img'+img).style.opacity=copacity;
  document.getElementById('img'+img).style.filter='alpha(opacity='+msopacity+')';

  if(step==0) {
    var arg='img'+img;
    document.getElementById(arg).style.zIndex=3;
    document.getElementById(arg).style.opacity=1;
    arg='img'+idnext;
    document.getElementById(arg).style.zIndex=2;
    document.getElementById(arg).style.opacity=copacity;
    document.getElementById(arg).style.filter='alpha(opacity='+msopacity+')';
    arg='img'+idprev;
    document.getElementById(arg).style.zIndex=1;

    var command='imgSwitch('+img+','+count+',1)';
    window.setTimeout(command,5000);
  }
  else if(step==100)
  {
    var command='imgSwitch('+idnext+','+count+',0)';
    window.setTimeout(command,10);
  }
  else if(step>79)
  {
    var command='imgSwitch('+img+','+count+','+(step+1)+')';
    window.setTimeout(command,10);
  }
  else if(step<80)
  {
    var command='imgSwitch('+img+','+count+','+(step+1)+')';
    window.setTimeout(command,(20));
  }
}


function show(id,disappearDelay) {
  document.getElementById(id).style.opacity=1;
  document.getElementById(id).style.filter='alpha(opacity=100)';
  document.getElementById(id).style.visibility='visible';
  
  if (disappearDelay>1) {
    window.setTimeout('disappear(\''+id+'\',0)',disappearDelay);
  }
}


function hide(id) {
  document.getElementById(id).style.visibility='hidden';
}


function appear(id,step) {
  var copacity = step/100;
  var msopacity = step;

  document.getElementById(id).style.visibility='visible';
  document.getElementById(id).style.opacity=copacity;
  document.getElementById(id).style.filter='alpha(opacity='+msopacity+')';
  
  if(step<100)
  {
    window.setTimeout('appear(\''+id+'\','+(step+5)+')',1);
  }
  else
  {
    document.getElementById('loadingProgress').style.visibility='hidden';
  }
}


function disappear(id,step) {
  var copacity = 1-(step/100);
  var msopacity = 100-step;
  
  document.getElementById(id).style.opacity=copacity;
  document.getElementById(id).style.filter='alpha(opacity='+msopacity+')';
  
  if(step<100)
  {
    window.setTimeout('disappear(\''+id+'\','+(step+5)+')',1);
  }
  else
  {
    document.getElementById(id).style.visibility='hidden';
  }
}


function clearInput(id,defaultValue) {
  if(document.getElementById(id).value==defaultValue) document.getElementById(id).value="";
}


function setInput(id,defaultValue) {
  if(document.getElementById(id).value=="") document.getElementById(id).value=defaultValue;
}

