/***********************************************
* Tab Content script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
function cascadedstyle_tab(el, cssproperty, csspropertyNS){
if (el.currentStyle)
return el.currentStyle[cssproperty]
else if (window.getComputedStyle){
var elstyle=window.getComputedStyle(el, "")
return elstyle.getPropertyValue(csspropertyNS)
}
}

function expandcontent_tab(cid, aobject, cible, id){
if (document.getElementById){
highlighttab_tab(aobject,cible,id)
detectSourceindex_tab(aobject,id)
if (previoustab[id]!=undefined){
document.getElementById(previoustab[id]).style.display="none"
}
document.getElementById(cid).style.display="block"
previoustab[id]=cid
if (aobject.blur)
aobject.blur()
return false
}else
return true
}

function highlighttab_tab(aobject,cible,id){
if (typeof tabobjlinks[id]=="undefined")
collecttablinks_tab(id)
for (i=0; i<tabobjlinks[id].length; i++)
tabobjlinks[id][i].style.backgroundColor=initTabcolor
var themecolor=aobject.getAttribute("theme")? aobject.getAttribute("theme") : initTabpostcolor
aobject.style.backgroundColor=document.getElementById(cible).style.backgroundColor=themecolor
}

function collecttablinks_tab(id){
var tabobj=document.getElementById(id)
tabobjlinks[id]=tabobj.getElementsByTagName("A")
}

function detectSourceindex_tab(aobject,id){
for (i=0; i<tabobjlinks[id].length; i++){
if (aobject==tabobjlinks[id][i]){
tabsourceindex[id]=i //source index of tab bar relative to other tabs
break
}
}
}

/*
function do_onload(id,cible){
	
var cookiecheck=false;
if (enablepersistence) {
var cookiename=(typeof persisttype!="undefined" && persisttype=="sitewide")? cookieBase+id : window.location.pathname+id
cookiecheck=window.get_cookie && get_cookie_tab(cookiename).indexOf("|")!=-1
}
collecttablinks_tab(id)
initTabcolor=cascadedstyle_tab(tabobjlinks[id][1], "backgroundColor", "background-color")
initTabpostcolor=cascadedstyle_tab(tabobjlinks[id][0], "backgroundColor", "background-color")
if (enablepersistence && cookiecheck) {
// alert("persistence");
if (typeof enablepersistence!="undefined" && enablepersistence && cookiecheck){
var cookieparse=get_cookie_tab(cookiename).split("|")
var whichtab=cookieparse[0]
var tabcontentid=cookieparse[1]
}
if (whichtab!="undefined"){
expandcontent_tab(tabcontentid, tabobjlinks[id][whichtab],cible,id)
}else{
expandcontent_tab(initialtab[id][1], tabobjlinks[id][initialtab[id][0]-1],cible,id)
}
}else{
// alert("pas de persistence");
expandcontent_tab(initialtab[id][1], tabobjlinks[id][initialtab[id][0]-1],cible,id)
}
}*/


//Set tab to intially be selected when page loads:
//[which tab (1=first tab), ID of tab content to display]:
var initialtab=Array();
var previoustab=Array();
var tabobjlinks=Array();
var tabsourceindex=Array();
var tabIds = Array();
var currTab = -1;
var cookieBase = "tabcontent";




//Dynamicdrive.com persistence feature add-on
var enablepersistence=true //true to enable persistence, false to turn off (or simply remove this entire script block).
var persisttype="sitewide" //enter "sitewide" for Tab content order to persist across site, "local" for this page only

function get_cookie_tab(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function saveAllTabState_tab(){
for(i=-1;i<tabIds.length;i++) {
id=tabIds[i];
var cookiename=(persisttype=="sitewide")? cookieBase+id : window.location.pathname+id
var cookievalue=(persisttype=="sitewide")? tabsourceindex[id]+"|"+previoustab[id]+";path=/" : tabsourceindex[id]+"|"+previoustab[id]
document.cookie=cookiename+"="+cookievalue
}
}

//if (enablepersistence) window.onunload=saveAllTabState;

