//
//	COPYRIGHT NOTICE:
// 	Copyright 2002 - 2006 Barry Saxifrage. Stonebreaker Designs. All Rights Reserved.
//	By using this code you agree to indemnify Barry Saxifrage and Stonebreaker Designs 
//	from any liability that might arise from its use. Selling this code or distributing 
//	this code without prior written consent is expressly forbidden. Copyright notice  
//	must remain with this code. For more information: www.stonebreakerdesigns.com	
//

	function setDialogFocus() {
		window.focus();
		
	}
	function updater() {
		if (window.opener != null) {
			window.opener.refreshPage();
		}
	}
	function updaterSite() {
		if (window.opener != null) {
			window.opener.refreshSite();
		}
	}
	function limitText(cchMaxTextChars, nV) {
		// limits the amount of text that can be typed into text field
		var cch = 0; 
		var cchRem = 0; 
		var t = getDOM("cchMaxTxt",0);
		var o = document.frm.TEXT;
		if (nV > 1) { eval('o = document.frm.TEXT'+nV); }
		cch = o.value.length;
		cchRem = cchMaxTextChars - cch;
		t.innerHTML = cchRem;
		if (cchRem < 0) {
			var strT = o.value;
			o.value = strT.substring(0, (cchMaxTextChars-1));
		}
	}
	function limitTextEx(cchMaxTextChars, strLABEL) {
		var o;
		eval('o = document.frm.'+strLABEL);
		if (o.value.length > cchMaxTextChars) {
			var strT = o.value;
			o.value = strT.substring(0, (cchMaxTextChars-1));
		}
	}
	function initDlgWaitMsg() {
		var d = getDOM('dialogwaitmsg', 1);
		d.display = "none";
	}
	function showDlgWaitMsg() {
		var d = getDOM('dialogwaitmsg', 1);
		d.display = "block";
		d = getDOM('formbox', 1);
		//d.visibility = "hidden";
		window.scroll(0,0);
	}
	// open/close group of controls in a dialog
	function dlgPopGroup(id) {
		var d = getDOM(id, 1);
		if (d.display == 'block') { 
			d.display = 'none';
		} else {
			d.display = 'block';			 
		}

	}
	// open/close infobox in a dialog
	function dlgShowInfo(id) {
		var d = getDOM(id, 1);
		if (d.display =='block') { 
			d.display = 'none';
		} else {
			d.display = 'block';			 
		}
	}	

	function showOptions(id) {
		var d = getDOM(id,1);
		d.visibility = "visible";
	}
	function hideOptions(id) {
		var d = getDOM(id,1);
		d.visibility = "hidden";
	}
	function dlgGrowTextbox(id) {
		var o = getDOM(id,0);
		var nRows = o.rows;
		o.rows = nRows + 10;
	}
	function dlgShrinkTextbox(id) {
		var o = getDOM(id,0);
		var nRows = o.rows;
		nRows -= 10;
		if (nRows < 4) { nRows = 4; }
		o.rows = nRows;
	}
		

	// Create Group Heading used to pop-open a group of controls in a dialog
	function drawDlgSubHead(strTitle) {
		var str = '<div class="dialog_subtitle">'+gSiteTitleShort+'</div>';
		str += '<div class="dialog_title">'+strTitle+'</div>';
		document.writeln(str);
	}
	function drawDlgSubHeadTopic(strTitle, strTopicName) {
		var str = '<div class="dialog_subtitle" style="margin-bottom:6px;">'+gSiteTitleShort+'</div>';
		str += '<div class="tp_pgtitle">'+strTopicName+' section</div>';		
		str += '<div class="dialog_title" style="margin-left:10px;">'+strTitle+'</div>';
		document.writeln(str);
	}
	// Create Group Heading used to pop-open a group of controls in a dialog
	function drawDlgGroupHead(strTitle, strClickText, iPopGroup) {
		var str = getDlgGroupHeadHTML(strTitle, strClickText, iPopGroup);
		document.writeln(str);
	}
	function getDlgGroupHeadHTML(strTitle, strClickText, iPopGroup) {
		var str = '';
		// dotted line
		str += '<img src="dialogs/dlg_div.gif" width="301" height="7" alt="" border="0"><br>';
		// bold heading
		str += '<a href="javascript:dlgPopGroup(';
		str += "'dlg_popgroup"+iPopGroup+"'";
		str += ')" class="dlg_subhead">';
		str += strTitle;
		str += ' <img src="bits/dlg_pop_down.gif" width="10" height="6" alt="" border="0">';
		str += '</a><br>';
		// "click here to ..." link
		str += '<a href="javascript:dlgPopGroup(';
		str += "'dlg_popgroup"+iPopGroup+"'";
		str += ')" class="dlgnotesmall">';
		str += 'Click here to '+strClickText+'...';
		str += '</a><br>';
		str += '';
		return (str);
	}


	function drawDlgRowIntroText(strText) {
		var str = '';
		// <!-- IntroText -->
			str += '<tr>';
				str += '<td class="dlg_tdL"  valign="top">&nbsp;</td>';
				str += '<td class="dlg_tdC"  valign="top">';
					str += '<div class="dlg_introtext">';
						str += strText;
					str += '</div>';
				str += '</td>';
				str += '<td class="dlg_tdR" valign="top">&nbsp;</td>';
			str += '</tr>';
		document.writeln(str);
	}

	// 	scenarios:
	//		1. no idTopic, not admin: show nothing
	//		2. no idTopic, admin, and some topics...then show chooser with "general" as default
	//		3. if idTopic: show all choices
	function drawDlgTopicChooser(idTopic, strTopicName, fIsGeneral, aTopics, fIsAdmin) {
		var str = '';
		var nTopics = aTopics.length - 1;
		var fJustAdminOpt = (idTopic <= 0 && fIsAdmin && (nTopics > 0));
		
		// create pop-group if no idTopic and just optional editor item
		if (fJustAdminOpt) {
			str += '<table cellpadding="0" cellspacing="0" class="dlg_table"><tr>';
				str += '<td class="dlg_tdL" valign="top">&nbsp;</td>';
				str += '<td class="dlg_tdC" valign="top">';
					str+=  getDlgGroupHeadHTML('Section','choose sections',10);
				str += '</td><td class="dlg_tdR" valign="top">&nbsp;</td></tr>';
			str += '</table>';
			str += '<div id="dlg_popgroup10">';
		}

		// main table
		if ((idTopic > 0) || (fIsAdmin && (nTopics > 0))) {
			var strChk = '';
			if (fIsGeneral == 1) { strChk = ' checked '; }
			str += '<table cellpadding="0" cellspacing="0" class="dlg_table">';
			str += '<tr>';
				str += '<td class="dlg_tdL"  valign="top">&nbsp;</td>';
				str += '<td class="dlg_tdC"  valign="top">';
					// heading
					if (!fJustAdminOpt) {
						str += '<img src="dialogs/dlg_div.gif" width="301" height="7" alt="" border="0">';
						str += '<div class="dlg_subhead">SECTION</div>';
					}
					str += '<div class="dlgnote">Show your item in...</div>';					
					// controls
					if ((idTopic > 0) && (nTopics <= 1) && !fIsAdmin) {
						str += '<input type="hidden" name="TOPIC" value="'+idTopic+'">';
						str += '<input type="text" name="TOPICNAME" maxlength="120" class="dlg_noedit" value="'+strTopicName+' section"><br>';
					} else if (idTopic > 0) {
						str += '<select name="TOPIC" size="1" class="dlg_select" onchange="toggleIsGeneral()">';
						if (fIsAdmin) { str += '<option value="0">Main Frontpage section only</option>'; }
						str += '<option value="'+idTopic+'" selected>'+strTopicName+'</option>';
						for (var i = 0; i < nTopics; i++) {
							var aT = aTopics[i].split('|');
							var idT  		= aT[0];
							var strT 		= aT[1];
							var nTStatus 	= aT[2];
							if (idT != idTopic) { 
								str += '<option value="'+idT+'">'+strT+'</option>';
							}
						}
						str += '</select><br>';

					} else {
						str += '<select name="TOPIC" size="1" class="dlg_select" onchange="toggleIsGeneral()">';
						str += '<option value="0" selected>Main Frontpage section only</option>';
						for (var i = 0; i < nTopics; i++) {
							var aT = aTopics[i].split('|');
							var idT  		= aT[0];
							var strT 		= aT[1];
							var nTStatus 	= aT[2];
							if (idT != idTopic) { 
								str += '<option value="'+idT+'">'+strT+'</option>';
							}
						}
						str += '</select><br>';
						strChk = '';
					}
					var strIGDisplay = 'none';
					if (idTopic > 0) { strIGDisplay = 'block'; }
					str += '<div id="dlg_IsGeneral" style="display:'+strIGDisplay+'"><input type="checkbox" name="ISGENERAL" '+strChk+' value="1"> Also show in main frontpage section</div>';
					//str += '<img src="dialogs/dlg_div.gif" width="301" height="7" alt="" border="0">';
				str += '</td>';
				str += '<td class="dlg_tdR" valign="top"><br>'
				str += getInfoBoxHTML('Your item can appear in both an inside section and the main frontpage section.', 103);
				str += '</td>';
			str += '</tr>';
			str += '</table>';
		}
		
		// close pop-group 10 if open
		if (fJustAdminOpt) {
			str += '</table></div>';
		}
		
		document.writeln(str);
	}
	function toggleIsGeneral() {
		var nTp = document.frm.TOPIC[document.frm.TOPIC.selectedIndex].value;
		var d = getDOM('dlg_IsGeneral',1);
		if (nTp == 0) { 
			d.display = "none";
		} else {
			d.display = "block";		
		}

	}
	
	
	function drawDlgRowAuthor(strAuthor, strLabel, fRequired) {
		var str = '';
		var strReq = '';
		if (strLabel == '') { strLabel = "Created By"; }
		if (fRequired) { 
			strReq = '<span class="dlgrequired">*</span>'; 
			if (strAuthor == '') {
				var strB = GetCookie('byname');
				if (isNotEmpty(strB)) { strAuthor = strB; }
			}
		}
		// <!-- AUTHOR -->
			str += '<tr>';
				str += '<td class="dlg_tdL"  valign="top">'+strReq+''+strLabel+'</td>';
				str += '<td class="dlg_tdC"  valign="top">';
					str += '<input type="text" name="BYNAME" maxlength="30" class="dlg_edit" style="font-weight:bold;" value="'+strAuthor+'">';
				str += '</td>';
				str += '<td class="dlg_tdR">'
				str += '30 characters  max.';
				str += '</td>';
			str += '</tr>';
		document.writeln(str);
	}

	function drawDlgRowTitle(strCurTitle, strLabel, fRequired) {
		var str = '';
		var strReq = '';
		if (fRequired) { strReq = '<span class="dlgrequired">*</span>'; }
		// <!-- Title -->
			str += '<tr>';
				str += '<td class="dlg_tdL"  valign="top">'+strReq+''+strLabel+'</td>';
				str += '<td class="dlg_tdC"  valign="top">';
					str += '<input type="text" name="TITLE" maxlength="60" class="dlg_edit" style="font-weight:bold;" value="'+strCurTitle+'">';
				str += '</td>';
				str += '<td class="dlg_tdR">'
				str += '60 characters  max.';
				str += '</td>';
			str += '</tr>';
		document.writeln(str);
	}


	function drawDlgRowText(strCurText, strLabel, fRequired, cchMax) {
		drawDlgRowTextMax(strCurText, strLabel, fRequired, cchMax, false, 0, 1);
	}
	function drawDlgRowTextSpecial(strCurText, strLabel, fRequired, cchMax, fSpecialChars) {
		drawDlgRowTextMax(strCurText, strLabel, fRequired, cchMax, fSpecialChars, 0, 1);
	}
	function drawDlgRowTextAll(strCurText, strLabel, fRequired, cchMax, fSpecialChars, dyText) {
		drawDlgRowTextMax(strCurText, strLabel, fRequired, cchMax, fSpecialChars, dyText, 1);	
	}
	function drawDlgRowTextMax(strCurText, strLabel, fRequired, cchMax, fSpecialChars, dyText, nVersion) {
 		var str = '';
		var strReq = '';
		var strTEXT = 'TEXT';
		if (nVersion > 1) { strTEXT = 'TEXT' + nVersion; }
		var fButtons = false;
		if (fSpecialChars && (document.selection || document.getSelection)) { 
			fButtons = true; 
			strReq += '<br><br>';
		}
		if (dyText <= 1) { dyText = 8; }
		if (fRequired) { strReq += '<span class="dlgrequired">*</span>'; }
			str += '<tr>';
				str += '<td class="dlg_tdL"  valign="top">'+strReq+''+strLabel+'</td>';
				str += '<td class="dlg_tdC"  valign="top">';
					if (fButtons) {
						str += '<div style="margin:0px;padding:0px;background-color:#fff6e9;">';
						str += '<input type="button" onclick="dlgTextareaTag(\'b\','+nVersion+');" value="B" title="Make selected text Bold" style="font-size:9px;font-weight:bold;padding-left:3px;padding-right:3px;"/>';
						str += '<input type="button" onclick="dlgTextareaTag(\'i\','+nVersion+');" value="I" title="Make selected text Italic"  style="font-size:9px;font-style:italic;padding-left:3px;padding-right:3px;"/>';
						str += '<input type="button" onclick="dlgTextareaTag(\'u\','+nVersion+');" value="U" title="Make selected text Underlined"  style="font-size:9px;text-decoration:underline;padding-left:3px;padding-right:3px;"/>';
						str += '<input type="button" onclick="dlgTextareaTag(\'+\','+nVersion+');" value="+" title="Make selected text a bigger font size"  style="font-size:9px;padding-left:3px;padding-right:3px;"/>';
						str += '<input type="button" onclick="dlgTextareaTag(\'-\','+nVersion+');" value="-" title="Make selected text a small font size"  style="font-size:9px;padding-left:3px;padding-right:3px;"/>';
						str += '<input type="button" onclick="showInfoWindow(1);" value="Link" title="Learn how to link to another web page"  style="font-size:9px;padding-left:3px;padding-right:3px;"/>';
						str += '<input type="button" onclick="showInfoWindow(1);" value="Spell" title="Learn how to spell check your text"  style="font-size:9px;padding-left:3px;padding-right:3px;"/>';
						str += '<input type="button" onclick="showInfoWindow(1);" value="Help?" title="Learn how to format your text"  style="font-size:9px;"/>';
						str += '</div>';
					}					
					str += '<textarea style="margin-bottom:0px;" wrap="soft" rows="'+dyText+'" cols="11" name="'+strTEXT+'" id="frmTEXT'+nVersion+'" class="dlg_textarea" onKeyPress="limitText('+cchMax+','+nVersion+');" style="margin-top:0px;">';
					str += strCurText;
					str += '</textarea>';
					str += '<div style="width:100%;text-align:right;line-height:8px;font-size:6px;">';
					str += '<a href="javascript:dlgGrowTextbox(\'frmTEXT'+nVersion+'\')"><img src="bits/textbox_down.gif" width="40" height="10" alt="resize" title="Make text area larger" border="0"></a>';
					str += '<a href="javascript:dlgShrinkTextbox(\'frmTEXT'+nVersion+'\')"><img src="bits/textbox_up.gif" width="40" height="10" alt="resize" title="Shrink text area" border="0" style="margin-right:14px;"></a>';
					str += '</div>';				
				str += '</td>';
				str += '<td class="dlg_tdR" valign="top">'
					if (fSpecialChars) {
						if (fButtons) {
							str += '<br>Select text then click formatting button. See Help for details.<br>';
						} else {
							str += '<br><a href="javascript:showInfoWindow(1)" class="dlg_infotext">click for editing tips...</a>';				
						}	
					} else {
						str += '<br>Plain text only. No styles or weblinks.';
					}
					if (cchMax >= 1000) {
						cchMax += '';
						cchMax = cchMax.substring(0,cchMax.length-3) + ',' + cchMax.substring(cchMax.length-3,cchMax.length);
					}
					str += '<br><span id="cchMaxTxt">'+cchMax+'</span> characters<br>remaining<br>';
				str += '</td>';
			str += '</tr>';
		document.writeln(str);
	}
	function dlgTextareaTag(strTag, nVersion) {
		var idT = 'frmTEXT'+nVersion;
		var o = getDOM(idT,0);
		var strOpenTag  = '**';
		var strCloseTag = '**'
		if        (strTag == 'b') { strOpenTag = '**'; strCloseTag = '**';  }
		else if   (strTag == 'i') { strOpenTag = '!!'; strCloseTag = '!!';  }
		else if   (strTag == 'u') { strOpenTag = '__'; strCloseTag = '__';  }
		else if   (strTag == '+') { strOpenTag = '++'; strCloseTag = '++';  }
		else if   (strTag == '-') { strOpenTag = '--'; strCloseTag = '--';  }
        if (document.selection) {
            var selected = document.selection.createRange().text;
            if (o == document.selection.createRange().parentElement()) {
                document.selection.createRange().text = strOpenTag+selected+strCloseTag;
                o.focus();
            }
            else { 
				// selection outside textarea
				return;
			}
        } 
        else if (o.selectionStart || o.selectionStart == 0) {
            var iStart      = o.selectionStart;
            var iEnd        = o.selectionEnd;
            var strT        = o.value;
    		var nScrollTop  = o.scrollTop;
            var pretext  = strT.substring(0, iStart);
            var codetext = strOpenTag+strT.substring(iStart, iEnd)+strCloseTag;
            var posttext = strT.substring(iEnd, strT.length);
            // update the text field
            o.value = pretext+codetext+posttext;
            o.focus();
            o.selectionStart = iEnd + strOpenTag.length;
            o.selectionEnd   = iEnd + strOpenTag.length;
            o.scrollTop      = nScrollTop;
        }
        else {
            alert('These buttons not supported by your browser.');
            o.focus();
            return;
         }
	}


	function drawDlgRowReplyEmail(strCurEmail) {
		var str = '';
		// <!-- Reply Email -->
			str += '<tr>';
				str += '<td class="dlg_tdL"  valign="top">Reply E-Mail</td>';
				str += '<td class="dlg_tdC"  valign="top">';
					str += '<input type="text" name="EMAIL" maxlength="256" class="dlg_edit" value="'+getMailAddress(strCurEmail)+'">';
				str += '</td>';
				str += '<td class="dlg_tdR" valign="top">'
				str += getInfoBoxHTML("PRESET-ReplyEmail", 101);
				str += '</td>';
			str += '</tr>';
		document.writeln(str);

	}

	function drawDlgRowMoreOptions(strT) {
		var str = '';
		var strText = 'Show more options...';
		if (strT != '') { strText = strT; }
		// <!-- Reply Email -->
			str += '<tr>';
				str += '<td class="dlg_tdL"  valign="top">&nbsp;</td>';
				str += '<td class="dlg_tdC"  valign="top">';
					str += '<input type="checkbox" name="SHOWOTHEROPTIONS" value="1" class="dlg_checkbox" onChange="dlgPopGroup(\'dlg_popgroup1\');"><i>'+strText+'</i>';
				str += '</td>';
				str += '<td class="dlg_tdR" valign="top">&nbsp;</td>';
			str += '</tr>';
		document.writeln(str);

	}

	function drawDlgRowWebLink(strCurLink) {
		drawDlgRowWebLinkPlus(strCurLink,-1);
	}
	function drawDlgRowWebLinkPlus(strCurLink,nLinkType) {
		// nLinkType values: -1=OnlyExternalLinks(noOptionsGiven), 0=InternalLink, 1=ExternalLink
		var str = '';
		// <!-- Reply Email -->
			str += '<tr>';
				str += '<td class="dlg_tdL"  valign="top">Website</td>';
				str += '<td class="dlg_tdC"  valign="top">';
					str += '<input type="text" name="URLLINK" maxlength="256" class="dlg_edit" value="'+strCurLink+'">';
					if (nLinkType >= 0) {
						var strInternalChecked = '';
						var strExternalChecked = '';
						if (nLinkType == 0) { strInternalChecked=' CHECKED '; }
						if (nLinkType == 1) { strExternalChecked=' CHECKED '; }
						str += '<br><input type="Radio" value="0" class="dlg_radio" '+strInternalChecked+' name="INTERNALURL"> This link is to a webpage on this site<br>';
						str += '<input type="Radio" value="1" class="dlg_radio" '+strExternalChecked+' name="INTERNALURL"> This link is to an external website';
					}
				str += '</td>';
				str += '<td class="dlg_tdR" valign="top">'
				if (nLinkType >= 0) {
					str += getInfoBoxHTML("PRESET-WebLinkPlus", 102);
				} else {
					str += getInfoBoxHTML("PRESET-WebLink", 102);
				}
				str += '</td>';
			str += '</tr>';
		document.writeln(str);
	}

	// Creates bottom part of dialog with Editing Password and Submit/Cancel buttons
	function drawDlgPasswordLockAndSubmit(fReqLock, strSubmitBtn, strSubmitNote) {
		drawDlgPasswordAndSubmitCore(false, fReqLock, strSubmitBtn, strSubmitNote);
	}
	function drawDlgPasswordMatchAndSubmit(fIsNotAdmin, strSubmitBtn, strSubmitNote) {
		if (fIsNotAdmin) {
			drawDlgPasswordAndSubmitCore(true, true, strSubmitBtn, strSubmitNote);
		} else {
			drawDlgAdminSubmit(strSubmitBtn);
		}
	}
	function drawDlgPasswordMatchAndDelete(fIsNotAdmin, strSubmitBtn) {
		if (fIsNotAdmin) {
			drawDlgPasswordAndSubmitCore(true, true, strSubmitBtn, '');
		} else {
			drawDlgAdminSubmit(strSubmitBtn);
		}
	}
	// Creates bottom part of dialog with Editing Password and Submit/Cancel buttons
	function drawDlgPasswordAndSubmitCore(fPasswordMatch, fReqLock, strSubmitBtn, strSubmitNote) {
		var str = '';
		// <!-- TABLE: Ending Controls ---------------------------- -->
		str += '<table cellpadding="0" cellspacing="0" class="dlg_table">';
			// <!-- divider bar -->
			str += '<tr>';
				str += '<td class="dlg_tdL"  valign="top">&nbsp;</td>';
				str += '<td class="dlg_tdC"  valign="top">';
					str += '<img src="dialogs/dlg_div.gif" width="301" height="7" alt="" border="0">';
					if (fPasswordMatch) {
						str += '<div class="dlg_subhead">UNLOCK</div>';
						str += '<div class="dlgnote">If you locked this item with a password when you posted it, you must enter that password now.</div>';					
					} else {
						if (fReqLock) {
							str += '<div class="dlg_subhead">LOCK IT</div>';
							str += '<div class="dlgnote">Lock this item, so other readers can\'t change it, by entering an easy to remember password. <i><u>Use letters and numbers only.</u></i></div>';
						} else {
							str += '<div class="dlg_subhead">LOCK IT?</div>';
							str += '<div class="dlgnote">Optional: Lock this item, so other readers can\'t change it, by entering an easy to remember password. <i><u>Use letters and numbers only.</u></i></div>';
						}
					}
				str += '</td>';
				str += '<td class="dlg_tdR"  valign="top">&nbsp;</td>';
			str += '</tr>';
		
			// <!-- Locking/Editing Password -->
			str += '<tr>';
				str += '<td class="dlg_tdL"  valign="top">&nbsp;';
				if (fPasswordMatch || fReqLock) { str += '<span class="dlgrequired">*</span>Password'; }
				str += '';
				str += '</td>';
				str += '<td class="dlg_tdC"  valign="top">';
					str += '<input type="password" name="PASSWORD" maxlength="30" class="dlg_password">';	
				str += '</td>';
				str += '<td class="dlg_tdR" valign="top">';
				str += '&nbsp;';
				str += '</td>';
			str += '</tr>';
			
			// <!-- divider bar -->
			str += '<tr>';
				str += '<td class="dlg_tdL"  valign="top">&nbsp;</td>';
				str += '<td class="dlg_tdC"  valign="top">';
					str += '<img src="dialogs/dlg_div.gif" width="301" height="7" alt="" border="0"><br>';
				str += '</td>';
				str += '<td class="dlg_tdR"  valign="top">&nbsp;</td>';
			str += '</tr>';
			
			// <!-- Buttons -->
			str += '<tr>';
				str += '<td class="dlg_tdL"  valign="top">&nbsp;</td>';
				str += '<td class="dlg_tdC"  valign="top">';
					if (strSubmitNote != '') {
						str += '<div class="dlg_conformity">';
						str += strSubmitNote+'<br>';
						str += '</div>';
					}
					str += '<input type="SUBMIT" value="'+strSubmitBtn+'" class="dlg_button">&nbsp;';
					str += '<input type="button" name="Cancel" value="Cancel" onClick="window.close();" class="dlg_button">';
				str += '</td>';
				str += '<td class="dlg_tdR" valign="top">&nbsp;</td>';
			str += '</tr>';
		str += '</table>';
		document.writeln(str);
	}
	
	// 
	function drawDlgSimpleSubmitWithNote(strSubmitBtn, strSubmitNote) {
		var str = '';
		// <!-- TABLE: Ending Controls ---------------------------- -->
		str += '<table cellpadding="0" cellspacing="0" class="dlg_table">';
		// <!-- divider bar -->
			str += '<tr>';
				str += '<td class="dlg_tdL"  valign="top">&nbsp;</td>';
				str += '<td class="dlg_tdC"  valign="top">';
					str += '<img src="dialogs/dlg_div.gif" width="301" height="7" alt="" border="0"><br>';
				str += '</td>';
				str += '<td class="dlg_tdR"  valign="top">&nbsp;</td>';
			str += '</tr>';
		// <!-- Buttons -->
			str += '<tr>';
				str += '<td class="dlg_tdL"  valign="top">&nbsp;</td>';
				str += '<td class="dlg_tdC"  valign="top">';
					if (strSubmitNote != '') {
						str += '<div class="dlg_conformity">';
						str += strSubmitNote+'<br>';
						str += '</div>';
					}
					str += '<input type="SUBMIT" value="'+strSubmitBtn+'" class="dlg_button">&nbsp;';
					str += '<input type="button" name="Cancel" value="Cancel" onClick="window.close();" class="dlg_button">';
				str += '</td>';
				str += '<td class="dlg_tdR" valign="top">&nbsp;</td>';
			str += '</tr>';
		str += '</table>';
		document.writeln(str);
	}
	
	// 
	function drawDlgSimpleSubmit(strSubmitBtn) {
		var str = '';
		// <!-- TABLE: Ending Controls ---------------------------- -->
		str += '<table cellpadding="0" cellspacing="0" class="dlg_table">';
		// <!-- divider bar -->
			str += '<tr>';
				str += '<td class="dlg_tdL"  valign="top">&nbsp;</td>';
				str += '<td class="dlg_tdC"  valign="top">';
					str += '<img src="dialogs/dlg_div.gif" width="301" height="7" alt="" border="0"><br>';
				str += '</td>';
				str += '<td class="dlg_tdR"  valign="top">&nbsp;</td>';
			str += '</tr>';
		// <!-- Buttons -->
			str += '<tr>';
				str += '<td class="dlg_tdL"  valign="top">&nbsp;</td>';
				str += '<td class="dlg_tdC"  valign="top">';
					str += '<input type="SUBMIT" value="'+strSubmitBtn+'" class="dlg_button">&nbsp;';
					str += '<input type="button" name="Cancel" value="Cancel" onClick="window.close();" class="dlg_button">';
				str += '</td>';
				str += '<td class="dlg_tdR" valign="top">&nbsp;</td>';
			str += '</tr>';
		str += '</table>';
		document.writeln(str);
	}

	// 
	function drawDlgAdminSubmit(strSubmitBtn) {
		var str = '';
		// <!-- TABLE: Ending Controls ---------------------------- -->
		str += '<table cellpadding="0" cellspacing="0" class="dlg_table">';
		// <!-- divider bar -->
			str += '<tr>';
				str += '<td class="dlg_tdL"  valign="top">&nbsp;</td>';
				str += '<td class="dlg_tdC"  valign="top">';
					str += '<img src="dialogs/dlg_div.gif" width="301" height="7" alt="" border="0"><br>';
				str += '</td>';
				str += '<td class="dlg_tdR"  valign="top">&nbsp;</td>';
			str += '</tr>';
		// <!-- Buttons -->
			str += '<tr>';
				str += '<td class="dlg_tdL"  valign="top">&nbsp;</td>';
				str += '<td class="dlg_tdC"  valign="top">';
					str += '<div class="dlg_conformity">';
					str += "Submissions by the Editor aren\'t reviewed and appear immediately on the site.";
					str += '</div>';
					str += '<input type="SUBMIT" value="'+strSubmitBtn+'" class="dlg_button">&nbsp;';
					str += '<input type="button" name="Cancel" value="Cancel" onClick="window.close();" class="dlg_button">';
				str += '</td>';
				str += '<td class="dlg_tdR" valign="top">&nbsp;</td>';
			str += '</tr>';
		str += '</table>';
		document.writeln(str);
	}

	//	Creates bottom part of simple dialog with just single Cancel button
	function drawDlgCancelOnly(nMsgType) {
		var str = '';
		var strButtonTitle = "Cancel";
		if (nMsgType == 1) { strButtonTitle = "Close This Window";	}
		// <!-- TABLE: Ending Controls ---------------------------- -->
		str += '<table cellpadding="0" cellspacing="0" class="dlg_table">';
		// <!-- Buttons -->
			str += '<tr>';
				str += '<td class="dlg_tdL"  valign="top">&nbsp;</td>';
				str += '<td class="dlg_tdC"  valign="top">';
					str += '<img src="dialogs/dlg_div.gif" width="301" height="7" alt="" border="0"><br>';
					str += '<input type="button" name="Cancel" value="'+strButtonTitle+'" onClick="window.close();" class="dlg_button">';
				str += '</td>';
				str += '<td class="dlg_tdR" valign="top">&nbsp;</td>';
			str += '</tr>';
		str += '</table>';
		document.writeln(str);
	}
	
	function drawDlgDividerRow() {
		var str = '';
		// <!-- divider bar -->
			str += '<tr>';
				str += '<td class="dlg_tdL"  valign="top">&nbsp;</td>';
				str += '<td class="dlg_tdC"  valign="top">';
					str += '<img src="dialogs/dlg_div.gif" width="301" height="7" alt="" border="0">';
				str += '</td>';
				str += '<td class="dlg_tdR"  valign="top">&nbsp;</td>';
			str += '</tr>';
		document.writeln(str);
	}
	
	// Create Info Icon used to pop-open info text in a dialog
	function drawInfoBoxHTML(strInfoText, iBox) {
		document.writeln(getInfoBoxHTML(strInfoText, iBox));
	}
	// Create Info Icon used to pop-open info text in a dialog
	function getInfoBoxHTML(strInfoText, iBox) {
		var str = '';
		var strT = strInfoText;
		// look for preset messages and fill in accordingly
		if 		  (strInfoText == "PRESET-ReplyEmail") {
			strT = "E-Mail address associated with this posting (optional). Readers may send e-mail to this address. NOTE: Your email address will be scrambled to prevent spammers from finding it on this site."; 
		} else if (strInfoText == "PRESET-MultiSelect") {
			strT = "Select multiple groups by holding down the control key while you click."; 
		} else if (strInfoText == "PRESET-WebLink") {
			strT = "Web address related to this posting (optional). Readers will be able to link to this address in a new browser window."; 
		} else if (strInfoText == "PRESET-WebLinkPlus") {
			strT = "Web address related to this posting (optional). These links will appear in the main window. External site links will show up in a new browser window."; 
		} else if (strInfoText == "PRESET-EditPassword") {
			strT = "Use letters and numbers only.(optional) If you want to lock this item so other readers can't delete it, enter an easy to remember password here"; 
		} 
		// create info icon
		str += '<a href="javascript:dlgShowInfo(';
		str += "'dlg_popinfo"+iBox+"'";
		str += ')" class="dlg_infohead">';
		str += '<img src="dialogs/info-icon.gif" width="14" height="14" alt="" border="0">';
		str += '</a><br>';
		// create popopen info text
		str += '<div id="dlg_popinfo'+iBox+'">';
		str += '<div class="dlg_infotext">'+strT+'</div>';
		str += '</div>';
		return (str);
	}


	// Creates the Wait Message box that is displayed with user hits submit button
	function drawWaitMessage(strTitle) {
		var str = '';
		str += '<div id="dialogwaitmsg">';
			str += '<div class="dialogwait">';
			str += strTitle+'<br>';
			str += 'In Progress...<br>';
			str += '<br>';
			str += 'Please wait until the page changes...<br>';
			str += '<br>';
			str += 'This can take a minute depending ';
			str += 'on how slow your internet connection is right now...';
			str += '</div>';
		str += '</div>';
		document.writeln(str);
	}

	function gotoAddPageBit(p,t,s) {
		var urlCGI = gCGIPath+"dlg_pagebit_new.cgi?P="+p+"&T="+t+"&S="+s;
		location = urlCGI;
	}

	// called in dialogs to jump to attachment dialog
	function gotoDlgPostingGlobals() {
		var strCGI = "dlg_adminoptions_postglobals.cgi";
		showDialogCGI("PostingGlobalSettings",590,800,strCGI);
	}

