/****************************************************************************************************
 * Radio.blog Tools : Detach Button
 * detach.js
 * 30.05.2006
 * Version : 0.2
 * Author : astro @ mubility
 * Blog : blog.mubility.com
 ****************************************************************************************************/

// ======= DETACH BUTTON =============================================================================
RadioBlog.detach = {
    text: 'Detach Radio.blog',
    save: '',
    position: 'after',
    
    start: function() {
        var div = document.createElement("div");
        div.innerHTML = '<a href="javascript:RadioBlog.detach.popup('+RadioBlog.id+');">'+RadioBlog.detach.text+'</a>';
        if (RadioBlog.detach.position == 'after') {
            RadioBlog.div.parentNode.insertBefore(div,RadioBlog.div.nextSibling);
        }
        else {
            RadioBlog.div.parentNode.insertBefore(div,RadioBlog.div);
        }
        //RadioBlog.where.appendChild(div);
    },

    popup: function(id) {
            var obj = document.getElementById('radioblog_'+id);
            var width = obj.offsetWidth;
            var height = obj.offsetHeight;
    	    RadioBlog.detach.save = obj.innerHTML;
    	    RadioBlog.width = '100%';
    	    RadioBlog.height = '100%';
            var popupWin = window.open('','radioblog_popup','width='+(parseInt(width))+',height='+(parseInt(height))+',toolbar=no,scrollbars=no,resizable=yes');
            popupWin.document.write('<html><head><title>'+RadioBlog.title+'</title></head>'
                                    +'<body onbeforeunload="window.opener.RadioBlog.detach.close('+id+')" style="background:'+RadioBlog.color.body+'">'+RadioBlog.createPlayer()+'</body></html>');
            popupWin.document.close();
            obj.innerHTML = '';
    },

    close: function(id) {
            var obj = document.getElementById('radioblog_'+id);
    	    obj.innerHTML = RadioBlog.detach.save;
    }
}