//convert all caps to just first letter of each word capitalized
var boxy;

function checkCaps(textBox)
{
  boxy = textBox;
  setTimeout ( 'checkCapsDelay()', 200 );
}

function checkCapsDelay()
{
  var a = boxy.value;
  if (a == a.toUpperCase() && a != '')
  {
    //lowercase all
    var a = a.toLowerCase();
    //cap after hyphen
    var b = [];
    b = a.split('-');
    var c = '';
    for (var i = 0;i<b.length;i++)
    {
      if (i != 0) c = c + '-';
      c = c + b[i].charAt(0).toUpperCase() + b[i].slice(1);
    }
    a = c;
    //cap after space
    var b = [];
    b = a.split(' ');
    var c = '';
    for (var i = 0;i<b.length;i++)
    {
      if (i != 0) c = c + ' ';
      c = c + b[i].charAt(0).toUpperCase() + b[i].slice(1);
    }
    boxy.value = c;
  }

}
