/***********************************************************************
*                                                                      *
* The purpose of the following Javascript function is to block email   *
* spam by building an email address with a mailto link and subject.    *
* To use this function, you make a Javascript call from the location   *
* within the HTML body where you want to insert the email link. You    *
* must supply the following 3 arguments:                               *
*                                                                      *
* end: (required) This is the domain of the email address after the    *
*      '@' excluding the trailing '.' plus extension such as .com or   *
*      .net. IMPORTANT: You must append an index number to this domain *
*      to indicate an extension as follows:                            *
*                                                                      *
*      0 = .com                                                        *
*      1 = .net                                                        *
*      2 = .org                                                        *
*      3 = .gov                                                        *
*      4 = .biz                                                        *
*                                                                      *
*      For example, 'nexteon0' for this parameter will translate to    *
*      nexteon.com; 'nexteon1' translates to nexteon.net.              *
*                                                                      *
* front: (required) This is the part of the email address before       *
*        the '@' character.                                            *
*                                                                      *
* linktext: (optional) This is the link text for the mailto email      *
*        address that the user clicks on. If omitted, the text         *
*        defaults to the email address.                                *
*                                                                      *
* subj:  (optional) This is the subject of the mailto email address.   *
*        If omitted, the subject is set to spaces.                     *
*                                                                      *
* NOTE:  To write the email link into the body of your HTML, you must  *
* make a call to the Javascript document.write function as in the      *
* following example:                                                   *
*                                                                      *
* <script>                                                             *
* document.write(buildem('nexteon0', 'somename', 'Hello'));            *
* </script>                                                            *
*                                                                      *
* Written by Steve Carey at Next Eon on 1/9/2009                       *
*                                                                      *
************************************************************************/
function buildem(end, front, linktext, subj) {
    var domArray = [
	[0, 'com'],
	[1, 'net'],
	[2, 'org'],
	[3, 'gov'],
	[4, 'biz']
    ]
    var s = (typeof subj == "undefined") ? '' : subj;
    var em = front + '@' + end.substring(0, end.length - 1) + '.' + domArray[end.slice(-1)][1];
    var lt = ((typeof linktext == "undefined") || (linktext == '')) ? em : linktext;
    return "<a href='mailto:" + em + "?subject=" + s + "'>" + lt + "</a>";
}
