//	Copyright (c) 1999-2001 by A Plus Consultants, L.L.C.
//	No part of this script may be used for any purpose without prior
//	written permission. Contact richard@aplusconsultants.com.
/*
	JavaScript Functions: (PREPARED FOR COMPRESSION.)
	These functions are more or less generic, but may, in some way, be tied
	to the features of MainStreetCentral.com.

	This is a list of functions contained in this script:

	bCheckSignIn(oLink, sGo, sOther)
	bSaveFileName(oFile, oName)
	CheckSome(oForm, sElement, sAction)
	OpenWin(sLoad, sUser, iKey, sPage, iWidth, iHeight)
	OpenWindow(sURL, sName, sMenu, iWidth, iHeight)
	ShowImage(oFile)

	The following set of functions is used in interactively building a
	select list within a form from a set of input fields.
	ItemAdd(oForm, sName, lstElements, aSubRules)
	ItemChange(oList, lstElements)
	ItemDel(oList, bRefresh, lstList)

	WriteCatOptions(iList, sType)
	WriteCommOptions(iList, sType, sField)
	mh(iPage, sTo, sFirst, sLast, sLink)	//	Added 10/23/2004.
*/

function bCheckSignIn(oLink, sGo, sOther) {
/*
	This determines presents the appropriate page depending on whether or
	not the	visitor is signed in.

	Parameters:
		oLink	: The anchor object that was clicked.
		sGo		: The target page, if signed in.
		sOther	: Other needed query string values.
*/
	var aPair = new Array();
	var ii = 0;
	var sLink = oLink.search.substring(1);
	var aQS = sLink.split("&");
	for (ii = 0; ii < aQS.length; ii++) {
		aPair = aQS[ii].split("=");
		if (aPair[0] == "U") {
			if (aPair[1].substr(0, 1) == "M") {
				oLink.href = sGo + "?" + sLink + "&" + sOther;
				return true;
			}
			else {
				if (confirm("You are not signed in.\n\nYou requested a members-only page. If you want to sign-in or join now, click 'OK'.")) {
					oLink.href = "SignIn.cfm?" + sLink + "&Go=" + sGo + "?" + sOther;
					return true;
				}
			}
		}
	}
	return false;
}

function bSaveFileName(oFile, oName) {
/*
	We need to preserve the name of the uploaded file for comparison.
*/
	var sFile = oFile.value;
	sFile = sFile.substr(sFile.lastIndexOf("\\") + 1, sFile.length);
	//	Condition added because of problem when leaving upload file name blank.
	if (sFile != "") {
		oName.value = sFile;
	}
}

function CheckSome(oForm, sElement, sAction) {
/*
	This selects or removes the selection from an array of form
	objects. The three actions are:
	All - select all items in the array.
	None - remove selection from all items in the array.
	Reverse - Toggle selected items off and unselected items on.
	It only works for the checkbox type, but it could be extended
	to work with the select-multiple type as well.
*/
//	alert(oForm.name + "," + sElement + "," + sAction);
	var oElement = oForm[sElement];
	var ii = 0;
	var iCnt = 0;
	for (ii = 0; ii < oElement.length; ii++) {
		if (oElement[ii].type == "checkbox") {
			if (sAction == "All") {
				oElement[ii].checked = true;
				iCnt++;
			}
			if (sAction == "None") {
				oElement[ii].checked = false;
			}
			if (sAction == "Reverse") {
				if (oElement[ii].checked) {
					oElement[ii].checked = false;
				}
				else {
					oElement[ii].checked = true;
					iCnt++;
				}
			}
		}
	}
	alert(iCnt + " box(es) are now selected.");
}

function OpenWin(sLoad, sUser, iKey, sPage, iWidth, iHeight) {
/*
	Launch a new window or set focus to a window with the same name that
	already exists, if window.focus() is supported.

	This takes the query string values as passed parameters because we
	cannot put CFOUTPUT tags within the SCRIPT tag. The 'dependent'
	attribute, if changed to yes, causes the window to lose focus
	permanently for the rest of the browser session, so I have set it to
	no for now.

	Window parameter names.
		copyhistory=no
		directories=no
		location=no
		menubar=no
		status=no
		toolbar=no

*/
	//	01/11/2003:90 Set the URL to a single variable.
	var sURL = sLoad + "?" + sUser + "&T=" + sPage;
	if (window.oWin) {
// 		alert(oWin.name + " is not closed.");
//		oWin.close();
		if (! oWin.closed) {
			//	01/11/2003:96 Changed the way focus worked.
//			oWin.focus();
			//	If the URL in the new call is not the same, but the window
			//	name is the same, reuse the window with the new URL.
			var ar = oWin.location.href.split("/");
			if (ar[ar.length - 1] != sURL) {
				oWin.location.href = sURL;
			}
		}	//	08/31/2004:105 Enclosed an unclosed block causing errors.
		if (! oWin.closed && jsver > 1.0) {
			//	Delay a bit because IE4 encounters errors
			//	when trying to focus a recently opened window.
			setTimeout("oWin.focus();", 250);
			return;
		}
	}

	if (arguments.length == 4) {
		iHeight = 360;
		iWidth = 320;
	}
	oWin = window.open(sLoad + "?" + sUser + "&T=" + sPage, "HelpWindow",
		"dependent=no,height="+iHeight+",resizable=yes,scrollbars=yes,status=yes,titlebar=yes,width="+iWidth);
}

function OpenWindow(sURL, sName, sMenu, iWidth, iHeight) {
/*
	Launch a new window or set focus to a window with the same name that
	already exists, if window.focus() is supported.

	The 'dependent' attribute, if changed to yes, causes the window to
	lose focus permanently for the rest of the browser session, so
	I have set it to no for now.

	Window parameter names.
		copyhistory=no
		directories=no
		location=no
		menubar=no
		status=no
		toolbar=no
*/
	var sWinAttr = "";
	if (window.oWin) {
		if (! oWin.closed) {
			//	01/11/2003:139 Changed the way focus worked.
//			oWin.focus();
			//	If the URL in the new call is not the same, but the window
			//	name is the same, reuse the window with the new URL.
			var ar = oWin.location.href.split("/");
			if (ar[ar.length - 1] != sURL)
				oWin.location.href = sURL;
			if (! oWin.closed && jsver > 1.0) {
				//	Delay a bit because IE4 encounters errors
				//	when trying to focus a recently opened window.
				setTimeout("oWin.focus();", 250);
				return;
			}
		}
	}
	if (arguments.length == 2) {
		sMenu = "no";
	}
	if (arguments.length == 3) {
		iHeight = 360;
		iWidth = 320;
	}
	//	Note that the appearance of the attribute name, regardless of the
	//	yes/no value, causes IE 4.0 to include the attribute in the window.
	if (sMenu == "yes") {
		sWinAttr = "dependent=no,height=" + iHeight + ",location=" + sMenu + ",menubar=" + sMenu + ",resizable=yes,scrollbars=yes,status=yes,titlebar=yes,width=" + iWidth;
	}
	else {
		sWinAttr = "dependent=no,height=" + iHeight + ",resizable=yes,scrollbars=yes,status=yes,titlebar=yes,width=" + iWidth;
	}
	oWin = window.open(sURL, sName, sWinAttr);
}

function ShowImage(oFile, sTarget) {
/*
	Display the file specified for upload in a window to preview it and
	determine its dimensions. A link is displayed that will set the
	dimensions into a form field in a form in the calling window.

	Created: 01/05/2003
*/
	var sFile = oFile.value;
	var bNN4 = (document.layers);
	if (sFile == "") {
		alert("There is no image file to view.");
		return true;
	}
	if (! sTarget || sTarget == "") {
		sTarget = "ImageOrient";
	}
	//	Make sure the file specification uses the expected separator.
	var re = /\\/gi;
	sFile = sFile.replace(re, "/");
	if (bNN4) {
		//	Navigator uses the file protocol locally.
		sFile = "file:///" + sFile.substr(0, 1) + "|" + sFile.substr(2, sFile.length);
	}
	//	01/11/2003:194 Initialized the window variable outside the script
	//			so that the same window can be reused each time the
	//			button is pressed.
	//	If the window is initialized, reuse it.
	if (! w) {
		w = window.open("", "ShowImage", "scrollbars=no");
	}
	var d = w.document;
	//	Write the image into the file to get its dimensions.
	d.write("<img src=\"" + sFile + "\" />");
	d.close();
	var iHigh = d.images[0].height;
	var iWide = d.images[0].width;
	var iHeight = iHigh + (bNN4? 90 : 110);
	var iWidth = iWide + 20;
	var ar = sFile.split("/");
	w.resizeTo(iWidth, iHeight);
	d.open();
	//	Now rewrite the image with the dimensions displayed.
	//	01/07/2003:177 Added link to set Custom dimensions in caller.
	d.write("<html><head><title>Image View</title><script type=\"text/javascript\">var sTarget = \"" + sTarget + "\"; var oTarget = window.opener.document.forms[0][sTarget][1];</script></head><body style=\"background: CCCCCC; margin: 0; padding: 5px;\">");
	d.write("<p style=\"font-family: Verdana,Arial,Sans-Serif; font-size: " + (bNN4 ? "X-Small" : "XX-Small") + ";\">" + ar[ar.length - 1] + "<br />");
	d.write("Width: " + iWide + " pixels.<br />");
	d.write("Height: " + iHigh + " pixels. <a href=\"JavaScript:void(0)\" onClick=\"oTarget.value='" + iWide + "x" + iHigh + "'; return false;\" title=\"Set the Custom dimensions to these values.\">Set</a></p>");
	if (bNN4) {
		//	Navigator doesn't understand the style attribute of img.
		d.write("<img border=\"2\" src=\"" + sFile + "\" />");
	}
	else {
		d.write("<img src=\"" + sFile + "\" style=\"border: Solid Blue 2px;\" />");
	}
	d.write("</body></html>");
	d.close();
	w.focus();
	return true;
/*
Change History:
01/07/2003:	177 Added link to set Custom dimensions in caller.
01/11/2003:	Moved the function into this script.
			194 Initialized the window variable outside the script
			so that the same window can be reused each time the
			button is pressed.
10/22/2004:	Added sTarget to generalize the function for use in multiple
			situations.
*/
}

function ItemAdd(oForm, sName, lstElements, aSubRules) {
/*
	This adds a new list item to an interactive list from a set of
	component fields. It validates the contents of the component fields
	and then adds the item and makes it the current selection. It also
	prevents duplicate items from being added to a list.

	lstElements is a three element array.
	#1 is the list of component fields.
	#2 is the list stored in the item's value property.
	#3 is the list stored in the item's text property.
*/
	var aElements = lstElements[1].split(",");
	var ii = 0;
	var oElement = "";
	var oItem = "";
	var oList = oForm[sName];
	var sList = "";
	var sText = lstElements[3];
	var sVal = "";
	var sValue = lstElements[2];

	//	Validate the fields for the item.
	if (! bCheckFormRules(oForm, aSubRules)) {
		return;
	}

	//	Build the various strings from the element values.
	for (ii = 0; ii < aElements.length; ii++) {
		oElement = oForm[aElements[ii]];
//		alert(oElement.name + " " + oElement.type + " " + oElement.selectedIndex);
		if (oElement.type == "select-one") {
			sVal = oElement.options[oElement.selectedIndex].value;
		}
		else {
			sVal = LTrim(RTrim(oElement.value));
		}

		re = new RegExp(oElement.name, "gi");
		if (sText.indexOf(oElement.name) >= 0) {
			sText = sText.replace(re, sVal);
		}
		if (sValue.indexOf(oElement.name) >= 0) {
			sValue = sValue.replace(re, sVal);
		}
		sList = sList + sVal;
		if (ii + 1 < aElements.length) {
			sList = sList + ",";
		}
	}
//	alert(sList + "\n" + sText + "\n" + sValue);
	//	Prevent duplicate list items.
	for (ii = 0; ii < oList.length; ii++) {
//		alert(oList.options[ii].text.length + "==" + sValue.length);
		if (oList.options[ii].value == sValue) {
			alert("Duplicate " + sName + " items are not permitted.");
			return;
		}
	}

	//	On the first add, remove any blanks from the list.
	if (oList.length > 0) {
		if (RTrim(oList.options[0].text) == "") {
			oList.options[0] = null;
		}
	}
	//	Build the option and make it the current selection.
	oItem = new Option(sText, sValue, false, true);
	//	Add the new item to the list.
	oList.options[oList.length] = oItem;
	//	Make the new item, the selected item.
//	oList.selectedIndex = oList.length - 1;
}

function ItemChange(oList, lstElements) {
/*
	This fills in the component fields for an interactive list when a list
	item is changed.

	lstElements is a three element array.
	#1 is the list of component fields.
	#2 is the list stored in the item's value property.
	#3 is the list stored in the item's text property.
*/
	var aElements = lstElements[1].split(",");
	var aPos = lstElements[2].split(",");
	var ii = 0;
	var jj = 0;
	var iPos = 0;
	var oElement = "";
	var oForm = oList.form;

	if (oList.selectedIndex == -1) {
		var aValues = new Array;
		aValues[aElements.length - 1] = null;
		var bClear = true;
	}
	else {
		var aValues = oList.options[oList.selectedIndex].value.split(",");
		var bClear = false;
	}

	for (ii = 0; ii < aElements.length; ii++) {
		oElement = oForm[aElements[ii]];
		//	Find the position of the field in the elements list.
		iPos = -1;
		for (jj = 0; jj < aPos.length; jj++) {
			aPos[jj] = LTrim(RTrim(aPos[jj]));
			if (oElement.name == aPos[jj]) {
				iPos = jj;
				break;
			}
		}
		if (iPos >= 0) {
			aValues[iPos] = LTrim(RTrim(aValues[iPos]));
			if (oElement.type == "select-one") {
				//	For select lists, select the matching index.
//				alert(iPos + " " + aPos[iPos] + " " + aValues[iPos] + " " + oElement.name + " " + oElement.length);
				if (bClear) {
					oElement.selectedIndex = 0;
				}
				else {
					for (jj = 0; jj < oElement.length; jj++) {
						if (oElement.options[jj].text == aValues[iPos]) {
							oElement.selectedIndex = jj;
							break;
						}
					}
				}
			}
			else {
				//	Otherwise, assign the element the value.
				if (bClear) {
					oElement.value = "";
				}
				else {
					oElement.value = aValues[iPos];
				}
			}
		}
	}
}

function ItemDel(oList, bRefresh, lstList) {
	var iItem = oList.selectedIndex;
	var oForm = oList.form;
	var sBrowser = oForm["Browser"].value;
	if (oList.length == 0)
		return;
	if (iItem == -1)
		return;
//	alert(iItem + " " + oList.options[iItem].value + " " + oList.options[iItem].text);
//	return;
	//	Remove the item from the list.
	oList.options[iItem] = null;
	//	Set the changed flag.
	switch (oList.name) {
	case "ClassList":
		oForm[oList.name + "_fg"].value = "true";
		break;
	}
	if (oList.length != 0)
		oList.options[0].selected = true;
	switch (oList.name) {
	case "DatesList":
		ItemChange(oList, lstDates);
		break;
	case "OrgsList":
		ItemChange(oList, lstList);
		break;
	}
	// Netscape and IE work differently on reload.
/*
	if (sBrowser.indexOf("Nav") > 0)
		if (bRefresh)
			history.go(0);
*/
}

function WriteCatOptions(iList, sType) {
/*
	This fills a subcategory select list depending on the category chosen.
	It is used in the Classifieds Central pages.
*/
	var sList = aSubCat[iList];
	var aCats = sList.split("|");
	var oForm = document.forms["Classify"];
	var ii = 0;
	var bRefresh = true;
	var sBrowser = navigator.appName;
//	if (oForm.Category != "undefined")
//		alert("'" + oForm.Category.options[oForm.Category.selectedIndex].value + "'");
//	alert("Writing");
	if (iList == 0) {
		if (sType == "cat") {
//			alert(oForm.Category);
			/*
				In IE 4.0, the following code which works in Netscape, errors, because
				it appears that the object is created, and therefore not equal to the
				string -- undefined.
			*/
			if (oForm.Category == "undefined" || oForm.Category == "[object]") {
				if (oForm.name == "Classify") {
					document.writeln("<option value=\"" + "All" + "\">" + "All");
				}
				else {
					document.writeln("<option value=\"" + "" + "\">" + "----- Choose -----");
				}
				for (ii = 0; ii < aCats.length; ii++) {
					document.writeln("<option value=\"" + aCats[ii] + "\">" + aCats[ii]);
				}
			}
		}
		else {
			if (oForm.name == "Classify") {
				oForm.CategorySub.length = 0;
				oOption = new Option("All", "All", true, true);
				oForm.CategorySub.options[oForm.CategorySub.length] = oOption;
			}
			else {
				//	When the category value is blank, make the
				//	subcategory value blank as well.
//				alert("1. " + oForm.Category.selectedIndex);
				/*
					In IE 4.0, the following code which works in Netscape, errors, because
					it appears that options array is not available in IE at this point.
					So, I changed the test to the first option, which hopefully is the same
					in all cases as the blank value.
				if (oForm.Category.options[oForm.Category.selectedIndex].value == "") {
					oForm.CategorySub.length = 0;
					oOption = new Option("                         ", "", true, true);
					oForm.CategorySub.options[oForm.CategorySub.length] = oOption;
				}
				*/
			if (oForm.Category.selectedIndex == 0) {
				aCats.length = 0;
			}
				if (oForm.Category.selectedIndex == 0) {
					oForm.CategorySub.length = 0;
					oOption = new Option("                         ", "", true, true);
					oForm.CategorySub.options[oForm.CategorySub.length] = oOption;
				}
			}
		}
	}
	else {
		oForm.CategorySub.length = 0;
		if (oForm.name == "Classify") {
			oOption = new Option("All", "All", true, true);
			oForm.CategorySub.options[oForm.CategorySub.length] = oOption;
		}
		else {
			oOption = new Option("                         ", "", true, true);
			alert("2. " + oOption.value);
			oForm.CategorySub.options[oForm.CategorySub.length] = oOption;
			//	When the category value is blank, make the
			//	subcategory value blank as well.
			/*
				In IE 4.0, the following code which works in Netscape, errors, because
				it appears that options array is not available in IE at this point.
				So, I changed the test to the first option, which hopefully is the same
				in all cases as the blank value.
			if (oForm.Category.options[oForm.Category.selectedIndex].value == "") {
				aCats.length = 0;
			}
			*/
			if (oForm.Category.selectedIndex == 0) {
				aCats.length = 0;
			}
		}
		for (ii = 0;ii < aCats.length; ii++) {
//			alert(ii + " " + aCats[ii]);
			oOption = new Option(aCats[ii], aCats[ii]);
			oForm.CategorySub.options[oForm.CategorySub.length] = oOption;
		}
		if (sBrowser == "Netscape")
			if (bRefresh)
				history.go(0);
	}
}

function WriteCommOptions(iList, sType, oElement, bDebug) {
/*
	This builds a list of Communities within a Region.

	It uses a pre-built aComm array whose 0 member is a list of Regions
	and whose other members are a list of Communities, one member for each
	of the Regions in the 0 member.
	12/02/2001:
	Added third, optional, parameter to allow for a field name other
	Community.
	11/09/2004: WriteCommOptions: Changed the third argument from sField to
				oElement to allow for recognition of the calling form.
*/
	var aVals;
	var bRefresh = true;
	var ii = 0;
	// Specify when more than one form is on the page.
	var oForm = document.forms[0];
	var sBrowser = navigator.appName;
	var sField = "";
	var sList = aComm[iList];
	var aArray = aBreakApart(sList, "|");
	var iFlag = 0;

	if (arguments.length <= 2) {
		sField = "Community";
	}
	else {
		sField = oElement.name;
		oForm = oElement.form;
	}

	if (bDebug) bDebug = confirm("Debug mode is on. Continue in debug mode?");
	if (bDebug) alert("sList: " + sList + "\niList: " + iList + "\nsType: " + sType + "\niDS: " + iDS);
	if (iList != 0 && iDS != 0) {
		/*
			We want the communities to coincide with the
			selected region, so we are capturing the array
			value in the page-scoped iDS variable.
		*/
/*
		iFlag = 0;
		for (ii = 0; ii < aArray.length; ii++) {
			aVals = aBreakApart(aArray[ii], "^");
			if (aVals[0] == iComm) {
				iFlag = -1;
				break;
			}
		}
		alert("iComm: " + iComm + "\niFlag: " + iFlag + "\niList: " + iList + "\niDS: " + iDS);
		if (iFlag == -1) {
//			alert("iFlag " + iFlag + " " + iComm + " " + iDS + " " + sList);
			sList = aComm[iList];
		}
		else {
			sList = aComm[iDS];
		}
//		alert(iDS + " " + iList + " " + sList);
		alert("second " + sList);
		aArray = aBreakApart(sList, "|");
		alert("second ok " + aArray[0]);
*/
	}
	if (iList == 0) {
		if (sType == "group") {
			//	This section writes the Region select list on page load.
//			document.writeln("<option value=\"" + "All" + "\">" + "All");
			for (ii = 0; ii < aArray.length; ii++) {
				aVals = aBreakApart(aArray[ii], "^");
				if (sDS == aVals[0]) {
					document.writeln("<option selected value=\"" + aVals[0] + "\">" + aVals[1]);
					iDS = ii + 1;
				}
				else {
					document.writeln("<option value=\"" + aVals[0] + "\">" + aVals[1]);
				}
			}
		}
		else {
//			oForm[sField].length = 0;
//			oOption = new Option("All", "All", true, true);
//			oForm[sField].options[oForm[sField].length] = oOption;
		}
	}
	else {
		if (sType == "group") {
			//	This section writes the Community select list on page load.
//			oForm[sField].length = 0;
//			document.writeln("<option value=\"" + "All" + "\">" + "All");
			for (ii = 0; ii < aArray.length; ii++) {
				aVals = aBreakApart(aArray[ii], "^");
//				alert(iComm + " " + aVals[0]+ " " + aVals[1]);
//				if (iComm == 0) {
//					iComm = aVals[0];
//				}
				if (iComm == aVals[0]) {
					//	01/12/2003:606 Added HoldPlace input to form to
					//	deal with IE back button problem.
					//	Set HoldPlace first time into the form to the
					//	selected community.
					if (oForm["HoldPlace"]) {
						if (oForm["HoldPlace"].value == "") {
							oForm["HoldPlace"].value = ii;
						}
					}
					document.writeln("<option selected value=\"" + aVals[0] + "\">" + aVals[1]);
				}
				else {
					document.writeln("<option value=\"" + aVals[0] + "\">" + aVals[1]);
				}
			}
		}
		else {
			/*
				This section writes the Community select list
				for the onChange event of Region.
			*/
			oForm[sField].length = 0;
//			oOption = new Option("All", "All", true, true);
//			oForm[sField].options[oForm[sField].length] = oOption;
			if(bDebug) alert(aArray);
			iComm = 0;
			for (ii = 0; ii < aArray.length; ii++) {
				aVals = aBreakApart(aArray[ii], "^");
//				if (iComm == 0) {
//					iComm = aVals[0];
//				}
				//	01/12/2003:637 Added HoldPlace input to form to
				//	deal with IE back button problem.
				//	When writing the community, select the index value
				//	from HoldPlace.
				var iSelect = 0;
				if (oForm["HoldPlace"]) {
					iSelect = oForm["HoldPlace"].value;
				}
				//	When new list is written, select the first item.
				//	01/12/2003:646 Select the index in HoldPlace.
				if (ii == 0 || ii == iSelect) {
					oOption = new Option(aVals[1], aVals[0], true, true);
				}
				else {
					oOption = new Option(aVals[1], aVals[0]);
				}
				oForm[sField].options[ii] = oOption;
			}
			if (sBrowser == "Netscape") {
				if (bRefresh) {
					history.go(0);
				}
			}
		}
	}
}

function mh(iPage, sTo, sFirst, sLast, sLink) {
/*
	This is a helper function built for ElectSUp.cfm.
	
	An admin browsing this page, will be able to click on the e-mail link
	an generate a message to the candidate from their local e-mail client.
	
	The subject and body of the message are pre-set for the page and are
	used by reference, similarly to sWhoseThere().
	
	Only variable information is passed to the function.
	
	Parameters:
		iPage:	Page identifier.
		sTo:	Recipient's e-mail address.
		sFirst:	Recipient's first name.
		sLast:	Recipient's last name.
		sLink:	Link to page on MainStreetCentral.
*/
	var reAmp = /\&/gi;		//	Regular expression for ampersand.
	var reQ = /\?/gi;		//	Regular expression for question mark.
	var reSp = /\s/gi;		//	Regular expression for spaces.
	var reSub = /\@\@/gi;	//	Variable substitution for the message body.

//	var sSubject = "[MSC] Inquiry from Election Central(tm) visitor at MainStreetCentral.com";
	var sSubject = eval("gsSubj" + iPage);

//	var sBody = "Hi Mr. " + sLast + ",%0D%0DI saw your profile at Main Street Central. Would you be kind enough to give me some additional information:%0D";
//	var sBody = "Hi Mr. " + sLast + ",%0D%0DI saw your profile at Main Street Central. Would you be kind enough to give me some additional information:%0D";
	var sBody = "Hi Mr. " + sLast + ",%0D%0D" + eval("gsBody" + iPage);

	sLink = sLink.replace(reAmp, "%26");
	sLink = sLink.replace(reQ, "%3F");
//	sLink = "%0D%0DThis was the page I looked at:%0D%0Dhttp://www.mainstreetcentral.com/" + sLink;
//	sBody = sBody + sLink;	
	sBody = sBody.replace(reSub, sLink);

	sSubject = sSubject.replace(reSp, "%20");
	sBody = sBody.replace(reSp, "%20");

	return "mailto:" + sTo + "?Subject=" + sSubject + "&Body=" + sBody;
}

/*
Change History:
01/11/2003:	OpenWin added conditional focus.
			OpenWindow added conditional focus.
01/12/2003:	606 Added HoldPlace input to form to deal with IE back button problem.
			637 Added HoldPlace input to form to deal with IE back button problem.
			646 Select the index in HoldPlace.
08/31/2004:	105 Enclosed an unclosed block causing errors.
10/23/2004:	Added mh() as an admin mail helper for Election Central.
10/29/2004:	Moved CheckSome() from la_emedt.cfm.
11/09/2004: WriteCommOptions: Changed the third argument from sField to
			oElement to allow for recognition of the calling form.
*/