// Fadeboxes
var TimeToFade = 1000.0;

function fade(eid)
{
  var element = document.getElementById(eid);
  if(element == null)
    return;
   
  if(element.FadeState == null)
  {
    if(element.style.opacity == null
        || element.style.opacity == ''
        || element.style.opacity == '1')
    { element.FadeState = -2; }
    else
    { element.FadeState = 2; }
  }
   
  if(element.FadeState == 1 || element.FadeState == -1)
  {
    element.FadeState = element.FadeState == 1 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
  }
  else
  {
    element.FadeState = element.FadeState == 2 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade;
    setTimeout("animateFade(" + new Date().getTime()
        + ",'" + eid + "')", 33);
  }
}

function animateFade(lastTick, eid)
{
  var curTick = new Date().getTime();
  var elapsedTicks = curTick - lastTick;
 
  var element = document.getElementById(eid);
 
  if(element.FadeTimeLeft <= elapsedTicks)
  {
    element.style.visibility = element.FadeState == 1 ? 'visible' : 'hidden'; // Switch visibility style rather than Dislay
    element.style.opacity = element.FadeState == 1 ? '1' : '0';
    element.style.filter = 'alpha(opacity = '
        + (element.FadeState == 1 ? '100' : '0') + ')';
    //element.FadeState = element.FadeState == 1 ? 2 : -2; // This code is commented out to prevent a fade out
    return;
  }
 
  element.FadeTimeLeft -= elapsedTicks;
  var newOpVal = element.FadeTimeLeft/TimeToFade;
  if(element.FadeState == 1)
    newOpVal = 1 - newOpVal;

 
  element.style.opacity = newOpVal;
  element.style.filter =
      'alpha(opacity = ' + (newOpVal*100) + ')';
 
  setTimeout("animateFade(" + curTick
      + ",'" + eid + "')", 33);
}
function boxshow(id)
{
 with (document)
 {
	if(getElementById('tr'+id).style.display=='none'){
		
	  getElementById('tr'+id).style.display='table-row';
	  getElementById('link'+id).innerHTML = 'Info minimieren';
	  
	  getElementById(id-4).style.borderLeft='2px solid #ff5000';
	  getElementById(id-4).style.borderTop='2px solid #ff5000';
	  
	  getElementById(id-3).style.borderTop='2px solid #ff5000';
	  getElementById(id-2).style.borderTop='2px solid #ff5000';
	  
	  getElementById(id-1).style.borderRight='2px solid #ff5000';
	  getElementById(id-1).style.borderTop='2px solid #ff5000';
	  
	  getElementById(id-4).style.backgroundColor='#EEE';
	  getElementById(id-3).style.backgroundColor='#EEE';
	  getElementById(id-2).style.backgroundColor='#EEE';
	  getElementById(id-1).style.backgroundColor='#EEE';
	  
	}
	else{
	  getElementById('tr'+id).style.display='none';
	  getElementById('link'+id).innerHTML = 'Kontakt einsehen';
	  
	  getElementById(id-4).style.borderLeft='1px solid #EEE';
	  getElementById(id-4).style.borderTop='none';
	  
	  getElementById(id-3).style.borderTop='none';
	  getElementById(id-2).style.borderTop='none';
	  
	  getElementById(id-1).style.borderRight='1px solid #EEE';
	  getElementById(id-1).style.borderTop='none';
	  
	  getElementById(id-4).style.backgroundColor='#FFF';
	  getElementById(id-3).style.backgroundColor='#FFF';
	  getElementById(id-2).style.backgroundColor='#FFF';
	  getElementById(id-1).style.backgroundColor='#FFF';
	}
 }
}

