var openClose=Class.create();
openClose.prototype={
	initialize:function(targID){
	
/*
	cutomize start
*/	
		this.linktext_wrapper_tag="p";
		this.linktext_wrapper_class="IMF_showAll";
		this.linktext_toShow=IMF_toShowText;
		this.linktext_toClose=IMF_toCloseText;
		this.limit_number=6;
/*
	cutomize end
*/	
		
		this.CLASS_HIDDEN="openClose_hidden";
		this.CLASS_APPEAR="openClose_appear";
		this.CLASS_OVER="openClose_over";
		this.targID=targID;
		
		var a=[],c=0;
		a[c++]="<style>#";
		a[c++]=targID;
		a[c++]="{visibility:hidden}.";
		a[c++]=this.CLASS_HIDDEN;
		a[c++]=" .";
		a[c++]=this.CLASS_OVER;
		a[c++]="{ position:absolute;right:3000px;}.";
		a[c++]=this.CLASS_APPEAR;
		a[c++]=" .";
		a[c++]=this.CLASS_OVER;
		a[c++]="{ position:static}<\/style>";
		document.write(a.join(""));

		Event.observe(window,"load",this.start.bind(this),false);
		
	},
	start:function(){
		if(!$(this.targID)) return null;
		this.targObj=$(this.targID);
		
		this.lis=$A(this.targObj.getElementsByTagName("li"));
		if(this.lis.length > this.limit_number){
			//this.lis.each(this.detect.bind(this));
			for(var i=0,L=this.lis.length;i<L;i++){
				if(i>=this.limit_number){
					this.lis[i].className=this.CLASS_OVER;
				}
			}
			
			var toggleID="toggle_"+this.targID;
			
			var a=[],c=0;
			a[c++]="<";
			a[c++]=this.linktext_wrapper_tag;
			a[c++]=" class='";
			a[c++]=this.linktext_wrapper_class	;
			a[c++]="'><a href='javascript:void(0)' id='";
			a[c++]=toggleID;
			a[c++]="'>";
			a[c++]=this.linktext_toShow;
			a[c++]="</a>";
			a[c++]="</";
			a[c++]=this.linktext_wrapper_tag;
			a[c++]=">";
			new Insertion.After(this.targObj,a.join(""));
			
			this.tooglelink=$(toggleID);
			Event.observe($(toggleID),"click",this.click.bind(this),false);
			
			Element.addClassName(this.targObj,this.CLASS_HIDDEN);
			this.ifopen=false;
			
		}
		
		this.targObj.style.visibility="visible";
		
	},
	detect:function(li){
	},
	click:function(){
		if(this.ifopen){
			Element.addClassName(this.targObj,this.CLASS_HIDDEN);
			Element.removeClassName(this.targObj,this.CLASS_APPEAR);
			this.tooglelink.innerHTML=this.linktext_toShow;
		} else{
			Element.addClassName(this.targObj,this.CLASS_APPEAR);
			Element.removeClassName(this.targObj,this.CLASS_HIDDEN);
			this.tooglelink.innerHTML=this.linktext_toClose;
		}
		this.ifopen=(!this.ifopen);
	}
};
