/* ex: set tabstop=2 softtabstop=2 shiftwidth=2 : */


/**
 * @description
 * shorthand for getElementById
 * @param el
 */
var ___ = function(el) {
  return document.getElementById( el );
};

/**
 * @name manipulateClass
 * @function
 *
 * @description
 * order of execution:
 * remove then add
 *
 * @param el
 * @param option
 * parameters:
 * {
 *    add   : STRING (must be unique)
 *    remove: STRING (must be unique)
 * }
 */
var manipulateClass = function(el, option) {
  if ( !el || !option || typeof option !== "object" ) {
    return;
  }

  if ( ( option.add &&typeof option.add !== "string" ) || ( option.remove && typeof option.remove !== "string" ) ) {
    throw new TypeError( "Parameters malformed." + option + " should be object of string" );
  }
  var _className = el.className;

  if ( !_className ) {
    if ( option.add ) {
      el.className = option.add;
      return;
    }
    return;
  }

  var _classNameArray = _className.split( " " ).unique();

  if ( option.remove ) {
    var classToRemove = option.remove.split( " " );
    _classNameArray = _classNameArray.diff( classToRemove );
  }
  if ( option.add ) {
    // in case there is duplicate
    var classToAdd = option.add.split( " " );
    // TODO: needs testing
    Array.prototype.push.apply( _classNameArray, classToAdd );
    _classNameArray = _classNameArray.unique();
  }
  _className = _classNameArray.join( " " );
  el.className = _className;
  return;
};

/**
 * @name toggleElement
 * @function
 *
 * @description
 * @param el
 * @param state
 */
var toggleElement = function(el, state) {
  if ( !___( el ) ) {
    return;
  }
  return ___( el ).style.display = state ? state : "none";
};

@@ -1217,34 +1217,55 @@
  );%0A
+%0A
     // 
-TODO: needs testing
+remove duplicates and join two arraries
 %0A   
@@ -1320,23 +1320,22 @@
 assToAdd
- );%0A   
+.diff(
  _classN
@@ -1346,34 +1346,22 @@
 rray
- = _classNameArray.unique(
+, %22exclude%22 ) 
 );%0A 

use a (probably) better way to handle array concat