// $Header: /HBI Websites/_client_common/js/hirediversity/email_selected_mediakitcontent.js 1     1/20/03 8:23a Kip.holcomb $
// this function takes the "mailto:" action
// of a form and the names of and links to
// selected content.

function email_selected_mediakitcontent(form)
{	var anything_checked = false;
	var mailtohref = form.action + "&body=";

	// DANGER: this will blow up if there are fewer than
	// two checkboxes!
	var num_boxes = form.content.length;

	// These are useful for building bodies that
	// look good in either HTML or Plaintext email clients
	var urlcrlf = "%0D%0A";
	var urlspace = "%20";
	var urlbr = "%3Cbr%20%2F%3E";

	for (var i = 0; i < num_boxes; i++)
	{	if (form.content[i].checked)
		{	anything_checked = true;

			// note the contentname[i].value
			// and contentlink[i].value
			// are already url-encoded
			mailtohref +=
				urlcrlf + urlbr + urlspace +
				form.contentname[i].value +
				urlcrlf + urlbr + urlspace + 
				form.contentlink[i].value + 
				urlcrlf + urlbr + urlspace;
		}
	}

	if (anything_checked)
	{	// IE blows up on URL's of longer than 2083 characters.
		// See http://support.microsoft.com/ article number Q208427
		// Experiments seem to indicate that Outlook blows up on
		// URL's of longer than 2023 characters.
		if (mailtohref.length > 2023)
		{	if (	confirm(
					"The URL required to send this email is " +
					mailtohref.length + " characters long. " +
					"Some browsers and email clients may have " +
					"difficulty with URL's of " +
					"this excessive length.\n\n" +
					"Press OK to try anyway - good luck! " +
					"Press Cancel to go back, uncheck some " +
					"boxes, and try again.\n\n" +
					"Examples:\n" +
					"* Microsoft Internet Explorer 6.0 has a " +
					"documented limit of 2083 characters, with any email client.\n" +
					"* Microsoft Outlook 2000 appears not to work " +
					"with anything over 2023 characters, with any browser.\n" +
					"* Mozilla 1.1 with its built-in email client appears to work fine " +
					"with a URL of almost any length (up to 4000 tested.)"
				)
			)
			{	window.location = mailtohref;
			}
		} else
		{	window.location = mailtohref;
		}
	} else
	{	alert("You have not selected any media kit content.");
	}

	// stop the form from submitting in any event
	return false;
}
