/*
Modified by Phil Croucher for Roksport 22/02/2007

Produces section menus based on site design for roksport surf page.

ar 		= Actinic Section array
rootSection 	= The name of the section to display
headClass	= the css class name for the header of the section
useImage 	= 	'true'	- use Images for links if available
			'false'	- use text based links

*/
function SectionList(ar,rootSection,headClass,menuClass,useImage) {
  var strIDs = '';
  var loc = window.location.href;
  var fileref = '';
  /*check file location*/
  loc = loc.toLowerCase();
  if (loc.indexOf('acatalog') != -1) {
    fileref ='';
  }
  if (loc.indexOf('cgi-bin') != -1) {
    fileref = '';
  }
  /*loop through section tree array*/
  for (var i=1;i<=ar.length;i++) {
    if (ar[i].sURL !=null) {
      if (ar[i].sName == rootSection) {
        strIDs += '<div class="' + headClass + '"><a href="' + ar[i].sURL + '"><h1>' + ar[i].sName + '</h1></a></div><div class="' + menuClass + '">'; {
          if (ar[i].pChild) {
            for (var j=1;j<=ar[i].pChild.length;j++) {
              if (j <= ar[i].pChild.length) {
                strIDs += '<a href="' + ar[i].pChild[j].sURL + '">';
                if (useImage == 'true') {
                  if (ar[i].pChild[j].sImage !='') {
                    strIDs += '<img src="' + fileref + ar[i].pChild[j].sImage + '" />';
                  } else {
                    strIDs += ar[i].pChild[j].sName;
                  }
                } else {
                  strIDs += ar[i].pChild[j].sName
                }
                strIDs += '</a>';
              }
            }
            strIDs += '</div>';
          }
        }
      }
    }
  } 
  return strIDs
}