(function(window, document, version, callback) { // http://stackoverflow.com/questions/2170439/how-to-embed-javascript-widget-that-depends-on-jquery-into-an-unknown-environmen
    var j, d;
    var loaded = false;
    if (!(j = window.jQuery) || version > j.fn.jquery || callback(j, loaded)) {
        var script = document.createElement("script");
        script.type = "text/javascript";
        script.src = "http://code.jquery.com/jquery-1.9.1.min.js";
        script.onload = script.onreadystatechange = function() {
            if (!loaded && (!(d = this.readyState) || d == "loaded" || d == "complete")) {
                callback((j = window.jQuery).noConflict(1), loaded = true);
                j(script).remove();
            }
        };
        document.documentElement.childNodes[0].appendChild(script)
    }
})(window, document, "1.3", function($, jquery_loaded) {
    $(document).ready(function () {
        var SOUNDCITE_CONFIG = {
            update_playing_element: function(el, percentage) {
                $(el).css({
                    'background' : '-webkit-linear-gradient(left, rgba(0,0,0,.15)' + percentage + '%, rgba(0,0,0,.05)' + (percentage + 1) + '%)',
                    'background' : 'linear-gradient(to right, rgba(0,0,0,.15)' + percentage + '%, rgba(0,0,0,.05)' + (percentage + 1) + '%)'
                });
            },
            // Use google analytics, set to false for no tracking
            use_analytics: true
        };
        $.extend(SOUNDCITE_CONFIG, window.SOUNDCITE_CONFIG)
  
        // add google analytics
        var _gaq = _gaq || [];
        if(SOUNDCITE_CONFIG.use_analytics) {            
            _gaq.push(
                function() {
                    var pageTracker = _gat._createTracker('UA-34830490-1', 'soundciteTracker');
                 },
                ['soundciteTracker._setDomainName', 'knightlab.com']
                ['soundciteTracker._setAllowLinker', true], 
                ['soundciteTracker._trackPageview']
            );
            (function() {
                var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
            })();
        }

        // global vars
        window.soundcite = {};

        var start;
        var end;
        var clips = [];
        
        // initialize SoundCloud SDK
        SC.initialize({
            client_id: "5ba7fd66044a60db41a97cb9d924996a",
        });

        // borrowing underscore.js bind function
        var bind = function(func, context) {
            var slice = Array.prototype.slice;
            var args = slice.call(arguments, 2);
            return function() {
              return func.apply(context, args.concat(slice.call(arguments)));
            };
        };

        // create clip constructor
        function Clip(el) {
            this.el = el;
            this.$el = $(this.el);
            this.id = el.attributes['data-id'].value;
            this.start = el.attributes['data-start'].value;
            this.end = el.attributes['data-end'].value;
            this.playing = false;
            this.times_played = 0;
            SC.stream(this.id,bind(function(sound) {
                this.sound = sound;
                sound.load({
                    onload: bind(this.sound_loaded, this)
                });
            }, this));
        };

        //clip methods
        Clip.prototype.sound_loaded = function() {
            this.$el.click(bind(this.click_handler, this));
            this.$el.addClass('soundcite-loaded soundcite-play');
        }

        Clip.prototype.click_handler = function() {
            //check for other playing clips and stop them
            for (i=0; i<clips.length; i++) {
                if (this.el !== clips[i].el) {
                    clips[i].sound.stop();
                    clips[i].playing = false;
                    clips[i].sound.setPosition(clips[i].start);
                    $(clips[i].el).removeClass('soundcite-pause');
                    $(clips[i].el).addClass('soundcite-play');
                }
            }

            if (!this.playing) {
                this.play_clip();
            }
            else {
                this.pause_clip();
            }
        }

        Clip.prototype.play_clip = function() {
            if (this.times_played == 0 || this.sound.position > this.end) {
                this.sound.setPosition(this.start);
            }
            if (this.times_played > 0) {
                this.sound.setPosition(this.sound.position);
            }

            this.$el.removeClass('soundcite-play');
            this.$el.addClass('soundcite-pause');

            this.sound.play({
                whileplaying: bind(function() {
                    this.track_progress();

                    if (this.sound.position > this.end) {
                        this.$el.removeClass('soundcite-pause');
                        this.$el.addClass('soundcite-play');
                        // this.$el.css({
                        //     'background': 'rgba(0,0,0,.05)'
                        // })
                        this.sound.stop();
                        this.playing = false;
                    }
                }, this),
            });
            this.playing = true;
            this.times_played++;
            
            // track play event
            if(SOUNDCITE_CONFIG.use_analytics) {
                _gaq.push(['soundciteTracker._trackEvent', 'soundcite', 'play', 'soundcloud:'+this.id]); 
            }
        }

        Clip.prototype.pause_clip = function() {
            this.$el.removeClass('soundcite-pause');
            this.$el.addClass('soundcite-play');
            this.playing = false;
            this.sound.pause();
            // track play event
            if(SOUNDCITE_CONFIG.use_analytics) {
                _gaq.push(['soundciteTracker._trackEvent', 'soundcite', 'pause', 'soundcloud:'+this.id]); 
            }
        }

        Clip.prototype.track_progress = function() {
            var totalTime = this.end - this.start;
            var position = this.sound.position;
            var relative_position = position - this.start;
            var percentage = (relative_position / totalTime) * 100
            SOUNDCITE_CONFIG.update_playing_element(this.el, percentage);
        }

        // set up clips array
        var soundcite_array = $('.soundcite');
        for (i = 0; i < soundcite_array.length; i++) {
            clips.push(new Clip(soundcite_array[i]));
        }
        soundcite.Clip = Clip;
    });
});

@@ -1357,107 +1357,9 @@
    %7D
-,%0A            // Use google analytics, set to false for no tracking%0A            use_analytics: true
+%0A
 %0A   
@@ -1356,33 +1356,32 @@
     %7D%0A%0A        %7D
-;
 %0A        $.exten
@@ -1429,888 +1429,8 @@
 IG)%0A
-  %0A        // add google analytics%0A        var _gaq = _gaq %7C%7C %5B%5D;%0A        if(SOUNDCITE_CONFIG.use_analytics) %7B            %0A            _gaq.push(%0A                function() %7B%0A                    var pageTracker = _gat._createTracker('UA-34830490-1', 'soundciteTracker');%0A                 %7D,%0A                %5B'soundciteTracker._setDomainName', 'knightlab.com'%5D%0A                %5B'soundciteTracker._setAllowLinker', true%5D, %0A                %5B'soundciteTracker._trackPageview'%5D%0A            );%0A            (function() %7B%0A                var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;%0A                ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';%0A                var s = document.getElementsByTagName('script')%5B0%5D; s.parentNode.insertBefore(ga, s);%0A            %7D)();%0A        %7D%0A%0A
     
@@ -1540,24 +1540,16 @@
 s = %5B%5D;%0A
-        
 %0A       
@@ -4558,222 +4558,8 @@
 ++;%0A
-            %0A            // track play event%0A            if(SOUNDCITE_CONFIG.use_analytics) %7B%0A                _gaq.push(%5B'soundciteTracker._trackEvent', 'soundcite', 'play', 'soundcloud:'+this.id%5D); %0A            %7D%0A
     
@@ -4786,210 +4786,8 @@
 ();%0A
-            // track play event%0A            if(SOUNDCITE_CONFIG.use_analytics) %7B%0A                _gaq.push(%5B'soundciteTracker._trackEvent', 'soundcite', 'pause', 'soundcloud:'+this.id%5D); %0A            %7D%0A
     

remove analytics from master branch until we make sure they work