//<![CDATA[

/* Version 1.0.1
 * Copyright (c) 2007 True Partners, LLC (wearetrue.com)
 *
 * 19 jan 2007 09:06
 * 
 * requires True core v1.1
 */
 
if(window.True.SWF == undefined)
{
    Type.register("True.SWF",
        function(src, id, c){
	        this.id = id;
	        this.src = src;
			c = c || {};
	        this.params = c.params || {};
	        this.variables = c.variables || {};
	        this.attributes = c.attributes || {};
	        this.params.quality = this.params.quality || "high";
	        this.attributes.width = this.attributes.width || "100%";
	        this.attributes.height = this.attributes.height || "100%";
        }
     );
     
    True.SWF.prototype = {
	    setVariable: function(name, value){
	        if(!this.getMovie()){
		        this.variables[name] = value;
		    }
		    else{
		        this.getMovie().SetVariable(name, value);
		    }
	    },
	    getVariablePairs: function(){
		    var vps = [];
		    for(var key in this.variables){
			    vps.push(key +"="+ this.variables[key]);
		    }
		    return vps;
	    },
	    getSWFHTML: function() {
		    var swfNode = "";
		    var pairs = this.getVariablePairs().join("&");
		    if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
		        swfNode = "<embed type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" src=\""+ this.src + "\" width=\"" + this.attributes.width + "\" height=\"" + this.attributes.height + "\"";
			    swfNode += " id=\"" + this.id +"\" name=\"" + this.id + "\" ";
			    for(var key in this.params){ swfNode += key + "=\"" + this.params[key] + "\" "; }
			    if (pairs.length > 0){ swfNode += "flashvars=\""+ pairs + "\""; }
			    swfNode += "/>";
		    } else { // PC IE
			    swfNode = "<object id=\""+ this.id + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+ this.attributes.width + "\" height=\"" + this.attributes.height +"\">";
			    swfNode += "<param name=\"movie\" value=\""+ this.src + "\" />";
			    for(var key in this.params) {swfNode += "<param name=\"" + key + "\" value=\"" + this.params[key] + "\" />";}
			    if(pairs.length > 0) {swfNode += "<param name=\"flashvars\" value=\"" + pairs + "\" />";}
			    swfNode += "</object>";
		    }
		    return swfNode;  
	    },
	    create: function(target){
		    var t = (typeof target == 'string') ? $("#" + target).get(0) : target;
		    t.innerHTML = this.getSWFHTML();
		    return true;
	    },
	    getMovie : function(){
	        if(!this.movie){this.movie = $("#" + this.id).get(0); }
	        return this.movie;
	    },
	    setJSON : function(data){
	        if((data instanceof Object)){this.setVariable("JSONData", Object.toJSON(data));}
	    }
    }
}
//]]>