/* site specific scripts */

function siteInit(){
  // Called with the body onload event.
  // Customise according to site requirements.
  fixScrollBugHack();
}

function fixScrollBugHack() {
  var ua = navigator.userAgent;
  if(ua.indexOf("Safari") >= 0 || ua.indexOf("Opera") >= 0) {
    divs = document.getElementsByTagName("div");
    for(var i = 0; i<divs.length;i++) {
      if(typeof divs[i] == "object" && divs[i] != null) { 
        if(divs[i].className.indexOf("contentArea") >= 0 && !(divs[i].className.indexOf("multipleComponents") >=0) ) {
          divs[i].style.overflow = "hidden";
        }
      }
    }
  }
}

function getSections() {
  sections = new Array();

  sections[0] = document.getElementById('main-banner');
  sections[1] = document.getElementById('main-left');
  sections[2] = document.getElementById('main-right');
  sections[3] = null;
  sections[4] = document.getElementById('main-content');
  sections[5] = document.getElementById('main-footer');

  return sections;
}

function setLayout() {
 ; // Not required.
}

function redrawLayout() {
  ;// Not required.
}

function printPageComponent() {
  html  = '<button class="componentLink" \n';
  html += '        id="component-box-print" \n';
  html += '        onclick="window.print();" \n';
  html += '        onmouseout="this.className = \'componentLink\'"\n';
  html += '        onmouseover="this.className = \'componentLink hover\'"\n';
  html += '        title="Print the current page." \n'; 
  html += '        type="button">'; 
  html += '  <span class="accessHidden">Print this page</span>';
  html += '</button>';
  return html;
}

function hoverHelp(el,action) {
  switch(action) {
    case 0: el.className = "hoverHelp hhClose";
            break;
    case 1: el.className = "hoverHelp hhOpen";
            break;
    default : ;
  }
}

SIZE_DOWN_MSG = "Change Text Size";
SIZE_UP_MSG = "Change Text Size";
function displayFontSwitch() {
  document.write("<a href=\"#top\" \n");
  document.write("   id=\"font-switch\" \n");
  document.write("   onclick=\"switchFontSize(this)\" \n");
  document.write("   onmouseup=\"this.blur();\"> \n");
  if(getCookie("baseFontSize") > 0) {
    document.write(SIZE_DOWN_MSG);
  }
  else {
    document.write(SIZE_UP_MSG);
  }
  document.write("</a>");
}

function addToClass(el,str) {
  currentClass = el.className;
  if(currentClass.length <= 0) {
    // Class is empty so stick str in
    el.className = str;
  }
  else {
    // Class not empty so make sure to put in preceding space
    el.className = currentClass + " " + str;
  }
}

function removeFromClass(el,str) {
  currentClass = el.className;
  // Do twice to catch any whitespace variants first.
  var withSpace = " " + str;
  el.className = currentClass.replace(withSpace,"");
  el.className = currentClass.replace(str,"");
}

function featureImageIs(el, indx) {
  var parent = el.parentNode;
  var images = parent.getElementsByTagName('img');
  indx = indx - 1;
  for(var i in images) {
    if(typeof images[i] == "object" && images[i] != null){
      if(i != indx) {
        images[i].style.visibility = "hidden";
      }
      else {
        images[i].style.visibility = "visible";
      }
    }
  }
}