// recherche pour les proprietes ispaneldefault="true" et panelid=""
var SimplePanel = new Class({
	Implements:Options,
	options: {
		panel:'div'
	},
	defaultpanel:false,
	panellist:{},

	initialize: function(options) {
		if( $defined( options ) ) {this.setOptions(options);}
	},

	doinit: function(options) {
		var liste = this.getElements(this.options.panel);
		liste.each( function(item, index) {
			try {
				var id = item.getProperty('panelid');
				if( id.length == 0 ) { return;}

				this.panellist[id]=item;

				if( item.getProperty('ispaneldefault') == "true" ) {
					this.defaultpanel = id;
				}
			}catch(e) {}
		},this);
	},
							
	// affiche le panel, sans toucher au reste
	showPanel: function(panel) {
		try {
			this.panellist[panel].setStyles({display:'block', visibility:'visible'});
		}catch(ex) {
		}
	}, 
	// masque panel sans toucher au reste
	hidePanel: function(panel) {
		try {
			this.panellist[panel].setStyles({display:'none', visibility:'hidden'});
		}catch(ex) {
		}
	},
	maximizePanel: function(panel) {
		try {
			for(var id in this.panellist) {
				this.panellist[id].setStyles({display:'none', visibility:'hidden'});
			}
			this.showPanel(panel);
		}catch(ex) {
		}
	},
	// masque tous les panel sauf default
	resetPanel: function() {
		this.maximizePanel(this.defaultpanel);
	}
});

// nota : avec $extend ie9 fait un plantage sur la copie de constructor
function $azerty(original, extended){
	for (var key in (extended || {})) {
		try {
			original[key] = extended[key];
		}catch(e) {
		}
	}
	return original;
};
function ApplySimplePanel( obj, options ) {
// 	$extend(obj, new SimplePanel(options));
	$azerty(obj, new SimplePanel(options));
	obj.doinit();
}
