//
// COPYRIGHT NOTICE
// Copyright 2002 Michael L. Benson. All rights reserved.
//
// This script may be used and modified free of charge provided that this
// copyright notice remains intact. By using this code you are agreeing to
// indemnify the author, Michael L. Benson, from any liability which might arise
// from its use.
//
// You may give copies of this program to any third party, but you may not sell
// this program for any reason whatsoever without the prior written consent of
// Michael L. Benson. 
//
// You must obtain prior written consent from Michael L. Benson if you intend to
// redistribute this script over the Internet or via any other medium.
//
// In all cases where this script is given to a third party, this copyright
// notice must remain intact and at the beginning of this script. At all times
// this script remains the property of Michael L. Benson.
//


var ns4;
var ie4;
var ns6;

// Test for which browser
if (document.layers) ns4 = true;
if (document.all) ie4 = true;
if ((document.getElementById) && (!document.all)) ns6 = true;


function submitForm(formName, theURL)
{
	var theForm = eval("document." + formName);
	theForm.action = theURL;
	theForm.submit();
}

function check_range_radio(name)
{
	var radioBtn = eval("document." + name);
	radioBtn[0].checked = false;
	radioBtn[1].checked = true;
}

function check_checkbox(name)
{
	var checkBox = eval("document." + name);
	checkBox.checked = true;
}

function update_event()
{
	document.event.update.value = "true";
	document.event.submit();
}

function back_to_event_category()
{
	document.event.action = "modify_event_category.cgi";
	document.event.submit();
}

function modify_event_link(id)
{
	document.eventcategory.catfunction.value = "modify," + id;
	document.eventcategory.action = "modify_event.cgi";
	document.eventcategory.submit();
	
	return true;
}

function modify_event(max_event_id)
{
	// Check that exactly one event is selected:
	numevents = 0;
	id = "";
	for (i = 0;  i <= max_event_id;  i++) {
		obj = eval("document.eventcategory.event_id" + i);
		if (obj && obj.checked) {
			if (numevents == 0) {
				id = i;
			}
			numevents++;
		}
	}
	if (numevents == 0) {
		alert("Please select an event to modify.");
		return false;
	}
	if (numevents > 1 && !confirm("You have selected more than one event.  Do you want to modify the first one selected?")) {
		return false;
	}

	document.eventcategory.catfunction.value = "modify," + id;
	document.eventcategory.action = "modify_event.cgi";
	document.eventcategory.submit();
	
	return true;
}

function add_event_to_category()
{
	document.eventcategory.catfunction.value = "new";
	document.eventcategory.action = "modify_event.cgi";
	document.eventcategory.submit();
}

function delete_event_from_category(max_event_id)
{
	// Check if at least one event is selected:
	atleast1 = false;
	ids = "";
	for (i = 0;  i <= max_event_id;  i++) {
		obj = eval("document.eventcategory.event_id" + i);
		if (obj && obj.checked) {
			if (atleast1) {
				ids += ",";
			}
			ids += i;
			atleast1 = true;
		}
	}
	if (!atleast1) {
		alert("Please select at least one event to delete.");
		return false;
	}
	if (!confirm("Are you sure you want to delete the checked events?")) {
		return false;
	}
	
	document.eventcategory.deleteevents.value = "true";
	document.eventcategory.submit();
	
	return true;
}

function update_event_category()
{
	document.eventcategory.update.value = "true";
	document.eventcategory.submit();
}

function back_to_event_categories()
{
	document.eventcategory.action = "event_categories.cgi";
	document.eventcategory.submit();
	
	return true;
}

function modify_cat_link(id)
{
	document.eventcats.thefunction.value = "modify," + id;
	document.eventcats.action = "modify_event_category.cgi";
	document.eventcats.submit();
	
	return true;
}

function add_event_category()
{
	document.eventcats.thefunction.value = "new";
	document.eventcats.action = "modify_event_category.cgi";
	document.eventcats.submit();
	
	return true;
}

function delete_event_category(max_cat_id)
{
	// Check if at least one category is selected:
	atleast1 = false;
	ids = "";
	for (i = 0;  i <= max_cat_id;  i++) {
		obj = eval("document.eventcats.cat_id" + i);
		if (obj && obj.checked) {
			if (atleast1) {
				ids += ",";
			}
			ids += i;
			atleast1 = true;
		}
	}
	if (!atleast1) {
		alert("Please select at least one event category to delete.");
		return false;
	}
	if (!confirm("WARNING: Deleting an event category will also delete all events in that category.  Delete anyway?")) {
		return false;
	}
	
	document.eventcats.thefunction.value = "delete," + ids;
	document.eventcats.submit();
	
	return true;
}

function modify_event_category(max_cat_id, verb)
{
	// Check that exactly one family is selected:
	numcats = 0;
	id = "";
	for (i = 0;  i <= max_cat_id;  i++) {
		obj = eval("document.eventcats.cat_id" + i);
		if (obj && obj.checked) {
			if (numcats == 0) {
				id = i;
			}
			numcats++;
		}
	}
	if (numcats == 0) {
		alert("Please select an event category to " + verb + ".");
		return false;
	}
	if (numcats > 1 && !confirm("You have selected more than one event category.  Do you want to " + verb + " the first one selected?")) {
		return false;
	}

	document.eventcats.thefunction.value = "modify," + id;
	document.eventcats.action = "modify_event_category.cgi";
	document.eventcats.submit();
	
	return true;
}

function add_career_category()
{
	document.careercats.thefunction.value = "new";
	document.careercats.action = "modify_career_category.cgi";
	document.careercats.submit();
	
	return true;
}

function delete_career_category(max_cat_id)
{
	// Check if at least one category is selected:
	atleast1 = false;
	ids = "";
	for (i = 0;  i <= max_cat_id;  i++) {
		obj = eval("document.careercats.cat_id" + i);
		if (obj && obj.checked) {
			if (atleast1) {
				ids += ",";
			}
			ids += i;
			atleast1 = true;
		}
	}
	if (!atleast1) {
		alert("Please select at least one career category to delete.");
		return false;
	}
	if (!confirm("WARNING: Deleting a career category will also delete all careers in that category.  Delete anyway?")) {
		return false;
	}
	
	document.careercats.thefunction.value = "delete," + ids;
	document.careercats.submit();
	
	return true;
}

function modify_career_category(max_cat_id, verb)
{
	// Check that exactly one category is selected:
	numcats = 0;
	id = "";
	for (i = 0;  i <= max_cat_id;  i++) {
		obj = eval("document.careercats.cat_id" + i);
		if (obj && obj.checked) {
			if (numcats == 0) {
				id = i;
			}
			numcats++;
		}
	}
	if (numcats == 0) {
		alert("Please select a career category to " + verb + ".");
		return false;
	}
	if (numcats > 1 && !confirm("You have selected more than one career category.  Do you want to " + verb + " the first one selected?")) {
		return false;
	}

	document.careercats.thefunction.value = "modify," + id;
	document.careercats.action = "modify_career_category.cgi";
	document.careercats.submit();
	
	return true;
}

function modify_career_link(id)
{
	document.careercategory.catfunction.value = "modify," + id;
	document.careercategory.action = "modify_career.cgi";
	document.careercategory.submit();
	
	return true;
}

function add_career_to_category()
{
	document.careercategory.catfunction.value = "new";
	document.careercategory.action = "modify_career.cgi";
	document.careercategory.submit();
}

function delete_career_from_category(max_career_id)
{
	// Check if at least one career is selected:
	atleast1 = false;
	ids = "";
	for (i = 0;  i <= max_career_id;  i++) {
		obj = eval("document.careercategory.career_id" + i);
		if (obj && obj.checked) {
			if (atleast1) {
				ids += ",";
			}
			ids += i;
			atleast1 = true;
		}
	}
	if (!atleast1) {
		alert("Please select at least one career to delete.");
		return false;
	}
	if (!confirm("Are you sure you want to delete the checked careers?")) {
		return false;
	}
	
	document.careercategory.deletecareers.value = "true";
	document.careercategory.submit();
	
	return true;
}

function modify_career(max_career_id)
{
	// Check that exactly one career is selected:
	numcareer = 0;
	id = "";
	for (i = 0;  i <= max_career_id;  i++) {
		obj = eval("document.careercategory.career_id" + i);
		if (obj && obj.checked) {
			if (numcareer == 0) {
				id = i;
			}
			numcareer++;
		}
	}
	if (numcareer == 0) {
		alert("Please select a career to modify.");
		return false;
	}
	if (numcareer > 1 && !confirm("You have selected more than one career.  Do you want to modify the first one selected?")) {
		return false;
	}

	document.careercategory.catfunction.value = "modify," + id;
	document.careercategory.action = "modify_career.cgi";
	document.careercategory.submit();
	
	return true;
}

function update_career_category()
{
	document.careercategory.update.value = "true";
	document.careercategory.submit();
}

function back_to_career_categories()
{
	document.careercategory.action = "career_categories.cgi";
	document.careercategory.submit();
	
	return true;
}

function modify_careercat_link(id)
{
	document.careercats.thefunction.value = "modify," + id;
	document.careercats.action = "modify_career_category.cgi";
	document.careercats.submit();
	
	return true;
}

function update_career()
{
	document.career.update.value = "true";
	document.career.submit();
}

function back_to_career_category()
{
	document.career.action = "modify_career_category.cgi";
	document.career.submit();
}

function back_to_salesquery()
{
	document.salesadmin.action = "salesreps.cgi";
	document.salesadmin.submit();
	
	return true;
}

function delete_products(numproducts)
{
	// Check if at least one product is selected:
	atleast1 = false;
	for (i = 0;  i <= numproducts;  i++) {
		obj = eval("document.modifysalesrep.product_" + i);
		if (obj && obj.checked) {
			atleast1 = true;
			break;
		}
	}
	if (!atleast1) {
		alert("Please select at least one product to delete from this sales rep.");
		return false;
	}
	if (!confirm("Are you sure you want to delete the selected products from this sales rep?")) {
		return false;
	}
	
	document.modifysalesrep.update.value = "true";
	document.modifysalesrep.deleteprods.value = "true";
	document.modifysalesrep.submit();
	
	return true;
}

function delete_rep_accounts(numaccounts)
{
	// Check if at least one account is selected:
	atleast1 = false;
	for (i = 0;  i <= numaccounts;  i++) {
		obj = eval("document.modifysalesrep.account_" + i);
		if (obj && obj.checked) {
			atleast1 = true;
			break;
		}
	}
	if (!atleast1) {
		alert("Please select at least one sales account to delete from this sales rep.");
		return false;
	}
	if (!confirm("Are you sure you want to delete the selected sales accounts from this sales rep?")) {
		return false;
	}
	
	document.modifysalesrep.update.value = "true";
	document.modifysalesrep.deleteaccounts.value = "true";
	document.modifysalesrep.submit();
	
	return true;
}

function delete_leads(max_leads)
{
	// Check if at least one lead is selected:
	atleast1 = false;
	ids = "";
	for (i = 0;  i <= max_leads;  i++) {
		obj = eval("document.leadsadmin.lead" + i);
		if (obj && obj.checked) {
			if (atleast1) {
				ids += ",";
			}
			hiddenobj = eval("document.leadsadmin.lead_id" + i);
			ids += hiddenobj.value;
			atleast1 = true;
		}
	}
	if (!atleast1) {
		alert("Please select at least one lead to delete.");
		return false;
	}
	if (!confirm("Are you sure you want to delete the selected leads?")) {
		return false;
	}
	
	document.leadsadmin.thefunction.value = "delete," + ids;
	document.leadsadmin.submit();
	
	return true;
}

function modify_lead(max_leads)
{
	// Check that exactly one lead is selected:
	numleads = 0;
	id = "";
	for (i = 0;  i <= max_leads;  i++) {
		obj = eval("document.leadsadmin.lead" + i);
		if (obj && obj.checked) {
			if (numleads == 0) {
				hiddenobj = eval("document.leadsadmin.lead_id" + i);
				id = hiddenobj.value;
			}
			numleads++;
		}
	}
	if (numleads == 0) {
		alert("Please select a lead to modify.");
		return false;
	}
	if (numleads > 1 && !confirm("You have selected more than one lead.  Do you want to modify the first one selected?")) {
		return false;
	}

	document.leadsadmin.thefunction.value = "modify," + id;
	document.leadsadmin.action = "modify_lead.cgi";
	document.leadsadmin.submit();
	
	return true;
}

function modify_lead_link(id)
{
	document.leadsadmin.thefunction.value = "modify," + id;
	document.leadsadmin.action = "modify_lead.cgi";
	document.leadsadmin.submit();
	
	return true;
}

function page_leads(pagenum)
{
	document.leadsadmin.pagenum.value = pagenum;
	document.leadsadmin.submit();
}

function get_leads()
{
	document.leadsadmin.action = "query_results.cgi";
	document.leadsadmin.submit();
	
	return true;
}

function add_lead()
{
	document.leadsadmin.action = "add_lead.cgi";
	document.leadsadmin.submit();
	
	return true;
}

function back_to_query()
{
	document.leadsadmin.action = "admin.cgi";
	document.leadsadmin.submit();
	
	return true;
}

function back_to_query2()
{
	document.addlead.action = "admin.cgi";
	document.addlead.submit();
	
	return true;
}

function add_to_mailing()
{
	document.leadsadmin.action = "add_to_mailing.cgi";
	document.leadsadmin.submit();
	
	return true;
}

function download_results()
{
	document.leadsadmin.action = "download_results.cgi";
	document.leadsadmin.submit();
	
	return true;
}

function submit_add_to_mailing()
{
	document.leadsadmin.thefunction.value = "addtomailing";
	document.leadsadmin.submit();
	
	return true;
}

function back_to_results()
{
	document.modifylead.action = "query_results.cgi";
	document.modifylead.submit();
}

function show_downloads()
{
	document.modifylead.action = "show_downloads.cgi";
	document.modifylead.submit();
}

function show_requests()
{
	document.modifylead.action = "show_requests.cgi";
	document.modifylead.submit();
}

function update_lead()
{
	document.modifylead.update.value = "true";
	document.modifylead.submit();
}

function add_sales_rep()
{
	document.salesadmin.action = "add_sales_rep.cgi";
	document.salesadmin.submit();
}

function back_to_salesreps()
{
	document.addsalesrep.action = "salesreps.cgi";
	document.addsalesrep.submit();
}

function back_to_salesreps2()
{
	document.modifysalesrep.action = "salesreps_results.cgi";
	document.modifysalesrep.submit();
}

function add_rep()
{
	if (document.addsalesrep.firstname.value == "") {
		alert("Please supply a first name.");
		return 0;
	}
	if (document.addsalesrep.lastname.value == "") {
		alert("Please supply a last name.");
		return 0;
	}
	if (document.addsalesrep.email.value == "") {
		alert("Please supply an email.");
		return 0;
	}

	document.addsalesrep.add.value = "true";
	document.addsalesrep.submit();
}

function modify_rep(max_rep_id)
{
	// Check that exactly one rep is selected:
	numreps = 0;
	id = "";
	for (i = 0;  i <= max_rep_id;  i++) {
		obj = eval("document.salesadmin.rep" + i);
		if (obj && obj.checked) {
			if (numreps == 0) {
				hiddenobj = eval("document.salesadmin.rep_id" + i);
				id = hiddenobj.value;
			}
			numreps++;
		}
	}
	if (numreps == 0) {
		alert("Please select a sales rep to modify.");
		return false;
	}
	if (numreps > 1 && !confirm("You have selected more than one sales rep.  Do you want to modify the first one selected?")) {
		return false;
	}

	document.salesadmin.thefunction.value = "modify," + id;
	document.salesadmin.action = "modify_sales_rep.cgi";
	document.salesadmin.submit();
	
	return true;
}

function modify_rep_link(id)
{
	document.salesadmin.thefunction.value = "modify," + id;
	document.salesadmin.action = "modify_sales_rep.cgi";
	document.salesadmin.submit();
	
	return true;
}

function update_sales_rep()
{
	document.modifysalesrep.update.value = "true";
	document.modifysalesrep.submit();
}

function add_sales_region()
{
	document.modifysalesrep.update.value = "true";
	document.modifysalesrep.add.value = "true";
	document.modifysalesrep.submit();
}

function add_sales_product()
{
	document.modifysalesrep.update.value = "true";
	document.modifysalesrep.addprod.value = "true";
	document.modifysalesrep.submit();
}

function add_rep_sales_account()
{
	document.modifysalesrep.update.value = "true";
	document.modifysalesrep.addaccount.value = "true";
	document.modifysalesrep.submit();
}

function delete_sales_reps(max_rep_id)
{
	// Check if at least one rep is selected:
	atleast1 = false;
	ids = "";
	for (i = 0;  i <= max_rep_id;  i++) {
		obj = eval("document.salesadmin.rep" + i);
		if (obj && obj.checked) {
			if (atleast1) {
				ids += ",";
			}
			hiddenobj = eval("document.salesadmin.rep_id" + i);
			ids += hiddenobj.value;
			atleast1 = true;
		}
	}
	if (!atleast1) {
		alert("Please select at least one sales rep to delete.");
		return false;
	}
	if (!confirm("Are you sure you want to delete the selected sales reps?")) {
		return false;
	}
	
	document.salesadmin.thefunction.value = "delete," + ids;
	document.salesadmin.submit();
	
	return true;
}

function delete_regions(numregions)
{
	// Check if at least one rep is selected:
	atleast1 = false;
	for (i = 0;  i <= numregions;  i++) {
		obj = eval("document.modifysalesrep.region_" + i);
		if (obj && obj.checked) {
			atleast1 = true;
			break;
		}
	}
	if (!atleast1) {
		alert("Please select at least one region to delete.");
		return false;
	}
	if (!confirm("Are you sure you want to delete the selected regions?")) {
		return false;
	}
	
	document.modifysalesrep.update.value = "true";
	document.modifysalesrep.deleteregions.value = "true";
	document.modifysalesrep.submit();
	
	return true;
}

function add_source()
{
	// Make sure there is something in the text field:
	if (document.sources.newsource.value == null || document.sources.newsource.value == "") {
		alert("Please type a new source in the text field.");
		return false;
	}

	document.sources.sourcefunction.value = "add," + document.sources.newsource.value;
	document.sources.submit();
	
	return true;
}

function delete_source()
{
	if (document.sources.sourcelist.selectedIndex < 0) {
		alert ("Please select a source to delete.");
		return false;
	}
	
	if (confirm("WARNING: Deleting a data source could cause existing leads to be inconsistent.  Delete anyway?")) {
		document.sources.sourcefunction.value = "delete," + document.sources.sourcelist.options[document.sources.sourcelist.selectedIndex].value;
		document.sources.submit();
	}

	return true;
}

function add_market()
{
	// Make sure there is something in the text field:
	if (document.markets.newmarket.value == null || document.markets.newmarket.value == "") {
		alert("Please type a new market in the text field.");
		return false;
	}

	document.markets.marketfunction.value = "add," + document.markets.newmarket.value;
	document.markets.submit();
	
	return true;
}

function delete_market()
{
	if (document.markets.marketlist.selectedIndex < 0) {
		alert ("Please select a market to delete.");
		return false;
	}
	
	if (confirm("WARNING: Deleting a market type could cause existing leads to be inconsistent.  Delete anyway?")) {
		document.markets.marketfunction.value = "delete," + document.markets.marketlist.options[document.markets.marketlist.selectedIndex].value;
		document.markets.submit();
	}

	return true;
}

function add_application()
{
	// Make sure there is something in the text field:
	if (document.applications.newapp.value == null || document.applications.newapp.value == "") {
		alert("Please type a new application in the text field.");
		return false;
	}

	document.applications.appfunction.value = "add," + document.applications.newapp.value;
	document.applications.submit();
	
	return true;
}

function delete_application()
{
	if (document.applications.applist.selectedIndex < 0) {
		alert ("Please select an application to delete.");
		return false;
	}
	
	if (confirm("WARNING: Deleting an application type could cause existing leads to be inconsistent.  Delete anyway?")) {
		document.applications.appfunction.value = "delete," + document.applications.applist.options[document.applications.applist.selectedIndex].value;
		document.applications.submit();
	}

	return true;
}

function add_country()
{
	// Make sure there is something in the text field:
	if (document.countries.newcountry.value == null || document.countries.newcountry.value == "") {
		alert("Please type a new country in the text field.");
		return false;
	}

	document.countries.countryfunction.value = "add," + document.countries.newcountry.value;
	document.countries.submit();
	
	return true;
}

function delete_country()
{
	if (document.countries.countrylist.selectedIndex < 0) {
		alert ("Please select a country to delete.");
		return false;
	}
	
	countryid = document.countries.countrylist.options[document.countries.countrylist.selectedIndex].value;
	if (countryid <= 2) {
		alert("Cannot delete USA or Canada.");
		return false;
	}
	if (confirm("WARNING: Deleting a country could cause existing data to be inconsistent.  Delete anyway?")) {
		document.countries.countryfunction.value = "delete," + countryid;
		document.countries.submit();
	}

	return true;
}

function add_instrument()
{
	// Make sure there is something in the text field:
	if (document.instruments.newinstrument.value == null || document.instruments.newinstrument.value == "") {
		alert("Please type a new instrument in the text field.");
		return false;
	}

	document.instruments.instrumentfunction.value = "add," + document.instruments.newinstrument.value;
	document.instruments.submit();
	
	return true;
}

function delete_instrument()
{
	if (document.instruments.instrumentlist.selectedIndex < 0) {
		alert ("Please select an instrument to delete.");
		return false;
	}
	
	instrumentid = document.instruments.instrumentlist.options[document.instruments.instrumentlist.selectedIndex].value;
	if (confirm("WARNING: Deleting an instrument could cause existing data to be inconsistent.  Delete anyway?")) {
		document.instruments.instrumentfunction.value = "delete," + instrumentid;
		document.instruments.submit();
	}

	return true;
}

function add_software()
{
	// Make sure there is something in the text field:
	if (document.software.newsoftware.value == null || document.software.newsoftware.value == "") {
		alert("Please type a new software application in the text field.");
		return false;
	}

	document.software.softwarefunction.value = "add," + document.software.newsoftware.value;
	document.software.submit();
	
	return true;
}

function delete_software()
{
	if (document.software.softwarelist.selectedIndex < 0) {
		alert ("Please select a software application to delete.");
		return false;
	}
	
	softwareid = document.software.softwarelist.options[document.software.softwarelist.selectedIndex].value;
	if (confirm("WARNING: Deleting a software application could cause existing data to be inconsistent.  Delete anyway?")) {
		document.software.softwarefunction.value = "delete," + softwareid;
		document.software.submit();
	}

	return true;
}

function get_internal_survey(whichlistval)
{
	document.reports.report.value = '901';
	document.reports.whichlist.value = whichlistval;
	document.reports.action = 'download_reports.cgi';
	document.reports.submit();
}

function get_survey(surveyid)
{
	document.reports.report.value = surveyid;
	document.reports.action = 'download_reports.cgi';
	document.reports.submit();
}

function get_survey_timestamp(surveyid)
{
	document.reports.report.value = surveyid;
	document.reports.timestamp.value = 'true';
	document.reports.action = 'download_reports.cgi';
	document.reports.submit();
}

function add_industry()
{
	// Make sure there is something in the text field:
	if (document.industries.newind.value == null || document.industries.newind.value == "") {
		alert("Please type a new industry in the text field.");
		return false;
	}

	document.industries.indfunction.value = "add," + document.industries.newind.value;
	document.industries.submit();
	
	return true;
}

function delete_industry()
{
	if (document.industries.indlist.selectedIndex < 0) {
		alert ("Please select an industry to delete.");
		return false;
	}
	
	indid = document.industries.indlist.options[document.industries.indlist.selectedIndex].value;
	if (confirm("WARNING: Deleting an industry could cause existing data to be inconsistent.  Delete anyway?")) {
		document.industries.indfunction.value = "delete," + indid;
		document.industries.submit();
	}

	return true;
}

function delete_tradeshow()
{
	if (document.tradeshows.tradelist.selectedIndex < 0) {
		alert ("Please select a trade show to delete.");
		return false;
	}
	
	indid = document.tradeshows.tradelist.options[document.tradeshows.tradelist.selectedIndex].value;
	if (confirm("WARNING: Deleting a trade show could cause existing data to be inconsistent.  Delete anyway?")) {
		document.tradeshows.tradefunction.value = "delete," + indid;
		document.tradeshows.submit();
	}

	return true;
}

function add_tradeshow()
{
	// Make sure there is something in the text field:
	if (document.tradeshows.newtrade.value == null || document.tradeshows.newtrade.value == "") {
		alert("Please type a new trade show in the text field.");
		return false;
	}

	document.tradeshows.tradefunction.value = "add," + document.tradeshows.newtrade.value;
	document.tradeshows.submit();
	
	return true;
}

function add_feedback()
{
	// Make sure there is something in the text field:
	if (document.feedback.newfeedback.value == null || document.feedback.newfeedback.value == "") {
		alert("Please type a new feedback type in the text field.");
		return false;
	}

	document.feedback.feedbackfunction.value = "add," + document.feedback.newfeedback.value;
	document.feedback.submit();
	
	return true;
}

function delete_feedback()
{
	if (document.feedback.feedbacklist.selectedIndex < 0) {
		alert ("Please select a feedback type to delete.");
		return false;
	}
	
	feedid = document.feedback.feedbacklist.options[document.feedback.feedbacklist.selectedIndex].value;
	if (confirm("WARNING: Deleting a feedback type could cause existing data to be inconsistent.  Delete anyway?")) {
		document.feedback.feedbackfunction.value = "delete," + feedid;
		document.feedback.submit();
	}

	return true;
}

function add_request_type(new_id)
{
	// Make sure there is something in the text field:
	if (document.reqtypes.newreq.value == null || document.reqtypes.newreq.value == "") {
		alert("Please type a new request type in the text field.");
		return false;
	}

	document.reqtypes.reqfunction.value = "add," + (new_id + 1) + "," + document.reqtypes.newreq.value;
	document.reqtypes.submit();
	
	return true;
}

function delete_request_type()
{
	if (document.reqtypes.reqlist.selectedIndex < 0) {
		alert ("Please select a request type to delete.");
		return false;
	}
	
	if (confirm("WARNING: Deleting a request type could cause existing leads to be inconsistent.  Delete anyway?")) {
		document.reqtypes.reqfunction.value = "delete," + document.reqtypes.reqlist.options[document.reqtypes.reqlist.selectedIndex].value;
		document.reqtypes.submit();
	}

	return true;
}

function add_category()
{
	document.categories.action = "add_category.cgi";
	document.categories.submit();
}

function add_cat()
{
	if (document.addcategory.category.value == "") {
		alert("Please supply a category.");
		return 0;
	}
	if (document.addcategory.urlprefix.value == "") {
		alert("Please supply a URL prefix.");
		return 0;
	}
	if (document.addcategory.gensuffix.value == "") {
		alert("Please supply a generic suffix.");
		return 0;
	}

	document.addcategory.add.value = "true";
	document.addcategory.submit();
}

function back_to_categories()
{
	document.addcategory.action = "categories.cgi";
	document.addcategory.submit();
}

function back_to_categories2()
{
	document.modifycategory.action = "categories.cgi";
	document.modifycategory.submit();
}

function delete_category(max_cat_id)
{
	// Check if at least one category is selected:
	atleast1 = false;
	ids = "";
	for (i = 0;  i <= max_cat_id;  i++) {
		obj = eval("document.categories.cat_id" + i);
		if (obj && obj.checked) {
			if (atleast1) {
				ids += ",";
			}
			ids += i;
			atleast1 = true;
		}
	}
	if (!atleast1) {
		alert("Please select at least one category to delete.");
		return false;
	}
	if (!confirm("WARNING: Deleting a user category could cause existing leads to be inconsistent.  Delete anyway?")) {
		return false;
	}
	
	document.categories.catfunction.value = "delete," + ids;
	document.categories.submit();
	
	return true;
}

function modify_category(max_cat_id)
{
	// Check that exactly one category is selected:
	numcats = 0;
	id = "";
	for (i = 0;  i <= max_cat_id;  i++) {
		obj = eval("document.categories.cat_id" + i);
		if (obj && obj.checked) {
			if (numcats == 0) {
				id = i;
			}
			numcats++;
		}
	}
	if (numcats == 0) {
		alert("Please select a category to modify.");
		return false;
	}
	if (numcats > 1 && !confirm("You have selected more than one category.  Do you want to modify the first one selected?")) {
		return false;
	}

	document.categories.catfunction.value = "modify," + id;
	document.categories.action = "modify_category.cgi";
	document.categories.submit();
	
	return true;
}

function modify_category_link(id)
{
	document.categories.catfunction.value = "modify," + id;
	document.categories.action = "modify_category.cgi";
	document.categories.submit();
	
	return true;
}

function update_category()
{
	document.modifycategory.update.value = "true";
	document.modifycategory.submit();
}


function add_sales_account()
{
	document.accounts.thefunction.value = "new";
	document.accounts.action = "modify_sales_account.cgi";
	document.accounts.submit();
}

function modify_sales_account(max_account_id)
{
	// Check that exactly one account is selected:
	numaccounts = 0;
	id = "";
	for (i = 0;  i <= max_account_id;  i++) {
		obj = eval("document.accounts.account_id" + i);
		if (obj && obj.checked) {
			if (numaccounts == 0) {
				id = i;
			}
			numaccounts++;
		}
	}
	if (numaccounts == 0) {
		alert("Please select a sales account to modify.");
		return false;
	}
	if (numaccounts > 1 && !confirm("You have selected more than one sales account.  Do you want to modify the first one selected?")) {
		return false;
	}

	document.accounts.thefunction.value = "modify," + id;
	document.accounts.action = "modify_sales_account.cgi";
	document.accounts.submit();
	
	return true;
}

function modify_account_link(id)
{
	document.accounts.thefunction.value = "modify," + id;
	document.accounts.action = "modify_sales_account.cgi";
	document.accounts.submit();
	
	return true;
}

function delete_sales_account(max_account_id)
{
	// Check if at least one sales account is selected:
	atleast1 = false;
	ids = "";
	for (i = 0;  i <= max_account_id;  i++) {
		obj = eval("document.accounts.account_id" + i);
		if (obj && obj.checked) {
			if (atleast1) {
				ids += ",";
			}
			ids += i;
			atleast1 = true;
		}
	}
	if (!atleast1) {
		alert("Please select at least one sales account to delete.");
		return false;
	}
	if (!confirm("WARNING: Deleting a sales account could cause existing sales rep info to be inconsistent.  Delete anyway?")) {
		return false;
	}
	
	document.accounts.thefunction.value = "delete," + ids;
	document.accounts.submit();
	
	return true;
}

function update_sales_account()
{
	document.salesaccount.update.value = "true";
	document.salesaccount.submit();
}

function back_to_sales_accounts()
{
	document.salesaccount.action = "sales_accounts.cgi";
	document.salesaccount.submit();
}

function add_campaign()
{
	document.campaigns.action = "add_campaign.cgi";
	document.campaigns.submit();
}

function modify_campaign(max_camp_id)
{
	// Check that exactly one campaign is selected:
	numcamps = 0;
	id = 0;
	for (i = 0;  i <= max_camp_id;  i++) {
		obj = eval("document.campaigns.camp_" + i);
		if (obj && obj.checked) {
			if (numcamps == 0) {
				id = i;
			}
			numcamps++;
		}
	}
	if (numcamps == 0) {
		alert("Please select a campaign to modify.");
		return false;
	}
	if (numcamps > 1 && !confirm("You have selected more than one campaign.  Do you want to modify the first one selected?")) {
		return false;
	}

	cobj = eval("document.campaigns.campdate_" + id);
	campdate = cobj.value;
	document.campaigns.campfunction.value = "modify," + campdate;
	document.campaigns.action = "modify_campaign.cgi";
	document.campaigns.submit();
	
	return true;
}

function launch_campaign(max_camp_id)
{
	// Check that exactly one campaign is selected:
	numcamps = 0;
	id = 0;
	for (i = 0;  i <= max_camp_id;  i++) {
		obj = eval("document.campaigns.camp_" + i);
		if (obj && obj.checked) {
			if (numcamps == 0) {
				id = i;
			}
			numcamps++;
		}
	}
	if (numcamps == 0) {
		alert("Please select a campaign to launch.");
		return false;
	}
	if (numcamps > 1 && !confirm("You have selected more than one campaign.  Do you want to launch the first one selected?")) {
		return false;
	}
	
	cobj = eval("document.campaigns.camptype_" + id);
	camptype = cobj.value;
	if (camptype != 'email') {
		alert("Launching only applies to email campaigns.");
		return false;
	}

	cobj = eval("document.campaigns.campdate_" + id);
	campdate = cobj.value;
	document.campaigns.campfunction.value = "launch," + campdate;
	document.campaigns.action = "launch_campaign.cgi";
	document.campaigns.submit();
	
	return true;
}

function modify_campaign_link(campdate)
{
	document.campaigns.campfunction.value = "modify," + campdate;
	document.campaigns.action = "modify_campaign.cgi";
	document.campaigns.submit();
	
	return true;
}

function start_email_campaign(mailing_date)
{
	document.launchcampaign.action = "start_email_campaign.cgi?mailing_date=" + mailing_date;
	document.launchcampaign.submit();
	
	return true;
}

function back_to_campaign()
{
	document.newmailing.action = "campaigns.cgi";
	document.newmailing.submit();
}

function back_to_campaign2()
{
	document.modifycampaign.action = "campaigns.cgi";
	document.modifycampaign.submit();
}

function back_to_campaign3()
{
	document.launchcampaign.action = "campaigns.cgi";
	document.launchcampaign.submit();
}

function add_administrator()
{
	document.administrators.action = "add_administrator.cgi";
	document.administrators.submit();
}

function delete_administrator(max_admin_id)
{
	// Check if at least one administrator is selected:
	atleast1 = false;
	ids = "";
	for (i = 0;  i <= max_admin_id;  i++) {
		obj = eval("document.administrators.admin_id" + i);
		if (obj && obj.checked) {
			if (atleast1) {
				ids += ",";
			}
			ids += i;
			atleast1 = true;
		}
	}
	if (!atleast1) {
		alert("Please select at least one administrator to delete.");
		return false;
	}
	if (!confirm("Are you sure you want to delete the selected administrators?")) {
		return false;
	}
	
	document.administrators.adminfunction.value = "delete," + ids;
	document.administrators.submit();
	
	return true;
}

function modify_administrator(max_admin_id)
{
	// Check that exactly one administrator is selected:
	numadmins = 0;
	id = "";
	for (i = 0;  i <= max_admin_id;  i++) {
		obj = eval("document.administrators.admin_id" + i);
		if (obj && obj.checked) {
			if (numadmins == 0) {
				id = i;
			}
			numadmins++;
		}
	}
	if (numadmins == 0) {
		alert("Please select an administrator to modify.");
		return false;
	}
	if (numadmins > 1 && !confirm("You have selected more than one administrator.  Do you want to modify the first one selected?")) {
		return false;
	}

	document.administrators.adminfunction.value = "modify," + id;
	document.administrators.action = "modify_administrator.cgi";
	document.administrators.submit();
	
	return true;
}

function modify_administrator_link(id)
{
	document.administrators.adminfunction.value = "modify," + id;
	document.administrators.action = "modify_administrator.cgi";
	document.administrators.submit();
	
	return true;
}

function update_administrator()
{
	document.modifyadministrator.update.value = "true";
	document.modifyadministrator.submit();
}

function add_admin()
{
	if (document.addadministrator.username.value == "") {
		alert("Please supply a username.");
		return 0;
	}
	if (document.addadministrator.password.value == "") {
		alert("Please supply a password.");
		return 0;
	}

	document.addadministrator.add.value = "true";
	document.addadministrator.submit();
}

function back_to_administrators()
{
	document.addadministrator.action = "administrators.cgi";
	document.addadministrator.submit();
}

function back_to_administrators2()
{
	document.modifyadministrator.action = "administrators.cgi";
	document.modifyadministrator.submit();
}

function submit_import()
{
	if (document.importusers.mailing.value == null || document.importusers.mailing.value == "") {
		alert("Please select a mailing list file to import.");
		return false;
	}
	
	document.importusers.importfunction.value = "import";
	document.importusers.submit();
	
	return true;
}

function confirmGoToCURL(CURL)
{
	if (confirm("If you go to '" + CURL + "', it will register in the database that the user visited the site.  Continue anyway?")) {
		window.open(CURL, "Test CURL");
	}
}

function add_document()
{
	document.documentsform.action = "add_document.cgi";
	document.documentsform.submit();
}

function modify_document(max_doc_id)
{
	// Check that exactly one document is selected:
	numdocs = 0;
	id = "";
	for (i = 0;  i <= max_doc_id;  i++) {
		obj = eval("document.documentsform.doc_id" + i);
		if (obj && obj.checked) {
			if (numdocs == 0) {
				id = i;
			}
			numdocs++;
		}
	}
	if (numdocs == 0) {
		alert("Please select a document to modify.");
		return false;
	}
	if (numdocs > 1 && !confirm("You have selected more than one document.  Do you want to modify the first one selected?")) {
		return false;
	}

	document.documentsform.optfunction.value = "modify," + id;
	document.documentsform.action = "modify_document.cgi";
	document.documentsform.submit();
	
	return true;
}

function modify_document_link(id)
{
	document.documentsform.optfunction.value = "modify," + id;
	document.documentsform.action = "modify_document.cgi";
	document.documentsform.submit();
	
	return true;
}

function delete_document(max_doc_id)
{
	// Check if at least one document is selected:
	atleast1 = false;
	ids = "";
	for (i = 0;  i <= max_doc_id;  i++) {
		obj = eval("document.documentsform.doc_id" + i);
		if (obj && obj.checked) {
			if (atleast1) {
				ids += ",";
			}
			ids += i;
			atleast1 = true;
		}
	}
	if (!atleast1) {
		alert("Please select at least one document to delete.");
		return false;
	}
	if (!confirm("Are you sure you want to delete the selected documents?")) {
		return false;
	}
	
	document.documentsform.optfunction.value = "delete," + ids;
	document.documentsform.submit();
	
	return true;
}

function delete_items(formname, max_id, id_prefix)
{
	return delete_items1(formname, 0, max_id, id_prefix);
}

function delete_items1(formname, min_id, max_id, id_prefix)
{
	// Check if at least one item is selected:
	theform = eval("document." + formname);
	atleast1 = false;
	ids = "";
	for (i = min_id;  i <= max_id;  i++) {
		obj = eval("document." + formname + "." + id_prefix + i);
		if (obj && obj.checked) {
			if (atleast1) {
				ids += ",";
			}
			ids += i;
			atleast1 = true;
		}
	}
	if (!atleast1) {
		alert("Please select at least one item to delete.");
		return false;
	}
	if (!confirm("Are you sure you want to delete the selected items?")) {
		return false;
	}
	
	theform.thefunction.value = "delete," + ids;
	theform.submit();
	
	return true;
}


function approve_users(formname, max_id, id_prefix)
{
	// Check if at least one item is selected:
	theform = eval("document." + formname);
	atleast1 = false;
	ids = "";
	for (i = 0;  i <= max_id;  i++) {
		obj = eval("document." + formname + "." + id_prefix + i);
		if (obj && obj.checked) {
			if (atleast1) {
				ids += ",";
			}
			ids += i;
			atleast1 = true;
		}
	}
	if (!atleast1) {
		alert("Please select at least one user to approve.");
		return false;
	}
	if (!confirm("Are you sure you want to approve the selected users?")) {
		return false;
	}
	
	theform.thefunction.value = "approve," + ids;
	theform.submit();
	
	return true;
}


function add_doc()
{
	if (document.add_document.docname.value == "") {
		alert("Please supply a document name.");
		return 0;
	}
	if (document.add_document.doclink.value == "") {
		alert("Please supply a document link.");
		return 0;
	}

	document.add_document.add.value = "true";
	document.add_document.submit();
}

function back_to_optin()
{
	document.add_document.action = "optin.cgi";
	document.add_document.submit();
}

function back_to_optin2()
{
	document.modifydocument.action = "optin.cgi";
	document.modifydocument.submit();
}

function update_document()
{
	document.modifydocument.update.value = "true";
	document.modifydocument.submit();
}

function submit_form(formname, url)
{
	var theform = eval("document." + formname);
	theform.action = url;
	theform.submit();
}

function update_form(formname, actionname)
{
	var theform = eval("document." + formname);
	theform.thefunction.value = actionname;
	theform.submit();
}

function DisplayBlock(which)
{
	if (ie4) {
		document.all[which].style.display = "block";
	}
	if (ns6) {
		document.getElementById(which).style.display = "block";
	}
	if (ns4) {
		document.layers[which].display = "block";
	}
}

function DisplayNone(which)
{
	if (ie4) {
		document.all[which].style.display = "none";
	}
	if (ns6) {
		document.getElementById(which).style.display = "none";
	}
	if (ns4) {
		document.layers[which].display = "none";
	}
}

function ShowHideSelectDiv(select_name, div_name, index, equals)
{
	var selectbox = eval("document." + select_name);
	curval = selectbox.options[selectbox.selectedIndex].value;
	if (equals == 1) {
		if (curval == index) {
			DisplayBlock(div_name);
		} else {
			DisplayNone(div_name);
		}
	} else {
		if (curval != index) {
			DisplayBlock(div_name);
		} else {
			DisplayNone(div_name);
		}
	}
}

function showDiv(which)
{
	if (ie4) {
		document.all[which].style.visibility = "visible";
	}
	if (ns6) {
		document.getElementById(which).style.visibility = "visible";
	}
	if (ns4) {
		document.layers[which].visibility = "show";
	}
}

function hideDiv(which)
{
	if (ie4) {
		document.all[which].style.visibility = "hidden";
	}
	if (ns6) {
		document.getElementById(which).style.visibility = "hidden";
	}
	if (ns4) {
		document.layers[which].visibility = "hide";
	}
}

function showHideWeekday()
{
	selection = document.settingsform.frequency.selectedIndex;
	if (document.settingsform.frequency.options[selection].value == 7) {
		showDiv('weekday_id');
	} else {
		hideDiv('weekday_id');
	}
}

function showHideIndustry(divName, industrySelectName)
{
	var selectbox = eval("document." + industrySelectName);
	industry = selectbox.options[selectbox.selectedIndex].value;
	if (industry == "other") {
		showDiv(divName);
	} else {
		hideDiv(divName);
	}
}

function showHideCountry(divName, countrySelectName)
{
	var selectbox = eval("document." + countrySelectName);
	country = selectbox.options[selectbox.selectedIndex].value;
	if (country == "other") {
		showDiv(divName);
	} else {
		hideDiv(divName);
	}
}

function showHideStates(divUS, divCanada, divOther, countrySelectName)
{
	var selectbox = eval("document." + countrySelectName);
	country = selectbox.options[selectbox.selectedIndex].value;
	if (country == "USA") {
		showDiv(divUS);
		hideDiv(divCanada);
		hideDiv(divOther);
	} else if (country == "Canada") {
		hideDiv(divUS);
		showDiv(divCanada);
		hideDiv(divOther);
	} else {
		hideDiv(divUS);
		hideDiv(divCanada);
		showDiv(divOther);
	}
}

function showHideStatesCountryReadOnly(divUS, divCanada, divOther, countrySelectName)
{
	var selectbox = eval("document." + countrySelectName);
	country = selectbox.value;
	if (country == "USA") {
		showDiv(divUS);
		hideDiv(divCanada);
		hideDiv(divOther);
	} else if (country == "Canada") {
		hideDiv(divUS);
		showDiv(divCanada);
		hideDiv(divOther);
	} else {
		hideDiv(divUS);
		hideDiv(divCanada);
		showDiv(divOther);
	}
}

function NewPopupWindow(url, name, options)
{
	var mynewwindow = window.open(url, name, options);
	//mynewwindow.document.close();
	mynewwindow.focus();
}

function SelectProductsForDoc()
{
	prods = ""
	for (i = 0;  i < document.product_form.products.length;  i++) {
		if (document.product_form.products.options[i].selected) {
			prods += document.product_form.products.options[i].text + "\n";
		}
	}
	self.opener.document.webform.doc_links.value = prods;
	window.close();
}

function GetStateForZip(index)
{
	var selectbox = eval("document.modifysalesrep.state_" + index);
	return selectbox.options[selectbox.selectedIndex].value;
}

function NewZipPopup(index, url, name, options)
{
	state = GetStateForZip(index);
	var ziplowbox = eval("document.modifysalesrep.ziplow_" + index);
	ziplow = ziplowbox.value;
	var ziphighbox = eval("document.modifysalesrep.ziphigh_" + index);
	ziphigh = ziphighbox.value;
	var countrybox = eval("document.modifysalesrep.country_" + index);
	countryindex = countrybox.selectedIndex;
	country = countrybox.options[countryindex].value;
	fullurl = url + "?index=" + index + "&state=" + state + "&country=" + country + "&ziplow=" + ziplow + "&ziphigh=" + ziphigh;
	NewPopupWindow(fullurl, name, options);
}

function NewHelpPopup(url, key)
{
	fullurl = url + "?key=" + key;
	var mynewwindow = window.open(fullurl, "Help", "width=400,height=300,scrollbars=yes,toolbar=no,location=no,menubar=no");
	//mynewwindow.document.close();
	mynewwindow.focus();
}

function fill_zip_range(index)
{
	fromIndex = document.getcodes.zipfrom.selectedIndex;
	fromValue = document.getcodes.zipfrom.options[fromIndex].value;
	toIndex = document.getcodes.zipto.selectedIndex;
	toValue = document.getcodes.zipto.options[toIndex].value;
	var frombox = eval("window.opener.document.modifysalesrep.ziplow_" + index);
	frombox.value = fromValue;
	var tobox = eval("window.opener.document.modifysalesrep.ziphigh_" + index);
	tobox.value = toValue;
	window.close();
}

var stateNames = [
	'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California',
	'Colorado', 'Connecticut', 'Delaware', 'Washington D.C.', 'Florida',
	'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana',
	'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine',
	'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi',
	'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire',
	'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota',
	'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Puerto Rico',
	'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas',
	'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia',
	'Wisconsin', 'Wyoming', 'Virgin Islands'
];

var provinceNames = [
	'Alberta', 'British Columbia', 'Manitoba', 'New Brunswick', 'Newfoundland',
	'Nova Scotia', 'Northwest Territories', 'Ontario', 'Prince Edward Island', 'Quebec', 
	'Saskatchewan', 'Yukon Territory', 'Nunavut'
];

var stateCodes = [
	'AL', 'AK', 'AZ', 'AR', 'CA',
	'CO', 'CT', 'DE', 'DC', 'FL',
	'GA', 'HI', 'ID', 'IL', 'IN',
	'IA', 'KS', 'KY', 'LA', 'ME',
	'MD', 'MA', 'MI', 'MN', 'MS',
	'MO', 'MT', 'NE', 'NV', 'NH',
	'NJ', 'NM', 'NY', 'NC', 'ND',
	'OH', 'OK', 'OR', 'PA', 'PR',
	'RI', 'SC', 'SD', 'TN', 'TX',
	'UT', 'VT', 'VA', 'WA', 'WV',
	'WI', 'WY', 'VI'
];

var provinceCodes = [
	'AB', 'BC', 'MB', 'NB', 'NF',
	'NS', 'NT', 'ON', 'PE', 'QC',
	'SK', 'YT', 'NU'
];

function reFillStates(countrysel, statesel)
{
	var countrybox = eval("document." + countrysel);
	var statebox = eval("document." + statesel);
	country = countrybox.options[countrybox.selectedIndex].value;
	
	statebox.options.length = 0;
	statebox.options[0] = new Option("(whole country)", "all");
	if (country == "USA") {
		for (i = 0;  i < stateNames.length;  i++) {
			statebox.options[i+1] = new Option(stateNames[i] + " (" + stateCodes[i] + ")", stateCodes[i]);
		}
	} else if (country == "Canada") {
		for (i = 0;  i < provinceNames.length;  i++) {
			statebox.options[i+1] = new Option(provinceNames[i] + " (" + provinceCodes[i] + ")", provinceCodes[i]);
		}
	}
}

function reFillLists(familysel, productsel, allprods, allword)
{
	var familybox = eval("document." + familysel);
	var productbox = eval("document." + productsel);
	var allprodsfield = eval("document." + allprods);
	var allprodstr = allprodsfield.value;
	var allprods = allprodstr.split(",");

	selectedFamily = familybox.options[familybox.selectedIndex].value;

	productbox.options.length = 0;
	productbox.options[0] = new Option(allword, 0);
	idx = 1;
	for (i = 0;  i <= allprods.length;  i+=3) {
		familyid = allprods[i];
		prodid = allprods[i+1];
		prodname = allprods[i+2];
		if (familyid == selectedFamily || selectedFamily == 0) {
			productbox.options[idx] = new Option(prodname, prodid);
			idx++;
		}
	}
}

function reFillProducts(familysel, productsel, allprods)
{
	reFillLists(familysel, productsel, allprods, "-All-");
}

function new_mailing()
{
	document.importusers.action = "new_mailing.cgi";
	document.importusers.submit();
}

function back_to_import()
{
	document.newmailing.action = "import.cgi";
	document.newmailing.submit();
}

function submit_download()
{
	if (document.download_form.operating_system.value == "") {
		alert("Please specify an operating system.");
		return false;
	}
	if (document.download_form.edition.value == "EE") {
		if (document.download_form.market_segment.value == "") {
			alert("Please specify an industry or market segment.");
			return false;
		}
	}

	document.download_form.action = "thank_you.cgi";
	document.download_form.submit();
	return true;
}

function open_release_notes()
{
	var user_id = document.download_form.user.value;
	NewPopupWindow("release_notes.cgi", "SoftMax_Pro_Release_Notes", "scrollbars=yes,toolbar=yes,location=yes,menubar=yes,directories=yes,status=yes");
}

function show_hide_no_changes()
{
	if (document.webform.change_type[0].checked) {
		hideDiv('no_change_2');
		hideDiv('no_change_3');
		hideDiv('no_change_4');
		hideDiv('no_change_5');
	} else {
		showDiv('no_change_2');
		showDiv('no_change_3');
		showDiv('no_change_4');
		showDiv('no_change_5');
	}
}

function UnsubscribeEmails()
{
	document.prefsform.unsubscribe.value = "true";
	document.prefsform.submit();
}

