var enabletabpersistence=1 //enable tab persistence via session only cookies, so selected tab is remembered?
var persisttype="sitewide"
var menuTimeout = 1000;
var initialtab = [1,'sc1']
//Turn menu into single level image tabs (completely hides 2nd level)?
var turntosingle = 0 //0 for no (default), 1 for yes
//Disable hyperlinks in 1st level tab images?
var disabletablinks = 0 //0 for no (default), 1 for yes
////////Stop editting////////////////
var previoustab = ""
if (turntosingle == 1)
	document.write('<style type="text/css">\n#tabcontentcontainernew{display: none;}\n</style>')

function expandcontent(cid, aobject){
if (document.getElementById){
highlighttab(aobject)
detectSourceindex(aobject)
if (previoustab!="")
document.getElementById(previoustab).style.display="none"
document.getElementById(cid).style.display="block"
previoustab=cid
if (aobject.blur)
aobject.blur()
return false
}
else
return true
}

function highlighttab(aobject)
{
	if (typeof tabobjlinks == "undefined")
		collecttablinks()
	for (i = 0; i < tabobjlinks.length; i++)
		tabobjlinks[i].className = ""
	aobject.className = "current"
}

function collecttablinks()
{
	var tabobj = document.getElementById("tablist")
	tabobjlinks = tabobj.getElementsByTagName("A")
}

function detectSourceindex(aobject){
for (i=0; i<tabobjlinks.length; i++){
if (aobject==tabobjlinks[i]){
tabsourceindex=i //source index of tab bar relative to other tabs
break
}
}
}

function do_onload(){ 
var cookiename=(typeof persisttype!="undefined" && persisttype=="sitewide")? "tabcontent" : window.location.pathname
var cookiecheck=window.get_cookie && get_cookie(cookiename).indexOf("|")!=-1
collecttablinks()
//initTabcolor=cascadedstyle(tabobjlinks[1], "backgroundColor", "background-color")

//initTabpostcolor=cascadedstyle(tabobjlinks[0], "backgroundColor", "background-color")

if (typeof enablepersistence!="undefined" && enablepersistence && cookiecheck){
//alert('qui...')
var cookieparse=get_cookie(cookiename).split("|")
//alert('qui pure...')
var whichtab=cookieparse[0]
//alert('whichtab:'+whichtab)
var tabcontentid=cookieparse[1]
//alert('tabcontentid:'+tabcontentid)
expandcontent(tabcontentid, tabobjlinks[whichtab])
}
else
//alert('...o qui?')
expandcontent(initialtab[1], tabobjlinks[initialtab[0]-1])
}

var thread1;

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

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(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))
//alert(returnvalue)
}
}
return returnvalue;
}


function savetabstate(){
var cookiename=(persisttype=="sitewide")? "tabcontent" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? tabsourceindex+"|"+previoustab+";path=/" : tabsourceindex+"|"+previoustab
document.cookie=cookiename+"="+cookievalue
}

function menuOnOut()
{
	thread1 = setTimeout('do_onload()', menuTimeout);
}
function menuOnIn(a,b)
{	
	clearTimeout(thread1);
}
window.onunload=savetabstate
