/*
File: notSpamMailto.js
Authors: Jean-Luc Hardy
Creation date: 18 May 2006
Language: JAVASCRIPT
Copyright: GNU GPL.
Liability: None, i.e. this program is provided as such, without any guarantee whatsoever.

Purpose: 
-------
This script prevents an e-mail address to appear in HTML static page.
It should prevent possible spamers' robots to collect e-mail addresses automatically on web pages.

Installation:
------------
The present file must be inserted in the HTML file before the <body> tag using the following instruction:
<script language="JavaScript" src="path/noSpamMailto.js"></script>
where "path/" must be replaced by the appropriate path.

Interface:
---------
The JavaScript function to be called is notSpamMailto(before,after)
where "before" and "after" are the characteres resp. before and after the at sign.
For example, the email address myname@mycompany.com will be called: notSpamMailto('myname','mycompany.com');

The javascript call is used instead of the mailto protocol in the href paramater of the <a> tag.
For example: <a href="javascript:noSpamMailto('myname','mycompany');">Contact us</a>

To make things even more secure, it could be useful to add function calls as parameter of notSpamMailto.
For example, noSpamMailto(unscramble1('myname2',"myname1'),unscramble1('mycompany2',mycompany3','mycompany1"))
where unscramble1 and unscramble2 have to be created by the user of this script. 
For example,
function unscramble1('myname2',"myname1') {return myname2+myname1;}
function unscramble2('mycompany2',mycompany3','mycompany1") {return mycompany1+mycompany2;} //mycompany3 not used.
*/

var dWindow=null;

function noSpamMailto(before,after) {	
var eMail=before+"@"+after;
if((dWindow==null)||(dWindow.closed)) {
	dWindow=window.open("mailto:" + eMail, "mailWindow", 
		"menubar=no,dependent=yes,height=50,width=260");
	var ligneHead=
		  '<HTML><HEAD><TITLE>e-mail to '
		+ eMail
		+ '</TITLE></HEAD>'							+ String.fromCharCode(13);
	var ligneBody=
		  '<BODY bgcolor="#102A98">'					+ String.fromCharCode(13)
		+ '<Font Face="Comic Sans MS" Size="3" Color="#FFFFFF">'	+ String.fromCharCode(13)
		+ 'Sto caricando il software <br>per invio della email...'				+ String.fromCharCode(13)
		+ '</font><br><br>'
		+ '<Font Face=arial Size=1 Color="#FFFFFF">'			+ String.fromCharCode(13)
		+ "&copy; Jean-Luc HARDY, distributed under GNU-GPL<br>"	+ String.fromCharCode(13)
//		+ "download: http://noSpamMailto.sourceforge.net<br>"		+ String.fromCharCode(13)
		+ '</font></BODY></HTML>'						+ String.fromCharCode(13);
	dWindow.document.writeln(ligneHead);
	dWindow.document.writeln(ligneBody);
	dWindow.document.writeln();
	var timerAvantClose= setTimeout("dWindow.close();",5000); // pour eviter le crash
	}
}


