//jstabs.js configuration; script by Kelly Davis, Jan. 2010; kdavis@thestate.com
//
// Write style conditionally depending on user settings
function writeStyle() {  
var jstabsStyle = "<style>.jstabs #jsmenu{width: "+menuWidth+"; border-bottom:"+menuBorderThickness+" "+menuBorderStyle+" "+menuBorderColor+";margin: "+menuMargins+"}.jstabs #jsmenu p {margin: "+menuMargins+";}.jstabs #jsmenu span{padding: "+menuPadding+"; margin: "+tabMargins+"; background-color: "+menuInactive+";}.jstabs #jsmenu a {color: "+menuLinkColor+"; font-weight: "+menuLinkWeight+"; font-size: "+menuLinkSize+"; text-decoration: "+menuLinkStyle+"}";
// create and write style tag to set initial display status for items
var x=0;
if (firstIsVisible) 
    {
    jstabsStyle += ".jstabs span#item1btn {background-color:"+menuActive+";}";  //highlight item1 button
    
    for (x=1; x<numItems; x++)  
        {
        jstabsStyle += ".jstabs #item"+(x+1);  //skip item1 when writing no-display style group 
        if (x<numItems-1) {
          jstabsStyle += ","; //add comma until end of list 
           } 
        }
    }
else 
    {     //include item1 in no-display style group when first item is hidden
    for (x=1; x<numItems+1; x++) 
        {
        jstabsStyle += ".jstabs #item"+x; 
        if (x<numItems) {
          jstabsStyle += "," //add comma until end of list 
           }  
         }
    }
jstabsStyle += "{display: none;}</style>";
document.write(jstabsStyle);
}
//
//
// Write menu
function writeMenu() {
document.write('<div class=\"jstabs\"><div id=\"jsmenu\"><p>');
var i;
for (i=0; i<(numItems); i++)  //create labels for as many items as user designates
   {
   document.write('<span id=\"item'+(i+1)+'btn\"><a href=\"#\" onclick=\"showitem('+(i+1)+');return false;\">'+labels[i]+'</a></span>');
   }
document.write('</p></div>');
}
//
//
// heart of the script: change which div shows when user makes selection, and change tab to "active" style
function showitem(choice){  
var x; var item; var button;
for (x=0; x<numItems; x++)  //first, hide all "item" divs and set all tabs to inactive
  {
  item = "item"+(x+1);
  button = item+"btn";
  document.getElementById(item).style.display="none";
  document.getElementById(button).style.background=menuInactive;
  }
item = "item"+choice;  //second, reactivate user's chosen div and associated tab
button = item+"btn";
document.getElementById(item).style.display="block";
document.getElementById(button).style.background=menuActive;
}

