function formatHTML(format, defaultVal){
	document.WYSIWYGEditor.document.execCommand(format, "", defaultVal);
	document.WYSIWYGEditor.focus();
}
			
function SaveDocument(formName) {
	document.forms[formName].WYSIWYGContent.value = WYSIWYGEditor.document.body.innerHTML;
	document.forms[formName].submit();
}
		
function swapImage(imagename, imagesrc) {
	document[imagename].src = imagesrc;
}

function loadContent(textToPaste) {
	document.frames.WYSIWYGEditor.document.open();
	document.frames.WYSIWYGEditor.document.write(textToPaste);
	document.frames.WYSIWYGEditor.document.close();
}

function previewContent(textToPaste,EditorWidth, EditorHeight) {
	document.write("<TABLE CELLPADDING=\"1\" CELLSPACING=\"1\" BORDER=\"0\" BGCOLOR=\"#CCCCCC\">");
	document.write("<TR>");
	document.write("<TD><IFrame width=" + EditorWidth + " height=" + EditorHeight + " ID=\"WYSIWYGEditor\" name=\"WYSIWYGEditor\"></IFrame></TD>");
	document.write("</TR>");
	document.write("</TABLE>");
	document.WYSIWYGEditor.document.designMode = "On";
	document.frames.WYSIWYGEditor.document.open();
	document.frames.WYSIWYGEditor.document.write(textToPaste);
	document.frames.WYSIWYGEditor.document.close();
}

function displayWYSIWYGEditor(EditorWidth, EditorHeight) {	
document.write('<TABLE CELLPADDING="1" CELLSPACING="1" BORDER="0" BGCOLOR="#CCCCCC">');
	document.write('<TR>');
	document.write('<TD>');
	document.write('<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">');
	document.write('<TR BGCOLOR="#CCCCCC">');
	
	document.write('<TD>');
	document.write('<select id="FormatBox" onChange="formatHTML(\'formatblock\', this.options[this.selectedIndex].value);">');
	document.write('<option value=""></option>');
	document.write('<option value="Heading 1">H1</option>');
	document.write('<option value="Heading 2">H2</option>');
	document.write('<option value="Heading 3">H3</option>');
	document.write('<option value="Heading 4">H4</option>');
	document.write('<option value="Heading 5">H5</option>');
	document.write('<option value="Heading 6">H6</option>');	
	document.write('</select>');
	document.write('</TD>');
	
	document.write("<TD><a onClick=\"swapImage(\'cut\', \'/cms/cmsimages/editor_cut_click.gif\'); formatHTML(\'Cut\', \'\');\" OnMouseOver=\"swapImage(\'cut\', \'/cms/cmsimages/editor_cut_on.gif\');\" OnMouseOut=\"swapImage(\'cut\', \'/cms/cmsimages/editor_cut_off.gif\');\"><img src=\"/cms/cmsimages/editor_cut_off.gif\" border=\"0\" hspace=\"0\" vspace=\"0\" alt=\"Cut\" name=\"cut\"></a></TD>");
	document.write("<TD><a onClick=\"swapImage(\'copy\', \'/cms/cmsimages/editor_copy_click.gif\'); formatHTML(\'Copy\', \'\');\" OnMouseOver=\"swapImage(\'copy\', \'/cms/cmsimages/editor_copy_on.gif\');\" OnMouseOut=\"swapImage(\'copy\', \'/cms/cmsimages/editor_copy_off.gif\');\"><img src=\"/cms/cmsimages/editor_copy_off.gif\" border=\"0\" hspace=\"0\" vspace=\"0\" alt=\"Copy\" name=\"copy\"></a></TD>");
	document.write("<TD><a onClick=\"swapImage(\'paste\', \'/cms/cmsimages/editor_paste_click.gif\'); formatHTML(\'Paste\');\"  OnMouseOver=\"swapImage(\'paste\', '/cms/cmsimages/editor_paste_on.gif\');\" OnMouseOut=\"swapImage(\'paste\', \'/cms/cmsimages/editor_paste_off.gif\');\"><img src=\"/cms/cmsimages/editor_paste_off.gif\" border=\"0\" hspace=\"0\" vspace=\"0\" alt=\"Paste\" name=\"paste\"></a></TD>");
	document.write("<TD><a onClick=\"swapImage(\'delete\', \'/cms/cmsimages/editor_delete_click.gif\'); formatHTML(\'Delete\');\"  OnMouseOver=\"swapImage(\'delete\', \'/cms/cmsimages/editor_delete_on.gif\');\" OnMouseOut=\"swapImage(\'delete\', \'/cms/cmsimages/editor_delete_off.gif\');\"><img src=\"/cms/cmsimages/editor_delete_off.gif\" border=\"0\" hspace=\"0\" vspace=\"0\" alt=\"Delete\" name=\"delete\"></a></TD>");
	document.write("<TD><img src=\"/cms/cmsimages/strip.gif\" border=\"0\" hspace=\"10\" vspace=\"3\"></TD>");
	document.write("<TD><a onClick=\"swapImage(\'undo\', \'/cms/cmsimages/editor_undo_click.gif\'); formatHTML(\'Undo\', \'\');\" OnMouseOver=\"swapImage(\'undo\', \'/cms/cmsimages/editor_undo_on.gif\');\" OnMouseOut=\"swapImage(\'undo\', \'/cms/cmsimages/editor_undo_off.gif\');\"><img src=\"/cms/cmsimages/editor_undo_off.gif\" border=\"0\" hspace=\"0\" vspace=\"0\" alt=\"Undo\" name=\"undo\"></a></TD>");
	document.write("<TD><a onClick=\"swapImage(\'redo\', \'/cms/cmsimages/editor_redo_click.gif\'); formatHTML(\'Redo\', \'\');\" OnMouseOver=\"swapImage(\'redo\', \'/cms/cmsimages/editor_redo_on.gif\');\" OnMouseOut=\"swapImage(\'redo\', \'/cms/cmsimages/editor_redo_off.gif\');\"><img src=\"/cms/cmsimages/editor_redo_off.gif\" border=\"0\" hspace=\"0\" vspace=\"0\" alt=\"Redo\" name=\"redo\"></a></TD>");
	document.write("<TD><img src=\"/cms/cmsimages/strip.gif\" border=\"0\" hspace=\"10\" vspace=\"3\"></TD>");
	document.write("<TD><a onClick=\"swapImage(\'bold\', \'/cms/cmsimages/editor_bold_click.gif\'); formatHTML(\'Bold\', \'\');\" OnMouseOver=\"swapImage(\'bold\', \'/cms/cmsimages/editor_bold_on.gif\');\" OnMouseOut=\"swapImage(\'bold\', \'/cms/cmsimages/editor_bold_off.gif\');\"><img src=\"/cms/cmsimages/editor_bold_off.gif\" border=\"0\" hspace=\"0\" vspace=\"0\" alt=\"Bold\" name=\"bold\"></a></TD>");
	document.write("<TD><a onClick=\"swapImage(\'italic\', \'/cms/cmsimages/editor_italic_click.gif\'); formatHTML(\'Italic\', \'\');\" OnMouseOver=\"swapImage(\'italic\', \'/cms/cmsimages/editor_italic_on.gif\');\" OnMouseOut=\"swapImage(\'italic\', \'/cms/cmsimages/editor_italic_off.gif\');\"><img src=\"/cms/cmsimages/editor_italic_off.gif\" border=\"0\" hspace=\"0\" vspace=\"0\" alt=\"Italic\" name=\"italic\"></a></TD>");
	document.write("<TD><a onClick=\"swapImage(\'underline\', \'/cms/cmsimages/editor_underline_click.gif\'); formatHTML(\'Underline\', \'\');\" OnMouseOver=\"swapImage(\'underline\', \'/cms/cmsimages/editor_underline_on.gif\');\" OnMouseOut=\"swapImage(\'underline\', \'/cms/cmsimages/editor_underline_off.gif\');\"><img src=\"/cms/cmsimages/editor_underline_off.gif\" border=\"0\" hspace=\"0\" vspace=\"0\" alt=\"Underline\" name=\"underline\"></a></TD>");
	document.write("<TD><img src=\"/cms/cmsimages/strip.gif\" border=\"0\" hspace=\"10\" vspace=\"3\"></TD>");
	document.write("<TD><a onClick=\"swapImage(\'alignleft\', \'/cms/cmsimages/editor_alignleft_click.gif\'); formatHTML(\'JustifyLeft\', \'\');\" OnMouseOver=\"swapImage(\'alignleft\', \'/cms/cmsimages/editor_alignleft_on.gif\');\" OnMouseOut=\"swapImage(\'alignleft\', \'/cms/cmsimages/editor_alignleft_off.gif\');\"><img src=\"/cms/cmsimages/editor_alignleft_off.gif\" border=\"0\" hspace=\"0\" vspace=\"0\" alt=\"Aling Left\" name=\"alignleft\"></a></TD>");
	document.write("<TD><a onClick=\"swapImage(\'aligncenter\', \'/cms/cmsimages/editor_aligncenter_click.gif\'); formatHTML(\'JustifyCenter\', \'\');\" OnMouseOver=\"swapImage(\'aligncenter\', \'/cms/cmsimages/editor_aligncenter_on.gif\');\" OnMouseOut=\"swapImage(\'aligncenter\', \'/cms/cmsimages/editor_aligncenter_off.gif\');\"><img src=\"/cms/cmsimages/editor_aligncenter_off.gif\" border=\"0\" hspace=\"0\" vspace=\"0\" alt=\"Aling Center\" name=\"aligncenter\"></a></TD>");
	document.write("<TD><a onClick=\"swapImage(\'alignright\', \'/cms/cmsimages/editor_alignright_click.gif\'); formatHTML(\'JustifyRight\', \'\');\" OnMouseOver=\"swapImage(\'alignright\', \'/cms/cmsimages/editor_alignright_on.gif\');\" OnMouseOut=\"swapImage(\'alignright\', \'/cms/cmsimages/editor_alignright_off.gif\');\"><img src=\"/cms/cmsimages/editor_alignright_off.gif\" border=\"0\" hspace=\"0\" vspace=\"0\" alt=\"Aling Right\" name=\"alignright\"></a></TD>");
	document.write("<TD><img src=\"/cms/cmsimages/strip.gif\" border=\"0\" hspace=\"10\" vspace=\"3\"></TD>");
	document.write("<TD><a onClick=\"swapImage(\'orderedlist\', \'/cms/cmsimages/editor_orderedlist_click.gif\'); formatHTML(\'InsertOrderedList\', \'\');\" OnMouseOver=\"swapImage(\'orderedlist\', \'/cms/cmsimages/editor_orderedlist_on.gif\');\" OnMouseOut=\"swapImage(\'orderedlist\', \'/cms/cmsimages/editor_orderedlist_off.gif\');\"><img src=\"/cms/cmsimages/editor_orderedlist_off.gif\" border=\"0\" hspace=\"0\" vspace=\"0\" alt=\"Ordered List\" name=\"orderedlist\"></a></TD>");
	document.write("<TD><a onClick=\"swapImage(\'unorderedlist\', \'/cms/cmsimages/editor_unorderedlist_click.gif\'); formatHTML(\'InsertUnOrderedList\', \'\');\" OnMouseOver=\"swapImage(\'unorderedlist\', \'/cms/cmsimages/editor_unorderedlist_on.gif\');\" OnMouseOut=\"swapImage(\'unorderedlist\', \'/cms/cmsimages/editor_unorderedlist_off.gif\');\"><img src=\"/cms/cmsimages/editor_unorderedlist_off.gif\" border=\"0\" hspace=\"0\" vspace=\"0\" alt=\"Unordered List\" name=\"unorderedlist\"></a></TD>");
	document.write("<TD><img src=\"/cms/cmsimages/strip.gif\" border=\"0\" hspace=\"10\" vspace=\"3\"></TD>");
	document.write("<TD><a onClick=\"swapImage(\'link\', \'/cms/cmsimages/editor_link_click.gif\'); formatHTML(\'CreateLink\');\" OnMouseOver=\"swapImage(\'link\', \'/cms/cmsimages/editor_link_on.gif\');\" OnMouseOut=\"swapImage(\'link\', \'/cms/cmsimages/editor_link_off.gif\');\"><img src=\"/cms/cmsimages/editor_link_off.gif\" border=\"0\" hspace=\"0\" vspace=\"0\" alt=\"Add Or Edit Link\" name=\"link\"></a></TD>");
	document.write("<TD><a onClick=\"swapImage(\'unlink\', \'/cms/cmsimages/editor_unlink_click.gif\'); formatHTML(\'UnLink\', \'\');\" OnMouseOver=\"swapImage(\'unlink\', \'/cms/cmsimages/editor_unlink_on.gif\');\" OnMouseOut=\"swapImage(\'unlink\', \'/cms/cmsimages/editor_unlink_off.gif\');\"><img src=\"/cms/cmsimages/editor_unlink_off.gif\" border=\"0\" hspace=\"0\" vspace=\"0\" alt=\"Remove Link\" name=\"unlink\"></a></TD>");
	document.write("<TD WIDTH=\"100%\"></TD>");
	document.write("</TR>");
	document.write("</TABLE>");
	document.write("</TD>");
	document.write("</TR>");
	
	document.write('<TR>');
	document.write('<TD><IFrame width=' + EditorWidth + ' height=' + EditorHeight + ' ID="WYSIWYGEditor" name="WYSIWYGEditor"></IFrame></TD>');
	document.write('</TR>');
	document.write('<TR>');
	document.write('<TD><input type="hidden" name="WYSIWYGContent" value=""></TD>');
	document.write('</TR>');
	document.write('</TABLE>');
	document.WYSIWYGEditor.document.designMode = "On";
}

