code: function string_to_boolean (string) {
  
    // It's a boolean already, no need to parse
    if (typeof string === 'boolean') { return string; }
  
    // Check for bad values
    if (string === undefined) { return false; }
    if (string === null)      { return false; }
  
    if (typeof string === 'string') { string = string.toLowerCase(); }
  
    switch (string) {
      case 'true':
      case 1:
      case '1':
      case 'yes':
        return true;
      case 'false':
      case 0:
      case '0':
      case 'no':
      case 'null':
      case null:
        return false;
      default:
        //return Boolean(string);
        return false;
    }
  
  }
docs: http://stackoverflow.com/questions/263965/how-can-i-convert-a-string-to-boolean-in-javascript