/**
 * Effects utility methods to extend other effects libraries.
 *
 * Version 1.0
 * 2005/12/01
 * - initial version
 * - requires scriptaculous
 *
 * @author Chris Fairbanks, <a href='http://www.williamsburger.com'>http://www.williamsburger.com</a>
 */


var Williamsburger = {
};


/**
 * The list of functions to run at page load time.
 */

var onloads = new Array( );

function runonloads( ) {
  for ( var i = 0 ; i < onloads.length ; i++ ) {
    onloads[ i ]( );
  }
}

window.onload = runonloads;


/**
 * The list of functions to run at page unload time.
 */

var onunloads = new Array( );

function runonunloads( ) {
  for ( var i = 0 ; i < onunloads.length ; i++ ) {
    onunloads[ i ]( );
  }
}

window.onunload = runonunloads;


function getElementValue( xml, tagName ) {
  var elements = xml.getElementsByTagName( tagName );

  if ( elements.length == 1 ) {
    return elements[ 0 ].firstChild.nodeValue;
  }
  else {
    return null;
  }
}


function getAttributeValue( xml, attributeName ) {
  return xml.getAttribute( attributeName );
}


function assert( a, errorMessage ) {
  if ( !a ) {
    throw new Exception( errorMessage );
  }
}


/**
 * Shorter version of document.getElementById( )
 *
 * @param id the ID of a div within the document
 * @return the div
 */

function getDiv( id ) {
  return document.getElementById( id );
}


/**
 * Shorter version of document.getElementById( ).style
 *
 * @param id the ID of a div within the document
 * @return the style of that div
 */

function getDivStyle( id ) {
  return getDiv( id ).style;
}


function hashToArray( hash ) {
  var array = [];

  for ( h in hash ) {
    array.push( hash[h] );
  }

  return array;
}


function trimArray( array, max ) {
  var trimmed = [];

  for ( var i = 0; i < array.length && i < max; i++ ) {
    trimmed.push( array[ i ] );
  }

  return trimmed;
}



