// JavaScript Document
/////////////////////////////////////////
//
//
//FOR DROP DOWN MENU + -
//<div imageid>(imageId)

//<div outside>(parentDivid) this div should have "outside" in the id of the div
//		<div inside> (contentDivid)

//////////////////////////////////////
function Box_DropDownAction_inner(parentDivId, contentDivId, imageId,menuWidth)
{

	var thisBox_inner			= document.getElementById( parentDivId );
	var thisInnerBox_inner	= document.getElementById( contentDivId );
	var thisInnerTop_inner	= parseInt( thisInnerBox_inner.style.top );
	var thisBox_innerHeight 	= parseInt(thisBox_inner.style.height);
	
	
	var parentsToResize_inner = "";
	var p = thisBox_inner.parentNode;
	while (p)
	{
		if (p.id && p.id.indexOf("outside") != -1)
		{
			if (parentsToResize_inner == "")
			{
				parentsToResize_inner = p.id;
			}
			else
			{
				parentsToResize_inner = parentsToResize_inner + "," + p.id;
			}
		}
		
		p = p.parentNode;
	}


	if( thisBox_innerHeight <= 0 || thisInnerTop_inner < 0)
	{
		thisBox_inner.style.display = "block";
		thisInnerBox_inner.style.display = "block";
		
		thisBox_inner.style.height	= "0px";
		thisBox_inner.style.width		= menuWidth+"px";
		thisInnerBox_inner.style.top  = "0px";
		
		Box_DropDown_Action_inner('open', parentDivId, contentDivId, parentsToResize_inner, imageId);
	}
	else
	{
		Box_DropDown_Action_inner('close', parentDivId, contentDivId, parentsToResize_inner, imageId);
	}
}

function Box_DropDown_Action_inner( thisAction, parentDivId, contentDivId, parentsToResize_inner, imageId)
{

	var thisBox_inner			= document.getElementById( parentDivId );
	var thisInnerBox_inner	= document.getElementById( contentDivId );
	var thisBox_innerHeight 	= parseInt(thisBox_inner.style.height);
	
	if (parentsToResize_inner)
	{
		var parents = parentsToResize_inner.split(",");
	}
	
	var pixelsPerSecond = parseInt(thisInnerBox_inner.offsetHeight) / 10;
		
	if( thisAction == 'open' )
	{
		if( thisBox_innerHeight < thisInnerBox_inner.offsetHeight)
		{	
			var pixelsToAdd = pixelsPerSecond;
			
			if (thisBox_innerHeight + pixelsPerSecond > thisInnerBox_inner.offsetHeight)
			{
				pixelsToAdd = thisInnerBox_inner.offsetHeight - thisBox_innerHeight;
			}
			
			thisBox_inner.style.height    = thisBox_inner.offsetHeight + pixelsToAdd + "px";
			
			if (parents)
			{
				for (var i = 0; i < parents.length; i++)
				{
					var pBox = document.getElementById(parents[i]);
					pBox.style.height = pBox.offsetHeight + pixelsToAdd + "px";
				}
			}
			
			var myFunction =  "Box_DropDown_Action_inner('open', '" 
						+ thisBox_inner.id + "', '" + thisInnerBox_inner.id + "', '" + parentsToResize_inner + "', '" +imageId + "')";
			setTimeout(myFunction, 1 );
			
		}
		else
		{
			Box_DropDown_Arrow_inner( "minusimage",imageId );
		}
	}
	else if( thisAction == 'close' )
	{
		if( thisBox_innerHeight > 0)
		{
			var pixelsToRemove = pixelsPerSecond;
			
			if (thisBox_innerHeight - pixelsPerSecond < 0)
			{
				pixelsToRemove = thisBox_innerHeight;
			}
			
			thisBox_inner.style.height    = thisBox_innerHeight - pixelsToRemove + "px";
			if (parents)
			{
				for (var i = 0; i < parents.length; i++)
				{
					var pBox = document.getElementById(parents[i]);
					var pBoxHeight 	= parseInt(pBox.style.height);
					pBox.style.height = pBoxHeight - pixelsToRemove + "px";
				}
			}
				
			var myFunction =  "Box_DropDown_Action_inner('close', '" 
						+ thisBox_inner.id + "', '" + thisInnerBox_inner.id  + "', '" + parentsToResize_inner + "', '" +imageId + "')";
			setTimeout( myFunction, 1 );
		}
		else
		{
			thisBox_inner.style.display = "none";
			thisInnerBox_inner.style.display = "none";
			Box_DropDown_Arrow_inner( "plusimage",imageId );
		}
	}
}

function Box_DropDown_Arrow_inner( arrowType,imageId )
{
	if(arrowType=="minusimage"){
	document.getElementById( imageId ).className ="treeON";}
	if(arrowType=="plusimage"){
	document.getElementById( imageId ).className ="treeOff";}
	
	
}
