﻿function animate(lastTick, timeLeft, closingId, openingId) {
    var curTick = new Date().getTime();
    
    var elapsedTicks = curTick - lastTick;
  

    var opening = (openingId == '') ? null : document.getElementById(openingId);

    var closing = (closingId == '') ? null : document.getElementById(closingId);


    if (timeLeft <= elapsedTicks) {
    
        if (opening != null)
            opening.style.height = ContentHeight + 'px';

        if (closing != null) {
            closing.style.display = 'none';
            closing.style.height = '0px';
        }
        return;
    }

    timeLeft -= elapsedTicks;

    var newClosedHeight = Math.round((timeLeft / TimeToSlide) * ContentHeight);


    if (opening != null) {
        if (img_show == 0) {
            img_show = 1;
            document.getElementById('image_news').innerHTML = '<img src="images/add2.gif">&nbsp; LATEST NEWS';
        }
        
        if (opening.style.display != 'block')
            opening.style.display = 'block';
        opening.style.height = (ContentHeight - newClosedHeight) + 'px';
    }

    if (closing != null)
    {
            img_show = 0;
            document.getElementById('image_news').innerHTML = '<img src="images/add.gif">&nbsp; LATEST NEWS';
            closing.style.height = newClosedHeight + 'px';
        }
        

    setTimeout("animate(" + curTick + "," + timeLeft + ",'"
      + closingId + "','" + openingId + "')", 33);
}
