
var coloroptions = new Array();
coloroptions = {
	"#000000" : "Black",
	"#A0522D" : "Sienna",
	"#556B2F" : "DarkOliveGreen",
	"#006400" : "DarkGreen",
	"#483D8B" : "DarkSlateBlue",
	"#000080" : "Navy",
	"#4B0082" : "Indigo",
	"#2F4F4F" : "DarkSlateGray",
	"#8B0000" : "DarkRed",
	"#FF8C00" : "DarkOrange",
	"#808000" : "Olive",
	"#008000" : "Green",
	"#008080" : "Teal",
	"#0000FF" : "Blue",
	"#708090" : "SlateGray",
	"#696969" : "DimGray",
	"#FF0000" : "Red",
	"#F4A460" : "SandyBrown",
	"#9ACD32" : "YellowGreen",
	"#2E8B57" : "SeaGreen",
	"#48D1CC" : "MediumTurquoise",
	"#4169E1" : "RoyalBlue",
	"#800080" : "Purple",
	"#808080" : "Gray",
	"#FF00FF" : "Magenta",
	"#FFA500" : "Orange",
	"#FFFF00" : "Yellow",
	"#00FF00" : "Lime",
	"#00FFFF" : "Cyan",
	"#00BFFF" : "DeepSkyBlue",
	"#9932CC" : "DarkOrchid",
	"#C0C0C0" : "Silver",
	"#FFC0CB" : "Pink",
	"#F5DEB3" : "Wheat",
	"#FFFACD" : "LemonChiffon",
	"#98FB98" : "PaleGreen",
	"#AFEEEE" : "PaleTurquoise",
	"#ADD8E6" : "LightBlue",
	"#DDA0DD" : "Plum",
	"#FFFFFF" : "White"
};

// variable to prevent init being called twice
var editor_loaded = false;

// initialize some arrays
var popupcontrols = new Array();
var colorindex = new Array();
var fontoptions = new Array();
var sizeoptions = new Array();
var buttonstatus = new Array();

// default values for URL / Image prompts
var imgurl = "http://";
var linkurl = "http://";

if ((navigator.appVersion.indexOf("MSIE 4.") != "-1" && is_ie) || (parseInt(navigator.appVersion) == 4 && is_ns))
{ // the v4 browsers dont support try / catch
	var is_v4 = true;
}

// function to change the appearence of a control element
function format_control(elm, elmtype, controlstate)
{
	// if we do not *need* to change the control state, then don't
	if (controlstate == elm.controlstate)
	{
		return;
	}

	// construct the name of the appropriate array key from the istyles array
	istyle = "my_" + elmtype + "_" + controlstate;
        
	// set element background, color, padding and border
	elm.style.background = istyles[istyle][0];
	elm.style.color = istyles[istyle][1];
	if (elmtype != "menu")
	{
		elm.style.padding = istyles[istyle][2];
	}
	elm.style.border = istyles[istyle][3];

	// set the element controlstate variable
	elm.controlstate = controlstate;


}

// function to set 'unselectable' for an element and all its child nodes
function set_unselectable(elm)
{
	if (is_ie4)
	{
		return;
	}
	else if (elm.tagName)
	{
		if (elm.hasChildNodes())
		{
			for (var i = 0; i < elm.childNodes.length; i++)
			{
				set_unselectable(elm.childNodes[i]);
			}
		}
		elm.unselectable = true;
	}
}

function build_fontoptions()
{
	for (key in fontoptions)
	{
		document.writeln('<option value="' + fontoptions[key] + '">' + fontoptions[key] + '</option>');
	}
}

function build_sizeoptions()
{
	for (key in sizeoptions)
	{
		document.writeln('<option value="' + sizeoptions[key] + '">' + sizeoptions[key] + '</option>');
		}
}


function build_coloroptions()
{
	for (key in coloroptions)
	{
		document.writeln('<option value="' + coloroptions[key] + '" style="background-color:' + coloroptions[key] + ';">' + coloroptions[key].replace(/([a-z]{1})([A-Z]{1})/g, "$1 $2") + '</option>');
	}
}