function protectMail(username, domain, subject) {
	email = username + '&#64;' + domain;
	email2 = username + '@' + domain;

	if(subject)
		document.write('<a href="mailto:' + email2 + '?subject=' + subject + '">' + email + '</a>');
	else
		document.write('<a href="mailto:' + email2 + '">' + email + '</a>');

	return false;
}

/**
 * fixRightHeight()
 *
 * If the nav panel (jt_content_left) gets taller than the right side, the line
 * between them won't go all the way down to the footer (because it's jt_content_right's
 * left border and jt_content_right doesn't have enough content to fill the extra
 * space. This function explicitly sets the height of jt_content_right to fix
 * that problem.
 *
 * @@@ This part doesn't work in IE:
 * If, however, there is enough content in jt_content_right to meet or exceed
 * the height of jt_content_left, the height style element is nulled out and the
 * browser defines its height.
 *
 * This function is also called from navpanel.js::greenArrowToggle() so that expanding
 * and contracting the sections in the navpanel also correct this problem.
 */
function fixRightHeight() {
	if($('jt_content_right') && $('jt_content_left')) {
		var contentLeft		= $('jt_content_left').getDimensions();
		var contentRight	= $('jt_content_right').getDimensions();

		if(contentRight.height < contentLeft.height) {
			$('jt_content_right').style.height = (contentLeft.height + 10) + 'px';
		} else {
			$('jt_content_right').style.height = null;
		}
	}
}

/* Call fixRightHeight() on window load. */
Event.observe(window, "load", function() { fixRightHeight(); });

/* Cause all of the inputs of type submit to add a CSS class of "button" 
 * to their existing classes. */
Event.observe(window, "load", function() {
	$A($$("input[type=submit]")).each(function(e) {
		e.className = e.className + ' jt_button';
	});
	$A($$("input[type=button]")).each(function(e) {
		e.className = e.className + ' jt_button';
	});
});

function newsletterSignup(form) {
	if(!form) {
		// The box isn't shown yet. Display it.
		TB_show2('Newsletter Signup', '/c2/newsletter_signup.cfm?width=300&height=300', null, null);
	} else {
		// There is a form being submitted; send its contents to the functionality piece.
		$('signup_status').innerHTML = '<div class="jt_status">Saving your information...</div>';
		new Ajax.Request('/c2/newsletter_save.cfm',
		{
			method: 'post',
			parameters: $(form).serialize(true),
			onSuccess: function(transport) {
				var response = transport.responseText || '';
				if(response.match(/success/)) {
					$('signup_status').innerHTML = '<div class="jt_status">Thanks for signing up for our newsletter!</div>';
				} else {
					$('signup_status').innerHTML = '<div class="jt_status">There was a problem saving your information. Please refresh the page and try again.</div>';
				}
			},
			onFailure: function() {
				$('signup_status').innerHTML = '<div class="jt_status">There was a problem saving your information. Please refresh the page and try again.</div>';
			}
		});
	}
	return false;
}
