/****************************************************************************************************
 * Radio.blog Tools : Embed Button
 * radioblog.embed.js
 * 12.10.2007
 * Version : 1.0
 * Author : astro @ mubility
 * Blog : blog.mubility.com
 * Description : Display a button to embed a Radio.blog
 ****************************************************************************************************/

// ======= SHARE BUTTON =========================================================================================================================
RadioBlog.embed = {
    text: { 
        open: 'Embed This Radio.blog', 
        close: 'Copy and paste this code. (Close)' 
    },
    div: '',
    position: 'after',
    color: {
        background: '#FFFFFF',
        border: '#CCCCCC',
        text: '#999999'
    },
    
    start: function() {
        var a = document.createElement("a");
        a.style.display = 'block';
        a.style.cursor = 'pointer';
        a.style.fontFamily = 'arial';
        a.style.fontSize = '10px';
        a.style.color = this.color.text;
        a.style.background = this.color.body;
        a.style.border = 'solid 1px '+this.color.border;
        a.style.width = RadioBlog.width;
        a.style.height = '12px';
        a.style.marginTop = '5px';
        a.style.textAlign = 'center';
        a.innerHTML = this.text.open;
        a.onclick = new Function('RadioBlog.embed.open(RadioBlog.id);');
        if (RadioBlog.embed.position == 'after') {
            RadioBlog.div.parentNode.insertBefore(a,RadioBlog.div.nextSibling);
        }
        else {
            RadioBlog.div.parentNode.insertBefore(a,RadioBlog.div);
        }
    },

    oldshow: function(id) {},
    
    open: function(id) {
        var rb = document.getElementById('radioblog_'+id);
        var html = rb.innerHTML;
        rb.style.visibility = 'hidden';
    
        this.div = document.createElement('div');
        this.div.style.display = 'none';
        this.div.style.position = 'absolute';
        this.div.zIndex = '999';
        this.div.style.fontFamiliy = 'arial';
        this.div.style.fontSize = '10px';
        this.div.style.color = RadioBlog.color.playlist_text;
        this.div.style.width = parseInt(RadioBlog.width)+'px';
        this.div.style.height = parseInt(RadioBlog.height)+'px';
        this.div.style.overflow = 'hidden';

        textarea = document.createElement('textarea');
        textarea.style.margin = '0px';
        textarea.style.width = (parseInt(RadioBlog.width)-2)+'px';
        textarea.style.height = (parseInt(RadioBlog.height)-14)+'px';
        textarea.style.fontSize = '12px';
        textarea.style.borderWidth = '1px';
        textarea.style.borderStyle = 'solid';
        textarea.style.borderColor = RadioBlog.color.border;
        textarea.style.overflow = 'hidden';
        textarea.style.background = RadioBlog.color.body;
        textarea.value = RadioBlog.createPlayer();
        textarea.onclick = new Function('this.focus();this.select();');

        var a = document.createElement("a");
        a.style.cursor = 'pointer';
        a.style.fontFamily = 'arial';
        a.style.fontSize = '10px';
        a.innerHTML = this.text.close;
        a.onclick = new Function('RadioBlog.embed.close('+id+');');

        this.div.appendChild(textarea);
        this.div.appendChild(a);
        rb.parentNode.insertBefore(this.div,rb);
    
        this.div.style.display = 'block';
        this.oldopen = this.open;
        this.open = this.close;
    },
    
    close: function(id) {
        RadioBlog.embed.div.style.display = 'none';
        var rb = document.getElementById('radioblog_'+id);
        rb.style.visibility = 'visible';
        this.open = this.oldopen;
    }
}
