/*
 * @author henryt,Michael Randolph
 *
 * @param elementId     (string)    DOM id to write to
 * @param clickHandler  (string)    function to call when text is clicked (this is only necessary for IE, pass null for FF)
 * @param swfwidth		(uint)      set width for text (default = 200)
 * @param swfheight		(uint)      set height for text (default = 200)
 * @param font			(string)    name of font (default = 'Codent')
 * @param fontHeight	(float)     point size of text, in pixels (default = 16)
 * @param fontColor		(string)    color rgb hex value (e.g. - '#ffcc33' or '0xffcc33' or 'ffcc33', default = '0x000000')
 * @param fontAlpha		(float)     value 0 to 1 (default = 1)
 * @param align			(string)    horizontal text alignment (e.g. - left, center, right, default = 'left')
 * @param valign		(string)    vertical text alignment (e.g. - top, center, bottom, default = 'top')
 * @param selectable	(bool)      makes text selectable for copy/paste operations (default = false)
 * @param wordWrap      (bool)      makes text wrap automatically (default = false)
 * @param fitToSize		(bool)		will shrink text to fit area (default = false)
 * @param buttonMode	(bool)		set this to true is the text should also be a button (default = false)
 * @param minifieldLocation (string) ADDED by adam.housman, requires freemarker, so set this variable in your template - URL path to minifield.swf
 */

function placeText(elementId, clickHandler, swfwidth, swfheight, font, fontHeight, fontColor, fontAlpha, align, valign, selectable, wordWrap, fitTextToSize, buttonMode, libPath)
{    
    var nWidth      	= (swfwidth == null) ? 200 : swfwidth;
    var nHeight     	= (swfheight == null) ? 200 : swfheight;
    var strFont     	= (font == null) ? 'Codent' : font;
    var nFontHeight 	= (fontHeight == null) ? 16 : fontHeight;
    var strFontColor	= (fontColor == null) ? '0x000000' : fontColor;
    var nFontAlpha  	= (fontAlpha == null) ? 1 : fontAlpha;
    var strAlign    	= (align == null) ? 'left' : align;
    var strVAlign   	= (valign == null) ? 'top' : valign;
    var bSelectable 	= (selectable == null) ? false : selectable;
    var bWordWrap   	= (wordWrap == null) ? false : wordWrap;
    var bShrinkToFit	= (fitTextToSize == null) ? false : fitTextToSize;
    var bButtonMode		= (buttonMode == null) ? false : buttonMode;
	
    var strText     	= Base64.encode(window.document.getElementById(elementId).innerHTML);  //encode to Base64
    var so          	= new SWFObject(minifieldLocation, "sotester", nWidth, nHeight, "9", "#ffffff");
    
    so.addVariable("elementId", elementId);
    so.addVariable("clickHandler", clickHandler);
    so.addVariable("font", strFont);
    so.addVariable("fontHeight", nFontHeight);
    so.addVariable("fontColor", strFontColor);
    so.addVariable("fontAlpha", nFontAlpha);
    so.addVariable("align", strAlign);
    so.addVariable("valign", strVAlign);
    so.addVariable("selectable", bSelectable);
    so.addVariable("wordWrap", bWordWrap);
    so.addVariable("fitTextToSize", bShrinkToFit);
    so.addVariable("buttonMode", bButtonMode)
    so.addVariable("txt", strText);
    if(libPath != null) so.addVariable("libPath", libPath);
	
    so.addVariable("debugMode", false);  //setting this to true will show textField borders in the same color as the text
    
    so.addParam("quality", "high");
    so.addParam("wmode", "transparent");
    so.write(elementId);
}