//******************************************************************************
// Name: misc_funcs.js
//
// Description:
//
// Provides a range of general purpose functions used throughout the website.
//
// Revision History:
//
// Version 1 by tc on 23/02/2010
// File created.
//
// Copyright 2010 I.T. Dev Ltd. All Rights Reserved.
//
//******************************************************************************

//******************************************************************************
// Get all elements of a particular class.
// Taken from http://www.dustindiaz.com/top-ten-javascript/
function getElementsByClass(searchClass,node,tag)
{
  var classElements = new Array();
  if ( node == null )
    node = document;
  if ( tag == null )
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
  for (i = 0, j = 0; i < elsLen; i++) {
    if ( pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}

