<!--
/* 
*  Copyright 2006-2007 Dynamic Site Solutions.
*  Free use of this script is permitted for commercial and non-commercial 
*  applications, subject to the requirement that this comment block be kept 
*  and not be altered.  The data and executable parts of the script may be 
*  changed as needed.  Dynamic Site Solutions makes no warranty regarding 
*  fitness of use or correct function of the script.  If you would like help
*  customizing this script or if you have other questions, contact 
*  "contact_us@dynamicsitesolutions.com".
*
*  Script by: Dynamic Site Solutions -- http://www.dynamicsitesolutions.com/
*  Last Updated: 2007-04-02
*/

function hasClassName(el,c){
  c=c.replace(/\-/g,'\\-');
  return (new RegExp('(^|\\s)'+c+'(\\s|$)')).test(el.className);
}
function addClassName(el,c){
  if(hasClassName(el,c)) return;
  var curClass=el.className;
  el.className=curClass+((curClass.length>0)?' ':'')+c;
}
function removeClassName(el,c){
  var re=new RegExp(c.replace(/\-/g,'\\-')+'\\s*');
  el.className=el.className.replace(re,'').replace(/^\s*|\s*$/g,'');
}

function makeToggleSection(idArray, // an array of the IDs for the sections
  textAr, // an array of the text for link to each section
  par, // an object reference to the element we'll append the list to
  initIndex) { // the section you want shown first, starting at 0,
    // or -1 to hide them all initially
  if(!document.getElementsByTagName || !document.createTextNode) return;
  if(!par || !idArray || !textAr || !idArray.length || !textAr.length) return;
  var elm,elm2;
  for(var i=0,l=idArray.length;i<l;i++) {
    if(i == initIndex) continue;
    elm = document.getElementById(idArray[i]);
    if(!elm) continue;
    elm.style.display='none';
  }
  var list=document.createElement('ul');
  for(var i=0,l=textAr.length;i<l;i++) {
    elm = document.createElement('li');
    elm2 = document.createElement('a');
    elm2.appendChild(document.createTextNode(textAr[i]));
    elm2.href = '#'+idArray[i];
    elm.appendChild(elm2);
    list.appendChild(elm);
  }
  list=par.appendChild(list);
  list.onclick=function(){
    return function(e){
    e = e||window.event;
    var el=e.target||e.srcElement;
    while(el.nodeType != 1) el=el.parentNode; //NS6 fix
    if(el.nodeName.toLowerCase() != 'a') return;
    var elm,links = list.getElementsByTagName('a');
    for(var i=0,l=links.length;i<l;i++) {
      elm = document.getElementById(idArray[i]);
      if(!elm) continue;
      if(links[i]==el) {
        addClassName(links[i],'active');
        elm.style.display='';
      } else {
        removeClassName(links[i],'active');
        elm.style.display='none';
      }
    }
    return false;
  }}();
  if(initIndex >= 0) {
    addClassName(list.getElementsByTagName('a')[initIndex],'active');
  }
}

function dss_addLoadEvent(fn) {
  if(typeof(fn)!="function")return;
  var tempFunc=window.onload;
  window.onload=function() {
    if(typeof(tempFunc)=="function")tempFunc();
    fn();
  }
}

if(document.getElementById) {
  dss_addLoadEvent(function(){
    makeToggleSection(
      ['section1','section2'],
      ['1','2'],
      document.getElementById('togList1'),
      0
    );
  });
}
// -->