$(function(){
	if ($(".structure-area").length == 0) return true;
	//
	
	var animDuration = 300;
	var opacityHigh = 0.95;
	var opacityLow = 0.7;
	var heightHigh = {normal:40,small:30};
	var heightLow = {normal:40,small:30};
	var borderHigh = {normal:8,small:5};
	var borderLow = {normal:0,small:0};
	// structure item behaviour
	if ($(".structure-area").height() < 600) $(".structure-area").height(600);
	
	$(".structure-item img").hide();
	
	$(".structure-item .bar").css({opacity:opacityLow});
	
	// handle structure column heights
	var maxHeight = 0;
	$(".structure-column.auto-adjust").each(function(){
		if ($(this).height() > maxHeight) maxHeight = $(this).height();
	});
	if (maxHeight > 0) $(".structure-column.auto-adjust").height(maxHeight);
	
	
	$(".structure-item").mouseenter(function(){
		var borderColor = $(this).find(".bar").css("borderBottomColor");
		var parentClass = ($(this).hasClass("small")) ? "small" : "normal";
		$(this).find(".bar").animate({
			opacity:opacityHigh,
			height:heightHigh[parentClass]+'px',
			borderTop:borderHigh[parentClass]+'px ' + 'solid ' + borderColor,
			borderColor:borderColor
			
		},animDuration);
	}).mouseleave(function(){
		var borderColor = $(this).find(".bar").css("borderBottomColor");
		var parentClass = ($(this).hasClass("small")) ? "small" : "normal"; 
		$(this).find(".bar").animate({
			opacity:opacityLow,
			height:heightLow[parentClass]+'px',
			borderTop:borderLow[parentClass]+'px ' + 'solid ' + borderColor,
			borderColor:borderColor
		},animDuration);
	});
	

	$(window).load(function(){
		var delay = 80;
		var currentDelay = 0;
		$(".structure-item").each(function(){
			var $item = $(this);
			
			setTimeout(function(){
				$item.find("img").fadeIn(animDuration);
				$item.mouseenter();
				setTimeout(function(){	$item.mouseleave(); },delay)
			},currentDelay);
			
			currentDelay += delay;
		});

	});
	
});

