var production_heights  = new Array();
var production_elements = new Array();
var production_state    = new Array();
var production_prev_cur	= false;
var production_prev		= -1;
var ie6_older			= false;

function production_initialize(e)
{	
	if (typeof document.body.style.maxHeight == "undefined") {
		ie6_older = true;
  	}
	
	for(var i = 0; i < 4; i++)
	{
		var el = document.getElementById('box' + i);
		if (el)
		{
			production_elements[i] = el;
			production_heights[i] = el.offsetHeight;
			
			var action_el = getElement('action' + i);
			
			if (i == 0)
			{
				production_state[i] = 1;
				production_prev = i;
				production_prev_cur = getElement('action' + i);
				production_elements[i] = (production_heights[i] + 20) + 'px';
				changeOpac(100, el);
			}else{
				production_state[i] = 0;			
				production_elements[i].style.height = '0px';
				changeOpac(0, el);
				action_el.className = '';
			}
		}
	}
}

function toogleElement( cur, el_index )
{
	var steps = 7;
	var offset_h = 0;
	
	if (ie6_older)
		offset_h = 20;
	
	if (production_elements[el_index] && production_state[el_index] == 0)
	{
		var step_h = (production_heights[el_index] + offset_h) / steps;
		var step_prev = (production_heights[production_prev] + offset_h) / steps;
		var step_o = 100 / steps;
		var cur_h = 0;
		var cur_prev = production_heights[production_prev] + offset_h;
		var cur_o = 0;
		var cur_prev_o = 100;
		var _action = '';
		
		for(var k = 0; k < steps; k++)
		{
			cur_h = cur_h + step_h;
			cur_prev = cur_prev - step_prev;
			cur_o = cur_o + step_o;
			cur_prev_o = cur_prev_o - step_o;
			
			
			_action = '';
			
			if (production_prev >= 0)
			{
				_action = _action + 'changeOpac(' + cur_prev_o + ', "box' + production_prev + '"); getElement("box' + production_prev + '").style.height="' + Math.round(cur_prev) + 'px";';
			}
			
			_action = _action + 'changeOpac(' + cur_o + ', "box' + el_index + '"); getElement("box' + el_index + '").style.height="' + Math.round(cur_h) + 'px";';
			
			setTimeout(_action, 32 * (k + 1));
		}
		
		_action = 'changeOpac(100, "box' + el_index + '"); getElement("box' + el_index + '").style.height="' + (production_heights[el_index] + offset_h) + 'px";';
		if (production_prev >= 0)
		{
			_action = _action + 'changeOpac(0, "box' + production_prev + '"); getElement("box' + production_prev + '").style.height="0px";';
		}
		
		setTimeout(_action, (32 * steps + 1)); 
		
		production_state[el_index] = 1;
		production_state[production_prev] = 0;		
		production_prev = el_index;
	}
	
	if (production_prev_cur)
		production_prev_cur.className = '';
		
	cur.className = "active";	
	production_prev_cur = cur;
}