//Set feature to intially be selected when page loads:
//[which feature (1=first feature), ID of feature content to display]:
var initialfeature=[1, "feature1"]

////////Stop editing////////////////

function cascadedstyle(el, cssproperty, csspropertyNS){
if (el.currentStyle)
return el.currentStyle[cssproperty]
else if (window.getComputedStyle){
var elstyle=window.getComputedStyle(el, "")
return elstyle.getPropertyValue(csspropertyNS)
}
}

var previousfeature=""

function expandcontent(cid, aobject){
if (document.getElementById){
highlightfeature(aobject)
detectSourceindex(aobject)
if (previousfeature!="")
document.getElementById(previousfeature).style.display="none"
document.getElementById(cid).style.display="block"
previousfeature=cid
if (aobject.blur)
aobject.blur()
return false
}
else
return true
}

function highlightfeature(aobject){
if (typeof featureobjlinks=="undefined")
collectfeaturelinks()
for (i=0; i<featureobjlinks.length; i++)
featureobjlinks[i].style.backgroundColor=initFeaturecolor
var themecolor=aobject.getAttribute("theme")? aobject.getAttribute("theme") : initFeaturepostcolor
aobject.style.backgroundColor=document.getElementById("featurecontainer").style.backgroundColor=themecolor
}

function collectfeaturelinks(){
var featureobj=document.getElementById("featurelist")
featureobjlinks=featureobj.getElementsByTagName("A")
}

function detectSourceindex(aobject){
for (i=0; i<featureobjlinks.length; i++){
if (aobject==featureobjlinks[i]){
featuresourceindex=i //source index of feature bar relative to other features
break
}
}
}

function do_onload(){
var cookiecheck=window.get_cookie && get_cookie(window.location.pathname).indexOf("|")!=-1
collectfeaturelinks()
initFeaturecolor=cascadedstyle(featureobjlinks[1], "backgroundColor", "background-color")
initFeaturepostcolor=cascadedstyle(featureobjlinks[0], "backgroundColor", "background-color")
if (typeof enablepersistence!="undefined" && enablepersistence && cookiecheck){
var cookieparse=get_cookie(window.location.pathname).split("|")
var whichfeature=cookieparse[0]
var featurecontentid=cookieparse[1]
expandcontent(featurecontentid, featureobjlinks[whichfeature])
}
else
expandcontent(initialfeature[1], featureobjlinks[initialfeature[0]-1])
}

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
