﻿
/*
 * EmbedHandler embed player (music, video) 
 *     and AppletHandler applet player
 *
 * This is (c) 2007 Spiderweb Logic 
 *  http://www.spiderweblogic.com
 */
 
// PURPOSE:set  attributes 
function setObjAttribute(attr,value)
{
  this.attributes[attr.toLowerCase()]=value;
}
function getObjAttribute(param) {
	return this.attributes[param] || "";
}

//PURPOSE: set parameters 
function setObjParam(param,value)
{
  this.params[param.toLowerCase()]=value;
}
function getObjParam(param) {
	return this.params[param] || "";
}

//PURPOSE:writing obj as HTML
function writeObjToId(ele)
{ 
  if (document.getElementById && document.getElementById(ele)) {
    document.getElementById(ele).innerHTML=this.html(); 
  }   
}




/*
 * EmbedHandler embed player
 */

//making embed tag
function embedHtml()
{ 
    var embedTag="<embed ";    
    for(var key in this.attributes)
    {    
     embedTag += [key] +'="'+ this.attributes[key] +'" ';
    }      
    embedTag+="></embed>";  
    if (this.noEmbed!="") {
       embedTag+="<noembed>" + this.noEmbed + "</noembed>";
    }
    return embedTag;
}

//set html to display if embed is not supported
function setNoEmbed(value) {
   this.noEmbed = value;
}

function EmbedHandler(filename,width,height)
{
  this.attributes=new Array();
  this.attributes["src"]=filename; 
  this.attributes["width"]=width;  
  this.attributes["height"]=height; 
 
  this.getAttribute=getObjAttribute;
  this.setAttribute=setObjAttribute;
  this.writeToId=writeObjToId;
  this.html=embedHtml;   
  this.setNoEmbed=setNoEmbed;  
  
  this.noEmbed = "";
}


/*
 * AppletHandler embed player
 */

//PURPOSE:making applet tag
function appletHtml()
{ 
    var appletTag='<applet ';    
    for(var key in this.attributes)
    {    
     appletTag += [key] +'="'+ this.attributes[key] +'" ';
    }      
    appletTag+=">"; 
    for(var name in this.params)
    {    
      var paramTag='<param name="'+[name] +'" value="' + this.params[name] +'" />';
      appletTag+=paramTag;
    }  
    appletTag+=this.altHTML;
    appletTag+='</applet>';
    
    return appletTag;
}

//PURPOSE:set alternate html for applet
function setAlternateHtml(value)
{ 
  this.altHTML=value;
}

//PURPOSE:Javascript Object should be below all methods referenced
function AppletHandler(archive,code,width,height)
{
  this.attributes=new Array();
  this.attributes["archive"]=archive; 
  this.attributes["code"]=code; 
  this.attributes["width"]=width;  
  this.attributes["height"]=height; 
   
  this.params=new Array();  
  this.setAttribute=setObjAttribute;
  this.getAttribute=getObjAttribute;  
  this.setParam=setObjParam;
  this.getParam=getObjParam;
  this.writeToId=writeObjToId;
  this.html=appletHtml;   
  this.setAlternateHtml=setAlternateHtml;    
  this.altHTML="";  
}




