	var	EditTypes = new Array('DW', 		'FP',			'HT',			'WD');
	var	EditFuncs = new Array( DW_Populate,	 FP_Populate,	 HT_Populate,	 WD_Populate);


		function Step4Load()
		{
			var UseIcon = (O3_RadioValue('WizardForm', 'UseIcon') != 'No');
			var UseText = (O3_RadioValue('WizardForm', 'UseText') != 'No');
			var	className;
			
			if(UseIcon)
			{
			    document.getElementById("PreviewImage3").src = RelIconPath + '/' + document.getElementById("IconImage").value;
			    document.getElementById("PreviewImage4").src = RelIconPath + '/' + document.getElementById("IconImage").value;
				document.getElementById("LinkCopyDialog").className = 'LinkCopyDialog LinkCopyDialogActive';
				
				GetClass('.InstructIcon').display = 'block';
				if(UseText)
				{
					GetClass('.InstructIconOnly').display = 'none';
					GetClass('.InstructIconText').display = 'block';
					GetClass('.InstructText').display = 'block';
					GetClass('.InstructTextOnly').display = 'none';
				}
				else
				{
					GetClass('.InstructIconOnly').display = 'block';
					GetClass('.InstructIconText').display = 'none';
					GetClass('.InstructText').display = 'none';
					GetClass('.InstructTextOnly').display = 'none';
				}
			}
			else
			{
				document.getElementById("LinkCopyDialog").className = 'LinkCopyDialog';
				GetClass('.InstructIconOnly').display = 'none';
				GetClass('.InstructIcon').display = 'none';
				GetClass('.InstructIconText').display = 'none';
				GetClass('.InstructText').display = 'block';
				GetClass('.InstructTextOnly').display = 'block';
			}
			LinkCopyChoice();
			document.getElementById('WizardForm').action='../cgi-bin/t2m_linkbuilder.cgi';
			document.getElementById('SendResult').src='';

			ShowLink('4');
			
		}
		
		function LinkCopyChoice()
		{
			if(O3_RadioValue('WizardForm', 'LinkCopy') == 'link')
			{
				document.getElementById("ImageLocnDialog").className = 'ImageLocnDialog';
				GetClass('.InstructIconLink').display = 'block';
				GetClass('.InstructIconCopy').display = 'none';
			}
			else
			{				
				document.getElementById("ImageLocnDialog").className = 'ImageLocnDialog ImageLocnDialogActive';
				GetClass('.InstructIconLink').display = 'none';
				GetClass('.InstructIconCopy').display = 'block';
			}
			document.getElementById('FullLink').value = BuildHTML()
			document.getElementById('FullLinkJS').value = WebJSIncl + BuildHTML('javascript')
			document.getElementById('FullLinkEmail').value = BuildHTML('email')
			EditChoice();
		}
		function EditChoice()
		{
			var	EditType = O3_RadioValue('WizardForm', 'EditType');
			
			for(i=0; i < EditTypes.length; i++)
			{
				if(EditTypes[i] == EditType)
				{
					document.getElementById(EditTypes[i] + '_Instruct').className = 'EditInstruct EditInstructActive';
					EditFuncs[i]();
				}
				else
				{
					document.getElementById(EditTypes[i] + '_Instruct').className = 'EditInstruct';
				}
			}
			ShowMe('ShowMe_Instruct.jpg', true);
		}

		function ShowMe(xi_Image_name, xi_Set)
		{
			if(xi_Set)
			{
				O3_Revert();
				Capture = false;
			}
			else Capture = true;
			O3_ImageSwap('UpdateShowMeImg', 'img/ShowMe/' + xi_Image_name, Capture);
		}

	function Editor_Populate(xi_Editor)
	{
		var	path;

		//ED_Instruct_ImageLocn
		if(O3_RadioValue('WizardForm', 'LinkCopy') == 'copy')
		{
			path = document.getElementById('ImageLocn').value;
		}
		else
		{
			path = WebIconPath;
		}

		document.getElementById(xi_Editor + '_Instruct_IconSaveLocal').innerHTML = path;
		
		if(!path.match(/^\s*$/) && !path.match(/\/$/))
			path += '/';
			
		document.getElementById(xi_Editor + '_Instruct_ImageLocn').innerHTML = path + document.getElementById('IconImage').value;

		//ED_Instruct_HrefIcon
		document.getElementById(xi_Editor + '_Instruct_HRefIcon').innerHTML = document.getElementById('Link').value;

		//ED_Instruct_Text
		document.getElementById(xi_Editor + '_Instruct_Text').innerHTML = document.getElementById('InputText').value;
		
		//ED_Instruct_HrefText
		document.getElementById(xi_Editor + '_Instruct_HRefText').innerHTML = document.getElementById('Link').value;

		return path;
	}
	function DW_Populate()
	{
		var	path = Editor_Populate('DW');
		var	format_inst = '';
		
		//DW_Instruct_TextFormat
		format_inst = BuildStyle();
		if (format_inst.length != 0) {
		    document.getElementById('DW_Instruct_TextFormat').innerHTML = format_inst;
		    document.getElementById('DW_Instruct_TextFormat_div').style.display = "";
		}
        
		O3_PreloadImgs(new Array(	'DW_ShowMe_IconAddress.jpg', 'DW_ShowMe_IconInsertLink.jpg',
									'DW_ShowMe_IconInsertLocal.jpg','DW_ShowMe_ImageAttr.jpg', 
									'DW_ShowMe_MenuInsertHyperlink.jpg', 'DW_ShowMe_MenuInsertImage.jpg',
									'DW_ShowMe_MenuModifyTag.jpg','DW_ShowMe_TagEdit.jpg',
									'DW_ShowMe_TextAddress.jpg', 'DW_ShowMe_ToolInsertHyperlink.jpg'
								),
					   'img/ShowMe/');
	}
	
	function FP_Populate()
	{
		var	path = Editor_Populate('FP');
		var	format_inst = '';

		//FP_Instruct_TextFormat
		format_inst = FP_Populate_Format();
		document.getElementById('FP_Instruct_TextFormat').innerHTML = format_inst;

		O3_PreloadImgs(new Array(	'FP_ShowMe_FormatFontColorInput.jpg', 'FP_ShowMe_FormatFontColorOK.jpg',
									'FP_ShowMe_FormatFontFont.jpg','FP_ShowMe_FormatFontMoreColor.jpg', 
									'FP_ShowMe_FormatFontOK.jpg', 'FP_ShowMe_FormatFontSize.jpg',
									'FP_ShowMe_FormatFontStyle.jpg','FP_ShowMe_HyperlinkOK.jpg',
									'FP_ShowMe_IconAddress.jpg', 'FP_ShowMe_IconInsertLink.jpg',
									'FP_ShowMe_IconInsertLocal.jpg','FP_ShowMe_MenuInsertHyperlink.jpg',
									'FP_ShowMe_MenuInsertPicture.jpg', 'FP_ShowMe_StyleButton.jpg',
									'FP_ShowMe_StyleFontMenu.jpg', 'FP_ShowMe_StyleOK.jpg',
									'FP_ShowMe_TextAddress.jpg'
								),
					   'img/ShowMe/');

	}
			
	function FP_Populate_Format()
	{
		var	format_inst;
		var	inst_req = false;
		var	bold_ital = "";
		var value;
		
		format_inst =	"<p>Click the <span class=\"KeyWord\">Style </span> button " +
						"<img src=\"img/Graphics/ShowMe.gif\" alt=\"Show Me\" title=\"Show Me\"	onmouseover=\"ShowMe('FP_ShowMe_StyleButton.jpg', false)\" onclick=\"ShowMe('FP_ShowMe_StyleButton.jpg', true)\" onmouseout=\"O3_Revert();\">.</p>" +
					  	"<p>In the style dialog select <span class=\"KeyWord\">Font</span> from the Format menu " +
						"<img src=\"img/Graphics/ShowMe.gif\" alt=\"Show Me\" title=\"Show Me\"	onmouseover=\"ShowMe('FP_ShowMe_StyleFontMenu.jpg', false)\" onclick=\"ShowMe('FP_ShowMe_StyleFontMenu.jpg', true)\" onmouseout=\"O3_Revert();\">.</p>";
		if(document.getElementById("InputFont").value)
		{
			inst_req = true;
			format_inst += "<p>In the <span class=\"KeyWord\">Font</span> section type or paste <pre>" + document.getElementById("InputFont").value + "</pre> (or you can select it from the list)."
			format_inst += "<img src=\"img/Graphics/ShowMe.gif\" alt=\"Show Me\" title=\"Show Me\"	onmouseover=\"ShowMe('FP_ShowMe_FormatFontFont.jpg', false)\" onclick=\"ShowMe('FP_ShowMe_FormatFontFont.jpg', true)\" onmouseout=\"O3_Revert();\">.</p>";
		}
		if((O3_RadioValue('WizardForm', 'FontWeight')) == 'bold')
		{
			bold_ital += "Bold";
		}
		if((O3_RadioValue('WizardForm', 'FontStyle')) == 'italic')
		{
			bold_ital += "Italic";
		}

		if(bold_ital)
		{
			inst_req = true;
			format_inst += "<p>In the Font <span class=\"KeyWord\">Style</span> section type or paste <pre>" + bold_ital + "</pre> (or you can select it from the list).";
			format_inst += "<img src=\"img/Graphics/ShowMe.gif\" alt=\"Show Me\" title=\"Show Me\"	onmouseover=\"ShowMe('FP_ShowMe_FormatFontStyle.jpg', false)\" onclick=\"ShowMe('FP_ShowMe_FormatFontStyle.jpg', true)\" onmouseout=\"O3_Revert();\">.</p>";
		}
		if(O3_RadioValue('WizardForm', 'FontSizeSpec') != 'default')
		{
			inst_req = true;
			format_inst += "<p>In the <span class=\"KeyWord\">Font Size</span> section type or paste <pre>" + document.getElementById("FontSize").value + document.getElementById("FontUnit").value + "</pre> (or you can select it from the list)."
			format_inst += "<img src=\"img/Graphics/ShowMe.gif\" alt=\"Show Me\" title=\"Show Me\"	onmouseover=\"ShowMe('FP_ShowMe_FormatFontSize.jpg', false)\" onclick=\"ShowMe('FP_ShowMe_FormatFontSize.jpg', true)\" onmouseout=\"O3_Revert();\">.</p>";
		}
		if(document.getElementById("InputColour").value)
		{
			inst_req = true;
			format_inst += "<p>In the <span class=\"KeyWord\">Color</span> section type select More Colors to display the Colour dialog ";
			format_inst += "<img src=\"img/Graphics/ShowMe.gif\" alt=\"Show Me\" title=\"Show Me\"	onmouseover=\"ShowMe('FP_ShowMe_FormatFontMoreColor.jpg', false)\" onclick=\"ShowMe('FP_ShowMe_FormatFontMoreColor', true)\" onmouseout=\"O3_Revert();\">.</p>";
			format_inst += "<p>In the <span class=\"KeyWord\">Value</span> input type or paste <span class='DisplayHTML'>" + document.getElementById("InputColour").value + "</span>."
			format_inst += "<img src=\"img/Graphics/ShowMe.gif\" alt=\"Show Me\" title=\"Show Me\"	onmouseover=\"ShowMe('FP_ShowMe_FormatFontColorInput.jpg', false)\" onclick=\"ShowMe('FP_ShowMe_FormatFontColorInput.jpg', true)\" onmouseout=\"O3_Revert();\">.</p>";
			format_inst += "<p>Press the <span class=\"KeyWord\">OK</span> button to return to the Font Format dialog ";
			format_inst += "<img src=\"img/Graphics/ShowMe.gif\" alt=\"Show Me\" title=\"Show Me\"	onmouseover=\"ShowMe('FP_ShowMe_FormatFontColorOK.jpg', false)\" onclick=\"ShowMe('FP_ShowMe_FormatFontColorOK.jpg', true)\" onmouseout=\"O3_Revert();\">.</p>";
		}
		format_inst += "<p>Press the <span class=\"KeyWord\">OK</span> button to return to the Modify Style dialog ";
		format_inst += "<img src=\"img/Graphics/ShowMe.gif\" alt=\"Show Me\" title=\"Show Me\"	onmouseover=\"ShowMe('FP_ShowMe_FormatFontOK.jpg', false)\" onclick=\"ShowMe('FP_ShowMe_FormatFontOK.jpg', true)\" onmouseout=\"O3_Revert();\">.</p>";
		format_inst += "<p>Press the <span class=\"KeyWord\">OK</span> button to return to the Hyperlink dialog ";
		format_inst += "<img src=\"img/Graphics/ShowMe.gif\" alt=\"Show Me\" title=\"Show Me\"	onmouseover=\"ShowMe('FP_ShowMe_StyleOK.jpg', false)\" onclick=\"ShowMe('FP_ShowMe_StyleOK.jpg', true)\" onmouseout=\"O3_Revert();\">.</p>";
		format_inst += "<p>Press the <span class=\"KeyWord\">OK</span> button ";
		format_inst += "<img src=\"img/Graphics/ShowMe.gif\" alt=\"Show Me\" title=\"Show Me\"	onmouseover=\"ShowMe('FP_ShowMe_HyperlinkOK.jpg', false)\" onclick=\"ShowMe('FP_ShowMe_HyperlinkOK.jpg', true)\" onmouseout=\"O3_Revert();\">.</p>";


		if(!inst_req)
		{
			format_inst = "";
		}
		if((O3_RadioValue('WizardForm', 'TextDec')) == 'none')
		{
			format_inst += "<p>With your link still highlighted click off the <span class=\"KeyWord\">Underline</span> button on the toolbar";
			format_inst += "<img src=\"img/Graphics/ShowMe.gif\" alt=\"Show Me\" title=\"Show Me\"	onmouseover=\"ShowMe('FP_ShowMe_NoUnderline.jpg', false)\" onclick=\"ShowMe('FP_ShowMe_NoUnderline.jpg', true)\" onmouseout=\"O3_Revert();\">.</p>";
		}
		return format_inst;

	}
	
	function HT_Populate()
	{
		document.getElementById('HT_Instruct_FullLink').value = document.getElementById('FullLink').value;
		document.getElementById('HT_Instruct_FullLinkJS').value = document.getElementById('FullLinkJS').value;
		
		// qdocument.getElementById('HT_Instruct_IconSaveLocal').innerHTML = document.getElementById('ImageLocn').value;
	}		
	
	function BuildStyle()
	{
		var	style = '';
		if(value = document.getElementById("InputFont").value)
			style += " font-family:" + value + ';';
		if((value = O3_RadioValue('WizardForm', 'FontWeight')) != 'default')
			style += " font-weight:" + value + ';';
		if((value = O3_RadioValue('WizardForm', 'FontStyle')) != 'default')
			style += " font-style:" + value + ';';
		if(O3_RadioValue('WizardForm', 'FontSizeSpec') != 'default')
			style += " font-size:" + document.getElementById("FontSize").value + document.getElementById("FontUnit").value + ';';
		if(value = document.getElementById("InputColour").value)
			style += " color:" + value + ';';
		if((value = O3_RadioValue('WizardForm', 'TextDec')) != 'default')
			style += " text-decoration:" + value + ';';
		return style;
	}
	
	function BuildHTML(xi_dest)
	{
		var	rawlink
		var fulllink = '';
		var imageLink = '';
		var textStyle = '';
		var linkText = '';
		var value;

		if (xi_dest == 'javascript' )
		    rawlink = document.getElementById('RawJavaScript').value.replace(/><\/a>/, '');
		else
	        rawlink = '<a href="' + document.getElementById('Link').value + '"';

	    if(O3_RadioValue('WizardForm', 'UseIcon') == 'Yes') {
   	       imageLink = '<img alt="SMS me this info via txtit2me!" src="';
		    if(xi_dest && (xi_dest == 'email'))
		        imageLink += 'cid:img1';
			else
			{
				if(O3_RadioValue('WizardForm', 'LinkCopy') == 'link')
					value = WebIconPath;
				else
					value = document.getElementById("ImageLocn").value;
			
				if(!value.match(/^\s*$/) && !value.match(/\/$/))
					value += '/';
	            imageLink += value;
	            imageLink += document.getElementById("IconImage").value;
				
			}
			imageLink += '" style="border:0px;'
			   if (document.getElementById("IconAlign").value != '')
			        imageLink += ' vertical-align:'+document.getElementById('IconAlign').value+";"
			imageLink += '" />';
			
		}		
	
		if((value = O3_RadioValue('WizardForm', 'UseText')) == 'Yes') {
		    var style = BuildStyle();
		    if ( style != '')
			    textStyle += ' style="' + BuildStyle()+'"';
			linkText += ' ' + document.getElementById("InputText").value;
        }
        if (document.getElementById('TextLocn').value == "AFTER")
            fulllink = rawlink + textStyle + ' >' + imageLink + linkText + " </a>";
        else
            fulllink = rawlink + textStyle + ' >' + linkText + imageLink+ " </a>";
	
		return fulllink;
    }
	
	function WD_Populate()
	{
		;
	}		
	function SendEmail()
	{
		document.getElementById('WizardForm').submit();
	}
	function CopyInner(xi_Name)
	{
		copy2clip(document.getElementById(xi_Name).innerHTML);
    }
    function ShowDirect() 
    {
        if (document.getElementById('ShowHTML').checked == true) {
            document.getElementById('HT_Instruct_FullLink').style.display = '';
            document.getElementById('HT_Instruct_FullLinkJS').style.display = 'none';
        }
        else {
            document.getElementById('HT_Instruct_FullLink').style.display = 'none';
            document.getElementById('HT_Instruct_FullLinkJS').style.display = '';
        }
    }
    function copyHTML() 
    {
        if (document.getElementById('ShowHTML').checked == true)
            copy2clip(document.getElementById('HT_Instruct_FullLink').value);
        else
            copy2clip(document.getElementById('HT_Instruct_FullLinkJS').value);
    }
