//Needs Prototype (prototype-1.5.1.1.js)
//Gestion d'onglets avec paneaux à afficher
// Utilisation: Creation de différent TabbedPanel => new TabbedPanel(idDeLOnglet,idDuPaneauLié)
// Creation de TabbedPanelManage avec en parametre un tableau des différent TabbedPanel
// utilisation si necessaire de la méthode changePanel(TabbedPanelAAfficher), par exemple pour initialisation
// Exemple:
// var photoPanel = new TabbedPanel("photo_onglet","photo_panel");
// var videoPanel = new TabbedPanel("video_onglet","video_panel");
// searchPanelManagement = new TabbedPanelManage([photoPanel,videoPanel]);
// searchPanelManagement.changePanel(photoPanel);
TabbedPanelManage = Class.create();
Object.extend(TabbedPanelManage.prototype,{
	ongletList:{},
	initialize: function(ongletsList) {
		this.ongletList = $A(ongletsList);
		this.ongletList.each(function(onglet){
			if(onglet.onglet != null)
				Event.observe(onglet.onglet,"click",this.changePanel.bind(this,onglet))
		}.bind(this));
	},
	changePanel:function(activeOnglet){
		this.ongletList.each(function(onglet){
			if(onglet == activeOnglet)
				{	Element.addClassName(onglet.onglet,"actif");
					if(onglet.panelToShow != null) onglet.panelToShow.show();
					if(onglet.onClickFunction != null) onglet.onClickFunction();	}
			else
				{	Element.removeClassName(onglet.onglet,"actif");
					if(onglet.panelToShow != null) onglet.panelToShow.hide();	}
		});
	}
});

TabbedPanel = Class.create();
Object.extend(TabbedPanel.prototype,{
	onglet:null,
	panelToShow:null,
	onClickFunction:null,
	initialize: function(ongletId,layoutId,onClickFn) {
		this.onglet = $(ongletId);
		this.panelToShow = $(layoutId);
		if(onClickFn != null)
			this.onClickFunction = onClickFn;
	}
});
