﻿// expanding manufacturer logos variables
var mlT = null, mlDir = 1, mlListHeight = 0, mlIsExpanded = false, mlMinHeight = 0, mlMaxHeight = 0, mlExpandSpeed = 0, mlCollapseSpeed = 0;

// initialise manufacturer logo resizing
function mlInit(minHeight, expandSpeed, collapseSpeed)
{
	// for the manufacturer logos, determine the size of the box and shrink it to the specified size (if fails will just remain full size)
	if (objectById("manLogos"))
	{
		mlMinHeight = minHeight || 100;
		mlExpandSpeed = expandSpeed || 30;
		mlCollapseSpeed = collapseSpeed || 50;
		
		mlListHeight = mlMinHeight;
		mlMaxHeight = objectById("manLogos").offsetHeight;
		objectById("manLogos").style.height= mlListHeight + "px";
		mlDir = 0;	// start by going in the right direction
	}
}

// toggle extended manufacturer logos view
function toggleMftrLogos()
{
	mlDir = (mlDir == 1) ? 0 : 1;
	clearInterval(mlT);
	mlT = setInterval("resizeMftrLogos(objectById('manLogos'))", 5);
}

// resize the manufacturer logos in the current direction
function resizeMftrLogos(target)
{
	if (mlDir == 1)
	{
		mlListHeight += mlExpandSpeed;
		if (mlListHeight >= mlMaxHeight)
		{
			mlListHeight = mlMaxHeight;
			clearInterval(mlT);
			mlT = null;
			objectById("xtraLogosShow").style.display = "none";
			objectById("xtraLogosHide").style.display = "block";
			mlIsExpanded = true;
		}
		target.style.height = mlListHeight + "px";
	}
	else
	{
		mlListHeight -= mlCollapseSpeed;
		if (mlListHeight <= mlMinHeight)
		{
			mlListHeight = mlMinHeight;
			clearInterval(mlT);
			mlT = null;
			objectById("xtraLogosShow").style.display = "block";
			objectById("xtraLogosHide").style.display = "none";
			mlIsExpanded=false;
		}
		target.style.height = mlListHeight + "px";
	}
}
