// JavaScript Document
/*******************************************************************************
	Filename		: swf_embed2.js

	Created			: 12 December 2007 (09:35:47)
	Created by		: Markus Sommerfeld
	Company		    : Charamel GmbH

	Comments		: Write a Flash object in HTML-Site 
*******************************************************************************/	
//swfEmbed('flash','{#shop_page#}','622','210','','','','','');


/****** Properties ***
WIDTH           = ( PX or % ) Flash Object width
HEIGHT          = ( PX or % ) Flash Object height

/****** Parameters ***
QUALITY         = ( Low, high, autolow, autohigh, best ) / Quality of Flash-Object
LOOP            = ( true / false ) Repeat Flash-Object or only once. 
PLAY            = ( true / false ) Automatic Start of animation, or not , when page is loaded.
BGCOLOR         = (bsp:#FF0000 ) / Animation's background color. 
SCALE           = (Showall, noborder, exactfit) Animation's resizing definition.
MENU            = ( true / false ) / Type of context menu over the animation. 
WMODE           = (	Window, opage, transparent )
*********************/


function swfEmbed(divLayerID,scrFile,scrWidth,scrHeight)
{
    // Vars
    this.divLayerID  = divLayerID;
    this.scrFile     = scrFile;
    this.scrWidth    = scrWidth;
    this.scrHeight   = scrHeight;
    
    this.flashVar    ="";
    
    this.sObject     = "";
    this.sObjectPara = "";
    this.sObjectVar  = "";
    
    this.sEmbed      = "";
    this.sEmbedPara  = "";
    this.sEmbedVar   = "";

    // METHODs
    this.addParameter = addParameter;
    this.createObject = createObject;
    this.createEmbed  = createEmbed;
    this.addVariable  = addVariable;
    this.write = write;
}
    
    function addParameter(paraName,paraValue)
    {
        this.sObjectPara += "<param name='" + paraName + "' value='" + paraValue + "' />";
        this.sEmbedPara  += paraName + "='" + paraValue + "' ";
    }
    
    function addVariable(varName,varValue)
    {
        if (varName!="")
            var andS = "=";
        else
            var andS = "";
    
        if (this.flashVar=="")
            this.flashVar += varName + andS + varValue;
        else
            this.flashVar += "%26"+ varName + andS + varValue;
    }
    
    function createObject()
    {
        this.sObject    +="<object ";
        this.sObject    +=" classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' ";
        this.sObject    +=" codebase='https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' ";
        this.sObject    +=" width='" + this.scrWidth + "' ";
        this.sObject    +=" width='" + this.scrWidth + "' ";
        this.sObject    +=" height='" + this.scrHeight + "' ";
        this.sObject    +="> ";
        this.sObject    +="<param name='movie' value='" + this.scrFile +"' />";
        
        if (this.flashVar!="")
            this.sObject    +="<param name='FlashVars' value='" + this.flashVar + "' />";
            
        this.sObject    += this.sObjectPara;
    }
    
    function createEmbed()
    {
        this.sEmbed     += "<embed ";
        this.sEmbed     += " pluginspage='https://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' ";
        this.sEmbed     += " type='application/x-shockwave-flash' ";
        //this.sEmbed     += " src='"+ this.scrFile + this.sVar +"' ";
        this.sEmbed     += " src='"+ this.scrFile + "' ";
        
        if (this.flashVar!="")
            this.sEmbed     += " FlashVars='" + this.flashVar + "'";
        
        this.sEmbed     += " width='" + this.scrWidth + "' ";
        this.sEmbed     += " height='" + this.scrHeight + "' ";
        this.sEmbed     += this.sEmbedPara;
        this.sEmbed     += " > ";
    }
    
    function write()
    {
        //alert(this.flashVar);
        this.createObject();
        this.createEmbed();
        var swfObject = this.sObject + this.sEmbed;
        swfObject += "<\/object>";
        //alert(swfObject);
        document.getElementById(this.divLayerID).innerHTML = swfObject;
    } 
