/* basic DOM api  */

function Element_From_Id( id )   {
   if ( document.getElementById )   {
      this.obj  =  document.getElementById(id);
   }
   else
   if ( document.all )  {
      this.obj  =  document.all[id];
   }
   else  {
      this.obj  =  false;
   }
}



/* useful helper functions */

function uc_words ( str )  {
   if ( str == "" )  {
      return   str;
   }
   words =  str.split(" ");
   for   ( i in words ) {
      word  =  words[i];
      first_letter   =  word.charAt(0);
      first_letter   =  first_letter.toUpperCase();
      word  =  word.replace(/^./,first_letter);
      words[i] =  word;
   }
   str   =  words.join(" ");
   return   str;
}

function bar_space ( str )  {
  if  ( trim(str) == "" ) {
    return  str;
  }
  str = str.replace(/ +/,'_');
  return  str;
}

function trim( str ) {
   if ( str == "" )  {
      return   str;
   }
   str   =  str.replace(/^\s+/,"");
   str   =  str.replace(/\s+$/,"");
   return   str;
}

function toggle_vis( id )  {
   el =  new Element_From_Id(id);
   if ( !el.obj ) {
      return   false;
   }
   cur_class   =  el.obj.className;
   if ( cur_class.indexOf("hidden") > -1 )   {
      new_class   =  cur_class.replace(/hidden/,"");
   }
   else  {
      new_class   =  cur_class + " hidden";
   }
   new_class   =  trim(new_class);
   el.obj.className  =  new_class;
   return   false;
}

