var EnFolder = $Class({
	$init: function(opt) {
		this.options = opt;

		this.text_hide = "隱藏更多英英詞典內容";
		this.text_show = "查看更多英英詞典內容";

		this.itemNum = this.options.minItemNum || 1;

		this.button = $$(".new_dic_more2 a")[0];
		this.moreBoxes = $$(".font_reslzable_bortop2 dl.sear_list01");

		this.box1 = this.moreBoxes.shift();

		this.moreItems = $A(this.box1.childNodes).filter(function(v, i) {
			return v.nodeType == 1 && v.tagName == "DD";
		});
		this.isHide = false;

		this._bindEvents();

		if(this.moreBoxes.length == 0&&this.moreItems.length() <= this.itemNum) {
			this.button.style.display = "none";
		}
	},
	
	_bindEvents: function() {
		$Fn(this.toggle, this).attach(this.button, "click");
	},

	toggle: function(e) {
		this[this.isHide?"showMore":"hideMore"](e);
	},
	
	showMore: function(e) {
		try{e.stop();} catch(a){};

		this.moreItems.forEach(function(v, i) {
			if(i >= this.itemNum) {
				v.style.display = "block";
			}
		}, this);

		$A(this.moreBoxes).forEach(function(v, i) {
			v.style.display = "block";
		});
		this.button.innerHTML = this.text_hide;
		this.isHide = false;
	},

	hideMore: function(e) {
		try{e.stop();} catch(a){};

		this.moreItems.forEach(function(v, i) {
			if(i >= this.itemNum) {
				v.style.display = "none";
			}
		}, this);

		$A(this.moreBoxes).forEach(function(v, i) {
			v.style.display = "none";
		});
		this.button.innerHTML = this.text_show;
		this.isHide = true;
	}
});
$Fn(function() {
	new EnFolder({minItemNum: 2}).hideMore();

	setTimeout(function() {
		var anch = /#(\w+)$/i.test(window.location.href)? RegExp.$1: "";
		if(!anch) return;
//		alert(window.location)
		document.getElementsByName(anch)[0].scrollIntoView();
	}, 1000);

}).attach(document, "domready");