/*-绫-*/
AE.namespace("AE.app");
AE.app.categories = function(a) {
	this.config = {
		rootTarget: get("categories"),
		subTarget: get("categories-subs"),
		afterLoadClass: "after-load-subs",
		itemCurrentClass: "current",
		afterShowSubClass: "after-show-sub",
		afterShowNextItemClass: "active-border-color",
		showDelayTime: 50,
		hiddenDelayTime: 50,
		excursion: [184, 0]
	};
	this.temp = {
		rootItems: [],
		subItems: {}
	};
	this.onAfterShow = new YAHOO.util.CustomEvent("onAfterShow", this);
	this.onAfterHide = new YAHOO.util.CustomEvent("onAfterHide", this);
	return this
};
AE.app.categories.prototype = {
	afterShow: function(f, e, d) {
		var b = this,
		c = this.config,
		a;
		this.onAfterShow.fire(this);
		if ((d.subItem.offsetHeight + YUD.getY(d.subItem)) > (YUD.getViewportHeight() + YUD.getDocumentScrollTop())) {
			a = YUD.getY(d.subItem) + YUD.getViewportHeight() + YUD.getDocumentScrollTop() - (d.subItem.offsetHeight + YUD.getY(d.subItem));
			if ((a + d.subItem.offsetHeight) < (YUD.getY(d.subItem) + d.rootItem.offsetHeight + 3)) {
				a += (YUD.getY(d.subItem) + d.rootItem.offsetHeight + 3) - (a + d.subItem.offsetHeight)
			}
			if (a > 110) {
				YUD.setY(d.subItem, a)
			}
		}
		if (c.afterShowSubClass) {
			YUD.addClass(c.rootTarget, c.afterShowSubClass)
		}
		YUD.addClass(d.nextItem, c.afterShowNextItemClass);
		YUD.addClass(d.rootItem.parentNode, c.itemCurrentClass)
	},
	afterHidden: function(e, d, c) {
		var a = this;
		var b = this.config;
		this.onAfterHide.fire(this);
		if (b.afterShowSubClass) {
			YUD.removeClass(b.rootTarget, b.afterShowSubClass)
		}
		YUD.removeClass(c.nextItem, b.afterShowNextItemClass);
		YUD.removeClass(c.rootItem.parentNode, b.itemCurrentClass)
	},
	init: function(n) {
		this.config = YL.merge(this.config, n || {});
		var l = this,
		d = this.config;
		var g = d.subTarget.getElementsByTagName("div");
		for (var f = 0; f < g.length; f++) {
			var c = g[f];
			l.temp.subItems[trim(c.getAttribute("rel")).toUpperCase()] = c
		}
		var h = d.rootTarget.getElementsByTagName("a");
		for (var f = 0; f < h.length; f++) {
			var o = h[f];
			var m = trim((o.textContent ? o.textContent: o.innerText)).toUpperCase();
			if (l.temp.subItems[m]) {
				var e = o.overShow = new AE.widget.overShow();
				var c = this.temp.subItems[m];
				var a = h[f + 1] ? h[f + 1] : null;
				e.afterShow.subscribe(l.afterShow, {
					rootItem: o,
					subItem: c,
					nextItem: a
				},
				l);
				e.afterHidden.subscribe(l.afterHidden, {
					rootItem: o,
					subItem: c,
					nextItem: a
				},
				l);
				var b = d.excursion;
				e.init({
					targetId: o,
					contentId: c,
					showDelayTime: d.showDelayTime,
					hiddenDelayTime: d.hiddenDelayTime,
					excursion: b
				})
			}
			l.temp.rootItems.push(o)
		}
		YUD.addClass(d.rootTarget, d.afterLoadClass);
		if (AE.bom.isIE) {
			CollectGarbage()
		}
		return l
	}
};
try {
	var cateControl = get("cate-father").categories = (new AE.app.categories()).init({
		excursion: [AE.bom.isIE6 ? 209: 210, 0]
	});
	cateControl.onAfterShow.subscribe(function() {
		autoSuggest.UIController.hideList()
	})
} catch(err) {}
if (get("test_deledt")) {
	var testtest2 = YUD.getElementsByClassName("homeL");
	testtest2[0].style.height = "600px";
	YUE.on("cate-button", "click",
	function() {
		if (YUD.hasClass(this, "cate-more")) {
			YUD.replaceClass(this, "cate-more", "cate-less");
			this.childNodes[0].nodeValue = "Less Categories";
			animBy(get("hidden-cate"), "height", 270, 8);
			return 0
		} else {
			YUD.replaceClass(this, "cate-less", "cate-more");
			this.childNodes[0].nodeValue = "More Categories";
			animBy(get("hidden-cate"), "height", -270, 8);
			return 0
		}
	})
} else {
	var testtest2 = YUD.getElementsByClassName("homeL");
	testtest2[0].style.height = "600px";
	YUE.on("cate-button", "click",
	function() {
		if (YUD.hasClass(this, "cate-more")) {
			YUD.replaceClass(this, "cate-more", "cate-less");
			this.childNodes[0].nodeValue = "Less Categories";
			get("hidden-cate").style.display='block';
			//animBy(get("hidden-cate"), "height", 50, 8);
			return 0
		} else {
			YUD.replaceClass(this, "cate-less", "cate-more");
			this.childNodes[0].nodeValue = "More Categories";
			get("hidden-cate").style.display='none';
			//animBy(get("hidden-cate"), "height", -50, 8);
			return 0
		}
	})
}
