if(typeof Splicd == "undefined") {
    
    splices = {};
    
    function onYouTubePlayerReady(playerId)
    {
        splice = splices[playerId];
                    
        splice.player = document.getElementById("splicd-" + playerId);
        splice.player.addEventListener("onStateChange", 'splices["' + playerId + '"].playerStateChange');
    }
    
    function startInterval(id, seconds)
    {
        return setInterval(function() {splices[id].checkYouTubePlayHead()}, seconds * 1000);
    }
    
    Splicd = function()
    {
        var defaults = { video_id: null, start: 0, end: 0 , autostart: false, width: 425, height: 344, unique_id: Math.floor((Math.random() * 100000)) };
        
        for(key in defaults)
            this[key] = arguments[0][key] || defaults[key];
                    
        this.video = 'http://www.youtube.com/v/' + this.video_id + '&amp;enablejsapi=1&amp;start=' + this.start + '&amp;playerapiid=' + this.unique_id;
        
        document.write('<div class="splicdVideo" style="width: ' + this.width + 'px;">'); /// rho removed margin-bottom: 10px;
            document.write('<object width="' + this.width + '" height="' + this.height + '" type="application/x-shockwave-flash" id="splicd-' + this.unique_id + '" data="' + this.video + '">');
                document.write('<param name="movie" value="' + this.video + '" />');
                document.write('<param name="allowScriptAccess" value="always" />');
                document.write('<param name="allowFullScreen" value="true" />');
            document.write('</object></div>'); /// rho added missing </div>
        
        splices[this.unique_id] = this;
    };
    
    Splicd.prototype =
    {
        playerStateChange: function(state)
        {
            if(state == 5 || state == 3)   
                this.splice = true;
                            
            if(state == 1)
                this.timer = startInterval(this.unique_id, 1);
                
            if(state == 2 || state == 0) 
                clearInterval(this.timer);
        },
        checkYouTubePlayHead: function()
        {
            var current = this.player.getCurrentTime();
                         
            if((current >= this.end) && this.splice) {
                this.player.seekTo(this.start, true);
                this.player.pauseVideo();
            }
            
            if(current > this.start)
                this.played = true;            
        },
        playAll: function()
        {
            this.splice = false;
            this.player.seekTo(0, true);
        },
        playSplice: function()
        {
            this.splice = true;
            this.player.seekTo(this.start, true);
        }
    }
}