var tabSwitcher = function(){
	var menu, anchorUrl, tabOpen, tabList, tabHeight, TO_OPC, TO_HGT;
	TO_OPC = 5;
	TO_HGT = 5;
	tabList = new Array();
	tabHeight = new Array();
	return{
		init:function(menu){
			m = document.getElementById(menu);									//Zone de menu
			a = m.getElementsByTagName('a');									//Tous les liens de la zone menu
			for(i = 0; i < a.length; i++){										//Pour tous les liens
				ahref = a[i].href;												//url du lien
				anchors = ahref.split('#');
				anchor = anchors[(anchors.length - 1)];							//On recupère le nom de l'ancre visée
				tabList[i] = anchor;											//On sauve les noms des ancres
				tab = document.getElementById(anchor);							//La div concernée
				tab.style.display = 'block';									//On masque la div concernée
				tabHeight[i] = tab.offsetHeight;								//On recupère la hauteur de la div
				tab.style.display = 'none';										//On masque la div concernée
				a[i].anchorId = i;
				a[i].onclick = function(){
					tabSwitcher.openDiv(this.anchorId);
					menuSlider.sw(a,this.anchorId,'menu','slide');
				};
			}
			tabSwitcher.getCurrentTab();										//Determine l'onglet actif
			menuSlider.sw(a,tabOpen,'menu','slide');
		},
		getCurrentTab:function(){
			url = window.location.toString();									//url de la page
			anchorSplit = url.split('#');
			anchorNb = anchorSplit.length;
			if(anchorNb > 1)													//on determine si il y a une ancre
				tabOpen = tabSwitcher.getTabId(anchorSplit[(anchorNb - 1)]);	//ancre active
			else
				tabOpen = 0;													//On affecte le premier tab
			tabSwitcher.openDiv(tabOpen);										//On affiche la div qu'il faut
		},
		getTabId:function(anchorStr){
			tabId = 0;
			for(i = 0; i < tabList.length; i++){
				if(tabList[i] == anchorStr)
					tabId = i;
			}
			return tabId;
		},
		openDiv:function(tabId){
			if(tabId != tabOpen)
				tabSwitcher.closeDiv(tabOpen);
			var id = tabList[tabId];
			var elm = document.getElementById(id);
			elm.style.height = "0px";
			elm.style.overflow = "hidden";
			elm.style.display = "block";
			var divH = tabHeight[tabId];
			for(var i = 0; i <= divH; i++){
				window.setTimeout("document.getElementById('" + id + "').style.height='" + i + "px';", (i * TO_HGT));
				var opc = i/divH;
				window.setTimeout("tabSwitcher.opChng('" + id + "', '" + (opc * 100) + "')", (i * TO_OPC));
			}
			tabOpen = tabId;
		},
		closeDiv:function(tabId){
			var id = tabList[tabId];
			var elm = document.getElementById(id);
			elm.style.margin = "0px";
			elm.style.overflow = "hidden";
			var divH = tabHeight[tabId];
			elm.style.height = divH + "px";
			elm.style.display = "block";
			for(var i = 0; i <= divH; i++){
				window.setTimeout("document.getElementById('" + id + "').style.height='" + (divH - i) + "px';", (i * TO_HGT));
				var opc = divH/i;
				window.setTimeout("tabSwitcher.opChng('" + id + "', '" + opc + "')", (i * TO_OPC));
			}
		},
		opChng:function(id, opc){
			document.getElementById(id).style.opacity=(opc/100);
			document.getElementById(id).style.MozOpacity=(opc/100);
			document.getElementById(id).style.KhtmlOpacity=(opc/100);
			document.getElementById(id).style.filter="alpha(opacity=" + opc + ")";
		}
	};
}();