/*
 * gfyCollection:
 * Global object to be called on page load.
 * This runs through the page DOM for elements
 * with class "gfyitem" and attempts to convert
 * them to gfycat embeds by creating a new
 * gfyObject with the element.
 * Can also be used _after_ page load
 * by calling gfyCollection.get() to get
 * the collection of gfycat objects on the page
 * and re-initialize them or interact with them
 * as desired.
 */
var gfyCollection = function () {

    var collection = [];

    // Helper function -- only required because some browsers do not have get by class name
    function byClass(className, obj) {

        if (obj.getElementsByClassName) {
            return obj.getElementsByClassName(className);
        } else {
            var retnode = [];
            var elem = obj.getElementsByTagName('*');
            for (var i = 0; i < elem.length; i++) {
                if ((' ' + elem[i].className + ' ').indexOf(' ' + className + ' ') > -1) retnode.push(elem[i]);
            }
            return retnode;
        }
    }

    function init() {
        scan();
    }

    function scan() {
        // this can be run multiple times, so we'll add to any existing gfycats
        var last = collection.length;
        // find each gfycat on page and run its init
        elem_coll = byClass("gfyitem", document);
        for (var i = 0; i < elem_coll.length; i++) {
            // don't need to worry about finding existing gfyitems - they are
            // replaced by gfyObject
            var gfyObj = new gfyObject(elem_coll[i]);
            collection.push(gfyObj);
        }
        // run init _after_ all are collected, because the init function deletes and recreates
        for (var i = last; i < collection.length; i++) {
            collection[i].init();
        }
    }

    function get() {
        // optional interface for an external script to interact with all objects on a page
        return collection;
    }

    return {
        init: init,
        get: get,
        scan: scan
    }

}();

@@ -129,19 +129,42 @@
 fyitem%22 
-and
+or class passed in and%0A * 
  attempt
@@ -175,20 +175,16 @@
  convert
-%0A * 
 them to 
@@ -199,16 +199,20 @@
 mbeds by
+%0A * 
  creatin
@@ -216,17 +216,13 @@
 ting
- 
 a new
-%0A *
  gfy
@@ -283,19 +283,16 @@
 age load
-%0A *
  by call
@@ -294,16 +294,19 @@
  calling
+%0A *
  gfyColl
@@ -324,19 +324,16 @@
 ) to get
-%0A *
  the col
@@ -339,16 +339,19 @@
 llection
+%0A *
  of gfyc
@@ -372,19 +372,16 @@
 the page
-%0A *
  and re-
@@ -390,16 +390,19 @@
 itialize
+%0A *
  them or
@@ -420,19 +420,16 @@
 ith them
-%0A *
  as desi
@@ -495,16 +495,46 @@
 ion = %5B%5D
+,%0A        gfyClass = %22gfyitem%22
 ;%0A%0A    /
@@ -1102,16 +1102,25 @@
 on init(
+classname
 ) %7B%0A    
@@ -1127,44 +1127,206 @@
     
-scan();%0A    %7D%0A%0A    function scan() %7B
+classname = typeof classname===%22string%22 ? classname : gfyClass;%0A        scan(classname);%0A    %7D%0A%0A    function scan(classname) %7B%0A        classname = typeof classname===%22string%22 ? classname : gfyClass;
 %0A   
@@ -1521,25 +1521,25 @@
 byClass(
-%22gfyitem%22
+classname
 , docume

Accept an alternate class name