// JavaScript Document
var delayTimer = null;
function showDesc(div, type) {
	var desc = div;
	if (type == 'wetsuit') {
		$(desc).setStyles({'display':'block', 'top':'0'});
	} else {
		$(desc).setStyles({'display':'table', 'top':'0'});
	}
/*	var fx =  new Fx.Morph(desc, {duration:400, transition: Fx.Transitions.Quad.easeInOut, onChainComplete:function() {
		fx.stop();
	}});
	fx.start({
		top:[-400, 0]
	});
*/	
}

function hideDesc(div, type) {
	var desc = div;
	/*var fx =  new Fx.Morph(desc, {duration:400, transition: Fx.Transitions.Quad.easeInOut, onChainComplete:function() {
		fx.stop();
		$(desc).setStyles({'display':'none'});
	}});
	fx.start({
		top:[0, -400]
	})*/
	$(desc).setStyles({'display':'none', 'top':'-400px'});
}

window.addEvent('domready', function() {
	if ($E('div.wetsuits-container')) {
		$E('div.wetsuits-container').getChildren().each(function(div, index) {
			var div2 = $(div).getChildren().getChildren()[0][1];
			$(div2).setStyles({'top':'-400px', 'display':'none'});
			//var div2 = div.getChildren().getChildren()[0][1];
			$(div).addEvent('mouseenter', function(event) {
				//clearTimeout(delayTimer)
				var div2 = $(this).getChildren().getChildren()[0][1];
//				alert($(div2).get("id"));
				showDesc(div2, 'wetsuit');
			});
			$(div).addEvent('mouseleave', function(event) {
//				clearTimeout(delayTimer)
				var div2 = $(this).getChildren().getChildren()[0][1];
				//var delayFunc = function() {
				//	hideDesc(div2, 'wetsuit');
				//}
				//delayTimer = delayFunc.delay(200)
				hideDesc(div2, 'wetsuit');
			});
		})
	}
	
	if ($E('div.sail-all-container')) {
		$E('div.sail-all-container').getChildren().each(function(div, index) {
			var divCategoryContainer = $(div).getChildren()[1];
			
			for (var i=0; i<$(divCategoryContainer).getChildren().length; i++) {
				var productItem = $(divCategoryContainer).getChildren()[i];
				$(productItem).getChildren()[0].getChildren()[2].setStyles({'top':'-400px', 'display':'none'});
				$(productItem).addEvent('mouseenter', function(event) {
					//clearTimeout(delayTimer)
					var div2 = $(this).getChildren()[0].getChildren()[2];
					showDesc(div2, 'sail');
				});
				$(productItem).addEvent('mouseleave', function(event) {
					clearTimeout(delayTimer)
					var div2 = $(this).getChildren()[0].getChildren()[2];
					//var delayFunc = function() {
					//}
					//delayTimer = delayFunc.delay(200)
					hideDesc(div2, 'sail');
				});
			}
			
		})
	}
});

