﻿// JScript File
var animationInterval;
var i = 0;

function toggleQuestion(targetDivID){

    targetDiv = document.getElementById(targetDivID);

    if(targetDiv.style.visibility == "" || targetDiv.style.visibility == "hidden"){        
        targetDiv.style.height = "0px";
        i=0;
        targetDiv.style.visibility = "visible";
        clearInterval(animationInterval);
        animationInterval = setInterval("sliderTick('" + targetDivID + "', 'down', " + targetDiv.scrollHeight + ")", 2);
    }
    else{
        clearInterval(animationInterval);
        animationInterval = setInterval("sliderTick('" + targetDivID + "', 'up', " + 0 + ")", 2);
        i = targetDiv.scrollHeight;
    }
}

function sliderTick(objName, direction, max){
    myObj = document.getElementById(objName);
    
    if(direction == "down"){    //sliding DIV down (increase height)
        i = i+3;
        if(parseInt(myObj.style.height) >= max){
            clearInterval(animationInterval);
        }            
    }
    else{                       //sliding DIV up (decrease height)
        if(parseInt(myObj.style.height) <= 6){
            i = 0;
            clearInterval(animationInterval);
            myObj.style.visibility = "hidden";
        }
        else{
            i = i-6
        }
    }
    myObj.style.height = i + "px";
    

}

