/*
*	modello框架
**
*	author 贺博
*	version 2007-8-15
**
*	显示/隐藏显示
*/
WebDisplay = Class.create();
WebDisplay.register("com.duxiu.js.WebDisplay");

WebDisplay.all_open =true;

WebDisplay.construct = function($self, $class){
	var arrMemo = [];
	
	this.initialize = function(){

		var checkbox = document.getElementsByName('favid');

		for(var i= 0 ; i< checkbox.length ; i++){
			arrMemo[arrMemo.length] = checkbox[i].value;
		}		
		//g('all_display').innerHTML = "全部收起";
		this.reset();		
	}	
	
	this.o = function( favid ){
		var obj = g('memo_'+favid);
		var ao = g('disp_'+favid);
		if(obj.style.display==''){
			close( obj ,ao );
		}		
		else{
			open( obj ,ao );
		}
	}
	
	this.doAll =  function(){
		
		ao = g('all_display');
		
		if($class.all_open){
			ao.innerHTML = "全部展开";
			doAll(close);
			WebDisplay.all_open=false;
		}
		else{
			ao.innerHTML = "全部收起";
			doAll(open);
			WebDisplay.all_open=true;
		}
	}
	
	this.reset = function(){
		ao = g('all_display');
		if($class.all_open){
			ao.innerHTML = "全部收起";
			doAll(open);
		}
		else{
			ao.innerHTML = "全部展开";
			doAll(close);
		}		
	}
	
	var close  = function(obj ,ao ){
		ao.innerHTML = "展开";	
		obj.style.display='none';
	}
	
	var open = function(obj ,ao ){
		ao.innerHTML = "收起";	
		obj.style.display='';
	}
	
	var doAll = function( handler ){
		for(var i= 0 ; i< arrMemo.length ; i++){
			var obj = g('memo_'+arrMemo[i]);
			var ao = g('disp_'+arrMemo[i]);
			handler(obj , ao);
		}		
	}
}
