/*jshint curly:false,forin:false*/

AnimationFrame.shim();

window.castor =
{
	_hasClass: function( el, className ) {
		if( el.classList ) return el.classList.contains( className );
		else return new RegExp( '\\b' + className + '\\b' ).test( el.className );
	},
	_addClass: function( el, className ) {
		if( el.classList ) el.classList.add( className );
		else if( !this._hasClass( el, className )) el.className += ' ' + className;
	},
	_removeClass: function( el, className ) {
		if( el.classList ) el.classList.remove( className );
		else el.className = el.className.replace( new RegExp( '\\b' + className + '\\b', 'g' ), '' );
	},
	_toggleClass: function( el, className ) {
		if( !this._hasClass( el, className )) this._addClass( el, className );
		else this._removeClass( el, className );
	},
	_isString: function( str ) {
		return Object.prototype.toString.call( str ) === "[object String]";
	},
	_on: function( type, el, handler ) {
		if( !el )return;
		el.addEventListener( type, handler, false );
	},
	_off: function( type, el, handler ) {
		if( !el )return;
		el.removeEventListener( type, handler, false );
	},
	_cssEventEnd: function( eventType ) {
		var el = document.createElement('fakeelement');
		var cssEvents = {
			animation: {
				animation:'animationend',
				WebkitAnimation:'webkitAnimationEnd',
				MozAnimation:'animationend',
				OAnimation:'oAnimationEnd oanimationend',
			},
			transition: {
				transition:'transitionend',
				WebkitTransition:'webkitTransitionEnd',
				MozTransition:'transitionend',
				OTransition:'oTransitionEnd otransitionend',
			},
		};
		if( cssEvents.hasOwnProperty( eventType )) {
			for( eventEnd in cssEvents[eventType] ) {
				if( el.style[eventEnd] !== undefined ) {
					return cssEvents[eventType][eventEnd];
				}
			}
		}
	},
	// see: https://github.com/angus-c/just#just-extend
	_extend: function()
	{
		var args = [].slice.call( arguments );
		var deep = false;
		if( typeof args[0] === 'boolean' ) {
			deep = args.shift();
		}
		var result = args[0];
		var extenders = args.slice(1);
		var len = extenders.length;
		for( var i = 0; i < len; i++ ) {
			var extender = extenders[i];
			for( var key in extender ) {
				var value = extender[ key ];
				if( deep && value && ( typeof value == 'object' )) {
					var base = Array.isArray( value ) ? [] : {};
					result[ key ] = this._extend( true, base, value );
				}
				else {
					result[ key ] = value;
				}
			}
		}
		return result;
	},
};

(function( ElementPrototype )
{
	// matches polyfill
	ElementPrototype.matches = ElementPrototype.matches ||
	function( selector ) {
		var matches = ( this.document || this.ownerDocument ).querySelectorAll( selector );
		var i = matches.length;
		while( --i >= 0 && matches.item( i ) !== this );
		return i > -1;
	};

	// closest polyfill
	ElementPrototype.closest = ElementPrototype.closest ||
	function( selector ) {
		var el = this;
		while( el.matches && !el.matches( selector )) {
			el = el.parentNode;
		}
		return el.matches ? el : null;
	};
})( Element.prototype );

@@ -287,32 +287,85 @@
 , className ) %7B%0A
+%09%09className.split( ' ' ).forEach( function( str ) %7B%0A%09
 %09%09if( el.classLi
@@ -387,29 +387,24 @@
 st.add( 
-className
+str
  );%0A
+%09
 %09%09else i
@@ -423,33 +423,27 @@
 sClass( el, 
-className
+str
  )) el.class
@@ -456,25 +456,38 @@
 = ' ' + 
-className
+str;%0A%09%09%7D);%0A%09%09return el
 ;%0A%09%7D,%0A%09_
@@ -519,32 +519,85 @@
 , className ) %7B%0A
+%09%09className.split( ' ' ).forEach( function( str ) %7B%0A%09
 %09%09if( el.classLi
@@ -622,29 +622,24 @@
 remove( 
-className
+str
  );%0A
+%09
 %09%09else e
@@ -690,33 +690,27 @@
 xp( '%5C%5Cb' + 
-className
+str
  + '%5C%5Cb', 'g
@@ -716,24 +716,43 @@
 g' ), '' );%0A
+%09%09%7D);%0A%09%09return el;%0A
 %09%7D,%0A%09_toggle
@@ -1754,16 +1754,20 @@
 %0A%09%09%09for(
+ var
  eventEn

allow passing multiple classnames to class methods