/**
 * Generates a browser-specific shockwave tag. Create a new instance, set whatever
 * properties you need, then call either toString() to get the tag as a string, or
 * call write() to write the tag out.
 */

/**
 * Creates a new instance of the dcrobject.
 * src: The path to the dcr file.
 * width: The width of your dcr content.
 * height: the height of your dcr content.
 */
function DcrObject(src, width, height)
{
    this.src       			= src;
    this.width     			= width;
    this.height    			= height;
    this.version   			= '7,0,0,0';
    this.id        			= null;
	this.swStretchStyle 	= null;
	this.swRemote			= null; 
	this.bgColor			= null;	
}

/**
 * Sets the version used in the DcrObject.
 */
DcrObject.prototype.setVersion = function(v)
{
    this.version = v;
}

/**
 * Sets the ID used in the DcrObject.
 */
DcrObject.prototype.setId = function(id)
{
    this.id = id;
}

/**
 * Sets the swStretchStyle used in the DcrObject.
 */
DcrObject.prototype.setSwStretchStyle = function(s)
{
    this.swStretchStyle = s;
}
/**
 * Sets the swRemote used in the DcrObject.
 */
DcrObject.prototype.setSwRemote = function(s)
{
    this.swRemote = s;
}
/**
 * Sets the bgColor used in the DcrObject.
 */
DcrObject.prototype.setBgColor = function(s)
{
    this.bgColor = s;
}


/**
 * Get the DcrObject as a string. 
 */
 
DcrObject.prototype.toString = function()
{
    var ie = (navigator.appName.indexOf ("Microsoft") != -1) ? 1 : 0;
    var dcrobject = new String();
    if (ie)
    {
        dcrobject += '<object classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000" ';
        if (this.id != null)
        {
            dcrobject += 'id="'+this.id+'" ';
        }
        dcrobject += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version='+this.version+'" ';
        dcrobject += 'width="'+this.width+'" ';
        dcrobject += 'height="'+this.height+'">';
        dcrobject += '<param name="src" value="'+this.src+'"/>';

        if (this.swStretchStyle != null)
        {
       		dcrobject += '<param name="swStretchStyle" value="'+this.swStretchStyle+'"/>';
        }
        if (this.swRemote != null)
        {
        	dcrobject += '<param name="swRemote" value="'+this.swRemote+'"/>';
        }
        if (this.bgColor != null)
        {
        	dcrobject += '<param name="bgColor" value="'+this.bgColor+'"/>';
        }
		
        dcrobject += '</object>';
    }
    else
    {
        dcrobject += '<embed src="'+this.src+'" ';
        dcrobject += 'width="'+this.width+'" ';
        dcrobject += 'height="'+this.height+'" ';
        if (this.id != null)
        {
            dcrobject += 'name="'+this.id+'" ';
        }
		if (this.swStretchStyle != null)
        {
       		dcrobject += 'swStretchStyle="'+this.swStretchStyle+'" ';
        }
        if (this.swRemote != null)
        {
        	dcrobject += 'swRemote="'+this.swRemote+'" ';
        }
        if (this.bgColor != null)
        {
        	dcrobject += 'bgColor="'+this.bgColor+'" ';
        }
        dcrobject += 'TYPE="application/x-director" pluginspage="http://www.macromedia.com/shockwave/download/">';
        dcrobject += '</embed>';
    }
    return dcrobject;
}

/**
 * Write the shockwave tag out. Pass in a reference to the document to write to. 
 */
DcrObject.prototype.write = function(doc)
{
    doc.write(this.toString());
}

