//DHTML Editor version 3.0

var editwin = null;
var editorURL;

editorURL = window.location.href;
editorURL = editorURL.toString();
editorURL = editorURL.toLowerCase();


//******************************************************************************************
function popup() 
{
}

var r0="";
var red="";
var url="javascript: popup()";
var img="";
var fla="";
var startr=2;
var width=76;
var height=24;


//******************************************************************************************
    function UtilBeginScript()
    {
	return String.fromCharCode(60, 115, 99, 114, 105, 112, 116, 62);
    }

//******************************************************************************************
    function UtilEndScript()
    {
	return String.fromCharCode(60, 47, 115, 99, 114, 105, 112, 116, 62);
    }


//******************************************************************************************
	function IDGenerator(nextID)
	{
		this.nextID = nextID;
		this.GenerateID = IDGeneratorGenerateID;
	}

//******************************************************************************************
	function IDGeneratorGenerateID()
	{
		return this.nextID++;
	}



	var BUTTON_IMAGE_PREFIX = "buttonImage";
	var BUTTON_DIV_PREFIX = "buttonDiv";
	var BUTTON_PAD1_PREFIX = "buttonPad1";
	var BUTTON_PAD2_PREFIX = "buttonPad2";
	var buttonMap = new Object();


//******************************************************************************************
	function Button
	(
		idGenerator,
		caption,
		action,
		image
	)
	{
		this.idGenerator = idGenerator;
		this.caption = caption;
		this.action = action;
		this.image = image;
		this.enabled = true;
		this.Instantiate = ButtonInstantiate;
		this.Enable = ButtonEnable;
	}


//******************************************************************************************
	function ButtonInstantiate()
	{
		this.id = this.idGenerator.GenerateID();
		buttonMap[this.id] = this;
		var html = "";
		html += '<div id="';
		html += BUTTON_DIV_PREFIX;
		html += this.id;
		html += '" class="ButtonNormal"';
		html += ' onselectstart="ButtonOnSelectStart()"';
		html += ' ondragstart="ButtonOnDragStart()"';
		html += ' onmousedown="ButtonOnMouseDown(this)"';
		html += ' onmouseup="ButtonOnMouseUp(this)"';
		html += ' onmouseout="ButtonOnMouseOut(this)"';
		html += ' onmouseover="ButtonOnMouseOver(this)"';
		html += ' onclick="ButtonOnClick(this)"';
		html += ' ondblclick="ButtonOnDblClick(this)"';
		html += '>';
		html += '<table cellpadding=0 cellspacing=0 border=0><tr><td><img id="';
		html += BUTTON_PAD1_PREFIX;
		html += this.id;
		html += '" width=2 height=2></td><td></td><td></td></tr><tr><td></td><td>';
		html += '<img id="';
		html += BUTTON_IMAGE_PREFIX;
		html += this.id;
		html += '" src="';
		html += this.image;
		html += '" title="';
		html += this.caption;
		html += '" class="Image"';
		html += '>';
		html += '</td><td></td></tr><tr><td></td><td></td><td><img id="';
		html += BUTTON_PAD2_PREFIX;
		html += this.id;
		html += '" width=2 height=2></td></tr></table>';
		html += '</div>';
		document.write(html);
	}


//******************************************************************************************
	function ButtonEnable(enabled)
	{
		this.enabled = enabled;
		if (this.enabled)
		{
			document.all[BUTTON_DIV_PREFIX + this.id].className = "ButtonNormal";
		}
		else
		{
			document.all[BUTTON_DIV_PREFIX + this.id].className = "ButtonDisabled";
		}
	}


//******************************************************************************************
	function ButtonOnSelectStart()
	{
		window.event.returnValue = false;
	}


//******************************************************************************************
	function ButtonOnDragStart()
	{
		window.event.returnValue = false;
	}


//******************************************************************************************
	function ButtonOnMouseDown(element)
	{
		if (event.button == 1)
		{
			var id = element.id.substring(BUTTON_DIV_PREFIX.length, element.id.length);
			var button = buttonMap[id];
			if (button.enabled)
			{
				ButtonPushButton(id);
			}
		}
	}


//******************************************************************************************
	function ButtonOnMouseUp(element)
	{
		if (event.button == 1)
		{
			var id = element.id.substring(BUTTON_DIV_PREFIX.length, element.id.length);
			var button = buttonMap[id];
			if (button.enabled)
			{
				ButtonReleaseButton(id);
			}
		}
	}


//******************************************************************************************
	function ButtonOnMouseOut(element)
	{
		var id = element.id.substring(BUTTON_DIV_PREFIX.length, element.id.length);
		var button = buttonMap[id];
		if (button.enabled)
		{
			ButtonReleaseButton(id);
		}
	}


//******************************************************************************************
	function ButtonOnMouseOver(element)
	{
		var id = element.id.substring(BUTTON_DIV_PREFIX.length, element.id.length);
		var button = buttonMap[id];
		if (button.enabled)
		{
			ButtonReleaseButton(id);
			document.all[BUTTON_DIV_PREFIX + id].className = "ButtonMouseOver";
		}
	}


//******************************************************************************************
	function ButtonOnClick(element)
	{
		var id = element.id.substring(BUTTON_DIV_PREFIX.length, element.id.length);
		var button = buttonMap[id];
		if (button.enabled)
		{
			eval(button.action);
		}
	}


//******************************************************************************************
	function ButtonOnDblClick(element)
	{
		ButtonOnClick(element);
	}


//******************************************************************************************
	function ButtonPushButton(id)
	{
		document.all[BUTTON_PAD1_PREFIX + id].width = 3;
		document.all[BUTTON_PAD1_PREFIX + id].height = 3;
		document.all[BUTTON_PAD2_PREFIX + id].width = 1;
		document.all[BUTTON_PAD2_PREFIX + id].height = 1;
		document.all[BUTTON_DIV_PREFIX + id].className = "ButtonPressed";
	}


//******************************************************************************************
	function ButtonReleaseButton(id)
	{
		document.all[BUTTON_PAD1_PREFIX + id].width = 2;
		document.all[BUTTON_PAD1_PREFIX + id].height = 2;
		document.all[BUTTON_PAD2_PREFIX + id].width = 2;
		document.all[BUTTON_PAD2_PREFIX + id].height = 2;
		document.all[BUTTON_DIV_PREFIX + id].className = "ButtonNormal";
	}


    var IMAGE_CHOOSER_DIV_PREFIX = "imageChooserDiv";
    var IMAGE_CHOOSER_IMG_PREFIX = "imageChooserImg";
    var IMAGE_CHOOSER_ICON_PREFIX = "imageChooserIcon";
    var imageChooserMap = new Object();

//******************************************************************************************
    function ImageChooser
    (
	    idGenerator,
	    numRows,
	    numCols,
	    images,
	    callback
    )
    {
	    this.idGenerator = idGenerator;
	    this.numRows = numRows;
	    this.numCols = numCols;
	    this.images = images;
	    this.callback = callback;
	    this.Instantiate = ImageChooserInstantiate;
	    this.Show = ImageChooserShow;
	    this.Hide = ImageChooserHide;
	    this.IsShowing = ImageChooserIsShowing;
	    this.SetUserData = ImageChooserSetUserData;
    }

//******************************************************************************************
    function ImageChooserInstantiate()
    {
	    this.id = this.idGenerator.GenerateID();
	    imageChooserMap[this.id] = this;
	    var html = '';
	    html += '<div id="' + IMAGE_CHOOSER_DIV_PREFIX + this.id + '" style="display:none;position:absolute;background-color:buttonface;border-left:buttonhighlight solid 1px;border-top:buttonhighlight solid 1px;border-right:buttonshadow solid 1px;border-bottom:buttonshadow solid 1px">';
	    html += '<table>';
	    for (var i = 0; i < this.numRows; i++) {
		    html += '<tr>';
		    for (var j = 0; j < this.numCols; j++) {
			    html += '<td>';
			    var k = i * this.numCols + j;
			    html += '<div id="' + IMAGE_CHOOSER_ICON_PREFIX + this.id + '_' + k + '" style="border:buttonface solid 1px">';
			    html += '<img src="' + this.images[k] + '" id="' + IMAGE_CHOOSER_IMG_PREFIX + this.id + '_' + k + '" onmouseover="ImageChooserOnMouseOver()" onmouseout="ImageChooserOnMouseOut()" onclick="ImageChooserOnClick()">';
			    html += '</div>';
			    html += '</td>';
		    }
		    html += '</tr>';
	    }
	    html += '</table>';
	    html += '</div>';
	    document.write(html);
    }

//******************************************************************************************
    function ImageChooserShow(x, y)
    {
	    eval(IMAGE_CHOOSER_DIV_PREFIX + this.id).style.left = x;
	    eval(IMAGE_CHOOSER_DIV_PREFIX + this.id).style.top = y;
	    eval(IMAGE_CHOOSER_DIV_PREFIX + this.id).style.display = "block";
    }

//******************************************************************************************
    function ImageChooserHide()
    {
	    eval(IMAGE_CHOOSER_DIV_PREFIX + this.id).style.display = "none";
    }

//******************************************************************************************
    function ImageChooserIsShowing()
    {
	    return eval(IMAGE_CHOOSER_DIV_PREFIX + this.id).style.display == "block";
    }

//******************************************************************************************
    function ImageChooserSetUserData(userData)
    {
	this.userData = userData;
    }

//******************************************************************************************
    function ImageChooserOnMouseOver()
    {
	    if (event.srcElement.tagName == "IMG") {
		    var underscore = event.srcElement.id.indexOf("_");
		    if (underscore != -1) {
			    var id = event.srcElement.id.substring(IMAGE_CHOOSER_IMG_PREFIX.length, underscore);
			    var index = event.srcElement.id.substring(underscore + 1);
			    eval(IMAGE_CHOOSER_ICON_PREFIX + id + "_" + index).style.borderColor = "black";
		    }
	    }
    }

//******************************************************************************************
    function ImageChooserOnMouseOut()
    {
	    if (event.srcElement.tagName == "IMG") {
		    var underscore = event.srcElement.id.indexOf("_");
		    if (underscore != -1) {
			    var id = event.srcElement.id.substring(IMAGE_CHOOSER_IMG_PREFIX.length, underscore);
			    var index = event.srcElement.id.substring(underscore + 1);
			    eval(IMAGE_CHOOSER_ICON_PREFIX + id + "_" + index).style.borderColor = "buttonface";
		    }
	    }
    }


//******************************************************************************************
	function ImageChooserOnClick()
    {
	    if (event.srcElement.tagName == "IMG") {
		    var underscore = event.srcElement.id.indexOf("_");
		    if (underscore != -1) {
			    var id = event.srcElement.id.substring(IMAGE_CHOOSER_IMG_PREFIX.length, underscore);
			    var imageChooser = imageChooserMap[id];
			    imageChooser.Hide();
			    var index = event.srcElement.id.substring(underscore + 1);
			    if (imageChooser.callback) {
				    imageChooser.callback(imageChooser.images[index], imageChooser.userData);
			    }
		    }
	    }
    }


	var EDITOR_COMPOSITION_PREFIX = "editorComposition";
	var EDITOR_PARAGRAPH_PREFIX = "editorParagraph";
	var EDITOR_LIST_AND_INDENT_PREFIX = "editorListAndIndent";
	var EDITOR_TOP_TOOLBAR_PREFIX = "editorTopToolbar";
	var EDITOR_BOTTOM_TOOLBAR_PREFIX = "editorBottomToolbar";
	var EDITOR_SMILEY_BUTTON_PREFIX = "editorSmileyButton";
	var EDITOR_IMAGE_CHOOSER_PREFIX = "editorImageChooser";
	var editorMap = new Object();
	var editorIDGenerator = null;
	
	var PageTitle = "";
	var PageLead = "";
	var NewsSource = "";
	var PageTopImage = "";
	var imageNumberArray = new Array(10);
	var editorheight;

	if (screen.height == 768)
	{
		editorheight = 528;
	}
	
	if (screen.height == 460)
	{
		editorheight = 380;
	}

	else
	{
		editorheight = 386;
	}
	
//******************************************************************************************
	function Editor(idGenerator)
	{
		this.idGenerator = idGenerator;
		this.textMode = false;
		this.brief = false;
		this.instantiated = false;
		this.Instantiate = EditorInstantiate;
		this.GetText = EditorGetText;
		this.SetText = EditorSetText;
		this.GetHTML = EditorGetHTML;
		this.SetHTML = EditorSetHTML;
		this.GetBrief = EditorGetBrief;
		this.SetBrief = EditorSetBrief;
		//this.ManualMode = false;
	}


//******************************************************************************************
	function EditorInstantiate()
	{
		if (this.instantiated) {
			return;
		}
		this.id = this.idGenerator.GenerateID();
		editorMap[this.id] = this;
		editorIDGenerator = this.idGenerator;

		var html = "";
		html += "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">";
		html += "<tr>";
		html += "<td id=\"" + EDITOR_TOP_TOOLBAR_PREFIX + this.id + "\" class=\"Toolbar\">";
		html += "<table cellpaddin=\"0\" cellspacing=\"0\" border=\"0\">";
		html += "<tr>";
		html += "<td>";
		html += "<div class=\"Space\"></div>";
		html += "</td>";
		html += "<td>";
		html += "<div class=\"Swatch\"></div>";
		html += "</td>";
		html += "<td>";
		html += "<span id=\"" + EDITOR_PARAGRAPH_PREFIX + this.id + "\" style=\"display:" + (this.brief ? "none" : "inline") + "\">";
		html += "<select class=\"List\" onchange=\"EditorOnParagraph(" + this.id + ", this)\">";
		html += "<option class=\"Heading\">Paragraph</option>";
		html += "<option value=\"Normal\">Normal</option>";

		html += "<option value=\"Heading 1\">Heading 1</option>";
		html += "<option value=\"Heading 2\">Heading 2</option>";
		html += "<option value=\"Heading 3\">Heading 3</option>";
		html += "<option value=\"Heading 4\">Heading 4</option>";
		html += "<option value=\"Heading 5\">Heading 5</option>";
		html += "<option value=\"Heading 6\">Heading 6</option>";
		html += "<option value=\"Address\">Address</option>";
		html += "<option value=\"Formatted\">Formatted</option>";

		html += "</select>";
		html += "</span>";
		html += "</td>";
		html += "<td>";
		html += "<select class=\"List\" onchange=\"EditorOnFont(" + this.id + ", this)\">";
		html += "<option class=\"Heading\">Font</option>";
		html += "<option value=\"Arial\">Arial</option>";
		html += "<option value=\"Arial Black\">Arial Black</option>";
		html += "<option value=\"Arial Narrow\">Arial Narrow</option>";
		html += "<option value=\"Comic Sans MS\">Comic Sans MS</option>";
		html += "<option value=\"Courier New\">Courier New</option>";
		html += "<option value=\"System\">System</option>";
		html += "<option value=\"Times New Roman\">Times New Roman</option>";
		html += "<option value=\"Verdana\">Verdana</option>";
		html += "<option value=\"Wingdings\">Wingdings</option>";
                                
                
		html += "</select>";
		html += "</td>";
		html += "<td>";
		html += "<select class=\"List\" onchange=\"EditorOnSize(" + this.id + ", this)\">";
		html += "<option class=\"Heading\">Size</option>";
		html += "<option value=\"1\">1</option>";
		html += "<option value=\"2\">2</option>";
		html += "<option value=\"3\">3</option>";
		html += "<option value=\"4\">4</option>";
		html += "<option value=\"5\">5</option>";
		html += "<option value=\"6\">6</option>";
		html += "<option value=\"7\">7</option>";
		html += "</select>";
		html += "</td>";
		html += "<td>";
		html += "<div class=\"Divider\"></div>";
		html += "</td>";
		
		html += "<td>";
		html += UtilBeginScript();
		html += "var createHyperlinkButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Create Hyperlink\",";
		html += "\"EditorOnCreateHyperlink(" + this.id + ")\",";
		html += "\"/Images/wlink.gif\"";
		html += ");";
		html += "createHyperlinkButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";
		
		html += "</td>";
		html += "<td>";
		html += "<div class=\"Divider\"></div>";
		html += "</td>";
		

		html += "<td>";
		html += UtilBeginScript();
		html += "var InsertTableButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Insert table\",";
		html += "\"EditorOnInsertTable(" + this.id + ")\",";
		html += "\"/Images/Table.gif\"";
		html += ");";
		html += "InsertTableButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";

		html += "<td>";
		html += UtilBeginScript();
		html += "var SetCellPropertiesButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Cell properties\",";
		html += "\"EditorSetCellProperties(" + this.id + ")\",";
		html += "\"/Images/CellProperties.gif\"";
		html += ");";
		html += "SetCellPropertiesButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";
		
		html += "<td>";
		html += "<div class=\"Divider\"></div>";
		html += "</td>";

		html += "<td>";
		html += UtilBeginScript();
		html += "var imageButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Image\",";
		html += "\"EditorOnSetImage(" + this.id + ")\",";
		html += "\"/Images/butImage.gif\"";
		html += ");";
		html += "imageButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";

		html += "<td>";
		html += UtilBeginScript();
		html += "var topImgButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Set Top Image\",";
		html += "\"SetTopImage(" + this.id + ")\",";
		html += "\"/Images/TopImage.gif\"";
		html += ");";
		html += "topImgButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";

		html += "</tr>";
		html += "</table>";
		html += "</td>";
		html += "</tr>";
		html += "<tr>";
		html += "<td id=\"" + EDITOR_BOTTOM_TOOLBAR_PREFIX + this.id + "\" class=\"Toolbar\">";
		html += "<table cellpaddin=\"0\" cellspacing=\"0\" border=\"0\">";
		html += "<tr>";
		html += "<td>";
		html += "<div class=\"Space\"></div>";
		html += "</td>";
		html += "<td>";
		html += "<div class=\"Swatch\"></div>";
		html += "</td>";
		html += "<td>";
		html += UtilBeginScript();
		html += "var cutButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Cut\",";
		html += "\"EditorOnCut(" + this.id + ")\",";
		html += "\"/Images/cut.gif\"";
		html += ");";
		html += "cutButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";
		html += "<td>";
		html += UtilBeginScript();
		html += "var copyButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Copy\",";
		html += "\"EditorOnCopy(" + this.id + ")\",";
		html += "\"/Images/copy.gif\"";
		html += ");";
		html += "copyButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";
		html += "<td>";
		html += UtilBeginScript();
		html += "var pasteButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Paste\",";
		html += "\"EditorOnPaste(" + this.id + ")\",";
		html += "\"/Images/paste.gif\"";
		html += ");";
		html += "pasteButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";
		html += "<td>";
		html += "<div class=\"Divider\"></div>";
		html += "</td>";
		html += "<td>";
		html += UtilBeginScript();
		html += "var boldButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Bold\",";
		html += "\"EditorOnBold(" + this.id + ")\",";
		html += "\"/Images/bold.gif\"";
		html += ");";
		html += "boldButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";
		html += "<td>";
		html += UtilBeginScript();
		html += "var italicButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Italic\",";
		html += "\"EditorOnItalic(" + this.id + ")\",";
		html += "\"/Images/italic.gif\"";
		html += ");";
		html += "italicButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";
		html += "<td>";
		html += UtilBeginScript();
		html += "var underlineButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Underline\",";
		html += "\"EditorOnUnderline(" + this.id + ")\",";
		html += "\"/Images/uline.gif\"";
		html += ");";
		html += "underlineButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";
		html += "<td>";
		html += "<div class=\"Divider\"></div>";
		html += "</td>";
		html += "<td>";
		html += UtilBeginScript();
		html += "var foregroundColorButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Foreground Color\",";
		html += "\"EditorOnForegroundColor(" + this.id + ")\",";
		html += "\"/Images/tpaint.gif\"";
		html += ");";
		html += "foregroundColorButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";
		html += "<td>";
		html += UtilBeginScript();
		html += "var backgroundColorButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Background Color\",";
		html += "\"EditorOnBackgroundColor(" + this.id + ")\",";
		html += "\"/Images/parea.gif\"";
		html += ");";
		html += "backgroundColorButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";
		html += "<td>";
		html += "<div class=\"Divider\"></div>";
		html += "</td>";
		html += "<td>";
		html += UtilBeginScript();
		html += "var alignLeftButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Align Left\",";
		html += "\"EditorOnAlignLeft(" + this.id + ")\",";
		html += "\"/Images/aleft.gif\"";
		html += ");";
		html += "alignLeftButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";
		html += "<td>";
		html += UtilBeginScript();
		html += "var centerButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Center\",";
		html += "\"EditorOnCenter(" + this.id + ")\",";
		html += "\"/Images/center.gif\"";
		html += ");";
		html += "centerButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";
		html += "<td>";
		html += UtilBeginScript();
		html += "var alignRightButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Align Right\",";
		html += "\"EditorOnAlignRight(" + this.id + ")\",";
		html += "\"/Images/aright.gif\"";
		html += ");";
		html += "alignRightButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";
		html += "<td>";
		html += "<div class=\"Divider\"></div>";
		html += "</td>";
		html += "<td id=\"" + EDITOR_LIST_AND_INDENT_PREFIX + this.id + "\" style=\"display:" + (this.brief ? "none" : "inline") + "\">";
		html += "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">";
		html += "<tr>";
		html += "<td>";
		html += UtilBeginScript();
		html += "var numberedListButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Numbered List\",";
		html += "\"EditorOnNumberedList(" + this.id + ")\",";
		html += "\"/Images/nlist.gif\"";
		html += ");";
		html += "numberedListButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";
		html += "<td>";
		html += UtilBeginScript();
		html += "var bullettedListButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Bulletted List\",";
		html += "\"EditorOnBullettedList(" + this.id + ")\",";
		html += "\"/Images/blist.gif\"";
		html += ");";
		html += "bullettedListButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";
		html += "<td>";
		html += "<div class=\"Divider\"></div>";
		html += "</td>";
		
		html += "<td>";
		html += UtilBeginScript();
		html += "var decreaseIndentButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Decrease Indent\",";
		html += "\"EditorOnDecreaseIndent(" + this.id + ")\",";
		html += "\"/Images/ileft.gif\"";
		html += ");";
		html += "decreaseIndentButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";
		
		html += "<td>";
		html += UtilBeginScript();
		html += "var increaseIndentButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Increase Indent\",";
		html += "\"EditorOnIncreaseIndent(" + this.id + ")\",";
		html += "\"/Images/iright.gif\"";
		html += ");";
		html += "increaseIndentButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";
		
		html += "<td>";
		html += "<div class=\"Divider\"></div>";
		html += "</td>";
		html += "</tr>";
		html += "</table>";
		html += "</td>";
		
		//***** Preview Button ******

		html += "<td>";
		html += UtilBeginScript();
		html += "var previewButton = new Button(";
		html += "editorIDGenerator,";
		html += "\"Preview\",";
		html += "\"EditorOnPreview(" + this.id + ")\",";
		html += "\"/Images/preview.gif\"";
		html += ");";
		html += "previewButton.Instantiate();";
		html += UtilEndScript();
		html += "</td>";

		//***** Editor space ******
			
		html += "</td>";
		html += "</tr>";
		html += "</table>";
		html += "</td>";
		html += "</tr>";
		html += "<tr>";
		html += "<td>";
		html += "<iframe id=\"" + EDITOR_COMPOSITION_PREFIX + this.id + "\" width=\"100%\" height=\""+ editorheight  +"\">";
		html += "</iframe>";
		html += "</td>";
		html += "</tr>";		
		
		document.write(html);

		html = '';
		html += '<body style="font:10pt arial">';
		html += '</body>';
		
		var ifrm = eval(EDITOR_COMPOSITION_PREFIX + this.id);
		ifrm.document.open();
		ifrm.document.write(html);
		ifrm.document.close();
		ifrm.document.designMode = "on";
		editwin = ifrm;
		
		editorIDGenerator = null;
		this.instantiated = true;

	}

	
//******************************************************************************************
	function  EditorGetText()
	{
		return eval(EDITOR_COMPOSITION_PREFIX + this.id).document.body.innerText;
	}

//******************************************************************************************
	function  EditorSetText(text)
	{
		text = text.replace(/\n/g, "<br>");
		eval(EDITOR_COMPOSITION_PREFIX + this.id).document.body.innerHTML = text;
	}

//******************************************************************************************
	function  EditorGetHTML()
	{	
		if (this.textMode) {
			return eval(EDITOR_COMPOSITION_PREFIX + this.id).document.body.innerText;
		}
		EditorCleanHTML(this.id);
		EditorCleanHTML(this.id);
		return eval(EDITOR_COMPOSITION_PREFIX + this.id).document.body.innerHTML;
	}

//******************************************************************************************
	function  EditorSetHTML(html)
	{
		if (this.textMode) {
			eval(EDITOR_COMPOSITION_PREFIX + this.id).document.body.innerText = html;
		}
		else {
			eval(EDITOR_COMPOSITION_PREFIX + this.id).document.body.innerHTML = html;
		}
	}

//******************************************************************************************
	function EditorGetBrief()
	{
		return this.brief;
	}

//******************************************************************************************
	function EditorSetBrief(brief)
	{
		this.brief = brief;
		var display = this.brief ? "none" : "inline";
		if (this.instantiated) {
			eval(EDITOR_PARAGRAPH_PREFIX + this.id).style.display = display;
			eval(EDITOR_LIST_AND_INDENT_PREFIX + this.id).style.display = display;
		}
	}

//******************************************************************************************
	function EditorOnCut(id)
	{
		EditorFormat(id, "cut");
	}

//******************************************************************************************
	function EditorOnCopy(id)
	{
		EditorFormat(id, "copy");
	}

//******************************************************************************************
	function EditorOnPaste(id)
	{
		EditorFormat(id, "paste");
	}

//******************************************************************************************
	function EditorOnBold(id)
	{
		EditorFormat(id, "bold");
	}

//******************************************************************************************
	function EditorOnItalic(id)
	{
		EditorFormat(id, "italic");
	}

//******************************************************************************************
	function EditorOnUnderline(id)
	{
		EditorFormat(id, "underline");
	}

//******************************************************************************************
	function EditorOnForegroundColor(id)
	{
		if (!EditorValidateMode(id)) {
			return;
		}
		var color = showModalDialog("ColorSelect.htm", "", "font-family:Verdana;font-size:12;dialogWidth:30em;dialogHeight:35em");
		if (color) {
			EditorFormat(id, "forecolor", color);
		}
		else {

			eval(EDITOR_COMPOSITION_PREFIX + id).focus();
		}
	}

//******************************************************************************************
	function EditorOnBackgroundColor(id)
	{
		if (!EditorValidateMode(id)) {
			return;
		}
		var color = showModalDialog("ColorSelect.htm", "", "font-family:Verdana;font-size:12;dialogWidth:30em;dialogHeight:35em");
		if (color) {
			EditorFormat(id, "backcolor", color);
		}
		else {
			eval(EDITOR_COMPOSITION_PREFIX + id).focus();
		}
	}

//******************************************************************************************
	function EditorOnAlignLeft(id)
	{
		EditorFormat(id, "justifyleft");
	}

//******************************************************************************************
	function EditorOnCenter(id)
	{
		EditorFormat(id, "justifycenter");
	}

//******************************************************************************************
	function EditorOnAlignRight(id)
	{
		EditorFormat(id, "justifyright");
	}

//******************************************************************************************
	function EditorOnNumberedList(id)
	{
		EditorFormat(id, "insertOrderedList");
	}

//******************************************************************************************
	function EditorOnBullettedList(id)
	{
		EditorFormat(id, "insertUnorderedList");
	}

//******************************************************************************************
	function EditorOnDecreaseIndent(id)
	{
		EditorFormat(id, "outdent");
	}

//******************************************************************************************
	function EditorOnIncreaseIndent(id)
	{
		EditorFormat(id, "indent");
	}


//******************************************************************************************
	function EditorOnCreateHyperlink(id)
	{
		var link;
	
		if (!EditorValidateMode(id)) {
			return;
		}
		
		if (eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.type == "Control")
		{
			var args = new Array(3);
			var range1 = eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.createRange().item(0);					
			args[0] = range1.src;
			args[1] = range1.width;
			args[2] = range1.height;

			link = prompt("enter link location (eg. http://www.vnmarketing.net):", anchor ? anchor.href : "JavaScript:EnlargePicture('" + args[0] + "'," + args[2] + "," + args[1] + ")");
		}
		else
		{
		var anchor = EditorGetElement("A", eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.createRange().parentElement());
		
			link = prompt("enter link location (eg. http://www.vnmarketing.net):", anchor ? anchor.href : "http://");
		}
		if (link && link != "http://") {
			if (eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.type == "None") 
			{
				var range = eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.createRange();
				range.pasteHTML('<A HREF="' + link + '"></A>');
				range.select();
			}
			else {
				EditorFormat(id, "CreateLink", link);
			}
		}
	}


//******************************************************************************************
	function EditorOnParagraph(id, select)
	{
		EditorFormat(id, "formatBlock", select[select.selectedIndex].value);
		select.selectedIndex = 0;
	}

//******************************************************************************************
	function EditorOnFont(id, select)
	{
		EditorFormat(id, "fontname", select[select.selectedIndex].value);
		select.selectedIndex = 0;
	}


//******************************************************************************************	
	function EditorOnSize(id, select)
	{
		EditorFormat(id, "fontsize", select[select.selectedIndex].value);
		select.selectedIndex = 0;
	}


//******************************************************************************************
	function EditorOnClick(id)
	{
		eval(EDITOR_IMAGE_CHOOSER_PREFIX + id).Hide();
	}

//******************************************************************************************		
	function EditorValidateMode(id)
	{
		var editor = editorMap[id];
		if (!editor.textMode) {
			return true;
		}
		alert("Please uncheck the \"View HTML Source\" checkbox to use the toolbars.");
		eval(EDITOR_COMPOSITION_PREFIX + id).focus();
		return false;
	}

//******************************************************************************************
	function EditorFormat(id, what, opt)
	{
		if (!EditorValidateMode(id)) {
			return;
		}
		if (opt == "removeFormat") {
			what = opt;
			opt = null;
		}
		if (opt == null) {
			eval(EDITOR_COMPOSITION_PREFIX + id).document.execCommand(what);
		}
		else {
			eval(EDITOR_COMPOSITION_PREFIX + id).document.execCommand(what, "", opt);
		}
	}

//******************************************************************************************
	function EditorCleanHTML(id)
	{
		var fonts = eval(EDITOR_COMPOSITION_PREFIX + id).document.body.all.tags("FONT");
		for (var i = fonts.length - 1; i >= 0; i--) {
			var font = fonts[i];
			if (font.style.backgroundColor == "#ffffff") {
				font.outerHTML = font.innerHTML;
			}
		}
	}

	function EditorGetElement(tagName, start)
	{
		while (start && start.tagName != tagName) {
			start = start.parentElement;
		}
		return start;
	}


//******************************************************************************************
function initVU (form) {

  if(!editwin) return;
  form.vArea = editwin.document.body;
  initTyper(form.vArea);
  form.vArea.win = editwin;
  form.vArea.getValue = function() { return this.innerHTML; }
  form.vArea.setValue = function(value) { this.innerHTML = value; this.focus(); }
  return true;
}


//******************************************************************************************
function initFilter (form, content) {

  if(!editwin) return;
  form.vArea = editwin.document.body;
  initTyper(form.vArea);
  form.vArea.win = editwin;
  form.vArea.getValue = function() { return this.innerHTML; }
  form.vArea.setValue = function(value) { this.innerHTML = value; this.focus(); }
  content = ReplaceAll(content, "chr39", "'")
  content = ReplaceAll(content, "chr34", "\"")
  eval(EDITOR_COMPOSITION_PREFIX + '0').document.body.innerHTML = content;
  return true;
  
}

//******************************************************************************************
function EditorOnInsertTable(id)
{
		var html;
		var myReturnValue;
		var args = new Array(6);
		var RowNum;
		var ColNum;
		var Alignment;
		var Border;
		var Width;
		var Bgcolor;
		var Padding;
		var Spacing;

		if (!EditorValidateMode(id)) 
		{
			return;
		}
		
		if (eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.type == "Control")
		{
			var range1 = eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.createRange().item(0);
		
			args[0] = range1.getAttribute("align",0);
			args[1] = range1.getAttribute("border",0);
			args[2] = range1.getAttribute("width",0);
			args[3] = range1.getAttribute("bgcolor",0);
			args[4] = range1.getAttribute("cellpadding",0);
			args[5] = range1.getAttribute("cellspacing",0);

			myReturnValue = showModalDialog("TableProperties.htm", args, "font-family:Verdana;font-size:12;dialogWidth:34em;dialogHeight:16em");

			if (myReturnValue != null)
				{
					Alignment = myReturnValue[0];
					Border = myReturnValue[1];
					Width = myReturnValue[2];
					Bgcolor = myReturnValue[3];
					Padding = myReturnValue[4];
					Spacing = myReturnValue[5]; 

					range1.setAttribute("align", Alignment, 0);
					range1.setAttribute("border", Border, 0);
					range1.setAttribute("width", Width, 0);
					range1.setAttribute("bgcolor", Bgcolor, 0);
					range1.setAttribute("cellpadding", Padding, 0);
					range1.setAttribute("cellspacing", Spacing, 0);
				}
		}
		else
		{
			myReturnValue = showModalDialog("InsertTable.htm", "", "font-family:Verdana;font-size:12;dialogWidth:34em;dialogHeight:22em");

			if (myReturnValue != null)
				{
					var range = eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.createRange();
					RowNum = myReturnValue[0];
					ColNum = myReturnValue[1];
					Alignment = myReturnValue[2];
					Border = myReturnValue[3];
					Width = myReturnValue[4];
					Bgcolor = myReturnValue[5];
					Padding = myReturnValue[6];
					Spacing = myReturnValue[7];
		
					html = '<table align=' + Alignment + ' border=' + Border + ' width=' + Width + ' bgcolor=' + Bgcolor + ' cellpadding=' + Padding + ' cellspacing=' + Spacing + '>';

					
					for (var i = 0; i < RowNum ; i++)
					{
						html = html + '<tr>';
							for (var j = 0; j < ColNum; j++)
							{
								html = html + '<td valign=top></td>';
							}

						html = html + '</tr>';
					}	

					html = html + '</table>'
					range.pasteHTML(html);
					//range.select();				

				}
		}

			
}


//******************************************************************************************
	function EditorOnSetImage(id)
	{
		var ImagePath = "";
		var AltText = "";
		var HyperLinh = "";
		var html = "";
		var Border = "";
		var HSpace = "";
		var VSpace = "";
		var Alignment  = "";
		var myReturnValue;
		var args = new Array(6);
		
		if (!EditorValidateMode(id)) 
		{
			return;
		}
		
		if (eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.type == "Control")
		{
			var range1 = eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.createRange().item(0);
					
			args[0] = range1.src;
			args[1] = range1.alt;
			args[2] = range1.border;
			args[3] = range1.hspace;
			args[4] = range1.vspace;
			args[5] = range1.align;

			range1.src = "";
			range1.src = args[0];
		}
		
		else
		{
			myReturnValue = showModalDialog("InsertImage.asp", "", "font-family:Verdana;font-size:12;dialogWidth:37em;dialogHeight:20em");
			
				if (myReturnValue != null)
					{
						var range = eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.createRange();
						ImagePath = myReturnValue[0];
						AltText = myReturnValue[1];
						HyperLink = myReturnValue[2];
						Border = myReturnValue[3];
						HSpace = myReturnValue[4];
						VSpace = myReturnValue[5];
						Alignment = myReturnValue[6];

						html = '<img';
			
						if (AltText.length !== 0)
							{
								html = html + ' alt=' + AltText;
							}

						if (Alignment.length !== 0)
							{	
								html = html + ' align=' + Alignment;
							}
				
						html = html + ' src=' + ImagePath + ' border=' + Border  + ' hspace=' +  HSpace + ' vspace=' + VSpace + '>';
				
						if (HyperLink.length !== 0)
							{
								html = '<a href=' + HyperLink + '>' + html + '</a>'
							}

						range.pasteHTML(html);
						range.select();
				}
		 }
	}


//*****************************************************************
function EditorOnPreview(id)
{

var previewHTML; 
//var winDef;
//var newwin;
var vHeight;
var vWidth;
var newwin;

vHeight = 550;
vWidth = 590;
previewHTML = eval(EDITOR_COMPOSITION_PREFIX + id).document.body.innerHTML;

	winDef = 'status=no,resizable=no,scrollbars=yes,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(',');
	winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
	winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);

	newwin = open('', '_blank', winDef);
	
	newwin.document.writeln('<html>');
	newwin.document.writeln('<head>');
	
	newwin.document.writeln('<script language=\"JavaScript\">');
	newwin.document.writeln('function EnlargePicture(vLink, vHeight, vWidth)');
	newwin.document.writeln('{');
	newwin.document.writeln('var winDef;');
	newwin.document.writeln('var newwin1;');
	newwin.document.writeln('winDef = \'status=no,resizable=no,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes,height=\'.concat(vHeight).concat(\',\').concat(\'width=\').concat(vWidth).concat(\',\');');
	newwin.document.writeln('winDef = winDef.concat(\'top=\').concat((screen.height - vHeight)/2).concat(\',\');');
	newwin.document.writeln('winDef = winDef.concat(\'left=\').concat((screen.width - vWidth)/2);');
	newwin.document.writeln('newwin1 = window.open(\'\', \'_blank\', winDef);');
	newwin.document.writeln('newwin1.document.writeln(\'<html>\');');
	newwin.document.writeln('newwin1.document.writeln(\'<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">\');');
	newwin.document.writeln('newwin1.document.writeln(\'<img src="\' + vLink + \'" onclick="window.close();" style="cursor:hand;">\');');
	newwin.document.writeln('newwin1.document.writeln(\'</body>\');');
	newwin.document.writeln('newwin1.document.writeln(\'</html>\');');
	newwin.document.writeln('}');
	newwin.document.writeln('</script>');

	newwin.document.writeln('<TITLE>Preview</TITLE>');
	newwin.document.writeln('</head>');
	newwin.document.writeln('<body topmargin="5" leftmargin="5" marginheight="0" marginwidth="0">');
	newwin.document.writeln(previewHTML);
	newwin.document.writeln('<center>&lt;<a href="" onClick="window.close();">Close</a>&gt;</center>');
	newwin.document.writeln('</body>');
	newwin.document.writeln('</html>');
	
}


//*************************************************************
function EditorSetCellProperties(id)
{
	if (!EditorValidateMode(id)) 
	{
		return;
	}

	var myvar;
	var args = new Array(6);
	var myReturnValue;
	var Width;
	var Height;
	var BackGroundPicture;
	var BgColor;
	var VAlignment;
	var HAlignment;

	myvar = eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.createRange().parentElement().tagName;
	if (myvar == "TD")
	{
			var range1 = eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.createRange().parentElement();
		
			args[0] = range1.getAttribute("width",0);
			args[1] = range1.getAttribute("height",0);
			args[2] = range1.getAttribute("background",0);
			args[3] = range1.getAttribute("bgcolor",0);
			args[4] = range1.getAttribute("valign",0);
			args[5] = range1.getAttribute("align",0);

		myReturnValue = showModalDialog("CellProperties.htm", args, "font-family:Verdana;font-size:12;dialogWidth:40em;dialogHeight:17em");

		if (myReturnValue != null)
				{
					Width = myReturnValue[0];
					Height = myReturnValue[1];
					BackGroundPicture = myReturnValue[2]
					BgColor = myReturnValue[3];
					VAlignment = myReturnValue[4];
					HAlignment = myReturnValue[5]; 

					range1.setAttribute("width", Width, 0);
					range1.setAttribute("height", Height, 0);
					range1.setAttribute("background", BackGroundPicture, 0);
					range1.setAttribute("bgcolor", BgColor, 0);
					range1.setAttribute("valign", VAlignment, 0);
					range1.setAttribute("align", HAlignment, 0);

				}
	}
	
}


//******************************************
function Replace_All(iStr, v1, v2)
{
	var i = 0, oStr = '', j = v1.length;

	while (i < iStr.length)
	{
		if (iStr.substr(i, j) == v1)
		{
			oStr+=v2;
			i+=j
		}
		else
		{
			oStr+=iStr.charAt(i);
			i++;
		}
	}

	return oStr;
}


//******************************************************************************************
	function SetTopImage(id)
	{
		
		if (!EditorValidateMode(id)) 
		{
			return;
		}
		
		if (eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.type == "Control")
		{
			var range = eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.createRange().item(0);		
			PageTopImage = range.src;
			PageTopImage = Replace_All(PageTopImage, window.location.protocol + '//' + window.location.host, '');
			document.Compose.PageTopImage.value = PageTopImage;
		
		}
	}
