﻿function replaceText(id, rows, text) {

    if (document.getElementById(id)) {
        var height = 0;
        var width = 359;

        if (text == "") { text = trim(document.getElementById(id).innerHTML); }

        if (rows == 1) { height = 35; }
        else if (rows == 2) { height = 66; }
        else if (rows == 3) { height = 98; }
        else if (rows == 4) { height = 130; }
        else { height = 500; }

        var so = new SWFObject("/js/FlashTextReplace/CastrolTextReplacer.swf", "shell", width, height, "8", "ffffff");
        // Swf file name, 	N/A, 	width, 	Height, 	minimumn flash version, 	background colour

        so.addVariable("extText", text); //Basic HTML copy using <BR/> to control line returns
        so.addVariable("extLeading", 2); // Spacing between line height
        so.addVariable("extLetterSpacing", 0); // Spacing between letters, can be psoitive or negative and decimal
        so.addVariable("extSize", 24); // font size in Pixels
        so.addVariable("extFontColour", 0x007B32); // font colour
        so.addVariable("extWidth", width); // textBox width
        so.addVariable("extHeight", height); // textBox height
        
        // Dont edit start #############
        so.addParam("scale", "noscale");
        so.addParam("salign", "TL");
        so.addParam("allowscale", "false");
        so.addParam("wmode", "transparent");
        // Dont edit end ############

        if (text != "") {
            so.write(id);
        }
    }
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

