﻿var ContentHeight1 = 200;
var TimeToSlide1 = 250.0;

var openAccordion1 = '';

function runAccordionMain(index) {
    var nID1 = "MainAccordion" + index + "Content";
    if (openAccordion1 == nID1)
        nID1 = '';

    setTimeout("animate(" + new Date().getTime() + "," + TimeToSlide1 + ",'"
      + openAccordion1 + "','" + nID1 + "')", 33);

    openAccordion1 = nID1;
}

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 = ContentHeight1 + 'px';

        if (closing != null) {
            closing.style.display = 'none';
            closing.style.height = '0px';
        }
        return;
    }

    timeLeft -= elapsedTicks;
    var newClosedHeight = Math.round((timeLeft / TimeToSlide1) * ContentHeight1);

    if (opening != null) {
        if (opening.style.display != 'block')
            opening.style.display = 'block';
        opening.style.height = (ContentHeight1 - newClosedHeight) + 'px';
    }

    if (closing != null)
        closing.style.height = newClosedHeight + 'px';

    setTimeout("animate(" + curTick + "," + timeLeft + ",'"
      + closingId + "','" + openingId + "')", 33);
}


