function checkUpload() {
	var str = document.upload.file1.value;
	var strLen = document.upload.file1.value.length;
	var strLen2 = document.upload.file1.value.length-4;
	strFour = str.substring(strLen2,strLen);
	
	if (str == "") {
		alert("Please choose a bulk upload list before proceeding.");
		document.upload.file1.select();
		document.upload.file1.focus();
		return false;
	} else if (strFour != ".txt") {
		alert("Please choose the correct csv file format for bulk uploading before proceeding.");
		document.upload.file1.select();
		document.upload.file1.focus();
		return false;
	} else {
		return true;
	}
}

function fverifyChange() {
	if ( document.fChange.new_mbruserid.value.length == 0 ) {
		alert("You must enter a value that is at least four characters long for your account name.");
		return false;
	} else if ( document.fChange.new_mbruserid.value.length < 4 ) {
		alert("Please enter a longer name for your account.");
		return false;
	} else {
		var message = "You have chosen to change '" + document.fChange.selected_campid.options[document.fChange.selected_campid.selectedIndex].text + "' to '" + document.fChange.new_mbruserid.value + "'. Are you sure? This cannot be undone or changed once you click [OK].";
		if ( !confirm(message) ) {
			return false;
		} else {
			return true;
		}
	}
}

function confirmDelete(what) {
	if (confirm("This action CANNOT be undone! Are you sure you want to continue?")) {
		location.href = what;
		return true;
	} else {
		return false;
	}
}

function findSelectedMsgs(what) {
	var msgid
	for (i=0,n=document.msglist1.elements.length;i<n;i++)
		if (document.msglist1.elements[i].name.indexOf('mlist_') != -1)
		if (document.msglist1.elements[i].checked == true)
		if (!msgid) {
			msgid = document.msglist1.mlist_[i].value + ',';
		} else {
			msgid = msgid + document.msglist1.mlist_[i].value + ',';
		}
	for (i=0,n=document.msglist2.elements.length;i<n;i++)
		if (document.msglist2.elements[i].name.indexOf('mlist_') != -1)
		if (document.msglist2.elements[i].checked == true)
		if (!msgid) {
			msgid = document.msglist2.mlist_[i].value + ',';
		} else {
			msgid = msgid + document.msglist2.mlist_[i].value + ',';
		}
	if (msgid) {
		if (what == 'delete') {
			location.href='messages_process.asp?action=group-delete&msgid=' + msgid;
		} else if (what == 'turnoff') {
			location.href='messages_process.asp?action=group-onoff&effect=0&msgid=' + msgid;
		} else if (what == 'turnon') {
			location.href='messages_process.asp?action=group-onoff&effect=1&msgid=' + msgid;
		} else if (what == 'tracking') {
			location.href='campaign_tracking-process.asp?msgid=' + msgid;
		}
	} else {
		alert('You must choose a selection of message(s) to perform this action.\nTo make your selection, check the checkbox next to the messages to which you wish to perform this action on.');
	}
}

function findSelectedTracking(what) {
	var msgid
	
	for (i=0,n=document.urllist.elements.length;i<n;i++)
		if (document.urllist.elements[i].name.indexOf('urllist_') != -1)
		if (document.urllist.elements[i].checked == true)
		if (!msgid) {
			msgid = document.urllist.urllist_[i].value + ',';
		} else {
			msgid = msgid + document.urllist.urllist_[i].value + ',';
		}
		if (what == 'tracking') {
			location.href='campaign_tracking-process.asp?msgid=' + msgid;
	}
}

function synchMenu(field,ndex) {
	field.options[ndex].selected = true;
}

function checkAllLeads() {
	if (document.leadslist.elements.length == 1) {
		if (document.leadslist.clist_.checked == true) {
			document.leadslist.clist_.checked = false;
		} else {
			document.leadslist.clist_.checked = true;
		}
	} else if (document.leadslist.elements.length > 1) {
		if (document.leadslist.clist_[0].checked == true) {
			for (i=0,n=document.leadslist.elements.length;i<n;i++)
				if (document.leadslist.elements[i].name.indexOf('clist_') !=-1)
				document.leadslist.elements[i].checked = false;
			
		} else {
			for (i=0,n=document.leadslist.elements.length;i<n;i++)
				if (document.leadslist.elements[i].name.indexOf('clist_') !=-1)
				document.leadslist.elements[i].checked = true;
		}
	}
}

function checkAllMessages1() {
	if (document.msglist1.elements.length == 1) {
		if (document.msglist1.mlist_.checked == true) {
			document.msglist1.mlist_.checked = false;
		} else {
			document.msglist1.mlist_.checked = true;
		}
	} else if (document.msglist1.elements.length > 1) {
		if (document.msglist1.mlist_[0].checked == true) {
			for (i=0,n=document.msglist1.elements.length;i<n;i++)
				if (document.msglist1.elements[i].name.indexOf('mlist_') !=-1)
				document.msglist1.elements[i].checked = false;
		} else {
			for (i=0,n=document.msglist1.elements.length;i<n;i++)
				if (document.msglist1.elements[i].name.indexOf('mlist_') !=-1)
				document.msglist1.elements[i].checked = true;
		}
	}
}

function checkAllMessages2() {
	if (document.msglist2.elements.length == 1) {
		if (document.msglist2.mlist_.checked == true) {
			document.msglist2.mlist_.checked = false;
		} else {
			document.msglist2.mlist_.checked = true;
		}
	} else if (document.msglist2.elements.length > 0) {
		if (document.msglist2.mlist_[0].checked == true) {
			for (i=0,n=document.msglist2.elements.length;i<n;i++)
				if (document.msglist2.elements[i].name.indexOf('mlist_') !=-1)
				document.msglist2.elements[i].checked = false;
		} else {
			for (i=0,n=document.msglist2.elements.length;i<n;i++)
				if (document.msglist2.elements[i].name.indexOf('mlist_') !=-1)
				document.msglist2.elements[i].checked = true;
		}
	}
}

function checkAllTrackingMessages() {
	if (document.urllist.elements.length == 1) {
		if (document.urllist.mlist_.checked == true) {
			document.urllist.mlist_.checked = false;
		} else {
			document.urllist.mlist_.checked = true;
		}
	} else if (document.urllist.elements.length > 0) {
		if (document.urllist.urllist_[0].checked == true) {
			for (i=0,n=document.urllist.elements.length;i<n;i++)
				if (document.urllist.elements[i].name.indexOf('urllist_') !=-1)
				document.urllist.elements[i].checked = false;
		} else {
			for (i=0,n=document.urllist.elements.length;i<n;i++)
				if (document.urllist.elements[i].name.indexOf('urllist_') !=-1)
				document.urllist.elements[i].checked = true;
		}
	}
}

function openViewlet(htmlFile,htmlWidth,htmlHeight) {
	str = 'resizable=0,toolbar=0,menubar=0,';
	str = str + 'scrollbars=0,status=0,location=0,directory=0,width=350,height=200';
	
	version=Math.round(parseFloat(navigator.appVersion) * 1000);
	
	if(navigator.appName.indexOf("Konqueror")!=-1) { // konqueror
		htmlWidth+=18;
		htmlHeight+=96;
	}
	
	if(navigator.appName.indexOf("Netscape")!=-1) {
		if(version>=5000) {
			if(navigator.appVersion.indexOf("Mac")!=-1) { // Netscape6+ on mac
				htmlHeight+=5;
			}
		}
	}
	
	if(navigator.appName.indexOf("Microsoft")!=-1) {
		if(navigator.appVersion.indexOf("Mac")!=-1) { // IE on Mac
			htmlWidth  -= 11;
			htmlHeight -= 11;
		}
	}
	
    if(!isViewletCompliant()) {
		open("http://www.qarbon.com/warning/index.html",'Leelou',str);
    } else {
		window.open(htmlFile,'Leelou','width='+htmlWidth+',height='+htmlHeight+',top=10,left=20');
	}
}

function isViewletCompliant() {
	answer=true;
	version=Math.round(parseFloat(navigator.appVersion) * 1000);
	
	if (navigator.appName.substring(0,9) == "Microsoft") {
		if(version<4000) answer=false;
	}
	
	if (navigator.appName.substring(0,8) == "Netscape") {
		if ((navigator.appVersion.indexOf("Mac")> 0) && (version<5000))
		answer=false;
		else
		if (version<4060)
		answer=false;
	}
	
	plugins=navigator.plugins;
	
	if (answer==false && plugins!=null) {
		for(i=0;i!=plugins.length;i++)
		if((plugins[i].name.indexOf("Java Plug-in")>=0) && (plugins[i].name.indexOf("1.0")<0))
		answer=true;
	}
	
	return answer;
}

function ListCheck() {
	if (document.theform.list[3].checked == true) {
		document.theform.list[0].checked = false;
		document.theform.list[1].checked = false;
		document.theform.list[2].checked = false;
	} else {
		document.theform.list[3].checked = false;
	}
}

function ListCheck2() {
	document.theform.list[3].checked = false;
}

function checkFirst(var1, var2) {
	if (confirm(var1)) {
		location.href = var2;
	}
}

function watchSelection() {
	if (theform.recipient.options[theform.recipient.selectedIndex].value == "webmaster@pro-send.com") {
		alert("The recipient you have chosen for this message should not be contacted for technical support related issues. Please send only MAJOR site problem reports to this recipient. Thank you.");
	}
}

function welcomeWin(var1) {
	if (var1 == 1) {
		window.open("splash.asp","welcomeWin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=528,height=385")
	}
	if (var1 == 2) {
		nwindow('/notices/price_upgrade.asp', '420', '470', '', 'toolbar');
		setTimeout('openwin.close()',120000);
	}
	if (var1 == 3) {
		nwindow('http://www.prostepinc.com/promo','450','450','','')
	}
	if (var1 == 4) {
		nwindow('/notices/dec_cancelation.asp','350','400','','')
		setTimeout('openwin.close()',120000);
	}
	if (var1 == 5) {
		nwindow('/notices/bonus_extension.asp','350','290','','')
		setTimeout('openwin.close()',120000);
	}
	if (var1 == 6) {
		nwindow('/notices/newyear_closed.asp','350','290','','')
		setTimeout('openwin.close()',120000);
	}
	if (var1 == 7) {
		nwindow('/notices/equip_upgrade.asp','350','350','','')
		setTimeout('openwin.close()',120000);
	}
	if (var1 == 8) {
		nwindow('/notices/hot_cash.asp','420','350','','')
		setTimeout('openwin.close()',120000);
	}
	if (var1 == 9) {
		nwindow('../+member_msg.asp','420','350','','')
		setTimeout('openwin.close()',120000);
	}
}

function forgot_passwd() {
	nwindow('/notices/forgot_passwd.asp', '420', '330', '', 'toolbar');
}

function chkEmail() {
	if (document.theform.email.value == "") {
		alert("Please enter the leads e-mail address.");
		document.theform.email.select();
		return false;
	} else {
		return true;
	}
}

function checkForm() {
	alert(document.theform.status.value);
	alert(document.theform.delay.value);
	alert(document.theform.subject.value);
	alert(document.theform.format.value);
	alert(document.theform.bgcolor.options[document.theform.bgcolor.selectedIndex].value);
	alert(document.theform.body.value);
}

function showSpan(var1) {
	if (var1 == "yes") {
		html_span.style.display = "block";
		helpon = true;
		modeIndex = 2;	// 0=simple, 1=sample, 2=prompt
		document.theform.btn_preview.disabled = false;
		document.theform.btn_sample.disabled = false;
	} else {
		html_span.style.display = "none";
		document.theform.btn_preview.disabled = true;
		document.theform.btn_sample.disabled = true;
	}
}

function formInit() {
	helpon = true;
	modeIndex = 2;
	
	origDelay = document.theform.delay.value;
	origSubject = document.theform.subject.value;
	origBody = document.theform.body.value;
	
	//changeOver('revert');
}

function setButtonColors() {
	document.theform.color_black.style.backgroundColor = "black";
	document.theform.color_gray.style.backgroundColor = "gray";
	document.theform.color_silver.style.backgroundColor = "silver";
	document.theform.color_white.style.backgroundColor = "white";
	document.theform.color_maroon.style.backgroundColor = "maroon";
	document.theform.color_red.style.backgroundColor = "red";
	document.theform.color_navy.style.backgroundColor = "navy";
	document.theform.color_blue.style.backgroundColor = "blue";
	document.theform.color_olive.style.backgroundColor = "olive";
	document.theform.color_yellow.style.backgroundColor = "yellow";
	document.theform.color_green.style.backgroundColor = "green";
	document.theform.color_lime.style.backgroundColor = "lime";
	document.theform.color_brown.style.backgroundColor = "brown";
	document.theform.color_orange.style.backgroundColor = "orange";
	document.theform.color_fuchsia.style.backgroundColor = "fuchsia";
	document.theform.color_pink.style.backgroundColor = "pink";
	document.theform.color_teal.style.backgroundColor = "teal";
	document.theform.color_aqua.style.backgroundColor = "aqua";
}

function changeOver(var1) {
	if (var1 == "change") {
		
		// ------------------------- //
		// CHANGE MODE				 //
		// ------------------------- //
		
		/*
		
		if (document.theform.status[0].checked == false) {
			origStatus = 0;
		} else {
			origStatus = 1;
		}
		
		origDelay = document.theform.delay.value;
		origSubject = document.theform.subject.value;
		origBody = document.theform.body.value;
		
		if (document.theform.format[0].checked == false) {
			origFormat = 0;
		} else {
			origFormat = 1;
			document.theform.btn_preview.disabled = false;
			document.theform.btn_sample.disabled = false;
		}
		
		*/
		
		if (origFormat == 1) {
			document.theform.btn_preview.disabled = false;
			document.theform.btn_sample.disabled = false;
		}
		
		document.theform.btn_change1.style.display = "none";
		document.theform.btn_change2.style.display = "block";
		document.theform.btn_save.style.backgroundColor = "#8DE08F";
		document.theform.btn_save.disabled = false;
		document.theform.btn_reset.disabled = false;
		
		document.theform.status[0].disabled = false;
		document.theform.status[1].disabled = false;
		document.theform.delay.disabled = false;
		document.theform.subject.disabled = false;
		document.theform.body.disabled = false;
		
		document.theform.format[0].disabled = false;
		document.theform.format[1].disabled = false;
		
		document.theform.help[0].disabled = false;
		document.theform.help[1].disabled = false;
		document.theform.mode[0].disabled = false;
		document.theform.mode[1].disabled = false;
		document.theform.mode[2].disabled = false;
		document.theform.b.disabled = false;
		document.theform.u.disabled = false;
		document.theform.i.disabled = false;
		document.theform.p.disabled = false;
		document.theform.br.disabled = false;
		document.theform.pre.disabled = false;
		document.theform.h1.disabled = false;
		document.theform.h2.disabled = false;
		document.theform.h3.disabled = false;
		document.theform.ol.disabled = false;
		document.theform.ul.disabled = false;
		document.theform.li.disabled = false;
		document.theform.left.disabled = false;
		document.theform.center.disabled = false;
		document.theform.right.disabled = false;
		document.theform.hr.disabled = false;
		document.theform.img.disabled = false;
		document.theform.a.disabled = false;
		
		document.theform.color_black.disabled = false;
		document.theform.color_black.style.backgroundColor = "black";
		document.theform.color_gray.disabled = false;
		document.theform.color_gray.style.backgroundColor = "gray";
		document.theform.color_silver.disabled = false;
		document.theform.color_silver.style.backgroundColor = "silver";
		document.theform.color_white.disabled = false;
		document.theform.color_white.style.backgroundColor = "white";
		document.theform.color_maroon.disabled = false;
		document.theform.color_maroon.style.backgroundColor = "maroon";
		document.theform.color_red.disabled = false;
		document.theform.color_red.style.backgroundColor = "red";
		document.theform.color_navy.disabled = false;
		document.theform.color_navy.style.backgroundColor = "navy";
		document.theform.color_blue.disabled = false;
		document.theform.color_blue.style.backgroundColor = "blue";
		document.theform.color_olive.disabled = false;
		document.theform.color_olive.style.backgroundColor = "olive";
		document.theform.color_yellow.disabled = false;
		document.theform.color_yellow.style.backgroundColor = "yellow";
		document.theform.color_green.disabled = false;
		document.theform.color_green.style.backgroundColor = "green";
		document.theform.color_lime.disabled = false;
		document.theform.color_lime.style.backgroundColor = "lime";
		document.theform.color_brown.disabled = false;
		document.theform.color_brown.style.backgroundColor = "brown";
		document.theform.color_orange.disabled = false;
		document.theform.color_orange.style.backgroundColor = "orange";
		document.theform.color_fuchsia.disabled = false;
		document.theform.color_fuchsia.style.backgroundColor = "fuchsia";
		document.theform.color_pink.disabled = false;
		document.theform.color_pink.style.backgroundColor = "pink";
		document.theform.color_teal.disabled = false;
		document.theform.color_teal.style.backgroundColor = "teal";
		document.theform.color_aqua.disabled = false;
		document.theform.color_aqua.style.backgroundColor = "aqua";
		
		document.theform.bgcolor.disabled = false;
	} else {
		
		// ------------------------- //
		// REVERT MODE				 //
		// ------------------------- //
		
		document.theform.delay.value = origDelay;
		document.theform.subject.value = origSubject;
		document.theform.body.value = origBody;
		
		/*
		
		if (origStatus = 1) { // Off
			document.theform.status[0].checked = true;
		}
		
		if (origStatus = 0) { // On
			document.theform.status[1].checked = true;
		}
		
		if (origFormat = 1) { // Plain Text
			document.theform.format[0].checked = true;
			showSpan('yes');
		}
		
		if (origFormat = 0) { // HTML
			document.theform.format[1].checked = true;
			showSpan('no');
		}
		
		*/
		
		document.theform.btn_preview.disabled = true;
		document.theform.btn_change1.style.display = "block";
		document.theform.btn_change2.style.display = "none";
		document.theform.btn_save.style.backgroundColor = "";
		document.theform.btn_save.disabled = true;
		document.theform.btn_reset.disabled = true;
		document.theform.btn_sample.disabled = true;
		
		document.theform.status[0].disabled = true;
		document.theform.status[1].disabled = true;
		document.theform.delay.disabled = true;
		document.theform.subject.disabled = true;
		document.theform.body.disabled = true;
		
		document.theform.format[0].disabled = true;
		document.theform.format[1].disabled = true;
		
		document.theform.help[0].disabled = true;
		document.theform.help[1].disabled = true;
		document.theform.mode[0].disabled = true;
		document.theform.mode[1].disabled = true;
		document.theform.mode[2].disabled = true;
		document.theform.b.disabled = true;
		document.theform.u.disabled = true;
		document.theform.i.disabled = true;
		document.theform.p.disabled = true;
		document.theform.br.disabled = true;
		document.theform.pre.disabled = true;
		document.theform.h1.disabled = true;
		document.theform.h2.disabled = true;
		document.theform.h3.disabled = true;
		document.theform.ol.disabled = true;
		document.theform.ul.disabled = true;
		document.theform.li.disabled = true;
		document.theform.left.disabled = true;
		document.theform.center.disabled = true;
		document.theform.right.disabled = true;
		document.theform.hr.disabled = true;
		document.theform.img.disabled = true;
		document.theform.a.disabled = true;
		
		document.theform.color_black.disabled = true;
		document.theform.color_black.style.backgroundColor = "";
		document.theform.color_gray.disabled = true;
		document.theform.color_gray.style.backgroundColor = "";
		document.theform.color_silver.disabled = true;
		document.theform.color_silver.style.backgroundColor = "";
		document.theform.color_white.disabled = true;
		document.theform.color_white.style.backgroundColor = "";
		document.theform.color_maroon.disabled = true;
		document.theform.color_maroon.style.backgroundColor = "";
		document.theform.color_red.disabled = true;
		document.theform.color_red.style.backgroundColor = "";
		document.theform.color_navy.disabled = true;
		document.theform.color_navy.style.backgroundColor = "";
		document.theform.color_blue.disabled = true;
		document.theform.color_blue.style.backgroundColor = "";
		document.theform.color_olive.disabled = true;
		document.theform.color_olive.style.backgroundColor = "";
		document.theform.color_yellow.disabled = true;
		document.theform.color_yellow.style.backgroundColor = "";
		document.theform.color_green.disabled = true;
		document.theform.color_green.style.backgroundColor = "";
		document.theform.color_lime.disabled = true;
		document.theform.color_lime.style.backgroundColor = "";
		document.theform.color_brown.disabled = true;
		document.theform.color_brown.style.backgroundColor = "";
		document.theform.color_orange.disabled = true;
		document.theform.color_orange.style.backgroundColor = "";
		document.theform.color_fuchsia.disabled = true;
		document.theform.color_fuchsia.style.backgroundColor = "";
		document.theform.color_pink.disabled = true;
		document.theform.color_pink.style.backgroundColor = "";
		document.theform.color_teal.disabled = true;
		document.theform.color_teal.style.backgroundColor = "";
		document.theform.color_aqua.disabled = true;
		document.theform.color_aqua.style.backgroundColor = "";
		
		document.theform.bgcolor.disabled = true;
	}
}

function resetBody(formvar) {
	formvar.body.value = "";
	helpon = true;
	modeIndex = 2;
}

function doFormat(formvar, selection) {
	if (helpon) {
		if (confirm(selection.helptext)) {
			addHTML(formvar,selection);
		}
	} else {
		addHTML(formvar,selection);
	}
}


function preview(formvar) {
	if (screen.width >= 1024) {				// 1024x768 (or higher)...
		iW = "800";
		iH = "600";
	} else if (screen.width == 800) {		// 800x600...
		iW = "760";
		iH = "500";
	} else {								// 640x480...
		iW = "620";
		iH = "350";
	}
	msg = open("","DisplayWindow","width=" + iW + ",height=" + iH + ",toolbar=no,directories=no,menubar=yes,resize=no,maximize=no,scrollbars=yes");
	msg.focus();
	if (formvar.external.value == 0) {
		msg.document.writeln('<html>');
		msg.document.writeln('<head>');
		msg.document.writeln('<title>' + formvar.subject.value + '</title>');
		msg.document.writeln('<style>');
		msg.document.writeln('body { font-family:Verdana;font-size:12px; }');
		msg.document.writeln('</style>');
		msg.document.writeln('</head>');
		if (formvar.browser.value == "msie") {
			msg.document.writeln('<body bgcolor="' + formvar.bgcolor.options[formvar.bgcolor.selectedIndex].value + '">');
			msg.document.writeln(formvar.body.value);
		} else {
			if (blah != 1) {
				msg.document.writeln('<body>');
				msg.document.writeln('<pre>' + formvar.body.value + '</pre>');
			} else {
				msg.document.writeln('<body bgcolor="' + formvar.bgcolor.options[formvar.bgcolor.selectedIndex].value + '">');
				msg.document.writeln(formvar.body.value);
			}
		}
		msg.document.writeln('<p align="center">');
		msg.document.writeln('<form><input type="button" value="Close" onClick="javascript:window.close()"></form>');
		msg.document.writeln('</p>');
		msg.document.writeln('</body>');
		msg.document.writeln('</html>');
		msg.document.close();
	} else {
		msg.document.writeln(formvar.body.value);
		msg.document.writeln('<p align="center">');
		msg.document.writeln('<form><input type="button" value="Close" onClick="javascript:window.close()"></form>');
		msg.document.writeln('</p>');
		msg.document.close();
	}
}


function sampleHTML(formvar) {
	origBody = document.theform.body.value;
	resetBody = '\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\                 Resetting Message';
	
	document.theform.body.value = '\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n                 Beginning Sample';
	
	HTMLbody1 = '<p>This is a test for HTML support to show you the added functionality it contains.</p>\r\n\r\n';
	HTMLbody2 = HTMLbody1 + '<h3>Here is what the H3 HTML tag would display when used. This tag can be used for headings to bring attention to specific places in the message.</h3>\r\n\r\n';
	HTMLbody3 = HTMLbody2 + '<b>Testing, Testing</b>';
	
	setTimeout('document.theform.body.value = HTMLbody1',2000)
	setTimeout('document.theform.body.value = HTMLbody2',4000)
	setTimeout('document.theform.body.value = HTMLbody3',6000)
	setTimeout('preview(document.theform)',8000)
	setTimeout('document.theform.body.value = resetBody',18000)
	setTimeout('document.theform.body.value = origBody',20000)
}

function addHTMLinsert(selection, addText, formvar) {
	// insert mode
	// addText alread as .tagstart, cancel=false
	// insertmodes 1=none, 2=insert, 3=lists (UL and OL), 4=DL list, 5=anchor (A HREF)
	
	// simple insert (e.g. <b>bold text</b>)
	if (selection.insertmode == 2) {
		i = ""
		i = prompt (selection.inserttext, "")
		// if input add
		if ((i != null) && (i != "")) {
			addText = i 
		} else {
			addText = ""
		}
	}
	// UL and OL lists
	if (selection.insertmode == 3) {
		addText = ""
		i = ""
		i = prompt (selection.inserttext, "")
		if ((i != null) && (i != "")) {
			addText = i
			// get next until null or cancel
			while ((i != null) && (i != "")) {
				i=prompt (selection.inserttext2, "")
				if ((i != null) && (i != "")) {
					addText=addText + selection.tagmiddle + i
				}
			}
		}
	}
	// DL list
	if (selection.insertmode == 4) {
		i= "dummy"
		j = i
		addText = ""
		count = 0
		// get next until null or cancel
		while ((i != null) && (i != "") && (j != null) && (j !="")) {
			++count 
			i = ""
			i = prompt (selection.inserttext, "")
			// used for debugging formvar.body.value += "-=>" + i + "<=-"
			if ((i != null) && (i != "")) {
				j = ""
				j=prompt (selection.inserttext2, "")
				if ((j != null) && (j != "")) {
					if (count > 1){
						addText += selection.tagmiddle2
					}
					addText=addText +i + selection.tagmiddle + j
				}
			}
		}
	}
	// Anchor (A HREF)
	if (selection.insertmode == 5) {
		addText = ""
		i = ""
		i = prompt (selection.inserttext, "")
		// used for debugging formvar.body.value += "-=>" + i + "<=-"
		if ((i != null) && (i != "")) {
			j = ""
			j = prompt (selection.inserttext2, "")
			if ((j != null) && (j != "")) {
				addText=i + selection.tagmiddle + j
			}
		}
	}
	return addText;
}

function addHTML(formvar,selection) {
	cancel = false
	addText = selection.tagstart
	// insert mode
	if (modeIndex == 2) {
		// if none, skip it all
		if (selection.insertmode != 1) {
			addText += addHTMLinsert(selection, addText, formvar)
			if (addText == selection.tagstart) {
				cancel = true
			}
		}
	}
	// sample mode
	if (modeIndex==1) {
		addText = addText + selection.sampletext + selection.tagmiddle + selection.sampletext2
	}
	// simple mode
	if (modeIndex==0) {
		addText += selection.tagmiddle
	}
	addText += selection.tagend
	// put text into TextArea unless canceled
	if (cancel == false) {
		document.theform.body.value += addText + '\r\n'
	}
}

function HTMLtag(buttonname, insertmode, inserttext, tagstart, tagmiddle, tagend, sampletext, sampletext2, helptext) {
	this.buttonname = buttonname
	this.insertmode = insertmode
	this.inserttext = inserttext
	this.tagstart = tagstart
	this.tagmiddle = tagmiddle
	this.tagend = tagend
	this.sampletext = sampletext
	this.sampletext2 = sampletext2
	this.helptext = helptext
}

formatB = new HTMLtag("b", 2, "Enter the text to be BOLD.", "<b>", "", "</b>", "This will be BOLD", "" , "The text placed between the <b> and the </b> will be BOLD.")
formatU = new HTMLtag("u", 2, "Enter the text to be UNDERLINED.", "<u>", "", "</u>", "This will be UNDERLINED", "" , "The text placed between the <u> and the </u> will be UNDERLINED.")
formatI = new HTMLtag("i", 2, "Enter the text to be ITALICIZED.", "<i>", "", "</i>", "This will be in ITALICS", "" , "The text placed between the <i> and the </i> will be ITALICIZED.")
formatPRE = new HTMLtag("pre", 2, "Enter the text to be PREformatted.", "<pre>", "", "</pre>", "This will be PREformatted", "" , "The text placed between the <pre> and the </pre> will be PREformatted.")
formatP = new HTMLtag("p", 2, "Enter the text for a PARAGRAPH.", "<p>", "", "</p>", "Start of a PARAGRAPH that continues until the start of next PARAGRAPH.", "" , "The text placed after the <p> will be a separate PARAGRAPH until the next <p>")
formatBR = new HTMLtag("br", 1, "", "<br>", "", "", "", "" , "This tag forces a line break, start of the next line.")
formatHR = new HTMLtag("hr", 1, "", "<hr>", "", "", "", "" , "This tag puts a (horizontal rule) line on the page.")
formatH1 = new HTMLtag("h1", 2, "Enter the text for the top level HEADLINE.", "<h1>", "", "</h1>", "This will be a top level HEADLINE", "" , "The text placed between the <h1> and the </h1> will be the top level HEADLINE.")
formatH2 = new HTMLtag("h2", 2, "Enter the text for the second level HEADLINE.", "<h2>", "", "</h2>", "This will be a second level HEADLINE", "" , "The text placed between the <h2> and the </h2> will be the second level HEADLINE.")
formatH3 = new HTMLtag("h3", 2, "Enter the text for the third level HEADLINE.", "<h3>", "", "</h3>", "This will be a third level HEADLINE", "" , "The text placed between the <h3> and the </h3> will be the third level HEADLINE.")
formatDIVLeft = new HTMLtag("left", 2, "Enter the text to be LEFT aligned.", '<div align="left">', "", "</div>", "This will be LEFT aligned", "" , 'The text placed between the <div align="left"> and the </div> will be aligned to the LEFT.')
formatCENTER = new HTMLtag("center", 2, "Enter the text to be CENTERED.", '<div align="center">', "", "</div>", "This will be CENTERED", "" , 'The text placed between the <div align="center"> and the </div> will be aligned to the CENTER.')
formatDIVRight = new HTMLtag("right", 2, "Enter the text to be RIGHT aligned.", '<div align="right">', "", "</div>", "This will be RIGHT aligned", "" , 'The text placed between the <div align="right"> and the </div> will be aligned to the RIGHT.')
formatLI = new HTMLtag("li", 2, "Enter the text for an item in a bulleted LIST.", "<li>", "", "</li>", "This is an item in a LIST", "" , "The text placed between the <li> and the </li> will one item in a LIST. (May require OL or UL)")
formatIMG = new HTMLtag("img", 2, "Enter the URL (e.g. sample.gif).", '<img src="', "", '">', "URL to graphic (e.g. sample.gif)" , "", "Enter the URL for the graphic (e.g., sample.gif)")

formatOL = new HTMLtag("ol", 3, "Enter the [FIRST] item for this ORDERED LIST (numbered), then click OK.", "<ol><li>", "</li><li>", "</li></ol>", "This is one item in the numbered list", "Next item in the numbered list" , "Create an ORDERED LIST (automatically numbered list) by placing multiple items between <li> and </li>")
formatOL.inserttext2 = "Enter the [NEXT] item for this ORDERED LIST (numbered). Click OK, to Submit OR Cancel to Finish."

formatUL = new HTMLtag("ul", 3, "Enter [FIRST] item for this UNORDERED LIST (bulleted), then click OK", "<ul><li>", "</li><li>", "</li></ul>", "This is one item in the plain list", "Next item in the plain list" , "Create an UN-ORDERED LIST by placing multiple items between <li> and </li>")
formatUL.inserttext2 = "Enter the [NEXT] item for this UNORDERED LIST (bulleted). Click OK to Submit OR Cancel to Finish."

formatA = new HTMLtag("a", 5, "Enter the URL (e.g. www.prostepinc.com).", '<a href="http://', '">', '</a>', "www.prostepinc.com", "ProSTEP Inc. (description here)", 'Enter the URL (e.g. "www.prostepinc.com/members") followed by the description.')
formatA.inserttext2 = "Enter description (e.g. ProSTEP Online)."

formatColorBlack = new HTMLtag("color_black", 2, "Enter the text to be in BLACK.", '<font style="color:black">', "", "</font>", "This will be BLACK", "", 'The text placed between the <font style="color:black"> and the </font> will be BLACK.')
formatColorGray = new HTMLtag("color_gray", 2, "Enter the text to be in GRAY.", '<font style="color:gray">', "", "</font>", "This will be GRAY", "", 'The text placed between the <font style="color:gray"> and the </font> will be GRAY.')
formatColorSilver = new HTMLtag("color_silver", 2, "Enter the text to be in SILVER.", '<font style="color:silver">', "", "</font>", "This will be SILVER", "", 'The text placed between the <font style="color:silver"> and the </font> will be SILVER.')
formatColorWhite = new HTMLtag("color_white", 2, "Enter the text to be in WHITE.", '<font style="color:white">', "", "</font>", "This will be WHITE", "", 'The text placed between the <font style="color:white"> and the </font> will be WHITE.')
formatColorMaroon = new HTMLtag("color_maroon", 2, "Enter the text to be in MAROOON.", '<font style="color:maroon">', "", "</font>", "This will be MAROON", "", 'The text placed between the <font style="color:maroon"> and the </font> will be MAROON.')
formatColorRed = new HTMLtag("color_red", 2, "Enter the text to be in RED.", '<font style="color:red">', "", "</font>", "This will be RED", "", 'The text placed between the <font style="color:red"> and the </font> will be RED.')
formatColorNavy = new HTMLtag("color_navy", 2, "Enter the text to be in NAVY.", '<font style="color:navy">', "", "</font>", "This will be NAVY", "", 'The text placed between the <font style="color:navy"> and the </font> will be NAVY.')
formatColorBlue = new HTMLtag("color_blue", 2, "Enter the text to be in BLUE.", '<font style="color:blue">', "", "</font>", "This will be BLUE", "", 'The text placed between the <font style="color:blue"> and the </font> will be BLUE.')
formatColorOlive = new HTMLtag("color_olive", 2, "Enter the text to be in OLIVE.", '<font style="color:olive">', "", "</font>", "This will be OLIVE", "", 'The text placed between the <font style="color:olive"> and the </font> will be OLIVE.')
formatColorYellow = new HTMLtag("color_yellow", 2, "Enter the text to be in YELLOW.", '<font style="color:yellow">', "", "</font>", "This will be YELLOW", "", 'The text placed between the <font style="color:yellow"> and the </font> will be YELLOW.')
formatColorGreen = new HTMLtag("color_green", 2, "Enter the text to be in GREEN.", '<font style="color:green">', "", "</font>", "This will be GREEN", "", 'The text placed between the <font style="color:green"> and the </font> will be GREEN.')
formatColorLime = new HTMLtag("color_lime", 2, "Enter the text to be in LIME.", '<font style="color:lime">', "", "</font>", "This will be LIME", "", 'The text placed between the <font style="color:lime"> and the </font> will be LIME.')
formatColorBrown = new HTMLtag("color_brown", 2, "Enter the text to be in BROWN.", '<font style="color:brown">', "", "</font>", "This will be BROWN", "", 'The text placed between the <font style="color:brown"> and the </font> will be BROWN.')
formatColorOrange = new HTMLtag("color_orange", 2, "Enter the text to be in ORANGE.", '<font style="color:orange">', "", "</font>", "This will be ORANGE", "", 'The text placed between the <font style="color:orange"> and the </font> will be ORANGE.')
formatColorFuchsia = new HTMLtag("color_fuchsia", 2, "Enter the text to be in FUCHSIA.", '<font style="color:fuchsia">', "", "</font>", "This will be FUCHSIA", "", 'The text placed between the <font style="color:fuchsia"> and the </font> will be FUCHSIA.')
formatColorPink = new HTMLtag("color_pink", 2, "Enter the text to be in PINK.", '<font style="color:pink">', "", "</font>", "This will be PINK", "", 'The text placed between the <font style="color:pink"> and the </font> will be PINK.')
formatColorTeal = new HTMLtag("color_teal", 2, "Enter the text to be in TEAL.", '<font style="color:teal">', "", "</font>", "This will be TEAL", "", 'The text placed between the <font style="color:teal"> and the </font> will be TEAL.')
formatColorAqua = new HTMLtag("color_aqua", 2, "Enter the text to be in AQUA.", '<font style="color:aqua">', "", "</font>", "This will be AQUA", "", 'The text placed between the <font style="color:aqua"> and the </font> will be AQUA.')