/* TAB CONTENTS */

var previoustab = '';
var tabmenus = new Array();
var tabobjlinks = new Array();
var initTabcolor = new Array();
var initTabpostcolor = new Array();
var previoustab = new Array();

function cascadedstyle(el, cssproperty, csspropertyNS)
{
	if ( el )
	{
	if ( el.currentStyle )
	{
		return el.currentStyle[cssproperty];
	}
	else if ( window.getComputedStyle )
	{
		var elstyle=window.getComputedStyle(el, '');
		return elstyle.getPropertyValue(csspropertyNS);
	}
	}
}

function expandcontent(container, list, cid, aobject, editor)
{
	if (document.getElementById)
	{
		highlighttab(container, list, aobject);
		
		detectSourceindex(list, aobject);

		if ( previoustab[list] )
		{
			document.getElementById(previoustab[list]).style.display="none";
		}
		
		document.getElementById(cid).style.display = "block";
		
		previoustab[list] = cid;
		
		if ( editor )
		{
			refreshEditors();
		}
		
		if ( aobject.blur )
		{
			aobject.blur();
			
			return false;
		}
		else
		{
			return true;
		}
	}
}


function highlighttab(container, list, aobject)
{
	if ( typeof tabobjlinks[list] == "undefined" )
	{
		collecttablinks(list);
	}

	for ( i = 0 ; i < tabobjlinks[list].length ; i++ )
	{
		//tabobjlinks[list][i].style.backgroundColor = initTabcolor[list];
		tabobjlinks[list][i].className = "";
	}
	
	//var themecolor = aobject.getAttribute("theme") ? aobject.getAttribute("theme") : initTabpostcolor[list];

	//aobject.style.backgroundColor = document.getElementById(container).style.backgroundColor = themecolor;
	aobject.className = "current";
	
}

function collecttablinks(list)
{
	if ( tabobj = document.getElementById(list) )
	{
		tabobjlinks[list] = tabobj.getElementsByTagName("LI");
	}
}

function detectSourceindex(list, aobject)
{
	for ( i = 0 ; i < tabobjlinks[list].length ; i++ )
	{
		if ( aobject == tabobjlinks[list][i] )
		{
			tabsourceindex = i;
			break;
		}
	}
}

function add_tabmenu(container, list, cid, num)
{

	var a = [container, list, cid, num];
	
	tabmenus.push(a);
}

function do_onload()
{

	for ( tm = 0 ; tm < tabmenus.length ; tm++ )
	{
		/* Correction - Attention à la déclaration des variable pour IE -> var ! */
		var container	= tabmenus[tm][0];
		var list		= tabmenus[tm][1];
		var cid			= tabmenus[tm][2];
		var num			= tabmenus[tm][3];

		collecttablinks(list);

		initTabcolor[list] = cascadedstyle(tabobjlinks[list][1], "backgroundColor", "background-color");
		initTabpostcolor[list] = cascadedstyle(tabobjlinks[list][0], "backgroundColor", "background-color");

		expandcontent(container, list, cid, tabobjlinks[list][num]);
	}
}

if ( window.addEventListener )
{
	window.addEventListener("load", do_onload, false);
}
else if (window.attachEvent)
{
	window.attachEvent("onload", do_onload);
}
else if (document.getElementById)
{
	window.onload = do_onload;
}

