var Viewer = new Class({
	initialize: function(rootPath, initialXML, elements)
	{
		this.rootPath = rootPath;
		this.canvas = $(elements.canvas);
		this.canvasParent = $(elements.canvasParent);
		this.renderXML(initialXML, true);
	},
	
	renderXML: function(xmlString, animate)
	{
		var flashvars = {flowXML:xmlString, animate: animate ? 1 : 0, baseURL: this.rootPath, applicationMode: "normal"};
				
		swfobject.embedSWF(this.rootPath+"static/main.swf", this.canvas.id, "700", "600", "9.0.0", null, flashvars, {},	{'allowScriptAccess':'always'});		
		if ( this.canvasParent.focus )
			this.canvasParent.focus();
	}
});

Viewer.renderEmbed = function(xmlString, baseURL, viewURL)
{
	flashvarsValue = createFlashVars({flowXML:xmlString, baseURL:baseURL, embedded: 1, viewURL: viewURL});
	flashvarsTag = '<param name="flashvars" value="' + flashvarsValue + '"/>';
	var html = '<object width="425" height="375" type="application/x-shockwave-flash" allowscriptaccess="always" data="http://www.productplanner.com/static/main.swf" style="visibility: visible;">';
	html += flashvarsTag;
	html += '</object>';
	return html;
}

var ViewerThumbnail = new Class({
	initialize: function(rootPath, initialXML, elements)
	{
		this.rootPath = rootPath;
		this.canvas = $(elements.canvas);
		this.canvasParent = $(elements.canvasParent);
		this.renderXML(initialXML, false);
	},
	
	renderXML: function(xmlString, animate)
	{
		var flashvars = {flowXML:xmlString, animate: animate ? 1 : 0, baseURL: this.rootPath, applicationMode: "thumbnail"};
				
		swfobject.embedSWF(this.rootPath+"static/main.swf", this.canvas.id, "100", "100", "9.0.0", null, flashvars, {},	{'allowScriptAccess':'always'});		
		if ( this.canvasParent.focus )
			this.canvasParent.focus();
	}
});
