
// Mail Munge
// Protect your clients email with foresight.
//
// Author c2002 to Isenic Development
// http://www.treenetnz.com
// Developer: AYJ Jeffries
// 
// Available under the terms of the GNU General Public Liscence
// details on the GGPL at http://www.gnu.org/licenses/licenses.html

/* WHAT THIS DOES

Allows email addresses to be munged without altering the html display

Breaking the address into several parts prevents the address from being 'harvested' by spammers

This script will either create an html href link or a stripped email address for display on the page
switchable depending on the action specified to be taken.

Tested and operational with Internet Explorer, Netscape, Mozilla, Opera, Gecko 2002+ clients

USEAGE:

Include in headers: <script language="javascript" src="/scripts/java/mail_munge.js"></script>
	With the appropriate path on your server to the script

In code use like this:

A: (shows email address as email hyperlink)
	<script language="javascript">
	showmailto('whoever','somedomain.com','any-subject-or-headers','other attributes of <A>');
	</script>

	ie. <a href="mailto:me@my.com?SUBJECT=Hello" class="link">me@my.com</a>
	Produced by:	<script>showmailto('me','my.com','SUBJECT=Hello',' class="link"');</script>

Or This:
B: (shows text as email hyperlink)
	<A href="javascript: maillink('whoever','somedomain.com','any-subject-or-headers')" other-attributes>
	some text
	</A>

*/
function makeaddr(a,b,c)
{
	var text = a + "@" + b;
	if(c) text += "?" + c;
	return text;
}
function maillink(a,b,c)
{
	location.href = "mailto:" + makeaddr(a,b,c);
}
function showmailto(a,b,c,d)
{
	document.write('<a href="javascript: maillink(');
	document.write("'" + a + "','" + b + "'");
	if(c) document.write(",'" + c + "'");
	document.write(');"');
	if(d) document.write(d);
	document.write('>' + makeaddr(a,b) + '</a>');
}
