function isHostNetscapeCompatible() {return navigator.mimeTypes.length ? true : false;};

function isHostActiveXCompatible() { 
    return window.ActiveXObject ? true : false; 
};

createObject = function (mimeType, params){
    switch(mimeType) {
        case "video/quicktime":
            var obj = new QuickTime(mimeType, params);
            document.writeln(obj.toHTML());
            break;
        case "application/asx":
            var obj = new WindowsMediaPlayer(mimeType, params);
            document.writeln(obj.toHTML());
            break;
        case "video/vnd.rn-realvideo":    
            var obj = new WindowsMediaPlayer(mimeType, params);
            document.writeln(obj.toHTML());
            break;            
        case "application/x-shockwave-flash":
            var obj = new FlashPlugin(mimeType, params);
            document.writeln(obj.toHTML());
            break;
        case "application/x-java-bean":
            var obj = new JavaBeansPlugin(mimeType, params);
            document.writeln(obj.toHTML());
            break;        
        case "application/x-java-applet":
            var obj = new JavaAppletPlugin(mimeType, params);
            document.writeln(obj.toHTML());
            break;    
        case "application/x-director":            
            var obj = new ShockwaveDirectorPlugin(mimeType, params);
            document.writeln(obj.toHTML());
            break;            
        }
}

/** 
 * QuickTime plugin object
 *
 */
function QuickTime(mimeType, params) {
    this.mimeType = mimeType;
    this.params = params;
}


/**
 * generates HTML code for Quicktime plugin
 *
 */
QuickTime.prototype.toHTML = function () {
    
  htmlStr = "";
  htmlStr += '<object';
  htmlStr += ' type="' + this.mimeType + '"';
  htmlStr += ' border="' + this.params["border"] + '"';
  htmlStr += ' height="' + this.params["height"] + '"';
  htmlStr += ' width="' + this.params["width"] + '"';
  htmlStr += ' title="' +  this.params["alt"] + '"';
  htmlStr += ' codebase="' + this.params["codebase"] +'"';
  htmlStr += ' classid="' + this.params["classid"] + '"';
  htmlStr += ' style="visibility:' +  this.params["hidden"] + '"';
  htmlStr += '>';  

  htmlStr += '\n';   
  htmlStr += '<param name="src" value="' + this.params["src"] + '">\n';
  htmlStr += '<param name="cache" value="' + this.params["cache"] + '">\n';
  htmlStr += '<param name="autoplay" value="' + this.params["autoplay"] + '">\n';
  htmlStr += '<param name="controller" value="' + this.params["controller"] + '">\n';
  htmlStr += '<param name="loop" value="' + this.params["loop"] + '">\n';

  htmlStr += '<embed';
  htmlStr += ' src="' + this.params["src"] + '"';
  htmlStr += ' width="' + this.params["width"] + '"';
  htmlStr += ' height="' + this.params["height"] + '"'; 
  htmlStr += ' loop="' + this.params["loop"] + '"';
  htmlStr += ' autoplay="' + this.params["autoplay"] + '"';
  htmlStr += ' pluginspage="http://www.apple.com/quicktime/download/"';
  htmlStr += ' type="' + this.mimeType + '"';
  htmlStr += '></embed>';
  htmlStr += '</object>\n';
  
    return htmlStr;
}

/**
 * Windows Media Player object
 *
 */
function WindowsMediaPlayer(mimeType, params){
    this.mimeType = mimeType;
    this.params = params;    
}

/**
 * generates HTML code for Windows Media Player plugin
 *
 */
WindowsMediaPlayer.prototype.toHTML = function(){
    htmlStr = "";
    
    htmlStr += '<object name="' + this.params["name"] + '"'; 
    htmlStr += ' border="' + this.params["border"] + '"';
    htmlStr += ' type="' + this.mimeType + '"';
    if (isHostActiveXCompatible()){
        htmlStr += ' classid="' + this.params["classid"] + '"';
    }

    htmlStr += ' data="' + this.params["src"] + '" ';

    htmlStr += ' height="' + this.params["height"] + '"';
    htmlStr += ' width="' + this.params["width"] + '"';
    htmlStr += ' alt="' + this.params["alt"] + '"';
    htmlStr += ' title="' + this.params["alt"] + '"';
    htmlStr += '>\n'
    
    if(isHostActiveXCompatible()){
        htmlStr += '<param name="src" value="' + this.params["src"] + '">\n';
    }
    
    htmlStr += '<param name="URL" value="' + this.params["src"] + '">\n';
    htmlStr += '<param name="uiMode" value="full">\n';
    htmlStr += '</object>';
    return htmlStr;
}

/** 
 * FlashPlugin object
 *
 */
function FlashPlugin(mimeType, params){
    this.mimeType = mimeType;
    this.params = params;
}

/**
 * generates HTML code for Windows Media Player plugin
 *
 */
FlashPlugin.prototype.toHTML = function(){
    
    this.params["loop"] = (this.params["loop"] == "1") ? "true" : "false" ;
    this.params["play"] = (this.params["play"] == "1") ? "true" : "false" ;

    htmlStr = "";
    
    // special case for Flash Splash Screen component
    if (this.params["isSplashScreen"] == 'true')
    {
        htmlStr += '<object '; 

        htmlStr += ' type="application/x-shockwave-flash"' ;

        if (isHostActiveXCompatible()){
            htmlStr += ' codebase="' + this.params["codebase"] + '"'; 
            htmlStr += ' classid="' + this.params["classid"] + '"';
        }
        
    if(!isHostActiveXCompatible()){
      htmlStr += ' data="' + this.params["movie"] + '" ';
        }
    
        htmlStr += ' height="' + this.params["height"] + '"';
        htmlStr += ' width="' + this.params["width"] + '"';
        htmlStr += ' alt="' + this.params["alt"] + '"';
        htmlStr += ' title="' + this.params["alt"] + '"';   
        htmlStr += '>'
        
        htmlStr += '\n';
        htmlStr += '<param name="movie" value="' + this.params["movie"] + '"/>\n';
        htmlStr += '<param name="FlashVars" value="' + this.params["flashVars"] + '"/>\n';
        htmlStr += '</object>';
    }
    else
    {
        htmlStr += '<object name="' + this.params["name"] + '"'; 
        
        if (isHostActiveXCompatible()){
            htmlStr += ' codebase="' + this.params["codebase"] + '"'; 
        }
        
        htmlStr += ' type="application/x-shockwave-flash"' ;
        
        if (isHostActiveXCompatible()){
            htmlStr += ' classid="' + this.params["classid"] + '"';
        }
    
        if (!isHostActiveXCompatible()){
      htmlStr += ' data="' + this.params["src"] + '" ';
    }
    
        htmlStr += ' height="' + this.params["height"] + '"';
        htmlStr += ' width="' + this.params["width"] + '"';
        htmlStr += ' alt="' + this.params["alt"] + '"';
        htmlStr += ' title="' + this.params["alt"] + '"';
        htmlStr += '>'
        
        if(isHostActiveXCompatible()){
            htmlStr += '<param name="src" value="' + this.params["src"] + '">\n';
        }
        
        htmlStr += '\n';
        htmlStr += '<param name="movie" value="' + this.params["src"] + '"/>\n';
        htmlStr += '<param name="quality" value="' + this.params["quality"] + '"/>\n';
        htmlStr += '<param name="loop" value="' + this.params["loop"] + '"/>\n';     
        htmlStr += '<param name="scale" value="' + this.params["scale"] + '"/>\n';    
        htmlStr += '<param name="wmode" value="' + this.params["wmode"] + '"/>\n';
        htmlStr += '<param name="salign" value="' + this.params["salign"] + '"/>\n';
        htmlStr += '<param name="bgcolor" value="' + this.params["bgcolor"] + '"/>\n';

		htmlStr += '<embed';
		htmlStr += ' src="' + this.params["src"] + '"';
		htmlStr += ' quality="' + this.params["quality"] + '"';
		htmlStr += ' width="' + this.params["width"] + '"';
		htmlStr += ' height="' + this.params["height"] + '"'; 
		htmlStr += ' loop="' + this.params["loop"] + '"';
		htmlStr += ' play="' + this.params["play"] + '"';
		htmlStr += ' wmode="' + this.params["wmode"] + '"';
		htmlStr += ' salign="' + this.params["salign"] + '"';
		htmlStr += ' scale="' + this.params["scale"] + '"';
		htmlStr += ' bgcolor="' + this.params["bgcolor"] + '"';
		htmlStr += ' flashvars="' + this.params["flashVars"] + '"';
		htmlStr += ' pluginspage="http://www.macromedia.com/go/getflashplayer"';
		htmlStr += ' type="application/x-shockwave-flash"';
		htmlStr += '></embed>';   
    
        htmlStr += '</object>';
    }
    return htmlStr;
}

/**
 * JavaBeansPlugin object
 *
 */
function JavaBeansPlugin(mimeType, params){
    this.mimeType = mimeType;
    this.params = params;
}

/**
 * generates HTML code for the Java plugin
 *
 */
JavaBeansPlugin.prototype.toHTML = function(){
    htmlStr = "";
    
    htmlStr += '<object name="' + this.params["name"] + '"'; 
    htmlStr += 'id="' + this.params["name"] + '"';
    
    if (isHostActiveXCompatible()){
        htmlStr += ' codebase="' + this.params["pluginCodebase"] + '"'; 
    }
    
    htmlStr += ' type="' + this.params["type"] + '"'; 
    
    if (isHostActiveXCompatible()){
        htmlStr += ' classid="' + this.params["classid"] + '"';
    }

    htmlStr += ' archive="' + this.params["archive"] + '"';

    htmlStr += ' height="' + this.params["height"] + '"';
    htmlStr += ' width="' + this.params["width"] + '"';
    htmlStr += ' alt="' + this.params["alt"] + '"';
    
    if (this.params["isApplet"] == "true")
        htmlStr += ' title="' + this.params["alt"] + '"';
    
    htmlStr += '>\n'
    htmlStr += '<param name="code" value="' + this.params["code"] + '"/>\n';
    htmlStr += '<param name="archive" value="' + this.params["archive"] + '"/>\n';
    htmlStr += '<param name="scriptable" value="' + this.params["scriptable"] + '"/>\n'; //MAYSCRIPT
    htmlStr += '<param name="FiresScriptEvents" value="' + this.params["scriptEvents"] + '"/>\n';
    htmlStr += '<param name="codebase" value="' + this.params["appletCodebase"] + '"/>\n'; 
    htmlStr += '<param name="mayscript" value="' + this.params["mayscript"] + '"/>\n';    

    // process custom params
    subParams = this.params["customParams"].split(";");
    for (i = 0; i < subParams.length; i++){
        tempArray = subParams[i].split("|");
        htmlStr += '<param name="' + tempArray[0] + '" value="' + tempArray[1] + '"/>\n';
    }
    
    htmlStr += '</object>';
    return htmlStr;    
    
}


function JavaAppletPlugin(mimeType, params){
    this.mimeType = mimeType;
    this.params = params;
}

/**
 * generates HTML code for the Java Applet plugin
 *
 */
JavaAppletPlugin.prototype.toHTML = function(){
    htmlStr = "";
    
    htmlStr += '<object name="' + this.params["name"] + '"'; 
    htmlStr += ' id="' + this.params["name"] + '"';
    
    if (isHostActiveXCompatible()){
        htmlStr += ' codebase="' + this.params["pluginCodebase"] + '"'; 
    }
    
    htmlStr += ' type="' + this.params["type"] + '"'; 
    
    if (isHostActiveXCompatible()){
        htmlStr += ' classid="' + this.params["classid"] + '"';
    }

    htmlStr += ' archive="' + this.params["archive"] + '"';

    htmlStr += ' height="' + this.params["height"] + '"';
    htmlStr += ' width="' + this.params["width"] + '"';
    htmlStr += ' alt="' + this.params["alt"] + '"';
    
    if (this.params["isApplet"] == "true")
        htmlStr += ' title="' + this.params["alt"] + '"';
    
    htmlStr += '>\n'

    htmlStr += '<param name="code" value="' + this.params["code"] + '"/>\n';
    htmlStr += '<param name="codebase" value="' + this.params["appletCodebase"] + '"/>\n'; 
    htmlStr += '<param name="archive" value="' + this.params["archive"] + '"/>\n';
    // process custom params
    subParams = this.params["customParams"].split(";");

    if (subParams.length > 0){    
        for (i = 0; i < subParams.length; i++){
            if (subParams[i] != "" || subParams[i] != ''){
                tempArray = subParams[i].split("|");
                htmlStr += '<param name="' + tempArray[0] + '" value="' + tempArray[1] + '"/>\n';
            }    
        }
    }
    
    htmlStr += '</object>';
    return htmlStr;    
    
}


function ShockwaveDirectorPlugin(mimeType, params){
    this.mimeType = mimeType;
    this.params = params;
}

/**
 * generates HTML code for the Shockwave Director plugin
 *
 */
ShockwaveDirectorPlugin.prototype.toHTML = function(){
    htmlStr = "";
    
    htmlStr += '<object name="' + this.params["name"] + '"'; 
    htmlStr += ' id="' + this.params["name"] + '"';
    
    if (isHostActiveXCompatible()){
        htmlStr += ' codebase="' + this.params["pluginCodebase"] + '"'; 
    }
    
    htmlStr += ' type="' + this.mimeType + '"'; 
    
    if (isHostActiveXCompatible()){
        htmlStr += ' classid="' + this.params["classid"] + '"';
    }
    
    htmlStr += ' data="' + this.params["src"] + '" ';
    htmlStr += ' height="' + this.params["height"] + '"';
    htmlStr += ' width="' + this.params["width"] + '"';
    htmlStr += ' alt="' + this.params["alt"] + '"';
    
    if (this.params["isApplet"] == "true")
        htmlStr += ' title="' + this.params["alt"] + '"';
    
    htmlStr += '>\n'

    htmlStr += '<param name="src" value="' + this.params["src"] + '"/>\n'; 
    htmlStr += '<param name="codebase" value="' + '.' + '"/>\n';     
    htmlStr += '<param name="swURL" value="' + this.params["swURL"] + '"/>\n';
    htmlStr += '<param name="swText" value="' + this.params["swText"] + '"/>\n';
    htmlStr += '<param name="swColor" value="' + this.params["swColor"] + '"/>\n';
    htmlStr += '<param name="swForeColor" value="' + this.params["swForeColor"] + '"/>\n';
    htmlStr += '<param name="swBackColor" value="' + this.params["swBackColor"] + '"/>\n';
    htmlStr += '<param name="swFrame" value="' + this.params["swFrame"] + '"/>\n';
    htmlStr += '<param name="swName" value="' + this.params["swName"] + '"/>\n';
    htmlStr += '<param name="swPassword" value="' + this.params["swPassword"] + '"/>\n';
    htmlStr += '<param name="swBanner" value="' + this.params["swBanner"] + '"/>\n';
    htmlStr += '<param name="swSound" value="' + this.params["swSound"] + '"/>\n';
    htmlStr += '<param name="swPreload" value="' + this.params["swPreload"] + '"/>\n';
    htmlStr += '<param name="swVolume" value="' + this.params["swVolume"] + '"/>\n';
    htmlStr += '<param name="swList" value="' + this.params["swList"] + '"/>\n';
    
    htmlStr += '<param name="SW1" value="' + this.params["sw1"] + '"/>\n';
    htmlStr += '<param name="SW2" value="' + this.params["sw2"] + '"/>\n';
    htmlStr += '<param name="SW3" value="' + this.params["sw3"] + '"/>\n';
    htmlStr += '<param name="SW4" value="' + this.params["sw4"] + '"/>\n';
    htmlStr += '<param name="SW5" value="' + this.params["sw5"] + '"/>\n';
    htmlStr += '<param name="SW6" value="' + this.params["sw6"] + '"/>\n';
    htmlStr += '<param name="SW7" value="' + this.params["sw7"] + '"/>\n';
    htmlStr += '<param name="SW8" value="' + this.params["sw8"] + '"/>\n';
    htmlStr += '<param name="SW9" value="' + this.params["sw9"] + '"/>\n';
    
    htmlStr += '</object>';

    return htmlStr;    
    
}
