
//////////////////////////////////////////////////////////////////////////////
//					Javascript Animation Function							//
// Author: Eriko Hidalgo													//
// Date: 21-11-2009															//
// Description: Set of Javascript Functions top animate collapsible panels  //
//						 	ZIONSOFT 										//
//////////////////////////////////////////////////////////////////////////////

// current animated collapsible panel content
var currentContent = null;

function togglePannelAnimatedStatus(content, interval, step)//, title_image , normal_image , over_image )
{
    // wait for another animated expand/collapse action to end
    if (currentContent==null)
    {
        currentContent = content;
        var expand = (content.style.display=="none");
		//var titleImage = document.getElementById (title_image);
		
        if (expand)
		{
			//alert (title_image);
            content.style.display = "block";
			
			var pnlNuestraEmpresa = document.getElementById ('pnlNuestraEmpresa');
			var pnlProductos = document.getElementById ('pnlProductos');
			var pnlServicios = document.getElementById ('pnlServicios');
			var pnlAreas = document.getElementById ('pnlAreas');
			var pnlProyectos = document.getElementById ('pnlProyectos');	
			
			if (pnlNuestraEmpresa != content)
				pnlNuestraEmpresa.style.display="none"
				
			if (pnlProductos != content)
				pnlProductos.style.display="none"
				
			if (pnlServicios != content)
				pnlServicios.style.display="none"
				
			if (pnlAreas != content)
				pnlAreas.style.display="none"				
				
			if (pnlProyectos != content)
				pnlProyectos.style.display="none"								
			
			//title_image.src = null ;
			//titleImage.src = "" ;
					  //.onMouseOut
		}
		else 
		{
			//title_image.src = normal_image ;
		}
		
        var max_height = content.offsetHeight;

        var step_height = step + (expand ? 0 : -max_height);
                
        // schedule first animated collapse/expand event
        content.style.height = Math.abs(step_height) + "px";
        setTimeout("togglePannelAnimatingStatus("
            + interval + "," + step
            + "," + max_height + "," + step_height + ")", interval);
    }
}

function togglePannelAnimatingStatus(interval,
    step, max_height, step_height)
{
    var step_height_abs = Math.abs(step_height);

    // schedule next animated collapse/expand event
    if (step_height_abs>=step && step_height_abs<=(max_height-step))
    {
        step_height += step;
        currentContent.style.height = Math.abs(step_height) + "px";
        setTimeout("togglePannelAnimatingStatus("
            + interval + "," + step
            + "," + max_height + "," + step_height + ")", interval);
    }
    // animated expand/collapse done
    else
    {
        if (step_height_abs<step)
            currentContent.style.display = "none";
        currentContent.style.height = "";
        currentContent = null;
    }
}
