if (ess) {
} else {
	var ess = {};
}

ess.showCustomPopUp = function(thisUrl,thisName,theseParams) {
	remote = open(thisUrl, thisName, theseParams);
}

showCustomPopUp = function(thisUrl,thisName,theseParams) {
	remote = open(thisUrl, thisName, theseParams);
}

$(document).observe('dom:loaded', function(e) {
	
	//enable drop nav
	if($('nav1')){
		$('nav1').dropnav({
			animate: {
				time: 200,
				opacity: 1,
				height:function(obj){
					return obj.getElement().scrollHeight;
				}	
			}	
		})
		$$('#nav1 ul.cHeaderNavUl').each(function(v) {
		   v.setStyle({height:"0px",opacity:0}); 
	  });
	}
	
	if($('mainNav3485576')){
		ess.distributeNavigation($('mainNav3485576').down('ul'), 2, 'li', {minimumChildren: 8}); // Category
	}
	if($('mainNav3487969')){
		ess.distributeNavigation($('mainNav3487969').down('ul'), 2, 'li', {minimumChildren: 8}); // Brand
	}
	if($('mainNav3485576')){
		ess.distributeNavigation($('mainNav3487968').down('ul'), 2, 'li', {minimumChildren: 8}); // Theme
	}	
	
})

ess.distributeNavigation = function(element, groups, childTag, options) {
	var tag = element.tagName
	var nodes = element.childElements()
	if (options && options.minimumChildren && nodes.length < options.minimumChildren) {
	} else {
		nodes = $A(nodes).distributeEvenly(groups);
		nodes.each(function(v, index) {
			var node = new Element(tag);
			if (index == 0) {
				var elementChild = new Element(childTag,{'class':'first'});
			} else {
				var elementChild = new Element(childTag);			
			}
			v.each(function(vv) {
				node.insert(vv);
			});
			elementChild.insert(node);
			element.insert(elementChild);
		})
	}
		
	return element
}