function Util(){};

// Takes an input string, replaces '_' with ' ' and
// capitalizes the first letter of each word.
// Ex: 'public_relations' becomes 'Public Relations'
Util.humanize = function( input )
{
  var pieces = input.split('_');
  var output = new Array();
  for( var i = 0; i < pieces.length; i++ )
  {
    output.push( pieces[i].slice(0,1).toUpperCase() + pieces[i].slice(1) );
  }
  return output.join( ' ' );
}

Util.sanitize = function( input )
{
  return input.replace( /'/g, '' );
}

/*
 * Force JS execution to sleep for m miliseconds.
 */
Util.nap = function( m )
{
  var then = new Date(new Date().getTime() + m); 
  while( new Date() < then )
  {
    continue;
  }
}

/*
 * Useful constants for millisecond date math.
 */
Util.Date = new Object();
Util.Date.ONE_SECOND = 1000;
Util.Date.ONE_MINUTE = Date.ONE_SECOND * 60;
Util.Date.ONE_HOUR = Date.ONE_MINUTE * 60;
Util.Date.ONE_DAY = Date.ONE_HOUR * 24;



/**
 * Faust helper methods.
 */
Util.Faust = new Object();

/**
 * innerXHTML
 *
 * Copyright (c) 2006 space150, LLC and released under the CPL license: http://opensource.org/licenses/cpl1.0.php
 */
Util.Faust.innerXHTML = function(obj, encode)
{
  // It is an option to pass innerXHTML() a string indicating an id attribute
  if (typeof obj == "string") {
    obj = document.getElementById(obj);
  }

  var open = '';
  var content = '';
  var close = '';
  var tagname = obj.nodeName.toLowerCase();
  var emptytag = (obj.nodeName.match(/area|base|basefont|br|col|frame|hr|img|input|isindex|link|meta|param/i)) ? true : false;

  // Write open tag
  open = '<'+tagname;
  for (var i=0; i<obj.attributes.length; i++) {
    if (obj.attributes[i].specified && obj.attributes[i].value != "null")
      open += ' '+obj.attributes[i].name.toLowerCase()+'="'+obj.attributes[i].value+'"';
  }
  open += (emptytag) ? ' />' : '>';

  if (!emptytag) {
    // Write tag content
    for (var i=0; i<obj.childNodes.length; i++) {
      var node = obj.childNodes[i];
      if (node.nodeType==3)
        content += node.data;
      else if (node.nodeType==1)
        content += Util.Faust.innerXHTML(obj.childNodes[i], false);
      else
        content += " ";
    }

    // Write closing tag
    close = '</'+tagname+'>';
  }

	// URI encode the content if desired
  return (typeof(encode)=="undefined" || encode==true) ? encodeURIComponent(open+content+close) : open+content+close;
}