/* --- Made by Frederico Figueiredo, INESC-ID / DEI, Portugal, 13.10.2003 (V1.0) --- */

//Some required vars (do not change this)
ar = "@"
itContacts=0;
contacts = new Array();

/*
List of contacts (change this)

A list consisted by:
	- alias -> short name of the contact, to be used later when we call the WriteTo function (see below)
	- name -> name of the contact
	- email name -> email of the contact (without its domain)
	- domain email name -> domain of the email address

For example:
("FF", "Frederico Figueiredo", "Frederico.Figueiredo", "inesc-id.pt")

This list must be changed to store the email address that need protection (change/add copies of the line below 
for each email address)
*/

contacts[itContacts++] = new Array("WM", "Webmaster", "tjvg", "immi.inesc-id.pt");
contacts[itContacts++] = new Array("E", "Eurovis06", "eurovis06", "immi.inesc-id.pt");


/*
MailTo: Main function that prints the email address on the HTML document

Example: <script>JavaScript:MailTo("FF", 1, 0, "Testing this Script");</script>

Receives:
	- alias (alias name of the contact you want to write, for example: "FF")
	- presentation (type of presentation of the email on the HTML document, for example: 1)
		- 0 -> writes the contact email address
		- 1 -> writes the contact name
	- writeTo (how the result is returned, for example: 0)
		- 0 -> does a javascript document.write of the result
		- 1 -> returns a string with the result (to be used in another JavaScript function)
		- 2 -> returns only the part from the 
	- subject (subject of the email to be send to the contact, for example: "Testing this Script")


*/
function MailTo(name, presentation, writeTo, subject) {
	//Change these vars (subjDefault and result)
	var subjDefault = "Default Subject"; //Default subject for the emails
	var result = "No email Available"; //If any problem occurs this string text is returned
	var sendTo = "Send an email to"; //Text shown in the browser footer bar (ex.:, "Send an email to Someone")

	//Do not change these vars
	var m = "mail";
	var t = "to";
	var p = ":";
	var it = "?";
	var sj = "subject";
	var e = "=";
	var href = "";

	for(var i=0; i<=(itContacts - 1); i++) {
		if(contacts[i][0] == name) {
			var mail = contacts[i][2]+ar+contacts[i][3];
			var name;
			if(presentation == 0)
				name = mail;
			else
				name = contacts[i][1];
			if(subject != null)
				if(subject != null)
					subjDefault = subject;
			href = "href='"+m+t+p+contacts[i][2]+ar+contacts[i][3]+it+sj+e+subjDefault+"' onMouseOver='window.status=\""+sendTo+" "+contacts[i][1]+"\";return true;' onMouseOut='window.status=\"\";'"+"'";
			result = "<a "+href+">"+name+"</a>";
		}
	}
	if(writeTo == 0) {
		document.write(result);
		return;
	}
	else
		if(writeTo == 1)
			return result;
		else
			if(writeTo == 2)
				return href;
}
