var _active = -1;
function initAccordion()
{
	$$('#accordion a.click').each(function(el,i){
		if(el.className.indexOf('active') != -1)
		{
			_active = i;
		}
	});

	var accordion_block = document.getElementById('accordion');
	if(accordion_block)
	{
		var accordion = new Accordion('a.click', 'ul.drop-down', {
			alwaysHide: true,
			opacity: false,
			show: _active,
			onActive: function(toggler, element){
				if(toggler.className.indexOf("active") == -1)
					toggler.className += ' active';
			},
		 
			onBackground: function(toggler, element){
				toggler.className = toggler.className.replace('active','');
			}
		}, accordion_block);
	}
}
if (window.addEventListener)
{
	window.addEventListener("load", initLinks, false);
	window.addEventListener("load", initAccordion, false);
	window.addEventListener("load", initTabs, false);
}
else if (window.attachEvent)
{
	window.attachEvent("onload", initLinks);
	window.attachEvent("onload", initAccordion);
	window.attachEvent("onload", initTabs);
}

function initNav() {
	if (typeof document.body.style.maxHeight == 'undefined') {
		var nav = document.getElementById("main-nav");
		if(nav)
		{
			var lis = nav.getElementsByTagName("li");
			for (var i=0; i<lis.length; i++)
			{
				lis[i].onmouseover = function()
				{
					this.className += " hover";
				}
				lis[i].onmouseout = function()
				{
					this.className = this.className.replace(" hover", "");
				}
			}
		}
		var _nav = document.getElementById("top-nav");
		if(_nav)
		{
			var _lis = _nav.getElementsByTagName("li");
			for (var i=0; i<_lis.length; i++)
			{
				_lis[i].onmouseover = function()
				{
					this.className += " hover";
				}
				_lis[i].onmouseout = function()
				{
					this.className = this.className.replace(" hover", "");
				}
			}
		}
	}
}
if (document.all && !window.opera)
	attachEvent("onload", initNav);

function initLinks()
{
		var _nav2 = document.getElementById("table");
		if(_nav2)
		{
			var _lis2 = _nav2.getElementsByTagName("div");
			for (var i=0; i<_lis2.length; i++)
			{
				if(_lis2[i].className == "tooltip-link")
				{
					_lis2[i].onmouseover = function()
					{
						this.className += " hover";
					}
					_lis2[i].onclick = function()
					{
						var _a = this.getElementsByTagName('a');
						if(_a[0])
						{
							//window.location = _a[0].href;
						}
					}
					_lis2[i].onmouseout = function()
					{
						this.className = this.className.replace(" hover", "");
					}
				}
			}
		}	
		
		var _linktip = document.getElementById("download-files");
		if(_linktip)
		{
			var _lis3 = _linktip.getElementsByTagName("li");
			for (var i=0; i<_lis3.length; i++)
			{
				if(_lis3[i].className == "tooltip-link-download")
				{
					_lis3[i].onmouseover = function()
					{
						this.className += " hover";
					}
					_lis3[i].onclick = function()
					{
						var _a = this.getElementsByTagName('a');
						if(_a[0])
						{
							//window.location = _a[0].href;
						}
					}
					_lis3[i].onmouseout = function()
					{
						this.className = this.className.replace(" hover", "");
					}
				}
			}
		}
		
		var _linkdoctip = document.getElementById("download-files-documents");
		if(_linkdoctip)
		{
			var _lis4 = _linkdoctip.getElementsByTagName("li");
			for (var i=0; i<_lis4.length; i++)
			{
				if(_lis4[i].className == "tooltip-link-download")
				{
					_lis4[i].onmouseover = function()
					{
						this.className += " hover";
					}
					_lis4[i].onclick = function()
					{
						var _a = this.getElementsByTagName('a');
						if(_a[0])
						{
							//window.location = _a[0].href;
						}
					}
					_lis4[i].onmouseout = function()
					{
						this.className = this.className.replace(" hover", "");
					}
				}
			}
		}		
}

function initTabs()
{
	cpttab=0;
	var sets = document.getElementsByTagName("ul");
	for (var i = 0; i < sets.length; i++)
	{
		if (sets[i].className.indexOf("tabset") != -1)
		{
			cpttab+=1;
			var tabs = [];
			var links = sets[i].getElementsByTagName("a");
			for (var j = 0; j < links.length; j++)
			{
				if (links[j].className.indexOf("tab") != -1)
				{
					tabs.push(links[j]);
					links[j].tabs = tabs;
					var c = document.getElementById(links[j].href.substr(links[j].href.indexOf("#") + 1));

					//reset all tabs on start
					if (c) if (links[j].className.indexOf("active") != -1) c.style.display = "block";
					else c.style.display = "none";

					links[j].onclick = function ()
					{
						var c = document.getElementById(this.href.substr(this.href.indexOf("#") + 1));
						if (c)
						{
							//reset all tabs before change
							for (var i = 0; i < this.tabs.length; i++)
							{
								document.getElementById(this.tabs[i].href.substr(this.tabs[i].href.indexOf("#") + 1)).style.display = "none";
								this.tabs[i].className = this.tabs[i].className.replace("active", "");
							}
							this.className += " active";
							c.style.display = "block";
							return false;
						}
					}
				}
			}
		}
	}
	if (cpttab>0)
	{
		if(typeof cache_tab_compte == 'function') {
			cache_tab_compte();
		}
	}
}

if (window.addEventListener) window.addEventListener("load", initTabs, false);
else if (window.attachEvent) window.attachEvent("onload", initTabs);