var CSEmbedBlob = function(tk) {
    var oThis = this;

    this.token = tk;

    this.config = { }

    $(document).ready(function() {
        oThis.input = $('<input type="text" onclick="this.select()" size="80" />')
                          .css('width', '100%');

        oThis.window = ($('<div class="flora" />')
                            .append( $('<div>Copy the following JavaScript code and paste it into your web page:</div>') )
                            .append( $('<div />')
                                .append( oThis.input ) )
                       )
                       .attr('id', 'blobEmbedWindow')
                       .appendTo(document.body);

        var width = 550;
        var height = 150;
        var title = '';

        oThis.window.dialog({   buttons: { "Close": function() { oThis.window.dialog("close"); } },
                                autoOpen: false, 
                                modal: true,
                                overlay: { opacity: 0.3, background: "black" },
		    				    resizable: false,
			    			    height: height,
				    		    width: width,
				    		    title: 'Embed script'
		    			    });
    });
}

CSEmbedBlob.prototype.show = function(type, id) {
    var embedScript = '';

    if( type == 'S' ) {    //  Spectrum
        var w = 750;
        var h = 400;

        embedScript = '<script type="text/javascript" src="http://' + window.location.host + '/csjsapi.ashx?op=spec&tk=' + this.token + '&bid=' + id + '&w=' + w + '&h=' + h + '"></script>'
    }
    else if ( type == 'C' ) {    //  CIF
        var w = 500;
        var h = 500;

        embedScript = '<script type="text/javascript" src="http://' + window.location.host + '/csjsapi.ashx?op=cif&tk=' + this.token + '&bid=' + id + '&w=' + w + '&h=' + h + '"></script>'
    }

    this.input.attr('value', embedScript);

    this.window.dialog("open");
}

