classList fallback (IE & older browsers)
I'm not a big fan of neither the function name classes nor the parameter name type. Something like modifyClassOfElement and action would be better fitting. 

You should define constants for the type/action values.

It's convention in JavaScript to have a space between keywords and a following open bracket: if  (

In classIndex the second if is unnecessary. Just put return null; after the loop. Or, even better, you can replace the whole function with an .indexOf() call. 

Move if (type == "remove" || type == "toggle") { up one level so you don't need it twice. Alternatively I'd just drop the special case for a single class, as it's an tiny optimization that is hardly worth it.

Remove one level of brackets on the final else: 

else if (type == "add" || type == "toggle") {
  element.className += " " + targetClass;
}


I'd consider throwing an exception, if the type/action is unknown to aid debugging.

It would be nice for the function to use classList if it's available. Personnally I'd implement this as a function that returns an existing classList or an object that implements the same interface (DOMTokenList)