// JavaScript Document
function shade(el)
{
	el.style.background = "#FC0";
}
function shadeBack(el)
{
	el.style.background = "#ccc";
}
var slidingTimer;
function openPractice(elem, theId)
{  
	var elemsClassName = [];
	var h5ClassName = [];
	var classToClose;
	var practiceDiv = document.getElementById("practice");
	var theElements = practiceDiv.getElementsByTagName('div');
	var h5Elements = practiceDiv.getElementsByTagName('h5');
	var closingHeight = 0;
	elemsClassName = getClassElements("infoOuter", theElements);
	h5ClassName = getClassElements("weekdayClick", h5Elements);
	for(i = 0; i < h5ClassName.length; i++){ h5ClassName[i].className = "weekday";}//h5ClassName[i].style.background = "#ccc"; h5ClassName[i].style.color = "#000";}
	for(i = 0; i < elemsClassName.length; i++)
	{
		if(elemsClassName[i].offsetHeight > 0)
		{
			classToClose = elemsClassName[i];
			closingHeight = elemsClassName[i].offsetHeight;
			sameDay = 0;
		}
		
	}
	
	var infoDiv = document.getElementById(theId);
	var parentInfoDiv = document.getElementById("parent" + theId);
	var toHeight = infoDiv.offsetHeight;
	elem.className = "weekdayClick";
	//elem.style.background = "#F60";
	//elem.style.color = "#FFF";
	
	
	infoDiv.style.borderTop = "#0074bc 1px solid";
	infoDiv.style.borderLeft = "#0074bc 1px solid";
	infoDiv.style.borderRight = "#0074bc 1px solid";
	openPanel(parentInfoDiv, classToClose, toHeight, 0, closingHeight);

}

function openPanel(panelId, toClose, endHeight, startHeight, toBeClosedHeight)
{
	var slidingDiv = panelId;
	var closingDiv = toClose;
	var jump = 3;
	var heightToBeClosed = 0;
	startHeight = startHeight + jump;
	if(typeof(closingDiv) != "undefined")
	{
	   
       heightToBeClosed = toBeClosedHeight - ((jump/(endHeight-startHeight)) * toBeClosedHeight);
	   if(startHeight >= endHeight)
	   {
		   heightToBeClosed = 0;
		   closingDiv.style.border = "none";
		}
        if(heightToBeClosed < 0){heightToBeClosed = 0;}
	    closingDiv.style.height = heightToBeClosed + "px";
	}
	else
	{
		slidingDiv.style.height = startHeight + "px";
	}
	
	if((typeof(closingDiv) != "undefined") && (slidingDiv.id != closingDiv.id))
	{
	   slidingDiv.style.height = startHeight + "px";
	}
	
	if(startHeight >= endHeight)
	{
		 clearTimeout(slidingTimer);
	}
	else
	{
		slidingTimer = window.setTimeout(function(){openPanel(slidingDiv, closingDiv, endHeight, startHeight, heightToBeClosed)}, 1);
	}
}
function getClassElements(theClassName, tagArray)
{
	var classArray = [];
	for(i = 0; i < tagArray.length; i++)
	{
		if(tagArray[i].className == theClassName)
		{
			classArray.push(tagArray[i]);
		}
	}
	return classArray;
}
