var initialtab=[1, "sc1"]


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 previoustab=""

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].style.backgroundColor=initTabcolor
tabobjlinks[i].style.color='black'
}
var themecolor=aobject.getAttribute("theme")? aobject.getAttribute("theme") : initTabpostcolor
aobject.style.backgroundColor=document.getElementById("tabcontentcontainer").style.backgroundColor=themecolor
aobject.style.color='red'
}

function highlighttabname(aobject, color){
aobject.style.backgroundColor=color
}

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){
var cookieparse=get_cookie(cookiename).split("|")
var whichtab=cookieparse[0]
var tabcontentid=cookieparse[1]
expandcontent(tabcontentid, tabobjlinks[whichtab])
}
else
expandcontent(initialtab[1], tabobjlinks[initialtab[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



function getObject(objectId) { return document.getElementById(objectId); }

function getObjectStyle(objectId) { var obj = getObject(objectId); return obj.style;}

function router(property, value)
{
var ms_body		= getObjectStyle("mysbody");
var ms_table1	= getObjectStyle("mystable1");
var ms_table2	= getObjectStyle("mystable2");
var ms_name		= getObjectStyle("mysname");
var ms_title	= getObjectStyle("mystitle");
var ms_text		= getObjectStyle("mystext");
var ms_link		= getObjectStyle("myslink");

switch(property)
{
case 'backgroundColor':				ms_body.backgroundColor = "rgb("+value+")"; break;
case 'backgroundImage':				ms_body.backgroundImage = "url(" + value + ")"; break;
case 'backgroundPosition':			ms_body.backgroundPosition = value;
break;
case 'backgroundRepeat':			ms_body.backgroundRepeat = value; break;
case 'backgroundAttachment':		ms_body.backgroundAttachment = value; break;

case 'sectionBackgroundColor':		if (value != "transparent") { ms_table1.backgroundColor = ms_table2.backgroundColor = "rgb("+value+")"; getObject('transparent_secbg').checked = 0; } else { ms_table1.backgroundColor = ms_table2.backgroundColor = value; } break;
case 'sectionBorderColor':			ms_table1.borderColor = ms_table2.borderColor = "rgb("+value+")"; break;
case 'sectionBorderWidth':			ms_table1.borderWidth = ms_table2.borderWidth = value + "px"; ms_table1.width = ms_table2.width = (350 - (value * 2)) + "px"; break;
case 'sectionBorderStyle':			ms_table1.borderStyle = ms_table2.borderStyle = value; break;
case 'sectionOpacity':				if (navigator.appName.indexOf("Netscape")!=-1 && parseInt(navigator.appVersion) >= 5) { ms_table1.MozOpacity = ms_table2.MozOpacity = value/100; } else if (navigator.appName.indexOf("Microsoft") != -1 && parseInt(navigator.appVersion)>=4) { ms_table1.filter = ms_table2.filter = "alpha(opacity=" + value + ")"; } break;

case 'nameFontFamily':				ms_name.fontFamily = value; break;
case 'nameFontSize':				ms_name.fontSize = value + "px"; break;
case 'nameFontColor':				ms_name.color = "rgb("+value+")"; break;
case 'nameFontWeight':				if (getObject("in_nameFontWeight").value == "normal") { ms_name.fontWeight = value; getObject("nfso1").style.borderColor = "rgb(255,102,0)"; } else { value = "normal"; ms_name.fontWeight = value; getObject("nfso1").style.borderColor = "rgb(255, 255, 255)"; } break;
case 'nameFontStyle':				if (getObject("in_nameFontStyle").value == "normal") { ms_name.fontStyle = value; getObject("nfso2").style.borderColor = "rgb(255,102,0)"; } else { value = "normal"; ms_name.fontStyle = value; getObject("nfso2").style.borderColor = "rgb(255, 255, 255)"; } break;
case 'nameFontDecoration':			if (getObject("in_nameFontDecoration").value == "none") { ms_name.textDecoration = value; getObject("nfso3").style.borderColor = "rgb(255,102,0)"; } else { value = "none"; ms_name.textDecoration = value; getObject("nfso3").style.borderColor = "rgb(255, 255, 255)"; } break;

case 'headingFontFamily':			ms_title.fontFamily = value; break;
case 'headingFontSize':				ms_title.fontSize = value + "px"; break;
case 'headingFontColor':			ms_title.color = "rgb("+value+")"; break;
case 'headingFontWeight':			if (getObject("in_headingFontWeight").value == "normal") { ms_title.fontWeight = value; getObject("hfso1").style.borderColor = "rgb(255,102,0)"; } else { value = "normal"; ms_title.fontWeight = value; getObject("hfso1").style.borderColor = "rgb(255, 255, 255)"; } break;
case 'headingFontStyle':			if (getObject("in_headingFontStyle").value == "normal") { ms_title.fontStyle = value; getObject("hfso2").style.borderColor = "rgb(255,102,0)"; } else { value = "normal"; ms_title.fontStyle = value; getObject("hfso2").style.borderColor = "rgb(255, 255, 255)"; } break;
case 'headingFontDecoration':		if (getObject("in_headingFontDecoration").value == "none") { ms_title.textDecoration = value; getObject("hfso3").style.borderColor = "rgb(255,102,0)"; } else { value = "none"; ms_title.textDecoration = value; getObject("hfso3").style.borderColor = "rgb(255, 255, 255)"; } break;

case 'fontFamily':					ms_text.fontFamily = ms_link.fontFamily = value; break;
case 'fontSize':					ms_text.fontSize = ms_link.fontSize = value + "px"; break;
case 'fontColor':					ms_text.color = "rgb("+value+")"; break;
case 'fontWeight':					if (getObject("in_fontWeight").value == "normal") { ms_text.fontWeight = value; getObject("fso1").style.borderColor = "rgb(255,102,0)"; } else { value = "normal"; ms_text.fontWeight = value; getObject("fso1").style.borderColor = "rgb(255, 255, 255)"; } break;
case 'fontStyle':					if (getObject("in_fontStyle").value == "normal") { ms_text.fontStyle = value; getObject("fso2").style.borderColor = "rgb(255,102,0)"; } else { value = "normal"; ms_text.fontStyle = value; getObject("fso2").style.borderColor = "rgb(255, 255, 255)"; } break;
case 'fontDecoration':				if (getObject("in_fontDecoration").value == "none") { ms_text.textDecoration = value; getObject("fso3").style.borderColor = "rgb(255,102,0)"; } else { value = "none"; ms_text.textDecoration = value; getObject("fso3").style.borderColor = "rgb(255, 255, 255)"; } break;

case 'linkFontColor':				ms_link.color = "rgb("+value+")"; break;
case 'linkFontWeight':				if (getObject("in_linkFontWeight").value == "normal") { ms_link.fontWeight = value; getObject("lso1").style.borderColor = "rgb(255,102,0)"; } else { value = "normal"; ms_link.fontWeight = value; getObject("lso1").style.borderColor = "rgb(255, 255, 255)"; } break;
case 'linkFontStyle':				if (getObject("in_linkFontStyle").value == "normal") { ms_link.fontStyle = value; getObject("lso2").style.borderColor = "rgb(255,102,0)"; } else { value = "normal"; ms_link.fontStyle = value; getObject("lso2").style.borderColor = "rgb(255, 255, 255)"; } break;
case 'linkFontDecoration':			if (getObject("in_linkFontDecoration").value == "none") { ms_link.textDecoration = value; getObject("lso3").style.borderColor = "rgb(255,102,0)"; } else { value = "none"; ms_link.textDecoration = value; getObject("lso3").style.borderColor = "rgb(255, 255, 255)"; } break;

case 'linkHoverFontColor':			/* */ break;
case 'linkHoverFontWeight':			if (getObject("in_linkHoverFontWeight").value == "normal") { getObject("lhso1").style.borderColor = "rgb(255,102,0)"; } else { value = "normal"; getObject("lhso1").style.borderColor = "rgb(255, 255, 255)"; } break;
case 'linkHoverFontStyle':			if (getObject("in_linkHoverFontStyle").value == "normal") { getObject("lhso2").style.borderColor = "rgb(255,102,0)"; } else { value = "normal"; getObject("lhso2").style.borderColor = "rgb(255, 255, 255)"; } break;
case 'linkHoverFontDecoration':		if (getObject("in_linkHoverFontDecoration").value == "none") { getObject("lhso3").style.borderColor = "rgb(255,102,0)"; } else { value = "none"; getObject("lhso3").style.borderColor = "rgb(255, 255, 255)"; } break;
}
getObject("in_" + property).value = value;
}

function bgalign_border(val) {
for(i=1; i < 10; i++) getObject("bgpos" + i).style.borderColor = "rgb(255,255,255)";	
val.style.borderColor="rgb(255,102,0)";
}

function link_hover(status)
{
var status = (status != "") ? "Hover" : "";
var ms_link = getObjectStyle("myslink");	
ms_link.color			= "rgb("+getObject("in_link" + status + "FontColor").value+")";
ms_link.fontWeight		= getObject("in_link" + status + "FontWeight").value;
ms_link.fontStyle		= getObject("in_link" + status + "FontStyle").value;
ms_link.textDecoration	= getObject("in_link" + status + "FontDecoration").value;
}

function secbg_transparent() {
if (getObject("in_sectionBackgroundColor").value == "transparent") {
router('sectionBackgroundColor', "255, 255, 255");
} else {
router('sectionBackgroundColor', 'transparent');
}
}
