//a stepping process that eases in an out of a loop process or animation.
function easeInOut(minValue,maxValue,totalSteps,actualStep,powr) 
{ 
    var delta = maxValue - minValue; 

    var stepp = parseInt(minValue) + parseInt(Math.pow(((1 / totalSteps) * actualStep), powr) * delta); 

    return Math.ceil(stepp) 
};

function changeHeight(id, start, end, steps, currentStep, powr, intervalID)
{
    document.getElementById(id).currentHeight = easeInOut(start,end,steps,currentStep,powr);
    
    document.getElementById(id).style.height = document.getElementById(id).currentHeight + "px";

    document.getElementById(id).currentAnimStep++;
    if (document.getElementById(id).currentAnimStep > steps) 
        window.clearInterval(intervalID);
};

//slides open or close the 'id' object to the 'height given'.  disables the 'caller' object till done and duration is the time to complete
function openClose(id, height, duration) 
{
    if (document.getElementById(id).interval)
        window.clearInterval(document.getElementById(id).interval);        

    document.getElementById(id).currentAnimStep = 0;
    if(document.getElementById(id).style.height == ("0px"))
        document.getElementById(id).interval = window.setInterval("changeHeight('" + id + "', 0, '" + height + "', '" + duration + "', document.getElementById('" + id + "').currentAnimStep, 0.5, document.getElementById('" + id + "').interval)",20);
    else
        document.getElementById(id).interval = window.setInterval("changeHeight('" + id + "', '" + height + "', 0, '" + duration + "', document.getElementById('" + id + "').currentAnimStep, 0.5, document.getElementById('" + id + "').interval)",20);
};

//slides open or close the 'id' object to the 'height given'.  disables the 'caller' object till done and duration is the time to complete
function openCloseNews(id, height, duration) 
{
    if (document.getElementById(id).interval)
        window.clearInterval(document.getElementById(id).interval);        

    document.getElementById(id).currentAnimStep = 0;
    if(document.getElementById(id).style.height == "0px" || document.getElementById(id).style.height == "")
        document.getElementById(id).interval = window.setInterval("changeHeight('" + id + "', 0, '" + height + "', '" + duration + "', document.getElementById('" + id + "').currentAnimStep, 0.5, document.getElementById('" + id + "').interval)",20);
    else
        document.getElementById(id).interval = window.setInterval("changeHeight('" + id + "', '" + height + "', 0, '" + duration + "', document.getElementById('" + id + "').currentAnimStep, 0.5, document.getElementById('" + id + "').interval)",20);
};

function openCloseNewsLetter(openNewsLetter)
{
	var divs = document.getElementsByTagName('div');
	for (var i = 0; i < divs.length; i++)
	{
		if(divs[i].getAttribute('newsLetter') != null)
		{
			if(divs[i].getAttribute('newsLetter') == 'true')
			{
				if(divs[i].getAttribute('newsLetterNum') != openNewsLetter)
				{	
					divs[i].className = "closedNewsletter";
				}
				else
				{
					divs[i].className = "openNewsletter";
				}
			}
		}
	}
	document.getElementById('divContent').scrollTop='0';
};